Bug 592557 - Eliminate uses of PR_Atomic{Increment,Decrement} in favor of PR_ATOMIC_{INCREMENT,DECREMENT}. r=bsmedberg,gal

This commit is contained in:
Justin Lebar 2010-10-03 15:42:14 -07:00
parent a8aeda94fb
commit 23a1029325
35 changed files with 102 additions and 89 deletions

View File

@ -66,7 +66,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsNullPrincipal::AddRef()
{
NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
NS_LOG_ADDREF(this, count, "nsNullPrincipal", sizeof(*this));
return count;
}
@ -75,7 +75,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsNullPrincipal::Release()
{
NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
NS_LOG_RELEASE(this, count, "nsNullPrincipal");
if (count == 0) {
delete this;

View File

@ -154,7 +154,7 @@ nsPrincipal::AddRef()
{
NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
// XXXcaa does this need to be threadsafe? See bug 143559.
nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
NS_LOG_ADDREF(this, count, "nsPrincipal", sizeof(*this));
return count;
}
@ -163,7 +163,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsPrincipal::Release()
{
NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
NS_LOG_RELEASE(this, count, "nsPrincipal");
if (count == 0) {
delete this;

View File

@ -63,7 +63,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsSystemPrincipal::AddRef()
{
NS_PRECONDITION(PRInt32(mJSPrincipals.refcount) >= 0, "illegal refcnt");
nsrefcnt count = PR_AtomicIncrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_INCREMENT(&mJSPrincipals.refcount);
NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this));
return count;
}
@ -72,7 +72,7 @@ NS_IMETHODIMP_(nsrefcnt)
nsSystemPrincipal::Release()
{
NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release");
nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount);
nsrefcnt count = PR_ATOMIC_DECREMENT(&mJSPrincipals.refcount);
NS_LOG_RELEASE(this, count, "nsSystemPrincipal");
if (count == 0) {
delete this;

View File

@ -406,7 +406,7 @@ IDBDatabase::Invalidate()
}
}
if (!PR_AtomicSet(&mInvalidated, 1)) {
if (!PR_ATOMIC_SET(&mInvalidated, 1)) {
DatabaseInfo* info;
if (!DatabaseInfo::Get(mDatabaseId, &info)) {
NS_ERROR("This should never fail!");

View File

@ -808,7 +808,7 @@ IndexedDatabaseManager::Observe(nsISupports* aSubject,
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_AtomicSet(&gShutdown, 1)) {
if (PR_ATOMIC_SET(&gShutdown, 1)) {
NS_ERROR("Shutdown more than once?!");
}
@ -948,7 +948,7 @@ IndexedDatabaseManager::AsyncUsageRunnable::AsyncUsageRunnable(
void
IndexedDatabaseManager::AsyncUsageRunnable::Cancel()
{
if (PR_AtomicSet(&mCanceled, 1)) {
if (PR_ATOMIC_SET(&mCanceled, 1)) {
NS_ERROR("Canceled more than once?!");
}
}

View File

@ -361,7 +361,7 @@ NS_IMPL_THREADSAFE_ADDREF(LazyIdleThread)
NS_IMETHODIMP_(nsrefcnt)
LazyIdleThread::Release()
{
nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt);
NS_LOG_RELEASE(this, count, "LazyIdleThread");
if (!count) {

View File

@ -2001,7 +2001,7 @@ PluginModuleChild::NPN_RetainObject(NPObject* aNPObj)
{
AssertPluginThread();
int32_t refCnt = PR_AtomicIncrement((PRInt32*)&aNPObj->referenceCount);
int32_t refCnt = PR_ATOMIC_INCREMENT((int32_t*)&aNPObj->referenceCount);
NS_LOG_ADDREF(aNPObj, refCnt, "NPObject", sizeof(NPObject));
return aNPObj;
@ -2029,7 +2029,7 @@ PluginModuleChild::NPN_ReleaseObject(NPObject* aNPObj)
return;
}
int32_t refCnt = PR_AtomicDecrement((PRInt32*)&aNPObj->referenceCount);
int32_t refCnt = PR_ATOMIC_DECREMENT((int32_t*)&aNPObj->referenceCount);
NS_LOG_RELEASE(aNPObj, refCnt, "NPObject");
if (refCnt == 0) {

View File

@ -425,7 +425,7 @@ void
nsDOMWorkerTimeout::AcquireSpinlock()
{
PRUint32 loopCount = 0;
while (PR_AtomicSet(&mSuspendSpinlock, 1) == 1) {
while (PR_ATOMIC_SET(&mSuspendSpinlock, 1) == 1) {
if (++loopCount > SUSPEND_SPINLOCK_COUNT) {
LOG(("AcquireSpinlock taking too long (looped %u times), yielding.",
loopCount));
@ -446,7 +446,7 @@ nsDOMWorkerTimeout::ReleaseSpinlock()
#ifdef DEBUG
PRInt32 suspended =
#endif
PR_AtomicSet(&mSuspendSpinlock, 0);
PR_ATOMIC_SET(&mSuspendSpinlock, 0);
NS_ASSERTION(suspended == 1, "Huh?!");
}

View File

@ -45,6 +45,7 @@
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsAtomicRefcnt.h"
#if 0
NS_IMPL_THREADSAFE_ADDREF(nsPrintProgress)
@ -54,7 +55,7 @@ NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::AddRef(void)
{
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
nsrefcnt count;
count = PR_AtomicIncrement((PRInt32*)&mRefCnt);
count = NS_AtomicIncrementRefcnt(mRefCnt);
//NS_LOG_ADDREF(this, count, "nsPrintProgress", sizeof(*this));
return count;
}
@ -63,7 +64,7 @@ NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::Release(void)
{
nsrefcnt count;
NS_PRECONDITION(0 != mRefCnt, "dup release");
count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
count = NS_AtomicDecrementRefcnt(mRefCnt);
//NS_LOG_RELEASE(this, count, "nsPrintProgress");
if (0 == count) {
mRefCnt = 1; /* stabilize */

View File

@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "pratom.h"
#include "nsAtomicRefcnt.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
@ -58,12 +58,12 @@ NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
: mIsInternal(PR_FALSE)
{
PR_AtomicIncrement(&gInstanceCount);
PR_ATOMIC_INCREMENT(&gInstanceCount);
}
nsScriptableUnicodeConverter::~nsScriptableUnicodeConverter()
{
PR_AtomicDecrement(&gInstanceCount);
PR_ATOMIC_DECREMENT(&gInstanceCount);
}
nsresult

View File

@ -48,7 +48,7 @@
#include "base/basictypes.h"
#include "pratom.h"
#include "nsAtomicRefcnt.h"
#include "mozilla/ipc/SyncChannel.h"
#include "nsAutoPtr.h"
@ -450,12 +450,10 @@ private:
void Run() { mTask->Run(); }
void Cancel() { mTask->Cancel(); }
void AddRef() {
PR_AtomicIncrement(reinterpret_cast<PRInt32*>(&mRefCnt));
NS_AtomicIncrementRefcnt(mRefCnt);
}
void Release() {
nsrefcnt count =
PR_AtomicDecrement(reinterpret_cast<PRInt32*>(&mRefCnt));
if (0 == count)
if (NS_AtomicDecrementRefcnt(mRefCnt) == 0)
delete this;
}

View File

@ -92,10 +92,10 @@ 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_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_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_CurrentThreadId() PR_GetCurrentThread()
#define JS_NEW_LOCK() PR_NewLock()

View File

@ -66,7 +66,7 @@ XPCWrappedNativeProto::XPCWrappedNativeProto(XPCWrappedNativeScope* Scope,
MOZ_COUNT_CTOR(XPCWrappedNativeProto);
#ifdef DEBUG
PR_AtomicIncrement(&gDEBUG_LiveProtoCount);
PR_ATOMIC_INCREMENT(&gDEBUG_LiveProtoCount);
#endif
}
@ -77,7 +77,7 @@ XPCWrappedNativeProto::~XPCWrappedNativeProto()
MOZ_COUNT_DTOR(XPCWrappedNativeProto);
#ifdef DEBUG
PR_AtomicDecrement(&gDEBUG_LiveProtoCount);
PR_ATOMIC_DECREMENT(&gDEBUG_LiveProtoCount);
#endif
// Note that our weak ref to mScope is not to be trusted at this point.

View File

@ -141,7 +141,7 @@ nsrefcnt nsJAR::Release(void)
{
nsrefcnt count;
NS_PRECONDITION(0 != mRefCnt, "dup release");
count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
count = NS_AtomicDecrementRefcnt(mRefCnt);
NS_LOG_RELEASE(this, count, "nsJAR");
if (0 == count) {
mRefCnt = 1; /* stabilize */

View File

@ -48,6 +48,7 @@
#include "prmem.h"
#include "prenv.h"
#include "prclist.h"
#include "nsAtomicRefcnt.h"
#include "jscntxt.h"
@ -1525,7 +1526,7 @@ _retainobject(NPObject* npobj)
#ifdef NS_BUILD_REFCNT_LOGGING
int32_t refCnt =
#endif
PR_AtomicIncrement((PRInt32*)&npobj->referenceCount);
NS_AtomicIncrementRefcnt(npobj->referenceCount);
NS_LOG_ADDREF(npobj, refCnt, "BrowserNPObject", sizeof(NPObject));
}
@ -1541,7 +1542,7 @@ _releaseobject(NPObject* npobj)
if (!npobj)
return;
int32_t refCnt = PR_AtomicDecrement((PRInt32*)&npobj->referenceCount);
int32_t refCnt = NS_AtomicDecrementRefcnt(npobj->referenceCount);
NS_LOG_RELEASE(npobj, refCnt, "BrowserNPObject");
if (refCnt == 0) {

View File

@ -43,6 +43,7 @@
#endif
#include "nsSocketTransport2.h"
#include "nsAtomicRefcnt.h"
#include "nsIOService.h"
#include "nsStreamUtils.h"
#include "nsNetSegmentUtils.h"
@ -55,7 +56,6 @@
#include "netCore.h"
#include "nsInt64.h"
#include "prmem.h"
#include "pratom.h"
#include "plstr.h"
#include "prnetdb.h"
#include "prerror.h"
@ -263,14 +263,14 @@ NS_IMPL_QUERY_INTERFACE2(nsSocketInputStream,
NS_IMETHODIMP_(nsrefcnt)
nsSocketInputStream::AddRef()
{
PR_AtomicIncrement((PRInt32*)&mReaderRefCnt);
NS_AtomicIncrementRefcnt(mReaderRefCnt);
return mTransport->AddRef();
}
NS_IMETHODIMP_(nsrefcnt)
nsSocketInputStream::Release()
{
if (PR_AtomicDecrement((PRInt32*)&mReaderRefCnt) == 0)
if (NS_AtomicDecrementRefcnt(mReaderRefCnt) == 0)
Close();
return mTransport->Release();
}
@ -522,14 +522,14 @@ NS_IMPL_QUERY_INTERFACE2(nsSocketOutputStream,
NS_IMETHODIMP_(nsrefcnt)
nsSocketOutputStream::AddRef()
{
PR_AtomicIncrement((PRInt32*)&mWriterRefCnt);
NS_AtomicIncrementRefcnt(mWriterRefCnt);
return mTransport->AddRef();
}
NS_IMETHODIMP_(nsrefcnt)
nsSocketOutputStream::Release()
{
if (PR_AtomicDecrement((PRInt32*)&mWriterRefCnt) == 0)
if (NS_AtomicDecrementRefcnt(mWriterRefCnt) == 0)
Close();
return mTransport->Release();
}

View File

@ -78,10 +78,10 @@ public:
void ClearBinding();
void IncrementInputStreamCount() { PR_AtomicIncrement(&mInStreamCount); }
void IncrementInputStreamCount() { PR_ATOMIC_INCREMENT(&mInStreamCount); }
void DecrementInputStreamCount()
{
PR_AtomicDecrement(&mInStreamCount);
PR_ATOMIC_DECREMENT(&mInStreamCount);
NS_ASSERTION(mInStreamCount >= 0, "mInStreamCount has gone negative");
}

View File

@ -39,7 +39,7 @@
#define nsHostResolver_h__
#include "nscore.h"
#include "pratom.h"
#include "nsAtomicRefcnt.h"
#include "prcvar.h"
#include "prclist.h"
#include "prnetdb.h"
@ -56,12 +56,12 @@ class nsResolveHostCallback;
nsAutoRefCnt _refc; \
public: \
PRInt32 AddRef() { \
PRInt32 n = PR_AtomicIncrement((PRInt32*)&_refc); \
PRInt32 n = NS_AtomicIncrementRefcnt(_refc); \
NS_LOG_ADDREF(this, n, #classname, sizeof(classname)); \
return n; \
} \
PRInt32 Release() { \
PRInt32 n = PR_AtomicDecrement((PRInt32*)&_refc); \
PRInt32 n = NS_AtomicDecrementRefcnt(_refc); \
NS_LOG_RELEASE(this, n, #classname); \
if (n == 0) \
delete this; \

View File

@ -75,14 +75,14 @@ public:
nsrefcnt AddRef()
{
nsrefcnt n = PR_AtomicIncrement((PRInt32 *) &mRef);
nsrefcnt n = NS_AtomicIncrementRefcnt(mRef);
NS_LOG_ADDREF(this, n, "nsHttpConnectionInfo", sizeof(*this));
return n;
}
nsrefcnt Release()
{
nsrefcnt n = PR_AtomicDecrement((PRInt32 *) &mRef);
nsrefcnt n = NS_AtomicDecrementRefcnt(mRef);
NS_LOG_RELEASE(this, n, "nsHttpConnectionInfo");
if (n == 0)
delete this;

View File

@ -54,7 +54,7 @@
#include "nsProxyRelease.h"
#include "nsIOService.h"
#include "nsAutoLock.h"
#include "pratom.h"
#include "nsAtomicRefcnt.h"
#include "nsISeekableStream.h"
#include "nsISocketTransport.h"
@ -1198,7 +1198,7 @@ nsHttpTransaction::Release()
{
nsrefcnt count;
NS_PRECONDITION(0 != mRefCnt, "dup release");
count = PR_AtomicDecrement((PRInt32 *) &mRefCnt);
count = NS_AtomicDecrementRefcnt(mRefCnt);
NS_LOG_RELEASE(this, count, "nsHttpTransaction");
if (0 == count) {
mRefCnt = 1; /* stablize */

View File

@ -143,11 +143,11 @@ class nsAutoAtomic {
public:
nsAutoAtomic(PRInt32 &i)
:mI(i) {
PR_AtomicIncrement(&mI);
PR_ATOMIC_INCREMENT(&mI);
}
~nsAutoAtomic() {
PR_AtomicDecrement(&mI);
PR_ATOMIC_DECREMENT(&mI);
}
protected:

View File

@ -334,13 +334,13 @@ SECStatus nsNSSHttpRequestSession::trySendAndReceiveFcn(PRPollDesc **pPollDesc,
void
nsNSSHttpRequestSession::AddRef()
{
PR_AtomicIncrement(&mRefCount);
NS_AtomicIncrementRefcnt(mRefCount);
}
void
nsNSSHttpRequestSession::Release()
{
PRInt32 newRefCount = PR_AtomicDecrement(&mRefCount);
PRInt32 newRefCount = NS_AtomicDecrementRefcnt(mRefCount);
if (!newRefCount) {
delete this;
}

View File

@ -206,7 +206,7 @@ public:
PRInt32 synchronous = PREF_TS_SYNCHRONOUS_DEFAULT;
if (pref)
(void)pref->GetIntPref(PREF_TS_SYNCHRONOUS, &synchronous);
::PR_AtomicSet(mSynchronousPrefValPtr, synchronous);
::PR_ATOMIC_SET(mSynchronousPrefValPtr, synchronous);
// Register our SQLite memory reporters. Registration can only happen on
// the main thread (otherwise you'll get cryptic crashes).

View File

@ -3914,20 +3914,20 @@ nsUrlClassifierDBService::Init()
PRInt32 tmpint;
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
PR_AtomicSet(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
PR_ATOMIC_SET(&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_AtomicSet(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
PR_ATOMIC_SET(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
rv = prefs->GetIntPref(UPDATE_WORKING_TIME, &tmpint);
PR_AtomicSet(&gWorkingTimeThreshold,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
PR_ATOMIC_SET(&gWorkingTimeThreshold,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
rv = prefs->GetIntPref(UPDATE_DELAY_TIME, &tmpint);
PR_AtomicSet(&gDelayTime,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
PR_ATOMIC_SET(&gDelayTime,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
}
// Start the background thread.
@ -4232,21 +4232,21 @@ nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic,
} else if (NS_LITERAL_STRING(CONFIRM_AGE_PREF).Equals(aData)) {
PRInt32 tmpint;
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
PR_AtomicSet(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
PR_ATOMIC_SET(&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_AtomicSet(&gUpdateCacheSize, NS_SUCCEEDED(rv) ? tmpint : UPDATE_CACHE_SIZE_DEFAULT);
PR_ATOMIC_SET(&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_AtomicSet(&gWorkingTimeThreshold,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_WORKING_TIME_DEFAULT);
PR_ATOMIC_SET(&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_AtomicSet(&gDelayTime,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
PR_ATOMIC_SET(&gDelayTime,
NS_SUCCEEDED(rv) ? tmpint : UPDATE_DELAY_TIME_DEFAULT);
}
} else if (!strcmp(aTopic, "profile-before-change") ||
!strcmp(aTopic, "xpcom-shutdown-threads")) {

View File

@ -436,8 +436,8 @@ nsAppShell::ProcessGeckoEvents(void* aInfo)
if (self->mTerminated) {
PRInt32 releaseCount = 0;
if (self->mNativeEventScheduledDepth > self->mNativeEventCallbackDepth) {
releaseCount = PR_AtomicSet(&self->mNativeEventScheduledDepth,
self->mNativeEventCallbackDepth);
releaseCount = PR_ATOMIC_SET(&self->mNativeEventScheduledDepth,
self->mNativeEventCallbackDepth);
}
while (releaseCount-- > self->mNativeEventCallbackDepth)
self->Release();
@ -447,8 +447,8 @@ nsAppShell::ProcessGeckoEvents(void* aInfo)
// (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_AtomicDecrement(&self->mNativeEventScheduledDepth) < 0) {
PR_AtomicSet(&self->mNativeEventScheduledDepth, 0);
if (PR_ATOMIC_DECREMENT(&self->mNativeEventScheduledDepth) < 0) {
PR_ATOMIC_SET(&self->mNativeEventScheduledDepth, 0);
NS_WARNING("Spontaneous call to ProcessGeckoEvents()!");
} else {
self->Release();
@ -512,7 +512,7 @@ nsAppShell::ScheduleNativeEventCallback()
// ProcessGeckoEvents(). But there are exceptions, for which see
// ProcessGeckoEvents() and Exit().
NS_ADDREF_THIS();
PR_AtomicIncrement(&mNativeEventScheduledDepth);
PR_ATOMIC_INCREMENT(&mNativeEventScheduledDepth);
// This will invoke ProcessGeckoEvents on the main thread.
::CFRunLoopSourceSignal(mCFRunLoopSource);
@ -796,7 +796,7 @@ nsAppShell::Exit(void)
// to ScheduleNativeEventCallback() and ProcessGeckoEvents() isn't on the
// stack, we need to take care of the problem here.
if (!mNativeEventCallbackDepth && mNativeEventScheduledDepth) {
PRInt32 releaseCount = PR_AtomicSet(&mNativeEventScheduledDepth, 0);
PRInt32 releaseCount = PR_ATOMIC_SET(&mNativeEventScheduledDepth, 0);
while (releaseCount-- > 0)
NS_RELEASE_THIS();
}

View File

@ -97,7 +97,7 @@ nsBaseAppShell::Init()
void
nsBaseAppShell::NativeEventCallback()
{
PRInt32 hasPending = PR_AtomicSet(&mNativeEventPending, 0);
PRInt32 hasPending = PR_ATOMIC_SET(&mNativeEventPending, 0);
if (hasPending == 0)
return;
@ -262,7 +262,7 @@ nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal *thr)
if (mBlockNativeEvent)
return NS_OK;
PRInt32 lastVal = PR_AtomicSet(&mNativeEventPending, 1);
PRInt32 lastVal = PR_ATOMIC_SET(&mNativeEventPending, 1);
if (lastVal == 1)
return NS_OK;

View File

@ -59,6 +59,12 @@ typedef PRInt32 nsAtomicRefcnt;
#endif
inline PRInt32
NS_AtomicIncrementRefcnt(PRInt32 &refcnt)
{
return PR_ATOMIC_INCREMENT(&refcnt);
}
inline nsrefcnt
NS_AtomicIncrementRefcnt(nsrefcnt &refcnt)
{
@ -84,4 +90,10 @@ NS_AtomicDecrementRefcnt(nsAutoRefCnt &refcnt)
return (nsrefcnt) PR_ATOMIC_DECREMENT((nsAtomicRefcnt*)&refcnt);
}
inline PRInt32
NS_AtomicDecrementRefcnt(PRInt32 &refcnt)
{
return PR_ATOMIC_DECREMENT(&refcnt);
}
#endif

View File

@ -348,7 +348,7 @@ NS_DebugBreak(PRUint32 aSeverity, const char *aStr, const char *aExpr,
}
// Now we deal with assertions
PR_AtomicIncrement(&gAssertionCount);
PR_ATOMIC_INCREMENT(&gAssertionCount);
switch (GetAssertBehavior()) {
case NS_ASSERT_WARN:

View File

@ -104,7 +104,7 @@ nsExceptionManager::nsExceptionManager(nsExceptionService *svc) :
{
/* member initializers and constructor code */
#ifdef NS_DEBUG
PR_AtomicIncrement(&totalInstances);
PR_ATOMIC_INCREMENT(&totalInstances);
#endif
}
@ -112,7 +112,7 @@ nsExceptionManager::~nsExceptionManager()
{
/* destructor code */
#ifdef NS_DEBUG
PR_AtomicDecrement(&totalInstances);
PR_ATOMIC_DECREMENT(&totalInstances);
#endif // NS_DEBUG
}
@ -160,7 +160,7 @@ nsExceptionService::nsExceptionService()
: mProviders(4, PR_TRUE) /* small, thread-safe hashtable */
{
#ifdef NS_DEBUG
if (PR_AtomicIncrement(&totalInstances)!=1) {
if (PR_ATOMIC_INCREMENT(&totalInstances)!=1) {
NS_ERROR("The nsExceptionService is a singleton!");
}
#endif
@ -186,7 +186,7 @@ nsExceptionService::~nsExceptionService()
Shutdown();
/* destructor code */
#ifdef NS_DEBUG
PR_AtomicDecrement(&totalInstances);
PR_ATOMIC_DECREMENT(&totalInstances);
#endif
}

View File

@ -112,7 +112,7 @@ nsMemoryImpl::FlushMemory(const PRUnichar* aReason, PRBool aImmediate)
}
}
PRInt32 lastVal = PR_AtomicSet(&sIsFlushing, 1);
PRInt32 lastVal = PR_ATOMIC_SET(&sIsFlushing, 1);
if (lastVal)
return NS_OK;

View File

@ -47,6 +47,7 @@
#include "prlog.h"
#include "nsInt64.h"
#include "nsIClassInfoImpl.h"
#include "nsAtomicRefcnt.h"
#if defined(PR_LOGGING)
//
@ -705,14 +706,14 @@ nsPipeInputStream::OnInputException(nsresult reason, nsPipeEvents &events)
NS_IMETHODIMP_(nsrefcnt)
nsPipeInputStream::AddRef(void)
{
PR_AtomicIncrement((PRInt32*)&mReaderRefCnt);
NS_AtomicIncrementRefcnt(mReaderRefCnt);
return mPipe->AddRef();
}
NS_IMETHODIMP_(nsrefcnt)
nsPipeInputStream::Release(void)
{
if (PR_AtomicDecrement((PRInt32 *)&mReaderRefCnt) == 0)
if (NS_AtomicDecrementRefcnt(mReaderRefCnt) == 0)
Close();
return mPipe->Release();
}
@ -1061,14 +1062,14 @@ nsPipeOutputStream::OnOutputException(nsresult reason, nsPipeEvents &events)
NS_IMETHODIMP_(nsrefcnt)
nsPipeOutputStream::AddRef()
{
PR_AtomicIncrement((PRInt32*)&mWriterRefCnt);
NS_AtomicIncrementRefcnt(mWriterRefCnt);
return mPipe->AddRef();
}
NS_IMETHODIMP_(nsrefcnt)
nsPipeOutputStream::Release()
{
if (PR_AtomicDecrement((PRInt32 *)&mWriterRefCnt) == 0)
if (NS_AtomicDecrementRefcnt(mWriterRefCnt) == 0)
Close();
return mPipe->Release();
}

View File

@ -300,7 +300,7 @@ void
nsProxyObjectCallInfo::SetCompleted()
{
PROXY_LOG(("PROXY(%p): SetCompleted\n", this));
PR_AtomicSet(&mCompleted, 1);
PR_ATOMIC_SET(&mCompleted, 1);
}
void

View File

@ -103,7 +103,7 @@ class nsStringStats
PRInt32 mAdoptFreeCount;
};
static nsStringStats gStringStats;
#define STRING_STAT_INCREMENT(_s) PR_AtomicIncrement(&gStringStats.m ## _s ## Count)
#define STRING_STAT_INCREMENT(_s) PR_ATOMIC_INCREMENT(&gStringStats.m ## _s ## Count)
#else
#define STRING_STAT_INCREMENT(_s)
#endif
@ -177,7 +177,7 @@ class nsACStringAccessor : public nsACString
void
nsStringBuffer::AddRef()
{
PR_AtomicIncrement(&mRefCount);
PR_ATOMIC_INCREMENT(&mRefCount);
STRING_STAT_INCREMENT(Share);
NS_LOG_ADDREF(this, mRefCount, "nsStringBuffer", sizeof(*this));
}
@ -185,7 +185,7 @@ nsStringBuffer::AddRef()
void
nsStringBuffer::Release()
{
PRInt32 count = PR_AtomicDecrement(&mRefCount);
PRInt32 count = PR_ATOMIC_DECREMENT(&mRefCount);
NS_LOG_RELEASE(this, count, "nsStringBuffer");
if (count == 0)
{

View File

@ -105,7 +105,7 @@ nsresult TimerThread::Init()
return NS_OK;
}
if (PR_AtomicSet(&mInitInProgress, 1) == 0) {
if (PR_ATOMIC_SET(&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)) {

View File

@ -87,7 +87,7 @@ NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void)
nsrefcnt count;
NS_PRECONDITION(0 != mRefCnt, "dup release");
count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
count = NS_AtomicDecrementRefcnt(mRefCnt);
NS_LOG_RELEASE(this, count, "nsTimerImpl");
if (count == 0) {
mRefCnt = 1; /* stabilize */
@ -223,7 +223,7 @@ nsresult nsTimerImpl::InitCommon(PRUint32 aType, PRUint32 aDelay)
if (mArmed)
gThread->RemoveTimer(this);
mCanceled = PR_FALSE;
mGeneration = PR_AtomicIncrement(&gGenerator);
mGeneration = PR_ATOMIC_INCREMENT(&gGenerator);
mType = (PRUint8)aType;
SetDelayInternal(aDelay);