Bug 884061 - Part 4: Remove nsAtomicRefcnt.h, r=jlebar

--HG--
extra : rebase_source : ce24ab345baa48104328e3c101b7266a31e81870
This commit is contained in:
Joshua Cranmer 2013-07-11 15:21:45 -05:00
parent 35a15ca540
commit bb26e8f816
37 changed files with 24 additions and 230 deletions

View File

@ -22,6 +22,7 @@
#include "nsError.h"
#include "nsIScriptSecurityManager.h"
#include "nsScriptSecurityManager.h"
#include "pratom.h"
using namespace mozilla;

View File

@ -10,6 +10,7 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "plstr.h"
#include "pratom.h"
#include "nsCRT.h"
#include "nsIURI.h"
#include "nsIFileURL.h"

View File

@ -17,6 +17,7 @@
#include "nsString.h"
#include "nsIClassInfoImpl.h"
#include "nsIScriptSecurityManager.h"
#include "pratom.h"
NS_IMPL_CLASSINFO(nsSystemPrincipal, nullptr,
nsIClassInfo::SINGLETON | nsIClassInfo::MAIN_THREAD_ONLY,

View File

@ -9,7 +9,6 @@
#include "IndexedDatabase.h"
#include "nsAtomicRefcnt.h"
#include "nsThreadUtils.h"
#include "FileManager.h"

View File

@ -24,6 +24,7 @@
#include "nsContentUtils.h"
#include "nsEventDispatcher.h"
#include "nsThreadUtils.h"
#include "pratom.h"
#include "IDBEvents.h"
#include "IDBFactory.h"

View File

@ -8,6 +8,7 @@
/* This must occur *after* layers/PLayerTransaction.h to avoid typedefs conflicts. */
#include "mozilla/Util.h"
#include "pratom.h"
#include "prmem.h"
#include "prenv.h"
#include "prclist.h"

View File

@ -36,6 +36,7 @@
#include "nsScriptSecurityManager.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
#include "pratom.h"
#include "xpcpublic.h"
#include "AcquireListener.h"

View File

@ -11,7 +11,6 @@
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsAtomicRefcnt.h"
#if 0
NS_IMPL_ADDREF(nsPrintProgress)

View File

@ -13,6 +13,7 @@
#include "gfxTypes.h"
#include "mozilla/RefPtr.h"
#include "mozilla/gfx/MacIOSurface.h"
#include "nsError.h"
// Get the system color space.
CGColorSpaceRef CreateSystemColorSpace();

View File

@ -13,6 +13,7 @@
#include "mozilla/TimeStamp.h"
#include "ImageTypes.h"
#include "nsTArray.h"
#include "pratom.h"
#ifdef XP_WIN
struct ID3D10Texture2D;

View File

@ -6,8 +6,6 @@
#ifndef GFX_TYPES_H
#define GFX_TYPES_H
#include "nsAtomicRefcnt.h"
/**
* Currently needs to be 'double' for Cairo compatibility. Could
* become 'float', perhaps, in some configurations.

View File

@ -8,6 +8,7 @@
#include "RasterImage.h"
#include "DiscardTracker.h"
#include "mozilla/Preferences.h"
#include "pratom.h"
namespace mozilla {
namespace image {

View File

@ -8,6 +8,7 @@
#include "mozilla/LinkedList.h"
#include "mozilla/TimeStamp.h"
#include "prlock.h"
class nsITimer;

View File

@ -3,7 +3,6 @@
* 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 "nsAtomicRefcnt.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
@ -14,6 +13,7 @@
#include "nsCRT.h"
#include "nsComponentManagerUtils.h"
#include "nsCharsetAlias.h"
#include "pratom.h"
static int32_t gInstanceCount = 0;

View File

@ -32,6 +32,7 @@
#endif
#include "MessagePump.h"
#include "pratom.h"
using base::Time;
using base::TimeDelta;

View File

@ -8,7 +8,6 @@
#include "xpcprivate.h"
#include "nsCxPusher.h"
#include "nsAtomicRefcnt.h"
#include "nsContentUtils.h"
#include "nsProxyRelease.h"
#include "nsThreadUtils.h"

View File

@ -8,6 +8,7 @@
#include "xpcprivate.h"
#include "nsCxPusher.h"
#include "pratom.h"
using namespace mozilla;

View File

@ -14,6 +14,7 @@
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "pratom.h"
#include "prlog.h"
#include "nsCRT.h"
#include "netCore.h"

View File

@ -10,7 +10,6 @@
#include "nsSocketTransport2.h"
#include "mozilla/Attributes.h"
#include "nsAtomicRefcnt.h"
#include "nsIOService.h"
#include "nsStreamUtils.h"
#include "nsNetSegmentUtils.h"

View File

@ -7,7 +7,6 @@
#define nsHostResolver_h__
#include "nscore.h"
#include "nsAtomicRefcnt.h"
#include "prclist.h"
#include "prnetdb.h"
#include "pldhash.h"

View File

@ -20,7 +20,6 @@
#include "nsNetUtil.h"
#include "nsProxyRelease.h"
#include "nsIOService.h"
#include "nsAtomicRefcnt.h"
#include "nsISeekableStream.h"
#include "nsISocketTransport.h"

View File

@ -40,6 +40,7 @@
#include "mozilla/Telemetry.h"
#include "plbase64.h"
#include "pratom.h"
#include "prmem.h"
#include "prnetdb.h"
#include "prbit.h"

View File

@ -34,6 +34,7 @@
#include "mozilla/Mutex.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Telemetry.h"
#include "pratom.h"
#include "prlog.h"
#include "prprf.h"
#include "prnetdb.h"

View File

@ -33,6 +33,7 @@
#include "TextInputHandler.h"
#include "mozilla/HangMonitor.h"
#include "GeckoProfiler.h"
#include "pratom.h"
#include "npapi.h"

View File

@ -9,6 +9,7 @@
#include "nsThreadUtils.h"
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "pratom.h"
#include "mozilla/Services.h"
// When processing the next thread event, the appshell may process native

View File

@ -35,7 +35,6 @@ DISABLED_SDK_HEADERS = \
ErrorListCDefines.h \
nsISupportsBase.h \
nscore.h \
nsAtomicRefcnt.h \
nsCycleCollector.h \
nsObjCExceptions.h \

View File

@ -45,7 +45,6 @@ EXPORTS += [
'ErrorListCDefines.h',
'ErrorListCxxDefines.h',
'nsAgg.h',
'nsAtomicRefcnt.h',
'nsAutoPtr.h',
'nsAutoRef.h',
'nsCom.h',

View File

@ -1,67 +0,0 @@
/* 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/. */
#ifndef nsAtomicRefcnt_h__
#define nsAtomicRefcnt_h__
#include "nscore.h"
#include "pratom.h"
class nsAutoRefCnt;
// This header defines functions for modifying refcounts which wrap the
// PR_ATOMIC_* macros.
#if defined(XP_WIN)
#if PR_BYTES_PER_LONG == 4
typedef volatile long nsAtomicRefcnt;
#else
#error "Windows should have 4 bytes per long."
#endif
#else /* !defined(XP_WIN) */
typedef int32_t nsAtomicRefcnt;
#endif
inline int32_t
NS_AtomicIncrementRefcnt(int32_t &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)
{
// This cast is safe since nsAtomicRefCnt contains just one member, its refcount.
return (nsrefcnt) PR_ATOMIC_INCREMENT((nsAtomicRefcnt*)&refcnt);
}
inline nsrefcnt
NS_AtomicDecrementRefcnt(nsrefcnt &refcnt)
{
return (nsrefcnt) PR_ATOMIC_DECREMENT((nsAtomicRefcnt*)&refcnt);
}
inline nsrefcnt
NS_AtomicDecrementRefcnt(nsAutoRefCnt &refcnt)
{
return (nsrefcnt) PR_ATOMIC_DECREMENT((nsAtomicRefcnt*)&refcnt);
}
inline int32_t
NS_AtomicDecrementRefcnt(int32_t &refcnt)
{
return PR_ATOMIC_DECREMENT(&refcnt);
}
#endif

View File

@ -10,6 +10,7 @@
#include "nsExceptionService.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "pratom.h"
#include "prthread.h"
#include "mozilla/Services.h"

View File

@ -19,6 +19,7 @@
#include "nsGZFileWriter.h"
#include "nsJSEnvironment.h"
#include "nsPrintfCString.h"
#include "pratom.h"
#ifdef XP_WIN
#include <process.h>

View File

@ -15,6 +15,7 @@
*/
#include <string.h>
#include "pratom.h"
#include "prlog.h"
#include "nsHashtable.h"
#include "nsReadableUtils.h"

View File

@ -22,7 +22,6 @@
#if !defined(XPCOM_GLUE_AVOID_NSPR)
#include "prthread.h" /* needed for thread-safety checks */
#include "nsAtomicRefcnt.h" /* for NS_Atomic{Increment,Decrement}Refcnt */
#ifdef DEBUG
#include "nsCycleCollectorUtils.h" /* for NS_IsCycleCollectorThread */
#endif // DEBUG
@ -235,19 +234,6 @@ class ThreadSafeAutoRefCnt {
Atomic<nsrefcnt> mValue;
};
}
// Temporary declarations until NS_IMPL_THREADSAFE_ADDREF/RELEASE are deleted.
inline nsrefcnt
NS_AtomicIncrementRefcnt(mozilla::ThreadSafeAutoRefCnt &refcnt)
{
return ++refcnt;
}
inline nsrefcnt
NS_AtomicDecrementRefcnt(mozilla::ThreadSafeAutoRefCnt &refcnt)
{
return --refcnt;
}
#endif
///////////////////////////////////////////////////////////////////////////////
@ -979,19 +965,6 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
NS_INTERFACE_TABLE_TAIL
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE0 NS_IMPL_QUERY_INTERFACE0
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE1 NS_IMPL_QUERY_INTERFACE1
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE2 NS_IMPL_QUERY_INTERFACE2
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE3 NS_IMPL_QUERY_INTERFACE3
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE4 NS_IMPL_QUERY_INTERFACE4
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE5 NS_IMPL_QUERY_INTERFACE5
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE6 NS_IMPL_QUERY_INTERFACE6
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE7 NS_IMPL_QUERY_INTERFACE7
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE8 NS_IMPL_QUERY_INTERFACE8
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE9 NS_IMPL_QUERY_INTERFACE9
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE10 NS_IMPL_QUERY_INTERFACE10
#define NS_IMPL_THREADSAFE_QUERY_INTERFACE11 NS_IMPL_QUERY_INTERFACE11
/**
* Declare that you're going to inherit from something that already
* implements nsISupports, but also implements an additional interface, thus
@ -1386,129 +1359,6 @@ NS_IMETHODIMP_(nsrefcnt) Class::Release(void) \
* @note These are not available when linking against the standalone glue,
* because the implementation requires PR_ symbols.
*/
#if !defined(XPCOM_GLUE_AVOID_NSPR)
/**
* Use this macro to implement the AddRef method for a given <i>_class</i>
* @param _class The name of the class implementing the method
*/
#define NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
{ \
MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); \
nsrefcnt count = NS_AtomicIncrementRefcnt(mRefCnt); \
NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
return (nsrefcnt) count; \
}
/**
* Use this macro to implement the Release method for a given <i>_class</i>
* @param _class The name of the class implementing the method
*
* Note that we don't need to use an atomic operation to stabilize the refcnt.
* If the refcnt is released to 0, only the current thread has a reference to
* the object; we thus don't have to use an atomic set to inform other threads
* that we've changed the refcnt.
*/
#define NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
{ \
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt); \
NS_LOG_RELEASE(this, count, #_class); \
if (0 == count) { \
mRefCnt = 1; /* stabilize */ \
/* enable this to find non-threadsafe destructors: */ \
/* NS_ASSERT_OWNINGTHREAD(_class); */ \
delete (this); \
return 0; \
} \
return count; \
}
#else // XPCOM_GLUE_AVOID_NSPR
#define NS_IMPL_THREADSAFE_ADDREF(_class) \
THREADSAFE_ISUPPORTS_NOT_AVAILABLE_IN_STANDALONE_GLUE;
#define NS_IMPL_THREADSAFE_RELEASE(_class) \
THREADSAFE_ISUPPORTS_NOT_AVAILABLE_IN_STANDALONE_GLUE;
#endif
#define NS_IMPL_THREADSAFE_ISUPPORTS0(_class) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE0(_class)
#define NS_IMPL_THREADSAFE_ISUPPORTS1(_class, _interface) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE1(_class, _interface)
#define NS_IMPL_THREADSAFE_ISUPPORTS2(_class, _i1, _i2) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE2(_class, _i1, _i2)
#define NS_IMPL_THREADSAFE_ISUPPORTS3(_class, _i1, _i2, _i3) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE3(_class, _i1, _i2, _i3)
#define NS_IMPL_THREADSAFE_ISUPPORTS4(_class, _i1, _i2, _i3, _i4) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE4(_class, _i1, _i2, _i3, _i4)
#define NS_IMPL_THREADSAFE_ISUPPORTS5(_class, _i1, _i2, _i3, _i4, _i5) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE5(_class, _i1, _i2, _i3, _i4, _i5)
#define NS_IMPL_THREADSAFE_ISUPPORTS6(_class, _i1, _i2, _i3, _i4, _i5, _i6) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)
#define NS_IMPL_THREADSAFE_ISUPPORTS7(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7)
#define NS_IMPL_THREADSAFE_ISUPPORTS8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8)
#define NS_IMPL_THREADSAFE_ISUPPORTS9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE9(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9)
#define NS_IMPL_THREADSAFE_ISUPPORTS10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9, _i10) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE10(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9, _i10)
#define NS_IMPL_THREADSAFE_ISUPPORTS11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9, _i10, _i11) \
NS_IMPL_THREADSAFE_ADDREF(_class) \
NS_IMPL_THREADSAFE_RELEASE(_class) \
NS_IMPL_THREADSAFE_QUERY_INTERFACE11(_class, _i1, _i2, _i3, _i4, _i5, _i6, \
_i7, _i8, _i9, _i10, _i11)
#define NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_QUERY_TAIL_GUTS
/**

View File

@ -14,7 +14,6 @@
#include "nsCRT.h"
#include "prlog.h"
#include "nsIClassInfoImpl.h"
#include "nsAtomicRefcnt.h"
#include "nsAlgorithm.h"
using namespace mozilla;

View File

@ -7,7 +7,6 @@
#include "xptiprivate.h"
#include "mozilla/XPTInterfaceInfoManager.h"
#include "nsAtomicRefcnt.h"
using namespace mozilla;

View File

@ -14,6 +14,7 @@
#include "nsAutoPtr.h"
#include "nsThreadUtils.h"
#include "nsXPCOMCIDInternal.h"
#include "pratom.h"
#include "prmon.h"
#include "mozilla/Attributes.h"

View File

@ -12,6 +12,7 @@
#include "nsIProgrammingLanguage.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "pratom.h"
#include "prlog.h"
#include "nsIObserverService.h"
#include "mozilla/HangMonitor.h"

View File

@ -10,6 +10,7 @@
#include "nsThreadManager.h"
#include "nsThreadUtils.h"
#include "plarena.h"
#include "pratom.h"
#include "GeckoProfiler.h"
using mozilla::TimeDuration;