bug 887854 - remove most useage of pratom.h r=mounir, mcmanus, jrmuizel
authorTrevor Saunders <trev.saunders@gmail.com>
Sun, 16 Jun 2013 03:09:07 -0400
changeset 137259 78fbb80cf76cc1fcb6c7c553b85ae80097a40182
parent 137258 1f09176d269b0e7359db6035665403421e3c8c0c
child 137260 1f667fc46908faba3a68ec0d7a852b20cc57e084
push id24916
push userryanvm@gmail.com
push dateWed, 03 Jul 2013 18:15:02 +0000
treeherdermozilla-central@dcbbfcdf7bb4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, mcmanus, jrmuizel
bugs887854
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 887854 - remove most useage of pratom.h r=mounir, mcmanus, jrmuizel
content/media/plugins/MediaPluginHost.cpp
dom/bluetooth/linux/BluetoothDBusService.cpp
extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
gfx/thebes/gfxReusableSurfaceWrapper.cpp
gfx/thebes/gfxReusableSurfaceWrapper.h
ipc/glue/MessagePump.cpp
modules/libjar/nsJAR.h
netwerk/cache/nsDiskCacheStreams.h
netwerk/dns/nsHostResolver.cpp
storage/src/mozStorageService.cpp
--- a/content/media/plugins/MediaPluginHost.cpp
+++ b/content/media/plugins/MediaPluginHost.cpp
@@ -6,17 +6,16 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/TimeRanges.h"
 #include "MediaResource.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "MediaPluginHost.h"
 #include "nsXPCOMStrings.h"
 #include "nsISeekableStream.h"
-#include "pratom.h"
 #include "MediaPluginReader.h"
 #include "nsIGfxInfo.h"
 #include "gfxCrashReporterUtils.h"
 #include "prmem.h"
 
 #include "MPAPI.h"
 
 #if defined(ANDROID) || defined(MOZ_WIDGET_GONK)
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -24,21 +24,21 @@
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothUnixSocketConnector.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 
 #include <cstdio>
 #include <dbus/dbus.h>
 
-#include "pratom.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsDebug.h"
 #include "nsDataHashtable.h"
+#include "mozilla/Atomics.h"
 #include "mozilla/Hal.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/ipc/DBusThread.h"
 #include "mozilla/ipc/DBusUtils.h"
 #include "mozilla/ipc/RawDBusConnection.h"
 #include "mozilla/Util.h"
 #include "mozilla/NullPtr.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
@@ -146,17 +146,17 @@ static const char* sBluetoothDBusSignals
 /**
  * DBus Connection held for the BluetoothCommandThread to use. Should never be
  * used by any other thread.
  *
  */
 static nsAutoPtr<RawDBusConnection> gThreadConnection;
 static nsDataHashtable<nsStringHashKey, DBusMessage* > sPairingReqTable;
 static nsDataHashtable<nsStringHashKey, DBusMessage* > sAuthorizeReqTable;
-static int32_t sIsPairing = 0;
+static Atomic<int32_t> sIsPairing;
 static nsString sAdapterPath;
 
 typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&);
 typedef bool (*FilterFunc)(const BluetoothValue&);
 typedef void (*SinkCallback)(DBusMessage*, void*);
 
 static bool
 GetConnectedDevicesFilter(const BluetoothValue& aValue)
@@ -451,17 +451,17 @@ RunDBusCallback(DBusMessage* aMsg, void*
 }
 
 static void
 GetObjectPathCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable)
 {
   if (sIsPairing) {
     RunDBusCallback(aMsg, aBluetoothReplyRunnable,
                     UnpackObjectPathMessage);
-    PR_AtomicDecrement(&sIsPairing);
+    sIsPairing--;
   }
 }
 
 static void
 UnpackVoidMessage(DBusMessage* aMsg, DBusError* aErr, BluetoothValue& aValue,
                   nsAString& aErrorStr)
 {
   DBusError err;
@@ -1673,17 +1673,17 @@ BluetoothDBusService::StopInternal()
 
   // unref stored DBusMessages before clear the hashtable
   sPairingReqTable.EnumerateRead(UnrefDBusMessages, nullptr);
   sPairingReqTable.Clear();
 
   sAuthorizeReqTable.EnumerateRead(UnrefDBusMessages, nullptr);
   sAuthorizeReqTable.Clear();
 
-  PR_AtomicSet(&sIsPairing, 0);
+  sIsPairing = 0;
 
   StopDBus();
   return NS_OK;
 }
 
 bool
 BluetoothDBusService::IsEnabledInternal()
 {
@@ -2168,17 +2168,17 @@ BluetoothDBusService::CreatePairedDevice
    * callback function GetObjectPathCallback (see the third argument of the
    * function call above) may still be called while enabling next time by
    * dbus daemon. To prevent this from happening, added a flag to distinguish
    * if Bluetooth has been turned off. Nevertheless, we need a check if there
    * is a better solution.
    *
    * Please see Bug 818696 for more information.
    */
-  PR_AtomicIncrement(&sIsPairing);
+  sIsPairing++;
 
   nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
   // Then send CreatePairedDevice, it will register a temp device agent then
   // unregister it after pairing process is over
   bool ret = dbus_func_args_async(mConnection,
                                   aTimeout,
                                   GetObjectPathCallback,
                                   (void*)runnable,
--- a/extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
+++ b/extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ModuleUtils.h"
 
 #include "nsCOMPtr.h"
 
 #include "nspr.h"
 #include "nsString.h"
-#include "pratom.h"
 #include "nsUniversalCharDetDll.h"
 #include "nsISupports.h"
 #include "nsICategoryManager.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsICharsetDetector.h"
 #include "nsIStringCharsetDetector.h"
 
--- a/gfx/thebes/gfxReusableSurfaceWrapper.cpp
+++ b/gfx/thebes/gfxReusableSurfaceWrapper.cpp
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxReusableSurfaceWrapper.h"
 #include "gfxImageSurface.h"
-#include "pratom.h"
 
 gfxReusableSurfaceWrapper::gfxReusableSurfaceWrapper(gfxImageSurface* aSurface)
   : mSurface(aSurface)
   , mFormat(aSurface->Format())
   , mSurfaceData(aSurface->Data())
   , mReadCount(0)
 {
   MOZ_COUNT_CTOR(gfxReusableSurfaceWrapper);
@@ -37,23 +36,23 @@ gfxReusableSurfaceWrapper::~gfxReusableS
     NS_DispatchToMainThread(new DeleteImageOnMainThread(mSurface));
   }
 }
 
 void
 gfxReusableSurfaceWrapper::ReadLock()
 {
   NS_CheckThreadSafe(_mOwningThread.GetThread(), "Only the owner thread can call ReadOnlyLock");
-  PR_ATOMIC_INCREMENT(&mReadCount);
+  mReadCount++;
 }
 
 void
 gfxReusableSurfaceWrapper::ReadUnlock()
 {
-  PR_ATOMIC_DECREMENT(&mReadCount);
+  mReadCount--;
   NS_ABORT_IF_FALSE(mReadCount >= 0, "Should not be negative");
 }
 
 gfxReusableSurfaceWrapper*
 gfxReusableSurfaceWrapper::GetWritable(gfxImageSurface** aSurface)
 {
   NS_CheckThreadSafe(_mOwningThread.GetThread(), "Only the owner thread can call GetWritable");
 
--- a/gfx/thebes/gfxReusableSurfaceWrapper.h
+++ b/gfx/thebes/gfxReusableSurfaceWrapper.h
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFXCOWSURFACEWRAPPER
 #define GFXCOWSURFACEWRAPPER
 
 #include "gfxASurface.h"
 #include "nsISupportsImpl.h"
 #include "nsAutoPtr.h"
+#include "mozilla/Atomics.h"
 
 class gfxImageSurface;
 
 /**
  * Provides a cross thread wrapper for a gfxImageSurface
  * that has copy-on-write schemantics.
  *
  * Only the owner thread can write to the surface and aquire
@@ -61,12 +62,12 @@ public:
   void ReadLock();
   void ReadUnlock();
 
 private:
   NS_DECL_OWNINGTHREAD
   nsRefPtr<gfxImageSurface>         mSurface;
   const gfxASurface::gfxImageFormat mFormat;
   const unsigned char*              mSurfaceData;
-  int32_t                           mReadCount;
+  mozilla::Atomic<int32_t>                           mReadCount;
 };
 
 #endif // GFXCOWSURFACEWRAPPER
--- a/ipc/glue/MessagePump.cpp
+++ b/ipc/glue/MessagePump.cpp
@@ -4,17 +4,16 @@
 
 #include "MessagePump.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStringGlue.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
-#include "pratom.h"
 #include "prthread.h"
 
 #include "base/logging.h"
 #include "base/scoped_nsautorelease_pool.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #endif
--- a/modules/libjar/nsJAR.h
+++ b/modules/libjar/nsJAR.h
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #ifndef nsJAR_h__
 #define nsJAR_h__
 
 #include "nscore.h"
-#include "pratom.h"
 #include "prio.h"
 #include "plstr.h"
 #include "prlog.h"
 #include "prtypes.h"
 #include "prinrval.h"
 
 #include "mozilla/Mutex.h"
 #include "nsIComponentManager.h"
--- a/netwerk/cache/nsDiskCacheStreams.h
+++ b/netwerk/cache/nsDiskCacheStreams.h
@@ -11,17 +11,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "nsDiskCacheBinding.h"
 
 #include "nsCache.h"
 
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 
-#include "pratom.h"
+#include "mozilla/Atomics.h"
 
 class nsDiskCacheInputStream;
 class nsDiskCacheDevice;
 
 class nsDiskCacheStreamIO : public nsIOutputStream {
 public:
              nsDiskCacheStreamIO(nsDiskCacheBinding *   binding);
     virtual ~nsDiskCacheStreamIO();
@@ -29,20 +29,20 @@ public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOUTPUTSTREAM
 
     nsresult    GetInputStream(uint32_t offset, nsIInputStream ** inputStream);
     nsresult    GetOutputStream(uint32_t offset, nsIOutputStream ** outputStream);
 
     nsresult    ClearBinding();
     
-    void        IncrementInputStreamCount() { PR_ATOMIC_INCREMENT(&mInStreamCount); }
+    void        IncrementInputStreamCount() { mInStreamCount++; }
     void        DecrementInputStreamCount()
                 {
-                    PR_ATOMIC_DECREMENT(&mInStreamCount);
+                    mInStreamCount--;
                     NS_ASSERTION(mInStreamCount >= 0, "mInStreamCount has gone negative");
                 }
 
     size_t     SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
 
     // GCC 2.95.2 requires this to be defined, although we never call it.
     // and OS/2 requires that it not be private
     nsDiskCacheStreamIO() { NS_NOTREACHED("oops"); }
@@ -53,17 +53,17 @@ private:
     nsresult    FlushBufferToFile();
     void        UpdateFileSize();
     void        DeleteBuffer();
     nsresult    CloseOutputStream();
     nsresult    SeekAndTruncate(uint32_t offset);
 
     nsDiskCacheBinding *        mBinding;       // not an owning reference
     nsDiskCacheDevice *         mDevice;
-    int32_t                     mInStreamCount;
+    mozilla::Atomic<int32_t>                     mInStreamCount;
     PRFileDesc *                mFD;
 
     uint32_t                    mStreamEnd;     // current size of data
     uint32_t                    mBufSize;       // current end of buffer
     char *                      mBuffer;
     bool                        mOutputStreamIsOpen;
 };
 
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -17,17 +17,16 @@
 #endif
 
 #include <stdlib.h>
 #include "nsHostResolver.h"
 #include "nsError.h"
 #include "nsISupportsBase.h"
 #include "nsISupportsUtils.h"
 #include "nsAutoPtr.h"
-#include "pratom.h"
 #include "prthread.h"
 #include "prerror.h"
 #include "prtime.h"
 #include "prlong.h"
 #include "prlog.h"
 #include "pldhash.h"
 #include "plstr.h"
 #include "nsURLHelper.h"
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 
 #include "mozStorageService.h"
 #include "mozStorageConnection.h"
 #include "prinit.h"
-#include "pratom.h"
 #include "nsAutoPtr.h"
 #include "nsCollationCID.h"
 #include "nsEmbedCID.h"
 #include "nsThreadUtils.h"
 #include "mozStoragePrivateHelpers.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #include "nsIXPConnect.h"