Backing out 819c8fe6bdbe due to red on Windows.
authorJustin Lebar <justin.lebar@gmail.com>
Mon, 28 Mar 2011 13:04:12 -0400
changeset 64099 d96ce1d1095605ce40d9e24e2d39f88533f7df9e
parent 64098 286a6d0c1f402c18272d9d9dec2385fd4f285e33
child 64100 4453354d000325ca18b30fe06487c215f88a2c0a
push idunknown
push userunknown
push dateunknown
milestone2.2a1pre
Backing out 819c8fe6bdbe due to red on Windows.
caps/src/nsNullPrincipal.cpp
caps/src/nsPrincipal.cpp
caps/src/nsSystemPrincipal.cpp
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IndexedDatabaseManager.cpp
dom/indexedDB/LazyIdleThread.cpp
dom/plugins/PluginModuleChild.cpp
dom/src/threads/nsDOMWorkerTimeout.cpp
embedding/components/printingui/src/win/nsPrintProgress.cpp
intl/uconv/src/nsScriptableUConv.cpp
ipc/glue/RPCChannel.h
js/src/jslock.h
js/src/xpconnect/src/xpcwrappednativeproto.cpp
modules/libjar/nsJAR.cpp
modules/plugin/base/src/nsNPAPIPlugin.cpp
netwerk/base/src/nsSocketTransport2.cpp
netwerk/cache/nsDiskCacheStreams.h
netwerk/dns/nsHostResolver.h
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpTransaction.cpp
security/manager/boot/src/nsSecureBrowserUIImpl.cpp
security/manager/ssl/src/nsNSSCallbacks.cpp
storage/src/mozStorageService.cpp
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
widget/src/cocoa/nsAppShell.mm
widget/src/xpwidgets/nsBaseAppShell.cpp
xpcom/base/nsAtomicRefcnt.h
xpcom/base/nsDebugImpl.cpp
xpcom/base/nsExceptionService.cpp
xpcom/base/nsMemoryImpl.cpp
xpcom/io/nsPipe3.cpp
xpcom/proxy/src/nsProxyEvent.cpp
xpcom/string/src/nsSubstring.cpp
xpcom/threads/TimerThread.cpp
xpcom/threads/nsTimerImpl.cpp
--- a/caps/src/nsNullPrincipal.cpp
+++ b/caps/src/nsNullPrincipal.cpp
@@ -61,26 +61,26 @@ NS_IMPL_QUERY_INTERFACE2_CI(nsNullPrinci
 NS_IMPL_CI_INTERFACE_GETTER2(nsNullPrincipal,
                              nsIPrincipal,
                              nsISerializable)
 
 NS_IMETHODIMP_(nsrefcnt) 
 nsNullPrincipal::AddRef()
 {
   NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
-  nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_ADDREF(this, count, "nsNullPrincipal", sizeof(*this));
   return count;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsNullPrincipal::Release()
 {
   NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
-  nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_RELEASE(this, count, "nsNullPrincipal");
   if (count == 0) {
     delete this;
   }
 
   return count;
 }
 
--- a/caps/src/nsPrincipal.cpp
+++ b/caps/src/nsPrincipal.cpp
@@ -149,26 +149,26 @@ NS_IMPL_CI_INTERFACE_GETTER2(nsPrincipal
                              nsIPrincipal,
                              nsISerializable)
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPrincipal::AddRef()
 {
   NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
   // XXXcaa does this need to be threadsafe?  See bug 143559.
-  nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_ADDREF(this, count, "nsPrincipal", sizeof(*this));
   return count;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPrincipal::Release()
 {
   NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
-  nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_RELEASE(this, count, "nsPrincipal");
   if (count == 0) {
     delete this;
   }
 
   return count;
 }
 
--- a/caps/src/nsSystemPrincipal.cpp
+++ b/caps/src/nsSystemPrincipal.cpp
@@ -58,26 +58,26 @@ NS_IMPL_QUERY_INTERFACE2_CI(nsSystemPrin
 NS_IMPL_CI_INTERFACE_GETTER2(nsSystemPrincipal,
                              nsIPrincipal,
                              nsISerializable)
 
 NS_IMETHODIMP_(nsrefcnt) 
 nsSystemPrincipal::AddRef()
 {
   NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
-  nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this));
   return count;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsSystemPrincipal::Release()
 {
   NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
-  nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
+  nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
   NS_LOG_RELEASE(this, count, "nsSystemPrincipal");
   if (count == 0) {
     delete this;
   }
 
   return count;
 }
 
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -401,17 +401,17 @@ IDBDatabase::Invalidate()
         if (helper->WindowSerial() == Owner()->GetSerial()) {
           helper->Cancel();
           break;
         }
       }
     }
   }
 
-  if (!PR_ATOMIC_SET(&mInvalidated, 1)) {
+  if (!PR_AtomicSet(&mInvalidated, 1)) {
     DatabaseInfo* info;
     if (!DatabaseInfo::Get(mDatabaseId, &info)) {
       NS_ERROR("This should never fail!");
     }
 
     NS_ASSERTION(info->referenceCount, "Bad reference count!");
     if (--info->referenceCount == 0) {
       DatabaseInfo::Remove(mDatabaseId);
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -803,17 +803,17 @@ IndexedDatabaseManager::Observe(nsISuppo
                                 const char* aTopic,
                                 const PRUnichar* aData)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID)) {
     // Setting this flag prevents the service from being recreated and prevents
     // further databases from being created.
-    if (PR_ATOMIC_SET(&gShutdown, 1)) {
+    if (PR_AtomicSet(&gShutdown, 1)) {
       NS_ERROR("Shutdown more than once?!");
     }
 
     // Make sure to join with our IO thread.
     if (NS_FAILED(mIOThread->Shutdown())) {
       NS_WARNING("Failed to shutdown IO thread!");
     }
 
@@ -943,17 +943,17 @@ IndexedDatabaseManager::AsyncUsageRunnab
   NS_ASSERTION(aURI, "Null pointer!");
   NS_ASSERTION(!aOrigin.IsEmpty(), "Empty origin!");
   NS_ASSERTION(aCallback, "Null pointer!");
 }
 
 void
 IndexedDatabaseManager::AsyncUsageRunnable::Cancel()
 {
-  if (PR_ATOMIC_SET(&mCanceled, 1)) {
+  if (PR_AtomicSet(&mCanceled, 1)) {
     NS_ERROR("Canceled more than once?!");
   }
 }
 
 nsresult
 IndexedDatabaseManager::AsyncUsageRunnable::RunInternal()
 {
   if (NS_IsMainThread()) {
--- a/dom/indexedDB/LazyIdleThread.cpp
+++ b/dom/indexedDB/LazyIdleThread.cpp
@@ -356,17 +356,17 @@ LazyIdleThread::SelfDestruct()
   delete this;
 }
 
 NS_IMPL_THREADSAFE_ADDREF(LazyIdleThread)
 
 NS_IMETHODIMP_(nsrefcnt)
 LazyIdleThread::Release()
 {
-  nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt);
+  nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
   NS_LOG_RELEASE(this, count, "LazyIdleThread");
 
   if (!count) {
     // Stabilize refcount.
     mRefCnt = 1;
 
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct);
--- a/dom/plugins/PluginModuleChild.cpp
+++ b/dom/plugins/PluginModuleChild.cpp
@@ -1996,17 +1996,17 @@ PluginModuleChild::NPN_CreateObject(NPP 
     return newObject;
 }
 
 NPObject* NP_CALLBACK
 PluginModuleChild::NPN_RetainObject(NPObject* aNPObj)
 {
     AssertPluginThread();
 
-    int32_t refCnt = PR_ATOMIC_INCREMENT((int32_t*)&aNPObj->referenceCount);
+    int32_t refCnt = PR_AtomicIncrement((PRInt32*)&aNPObj->referenceCount);
     NS_LOG_ADDREF(aNPObj, refCnt, "NPObject", sizeof(NPObject));
 
     return aNPObj;
 }
 
 void NP_CALLBACK
 PluginModuleChild::NPN_ReleaseObject(NPObject* aNPObj)
 {
@@ -2024,17 +2024,17 @@ PluginModuleChild::NPN_ReleaseObject(NPO
         if (!doe) {
             NS_ERROR("An object for a destroyed instance isn't in the instance deletion hash");
             return;
         }
         if (doe->mDeleted)
             return;
     }
 
-    int32_t refCnt = PR_ATOMIC_DECREMENT((int32_t*)&aNPObj->referenceCount);
+    int32_t refCnt = PR_AtomicDecrement((PRInt32*)&aNPObj->referenceCount);
     NS_LOG_RELEASE(aNPObj, refCnt, "NPObject");
 
     if (refCnt == 0) {
         DeallocNPObject(aNPObj);
         if (doe)
             doe->mDeleted = true;
     }
     return;
--- a/dom/src/threads/nsDOMWorkerTimeout.cpp
+++ b/dom/src/threads/nsDOMWorkerTimeout.cpp
@@ -420,17 +420,17 @@ nsDOMWorkerTimeout::Resume()
   mTimer->InitWithCallback(this, mSuspendInterval, nsITimer::TYPE_ONE_SHOT);
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init timer!");
 }
 
 void
 nsDOMWorkerTimeout::AcquireSpinlock()
 {
   PRUint32 loopCount = 0;
-  while (PR_ATOMIC_SET(&mSuspendSpinlock, 1) == 1) {
+  while (PR_AtomicSet(&mSuspendSpinlock, 1) == 1) {
     if (++loopCount > SUSPEND_SPINLOCK_COUNT) {
       LOG(("AcquireSpinlock taking too long (looped %u times), yielding.",
            loopCount));
       loopCount = 0;
       PR_Sleep(PR_INTERVAL_NO_WAIT);
     }
   }
 #ifdef PR_LOGGING
@@ -441,17 +441,17 @@ nsDOMWorkerTimeout::AcquireSpinlock()
 }
 
 void
 nsDOMWorkerTimeout::ReleaseSpinlock()
 {
 #ifdef DEBUG
   PRInt32 suspended =
 #endif
-  PR_ATOMIC_SET(&mSuspendSpinlock, 0);
+  PR_AtomicSet(&mSuspendSpinlock, 0);
   NS_ASSERTION(suspended == 1, "Huh?!");
 }
 
 NS_IMETHODIMP
 nsDOMWorkerTimeout::Notify(nsITimer* aTimer)
 {
   // Should be on the timer thread.
   NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
--- a/embedding/components/printingui/src/win/nsPrintProgress.cpp
+++ b/embedding/components/printingui/src/win/nsPrintProgress.cpp
@@ -40,36 +40,35 @@
 #include "nsPrintProgress.h"
 
 #include "nsIBaseWindow.h"
 #include "nsISupportsArray.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
-#include "nsAtomicRefcnt.h"
 
 #if 0
 NS_IMPL_THREADSAFE_ADDREF(nsPrintProgress)
 NS_IMPL_THREADSAFE_RELEASE(nsPrintProgress)
 #else
 NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::AddRef(void)
 {
   NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
   nsrefcnt count;
-  count = NS_AtomicIncrementRefcnt(mRefCnt);
+  count = PR_AtomicIncrement((PRInt32*)&mRefCnt);
   //NS_LOG_ADDREF(this, count, "nsPrintProgress", sizeof(*this));
   return count;
 }
 
 NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::Release(void)
 {
   nsrefcnt count;
   NS_PRECONDITION(0 != mRefCnt, "dup release");
-  count = NS_AtomicDecrementRefcnt(mRefCnt);
+  count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
   //NS_LOG_RELEASE(this, count, "nsPrintProgress");
   if (0 == count) {
     mRefCnt = 1; /* stabilize */
     /* enable this to find non-threadsafe destructors: */
     /* NS_ASSERT_OWNINGTHREAD(nsPrintProgress); */
     delete this;
     return 0;
   }
--- a/intl/uconv/src/nsScriptableUConv.cpp
+++ b/intl/uconv/src/nsScriptableUConv.cpp
@@ -32,17 +32,17 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsAtomicRefcnt.h"
+#include "pratom.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsIServiceManager.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIScriptableUConv.h"
 #include "nsScriptableUConv.h"
 #include "nsIStringStream.h"
 #include "nsCRT.h"
@@ -53,22 +53,22 @@
 static PRInt32          gInstanceCount = 0;
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
 
 nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
 : mIsInternal(PR_FALSE)
 {
-  PR_ATOMIC_INCREMENT(&gInstanceCount);
+  PR_AtomicIncrement(&gInstanceCount);
 }
 
 nsScriptableUnicodeConverter::~nsScriptableUnicodeConverter()
 {
-  PR_ATOMIC_DECREMENT(&gInstanceCount);
+  PR_AtomicDecrement(&gInstanceCount);
 }
 
 nsresult
 nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc,
                                                            PRInt32* aOutLen,
                                                            char **_retval)
 {
   if (!mEncoder)
--- a/ipc/glue/RPCChannel.h
+++ b/ipc/glue/RPCChannel.h
@@ -43,17 +43,17 @@
 
 // FIXME/cjones probably shouldn't depend on STL
 #include <queue>
 #include <stack>
 #include <vector>
 
 #include "base/basictypes.h"
 
-#include "nsAtomicRefcnt.h"
+#include "pratom.h"
 
 #include "mozilla/ipc/SyncChannel.h"
 #include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace ipc {
 //-----------------------------------------------------------------------------
 
@@ -445,20 +445,22 @@ private:
       public:
         RefCountedTask(CancelableTask* aTask)
         : mTask(aTask)
         , mRefCnt(0) {}
         ~RefCountedTask() { delete mTask; }
         void Run() { mTask->Run(); }
         void Cancel() { mTask->Cancel(); }
         void AddRef() {
-            NS_AtomicIncrementRefcnt(mRefCnt);
+            PR_AtomicIncrement(reinterpret_cast<PRInt32*>(&mRefCnt));
         }
         void Release() {
-            if (NS_AtomicDecrementRefcnt(mRefCnt) == 0)
+            nsrefcnt count =
+                PR_AtomicDecrement(reinterpret_cast<PRInt32*>(&mRefCnt));
+            if (0 == count)
                 delete this;
         }
 
       private:
         CancelableTask* mTask;
         nsrefcnt mRefCnt;
     };
 
--- a/js/src/jslock.h
+++ b/js/src/jslock.h
@@ -87,20 +87,20 @@ typedef struct JSThinLock {
 #define CURRENT_THREAD_IS_ME(me) (((JSThread *)me)->id == js_CurrentThreadId())
 
 typedef PRLock JSLock;
 
 /*
  * Atomic increment and decrement for a reference counter, given jsrefcount *p.
  * NB: jsrefcount is int32, aka PRInt32, so that pratom.h functions work.
  */
-#define JS_ATOMIC_INCREMENT(p)      PR_ATOMIC_INCREMENT((PRInt32 *)(p))
-#define JS_ATOMIC_DECREMENT(p)      PR_ATOMIC_DECREMENT((PRInt32 *)(p))
-#define JS_ATOMIC_ADD(p,v)          PR_ATOMIC_ADD((PRInt32 *)(p), (PRInt32)(v))
-#define JS_ATOMIC_SET(p,v)          PR_ATOMIC_SET((PRInt32 *)(p), (PRInt32)(v))
+#define JS_ATOMIC_INCREMENT(p)      PR_AtomicIncrement((PRInt32 *)(p))
+#define JS_ATOMIC_DECREMENT(p)      PR_AtomicDecrement((PRInt32 *)(p))
+#define JS_ATOMIC_ADD(p,v)          PR_AtomicAdd((PRInt32 *)(p), (PRInt32)(v))
+#define JS_ATOMIC_SET(p,v)          PR_AtomicSet((PRInt32 *)(p), (PRInt32)(v))
 
 #define js_CurrentThreadId()        PR_GetCurrentThread()
 #define JS_NEW_LOCK()               PR_NewLock()
 #define JS_DESTROY_LOCK(l)          PR_DestroyLock(l)
 #define JS_ACQUIRE_LOCK(l)          PR_Lock(l)
 #define JS_RELEASE_LOCK(l)          PR_Unlock(l)
 
 #define JS_NEW_CONDVAR(l)           PR_NewCondVar(l)
--- a/js/src/xpconnect/src/xpcwrappednativeproto.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativeproto.cpp
@@ -61,28 +61,28 @@ XPCWrappedNativeProto::XPCWrappedNativeP
       mOffsets(offsets)
 {
     // This native object lives as long as its associated JSObject - killed
     // by finalization of the JSObject (or explicitly if Init fails).
 
     MOZ_COUNT_CTOR(XPCWrappedNativeProto);
 
 #ifdef DEBUG
-    PR_ATOMIC_INCREMENT(&gDEBUG_LiveProtoCount);
+    PR_AtomicIncrement(&gDEBUG_LiveProtoCount);
 #endif
 }
 
 XPCWrappedNativeProto::~XPCWrappedNativeProto()
 {
     NS_ASSERTION(!mJSProtoObject, "JSProtoObject still alive");
 
     MOZ_COUNT_DTOR(XPCWrappedNativeProto);
 
 #ifdef DEBUG
-    PR_ATOMIC_DECREMENT(&gDEBUG_LiveProtoCount);
+    PR_AtomicDecrement(&gDEBUG_LiveProtoCount);
 #endif
     
     // Note that our weak ref to mScope is not to be trusted at this point.
 
     XPCNativeSet::ClearCacheEntryForClassInfo(mClassInfo);
 
     delete mScriptableInfo;
 }
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -136,17 +136,17 @@ nsJAR::~nsJAR()
 NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsJAR, nsIZipReader)
 NS_IMPL_THREADSAFE_ADDREF(nsJAR)
 
 // Custom Release method works with nsZipReaderCache...
 nsrefcnt nsJAR::Release(void) 
 {
   nsrefcnt count; 
   NS_PRECONDITION(0 != mRefCnt, "dup release"); 
-  count = NS_AtomicDecrementRefcnt(mRefCnt); 
+  count = PR_AtomicDecrement((PRInt32 *)&mRefCnt); 
   NS_LOG_RELEASE(this, count, "nsJAR"); 
   if (0 == count) {
     mRefCnt = 1; /* stabilize */ 
     /* enable this to find non-threadsafe destructors: */ 
     /* NS_ASSERT_OWNINGTHREAD(nsJAR); */ 
     delete this;
     return 0; 
   }
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -43,17 +43,16 @@
 #ifdef MOZ_IPC
 #include "base/basictypes.h"
 #endif 
 
 #include "prtypes.h"
 #include "prmem.h"
 #include "prenv.h"
 #include "prclist.h"
-#include "nsAtomicRefcnt.h"
 
 #include "jscntxt.h"
 
 #include "nsAutoLock.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsNPAPIPluginStreamListener.h"
 #include "nsIServiceManager.h"
@@ -1521,33 +1520,33 @@ NPObject* NP_CALLBACK
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_retainobject called from the wrong thread\n"));
   }
   if (npobj) {
 #ifdef NS_BUILD_REFCNT_LOGGING
     int32_t refCnt =
 #endif
-      NS_AtomicIncrementRefcnt(npobj->referenceCount);
+      PR_AtomicIncrement((PRInt32*)&npobj->referenceCount);
     NS_LOG_ADDREF(npobj, refCnt, "BrowserNPObject", sizeof(NPObject));
   }
 
   return npobj;
 }
 
 void NP_CALLBACK
 _releaseobject(NPObject* npobj)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releaseobject called from the wrong thread\n"));
   }
   if (!npobj)
     return;
 
-  int32_t refCnt = NS_AtomicDecrementRefcnt(npobj->referenceCount);
+  int32_t refCnt = PR_AtomicDecrement((PRInt32*)&npobj->referenceCount);
   NS_LOG_RELEASE(npobj, refCnt, "BrowserNPObject");
 
   if (refCnt == 0) {
     nsNPObjWrapper::OnDestroy(npobj);
 
     NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
                    ("Deleting NPObject %p, refcount hit 0\n", npobj));
 
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -38,29 +38,29 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #endif
 
 #include "nsSocketTransport2.h"
-#include "nsAtomicRefcnt.h"
 #include "nsIOService.h"
 #include "nsStreamUtils.h"
 #include "nsNetSegmentUtils.h"
 #include "nsTransportUtils.h"
 #include "nsProxyInfo.h"
 #include "nsNetCID.h"
 #include "nsAutoLock.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "netCore.h"
 #include "nsInt64.h"
 #include "prmem.h"
+#include "pratom.h"
 #include "plstr.h"
 #include "prnetdb.h"
 #include "prerror.h"
 #include "prerr.h"
 
 #include "nsIServiceManager.h"
 #include "nsIProxyObjectManager.h"
 #include "nsISocketProviderService.h"
@@ -258,24 +258,24 @@ nsSocketInputStream::OnSocketReady(nsres
 
 NS_IMPL_QUERY_INTERFACE2(nsSocketInputStream,
                          nsIInputStream,
                          nsIAsyncInputStream)
 
 NS_IMETHODIMP_(nsrefcnt)
 nsSocketInputStream::AddRef()
 {
-    NS_AtomicIncrementRefcnt(mReaderRefCnt);
+    PR_AtomicIncrement((PRInt32*)&mReaderRefCnt);
     return mTransport->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsSocketInputStream::Release()
 {
-    if (NS_AtomicDecrementRefcnt(mReaderRefCnt) == 0)
+    if (PR_AtomicDecrement((PRInt32*)&mReaderRefCnt) == 0)
         Close();
     return mTransport->Release();
 }
 
 NS_IMETHODIMP
 nsSocketInputStream::Close()
 {
     return CloseWithStatus(NS_BASE_STREAM_CLOSED);
@@ -517,24 +517,24 @@ nsSocketOutputStream::OnSocketReady(nsre
 
 NS_IMPL_QUERY_INTERFACE2(nsSocketOutputStream,
                          nsIOutputStream,
                          nsIAsyncOutputStream)
 
 NS_IMETHODIMP_(nsrefcnt)
 nsSocketOutputStream::AddRef()
 {
-    NS_AtomicIncrementRefcnt(mWriterRefCnt);
+    PR_AtomicIncrement((PRInt32*)&mWriterRefCnt);
     return mTransport->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsSocketOutputStream::Release()
 {
-    if (NS_AtomicDecrementRefcnt(mWriterRefCnt) == 0)
+    if (PR_AtomicDecrement((PRInt32*)&mWriterRefCnt) == 0)
         Close();
     return mTransport->Release();
 }
 
 NS_IMETHODIMP
 nsSocketOutputStream::Close()
 {
     return CloseWithStatus(NS_BASE_STREAM_CLOSED);
--- a/netwerk/cache/nsDiskCacheStreams.h
+++ b/netwerk/cache/nsDiskCacheStreams.h
@@ -73,20 +73,20 @@ public:
                        PRUint32 *   bytesWritten);
 
     nsresult    Seek(PRInt32 whence, PRInt32 offset);
     nsresult    Tell(PRUint32 * position);    
     nsresult    SetEOF();
 
     void        ClearBinding();
     
-    void        IncrementInputStreamCount() { PR_ATOMIC_INCREMENT(&mInStreamCount); }
+    void        IncrementInputStreamCount() { PR_AtomicIncrement(&mInStreamCount); }
     void        DecrementInputStreamCount()
                 {
-                    PR_ATOMIC_DECREMENT(&mInStreamCount);
+                    PR_AtomicDecrement(&mInStreamCount);
                     NS_ASSERTION(mInStreamCount >= 0, "mInStreamCount has gone negative");
                 }
 
     // 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"); }
 private:
 
--- a/netwerk/dns/nsHostResolver.h
+++ b/netwerk/dns/nsHostResolver.h
@@ -34,39 +34,39 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsHostResolver_h__
 #define nsHostResolver_h__
 
 #include "nscore.h"
-#include "nsAtomicRefcnt.h"
+#include "pratom.h"
 #include "prcvar.h"
 #include "prclist.h"
 #include "prnetdb.h"
 #include "pldhash.h"
 #include "nsISupportsImpl.h"
 
 class nsHostResolver;
 class nsHostRecord;
 class nsResolveHostCallback;
 
 /* XXX move this someplace more generic */
 #define NS_DECL_REFCOUNTED_THREADSAFE(classname)                             \
   private:                                                                   \
     nsAutoRefCnt _refc;                                                      \
   public:                                                                    \
     PRInt32 AddRef() {                                                       \
-        PRInt32 n = NS_AtomicIncrementRefcnt(_refc);                         \
+        PRInt32 n = PR_AtomicIncrement((PRInt32*)&_refc);                    \
         NS_LOG_ADDREF(this, n, #classname, sizeof(classname));               \
         return n;                                                            \
     }                                                                        \
     PRInt32 Release() {                                                      \
-        PRInt32 n = NS_AtomicDecrementRefcnt(_refc);                         \
+        PRInt32 n = PR_AtomicDecrement((PRInt32*)&_refc);                    \
         NS_LOG_RELEASE(this, n, #classname);                                 \
         if (n == 0)                                                          \
             delete this;                                                     \
         return n;                                                            \
     }
 
 #define MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY  3
 #define MAX_RESOLVER_THREADS_FOR_HIGH_PRIORITY 5
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -70,24 +70,24 @@ public:
     
    ~nsHttpConnectionInfo()
     {
         LOG(("Destroying nsHttpConnectionInfo @%x\n", this));
     }
 
     nsrefcnt AddRef()
     {
-        nsrefcnt n = NS_AtomicIncrementRefcnt(mRef);
+        nsrefcnt n = PR_AtomicIncrement((PRInt32 *) &mRef);
         NS_LOG_ADDREF(this, n, "nsHttpConnectionInfo", sizeof(*this));
         return n;
     }
 
     nsrefcnt Release()
     {
-        nsrefcnt n = NS_AtomicDecrementRefcnt(mRef);
+        nsrefcnt n = PR_AtomicDecrement((PRInt32 *) &mRef);
         NS_LOG_RELEASE(this, n, "nsHttpConnectionInfo");
         if (n == 0)
             delete this;
         return n;
     }
 
     const nsAFlatCString &HashKey() const { return mHashKey; }
 
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -49,17 +49,17 @@
 #include "nsHttpRequestHead.h"
 #include "nsHttpResponseHead.h"
 #include "nsHttpChunkedDecoder.h"
 #include "nsTransportUtils.h"
 #include "nsNetUtil.h"
 #include "nsProxyRelease.h"
 #include "nsIOService.h"
 #include "nsAutoLock.h"
-#include "nsAtomicRefcnt.h"
+#include "pratom.h"
 
 #include "nsISeekableStream.h"
 #include "nsISocketTransport.h"
 #include "nsMultiplexInputStream.h"
 #include "nsStringStream.h"
 
 #include "nsComponentManagerUtils.h" // do_CreateInstance
 #include "nsServiceManagerUtils.h"   // do_GetService
@@ -1193,17 +1193,17 @@ nsHttpTransaction::DeleteSelfOnConsumerT
 
 NS_IMPL_THREADSAFE_ADDREF(nsHttpTransaction)
 
 NS_IMETHODIMP_(nsrefcnt)
 nsHttpTransaction::Release()
 {
     nsrefcnt count;
     NS_PRECONDITION(0 != mRefCnt, "dup release");
-    count = NS_AtomicDecrementRefcnt(mRefCnt);
+    count = PR_AtomicDecrement((PRInt32 *) &mRefCnt);
     NS_LOG_RELEASE(this, count, "nsHttpTransaction");
     if (0 == count) {
         mRefCnt = 1; /* stablize */
         // it is essential that the transaction be destroyed on the consumer 
         // thread (we could be holding the last reference to our consumer).
         DeleteSelfOnConsumerThread();
         return 0;
     }
--- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
@@ -138,21 +138,21 @@ static PLDHashTableOps gMapOps = {
   RequestMapInitEntry
 };
 
 #ifdef DEBUG
 class nsAutoAtomic {
   public:
     nsAutoAtomic(PRInt32 &i)
     :mI(i) {
-      PR_ATOMIC_INCREMENT(&mI);
+      PR_AtomicIncrement(&mI);
     }
 
     ~nsAutoAtomic() {
-      PR_ATOMIC_DECREMENT(&mI);
+      PR_AtomicDecrement(&mI);
     }
 
   protected:
     PRInt32 &mI;
 
   private:
     nsAutoAtomic(); // not accessible
 };
--- a/security/manager/ssl/src/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/src/nsNSSCallbacks.cpp
@@ -329,23 +329,23 @@ SECStatus nsNSSHttpRequestSession::trySe
 #endif
 
   return result_sec_status;
 }
 
 void
 nsNSSHttpRequestSession::AddRef()
 {
-  NS_AtomicIncrementRefcnt(mRefCount);
+  PR_AtomicIncrement(&mRefCount);
 }
 
 void
 nsNSSHttpRequestSession::Release()
 {
-  PRInt32 newRefCount = NS_AtomicDecrementRefcnt(mRefCount);
+  PRInt32 newRefCount = PR_AtomicDecrement(&mRefCount);
   if (!newRefCount) {
     delete this;
   }
 }
 
 SECStatus
 nsNSSHttpRequestSession::internal_send_receive_attempt(PRBool &retryable_error,
                                                        PRPollDesc **pPollDesc,
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -201,17 +201,17 @@ public:
 
     // We need to obtain the toolkit.storage.synchronous preferences on the main
     // thread because the preference service can only be accessed there.  This
     // is cached in the service for all future Open[Unshared]Database calls.
     nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
     PRInt32 synchronous = PREF_TS_SYNCHRONOUS_DEFAULT;
     if (pref)
       (void)pref->GetIntPref(PREF_TS_SYNCHRONOUS, &synchronous);
-    ::PR_ATOMIC_SET(mSynchronousPrefValPtr, synchronous);
+    ::PR_AtomicSet(mSynchronousPrefValPtr, synchronous);
 
     // Register our SQLite memory reporters.  Registration can only happen on
     // the main thread (otherwise you'll get cryptic crashes).
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLitePageCacheMemoryUsed));
     NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLiteOtherMemoryUsed));
 
     return NS_OK;
   }
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -3909,30 +3909,30 @@ nsUrlClassifierDBService::Init()
     if (NS_SUCCEEDED(prefs->GetCharPref(GETHASH_TABLES_PREF, getter_Copies(tmpstr)))) {
       SplitTables(tmpstr, mGethashWhitelist);
     }
 
     prefs->AddObserver(GETHASH_TABLES_PREF, this, PR_FALSE);
 
     PRInt32 tmpint;
     rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
-    PR_ATOMIC_SET(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
+    PR_AtomicSet(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
 
     prefs->AddObserver(CONFIRM_AGE_PREF, this, PR_FALSE);
 
     rv = prefs->GetIntPref(UPDATE_CACHE_SIZE_PREF, &tmpint);
-    PR_ATOMIC_SET(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
+    PR_AtomicSet(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
 
     rv = prefs->GetIntPref(UPDATE_WORKING_TIME, &tmpint);
-    PR_ATOMIC_SET(&gWorkingTimeThreshold,
-                  NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
+    PR_AtomicSet(&gWorkingTimeThreshold,
+                 NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
 
     rv = prefs->GetIntPref(UPDATE_DELAY_TIME, &tmpint);
-    PR_ATOMIC_SET(&gDelayTime,
-                  NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
+    PR_AtomicSet(&gDelayTime,
+                 NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
   }
 
   // Start the background thread.
   rv = NS_NewThread(&gDbBackgroundThread);
   if (NS_FAILED(rv))
     return rv;
 
   mWorker = new nsUrlClassifierDBServiceWorker();
@@ -4227,31 +4227,31 @@ nsUrlClassifierDBService::Observe(nsISup
       mGethashWhitelist.Clear();
       nsXPIDLCString val;
       if (NS_SUCCEEDED(prefs->GetCharPref(GETHASH_TABLES_PREF, getter_Copies(val)))) {
         SplitTables(val, mGethashWhitelist);
       }
     } else if (NS_LITERAL_STRING(CONFIRM_AGE_PREF).Equals(aData)) {
       PRInt32 tmpint;
       rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
-      PR_ATOMIC_SET(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
+      PR_AtomicSet(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
     } else if (NS_LITERAL_STRING(UPDATE_CACHE_SIZE_PREF).Equals(aData)) {
       PRInt32 tmpint;
       rv = prefs->GetIntPref(UPDATE_CACHE_SIZE_PREF, &tmpint);
-      PR_ATOMIC_SET(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
+      PR_AtomicSet(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
     } else if (NS_LITERAL_STRING(UPDATE_WORKING_TIME).Equals(aData)) {
       PRInt32 tmpint;
       rv = prefs->GetIntPref(UPDATE_WORKING_TIME, &tmpint);
-      PR_ATOMIC_SET(&gWorkingTimeThreshold,
-                    NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
+      PR_AtomicSet(&gWorkingTimeThreshold,
+                   NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
     } else if (NS_LITERAL_STRING(UPDATE_DELAY_TIME).Equals(aData)) {
       PRInt32 tmpint;
       rv = prefs->GetIntPref(UPDATE_DELAY_TIME, &tmpint);
-      PR_ATOMIC_SET(&gDelayTime,
-                    NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
+      PR_AtomicSet(&gDelayTime,
+                 NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
     }
   } else if (!strcmp(aTopic, "profile-before-change") ||
              !strcmp(aTopic, "xpcom-shutdown-threads")) {
     Shutdown();
   } else {
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/widget/src/cocoa/nsAppShell.mm
+++ b/widget/src/cocoa/nsAppShell.mm
@@ -431,29 +431,29 @@ nsAppShell::ProcessGeckoEvents(void* aIn
   // call to ScheduleNativeEventCallback() from NativeEventCallback().  We
   // balance the "extra" AddRefs here (rather than always in Exit()) in order
   // to ensure that 'self' stays alive until the end of this method.  We also
   // make sure not to finish the balancing until all the recursion has been
   // unwound.
   if (self->mTerminated) {
     PRInt32 releaseCount = 0;
     if (self->mNativeEventScheduledDepth > self->mNativeEventCallbackDepth) {
-      releaseCount = PR_ATOMIC_SET(&self->mNativeEventScheduledDepth,
-                                   self->mNativeEventCallbackDepth);
+      releaseCount = PR_AtomicSet(&self->mNativeEventScheduledDepth,
+                                  self->mNativeEventCallbackDepth);
     }
     while (releaseCount-- > self->mNativeEventCallbackDepth)
       self->Release();
   } else {
     // As best we can tell, every call to ProcessGeckoEvents() is triggered
     // by a call to ScheduleNativeEventCallback().  But we've seen a few
     // (non-reproducible) cases of double-frees that *might* have been caused
     // by spontaneous calls (from the OS) to ProcessGeckoEvents().  So we
     // deal with that possibility here.
-    if (PR_ATOMIC_DECREMENT(&self->mNativeEventScheduledDepth) < 0) {
-      PR_ATOMIC_SET(&self->mNativeEventScheduledDepth, 0);
+    if (PR_AtomicDecrement(&self->mNativeEventScheduledDepth) < 0) {
+      PR_AtomicSet(&self->mNativeEventScheduledDepth, 0);
       NS_WARNING("Spontaneous call to ProcessGeckoEvents()!");
     } else {
       self->Release();
     }
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
@@ -507,17 +507,17 @@ nsAppShell::ScheduleNativeEventCallback(
 
   if (mTerminated)
     return;
 
   // Each AddRef() here is normally balanced by exactly one Release() in
   // ProcessGeckoEvents().  But there are exceptions, for which see
   // ProcessGeckoEvents() and Exit().
   NS_ADDREF_THIS();
-  PR_ATOMIC_INCREMENT(&mNativeEventScheduledDepth);
+  PR_AtomicIncrement(&mNativeEventScheduledDepth);
 
   // This will invoke ProcessGeckoEvents on the main thread.
   ::CFRunLoopSourceSignal(mCFRunLoopSource);
   ::CFRunLoopWakeUp(mCFRunLoop);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
@@ -791,17 +791,17 @@ nsAppShell::Exit(void)
 
   // A call to Exit() just after a call to ScheduleNativeEventCallback()
   // prevents the (normally) matching call to ProcessGeckoEvents() from
   // happening.  If we've been called from ProcessGeckoEvents() (as usually
   // happens), we take care of it there.  But if we have an unbalanced call
   // to ScheduleNativeEventCallback() and ProcessGeckoEvents() isn't on the
   // stack, we need to take care of the problem here.
   if (!mNativeEventCallbackDepth && mNativeEventScheduledDepth) {
-    PRInt32 releaseCount = PR_ATOMIC_SET(&mNativeEventScheduledDepth, 0);
+    PRInt32 releaseCount = PR_AtomicSet(&mNativeEventScheduledDepth, 0);
     while (releaseCount-- > 0)
       NS_RELEASE_THIS();
   }
 
   return nsBaseAppShell::Exit();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
--- a/widget/src/xpwidgets/nsBaseAppShell.cpp
+++ b/widget/src/xpwidgets/nsBaseAppShell.cpp
@@ -92,17 +92,17 @@ nsBaseAppShell::Init()
     obsSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
   return NS_OK;
 }
 
 // Called by nsAppShell's native event callback
 void
 nsBaseAppShell::NativeEventCallback()
 {
-  PRInt32 hasPending = PR_ATOMIC_SET(&mNativeEventPending, 0);
+  PRInt32 hasPending = PR_AtomicSet(&mNativeEventPending, 0);
   if (hasPending == 0)
     return;
 
   // If DoProcessNextNativeEvent is on the stack, then we assume that we can
   // just unwind and let nsThread::ProcessNextEvent process the next event.
   // However, if we are called from a nested native event loop (maybe via some
   // plug-in or library function), then go ahead and process Gecko events now.
   if (mEventloopNestingState == eEventloopXPCOM) {
@@ -257,17 +257,17 @@ nsBaseAppShell::GetEventloopNestingLevel
 
 // Called from any thread
 NS_IMETHODIMP
 nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal *thr)
 {
   if (mBlockNativeEvent)
     return NS_OK;
 
-  PRInt32 lastVal = PR_ATOMIC_SET(&mNativeEventPending, 1);
+  PRInt32 lastVal = PR_AtomicSet(&mNativeEventPending, 1);
   if (lastVal == 1)
     return NS_OK;
 
   // Returns on the main thread in NativeEventCallback above
   ScheduleNativeEventCallback();
   return NS_OK;
 }
 
--- a/xpcom/base/nsAtomicRefcnt.h
+++ b/xpcom/base/nsAtomicRefcnt.h
@@ -54,22 +54,16 @@ typedef volatile long nsAtomicRefcnt;
 #endif
 
 #else /* !defined(XP_WIN) */
 
 typedef PRInt32  nsAtomicRefcnt;
 
 #endif
 
-inline PRInt32
-NS_AtomicIncrementRefcnt(PRInt32 &refcnt)
-{
-  return PR_ATOMIC_INCREMENT(&refcnt);
-}
-
 inline nsrefcnt
 NS_AtomicIncrementRefcnt(nsrefcnt &refcnt)
 {
   return (nsrefcnt) PR_ATOMIC_INCREMENT((nsAtomicRefcnt*)&refcnt);
 }
 
 inline nsrefcnt
 NS_AtomicIncrementRefcnt(nsAutoRefCnt &refcnt)
@@ -85,15 +79,9 @@ NS_AtomicDecrementRefcnt(nsrefcnt &refcn
 }
 
 inline nsrefcnt
 NS_AtomicDecrementRefcnt(nsAutoRefCnt &refcnt)
 {
   return (nsrefcnt) PR_ATOMIC_DECREMENT((nsAtomicRefcnt*)&refcnt);
 }
 
-inline PRInt32
-NS_AtomicDecrementRefcnt(PRInt32 &refcnt)
-{
-  return PR_ATOMIC_DECREMENT(&refcnt);
-}
-
 #endif
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -343,17 +343,17 @@ NS_DebugBreak(PRUint32 aSeverity, const 
      nsTraceRefcntImpl::WalkTheStack(stderr);
 #endif
      Abort(buf.buffer);
      return;
    }
    }
 
    // Now we deal with assertions
-   PR_ATOMIC_INCREMENT(&gAssertionCount);
+   PR_AtomicIncrement(&gAssertionCount);
 
    switch (GetAssertBehavior()) {
    case NS_ASSERT_WARN:
      return;
 
    case NS_ASSERT_SUSPEND:
 #ifdef XP_UNIX
       fprintf(stderr, "Suspending process; attach with the debugger.\n");
--- a/xpcom/base/nsExceptionService.cpp
+++ b/xpcom/base/nsExceptionService.cpp
@@ -99,25 +99,25 @@ PRInt32 nsExceptionManager::totalInstanc
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
 
 nsExceptionManager::nsExceptionManager(nsExceptionService *svc) :
   mNextThread(nsnull),
   mService(svc)
 {
   /* member initializers and constructor code */
 #ifdef NS_DEBUG
-  PR_ATOMIC_INCREMENT(&totalInstances);
+  PR_AtomicIncrement(&totalInstances);
 #endif
 }
 
 nsExceptionManager::~nsExceptionManager()
 {
   /* destructor code */
 #ifdef NS_DEBUG
-  PR_ATOMIC_DECREMENT(&totalInstances);
+  PR_AtomicDecrement(&totalInstances);
 #endif // NS_DEBUG
 }
 
 /* void setCurrentException (in nsIException error); */
 NS_IMETHODIMP nsExceptionManager::SetCurrentException(nsIException *error)
 {
     CHECK_MANAGER_USE_OK();
     mCurrentException = error;
@@ -155,17 +155,17 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsExceptio
                               nsIExceptionService,
                               nsIExceptionManager,
                               nsIObserver)
 
 nsExceptionService::nsExceptionService()
   : mProviders(4, PR_TRUE) /* small, thread-safe hashtable */
 {
 #ifdef NS_DEBUG
-  if (PR_ATOMIC_INCREMENT(&totalInstances)!=1) {
+  if (PR_AtomicIncrement(&totalInstances)!=1) {
     NS_ERROR("The nsExceptionService is a singleton!");
   }
 #endif
   /* member initializers and constructor code */
   if (tlsIndex == BAD_TLS_INDEX) {
     PRStatus status;
     status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct );
     NS_ASSERTION(status==0, "ScriptErrorService could not allocate TLS storage.");
@@ -181,17 +181,17 @@ nsExceptionService::nsExceptionService()
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
 }
 
 nsExceptionService::~nsExceptionService()
 {
   Shutdown();
   /* destructor code */
 #ifdef NS_DEBUG
-  PR_ATOMIC_DECREMENT(&totalInstances);
+  PR_AtomicDecrement(&totalInstances);
 #endif
 }
 
 /*static*/
 void nsExceptionService::ThreadDestruct( void *data )
 {
   if (!lock) {
     NS_WARNING("nsExceptionService ignoring thread destruction after shutdown");
--- a/xpcom/base/nsMemoryImpl.cpp
+++ b/xpcom/base/nsMemoryImpl.cpp
@@ -107,17 +107,17 @@ nsMemoryImpl::FlushMemory(const PRUnicha
         // got to be on the UI main thread for us to be able to do
         // that...are we?
         if (!NS_IsMainThread()) {
             NS_ERROR("can't synchronously flush memory: not on UI thread");
             return NS_ERROR_FAILURE;
         }
     }
 
-    PRInt32 lastVal = PR_ATOMIC_SET(&sIsFlushing, 1);
+    PRInt32 lastVal = PR_AtomicSet(&sIsFlushing, 1);
     if (lastVal)
         return NS_OK;
 
     PRIntervalTime now = PR_IntervalNow();
 
     // Run the flushers immediately if we can; otherwise, proxy to the
     // UI thread an run 'em asynchronously.
     if (aImmediate) {
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -42,17 +42,16 @@
 #include "nsSegmentedBuffer.h"
 #include "nsStreamUtils.h"
 #include "nsAutoLock.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "prlog.h"
 #include "nsInt64.h"
 #include "nsIClassInfoImpl.h"
-#include "nsAtomicRefcnt.h"
 
 #if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=nsPipe:5
 //
 static PRLogModuleInfo *gPipeLog = PR_NewLogModule("nsPipe");
 #define LOG(args) PR_LOG(gPipeLog, PR_LOG_DEBUG, args)
 #else
@@ -701,24 +700,24 @@ nsPipeInputStream::OnInputException(nsre
         result = PR_TRUE;
 
     return result;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeInputStream::AddRef(void)
 {
-    NS_AtomicIncrementRefcnt(mReaderRefCnt);
+    PR_AtomicIncrement((PRInt32*)&mReaderRefCnt);
     return mPipe->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeInputStream::Release(void)
 {
-    if (NS_AtomicDecrementRefcnt(mReaderRefCnt) == 0)
+    if (PR_AtomicDecrement((PRInt32 *)&mReaderRefCnt) == 0)
         Close();
     return mPipe->Release();
 }
 
 NS_IMETHODIMP
 nsPipeInputStream::CloseWithStatus(nsresult reason)
 {
     LOG(("III CloseWithStatus [this=%x reason=%x]\n", this, reason));
@@ -1057,24 +1056,24 @@ nsPipeOutputStream::OnOutputException(ns
 
     return result;
 }
 
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeOutputStream::AddRef()
 {
-    NS_AtomicIncrementRefcnt(mWriterRefCnt);
+    PR_AtomicIncrement((PRInt32*)&mWriterRefCnt);
     return mPipe->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeOutputStream::Release()
 {
-    if (NS_AtomicDecrementRefcnt(mWriterRefCnt) == 0)
+    if (PR_AtomicDecrement((PRInt32 *)&mWriterRefCnt) == 0)
         Close();
     return mPipe->Release();
 }
 
 NS_IMETHODIMP
 nsPipeOutputStream::CloseWithStatus(nsresult reason)
 {
     LOG(("OOO CloseWithStatus [this=%x reason=%x]\n", this, reason));
--- a/xpcom/proxy/src/nsProxyEvent.cpp
+++ b/xpcom/proxy/src/nsProxyEvent.cpp
@@ -295,17 +295,17 @@ nsProxyObjectCallInfo::GetCompleted()
 {
     return !!mCompleted;
 }
 
 void
 nsProxyObjectCallInfo::SetCompleted()
 {
     PROXY_LOG(("PROXY(%p): SetCompleted\n", this));
-    PR_ATOMIC_SET(&mCompleted, 1);
+    PR_AtomicSet(&mCompleted, 1);
 }
 
 void                
 nsProxyObjectCallInfo::PostCompleted()
 {
     PROXY_LOG(("PROXY(%p): PostCompleted\n", this));
 
     if (mCallersTarget) {
--- a/xpcom/string/src/nsSubstring.cpp
+++ b/xpcom/string/src/nsSubstring.cpp
@@ -98,17 +98,17 @@ class nsStringStats
       PRInt32 mAllocCount;
       PRInt32 mReallocCount;
       PRInt32 mFreeCount;
       PRInt32 mShareCount;
       PRInt32 mAdoptCount;
       PRInt32 mAdoptFreeCount;
   };
 static nsStringStats gStringStats;
-#define STRING_STAT_INCREMENT(_s) PR_ATOMIC_INCREMENT(&gStringStats.m ## _s ## Count)
+#define STRING_STAT_INCREMENT(_s) PR_AtomicIncrement(&gStringStats.m ## _s ## Count)
 #else
 #define STRING_STAT_INCREMENT(_s)
 #endif
 
 // ---------------------------------------------------------------------------
 
 inline void
 ReleaseData( void* data, PRUint32 flags )
@@ -172,25 +172,25 @@ class nsACStringAccessor : public nsACSt
         }
   };
 
 // ---------------------------------------------------------------------------
 
 void
 nsStringBuffer::AddRef()
   {
-    PR_ATOMIC_INCREMENT(&mRefCount);
+    PR_AtomicIncrement(&mRefCount);
     STRING_STAT_INCREMENT(Share);
     NS_LOG_ADDREF(this, mRefCount, "nsStringBuffer", sizeof(*this));
   }
 
 void
 nsStringBuffer::Release()
   {
-    PRInt32 count = PR_ATOMIC_DECREMENT(&mRefCount);
+    PRInt32 count = PR_AtomicDecrement(&mRefCount);
     NS_LOG_RELEASE(this, count, "nsStringBuffer");
     if (count == 0)
       {
         STRING_STAT_INCREMENT(Free);
         free(this); // we were allocated with |malloc|
       }
   }
 
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -100,17 +100,17 @@ nsresult TimerThread::Init()
 
   if (mInitialized) {
     if (!mThread)
       return NS_ERROR_FAILURE;
 
     return NS_OK;
   }
 
-  if (PR_ATOMIC_SET(&mInitInProgress, 1) == 0) {
+  if (PR_AtomicSet(&mInitInProgress, 1) == 0) {
     // We hold on to mThread to keep the thread alive.
     nsresult rv = NS_NewThread(getter_AddRefs(mThread), this);
     if (NS_FAILED(rv)) {
       mThread = nsnull;
     }
     else {
       nsCOMPtr<nsIObserverService> observerService =
           mozilla::services::GetObserverService();
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -82,17 +82,17 @@ myNS_MeanAndStdDev(double n, double sumO
 NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsTimerImpl, nsITimer)
 NS_IMPL_THREADSAFE_ADDREF(nsTimerImpl)
 
 NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void)
 {
   nsrefcnt count;
 
   NS_PRECONDITION(0 != mRefCnt, "dup release");
-  count = NS_AtomicDecrementRefcnt(mRefCnt);
+  count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
   NS_LOG_RELEASE(this, count, "nsTimerImpl");
   if (count == 0) {
     mRefCnt = 1; /* stabilize */
 
     /* enable this to find non-threadsafe destructors: */
     /* NS_ASSERT_OWNINGTHREAD(nsTimerImpl); */
     delete this;
     return 0;
@@ -218,17 +218,17 @@ nsresult nsTimerImpl::InitCommon(PRUint3
    * checking its list for this timer.  It's safe to test mArmed even though
    * it might be cleared on another thread in the next cycle (or even already
    * be cleared by another CPU whose store hasn't reached our CPU's cache),
    * because RemoveTimer is idempotent.
    */
   if (mArmed)
     gThread->RemoveTimer(this);
   mCanceled = PR_FALSE;
-  mGeneration = PR_ATOMIC_INCREMENT(&gGenerator);
+  mGeneration = PR_AtomicIncrement(&gGenerator);
 
   mType = (PRUint8)aType;
   SetDelayInternal(aDelay);
 
   return gThread->AddTimer(this);
 }
 
 NS_IMETHODIMP nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,