From d85b062b2dbd37a3de4bceda42eb6b5eef27a683 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 21 Nov 2007 22:42:56 +0000 Subject: [PATCH] don't limit counters to 32-bit --- dtool/src/dtoolbase/atomicAdjustDummyImpl.I | 24 ++--- dtool/src/dtoolbase/atomicAdjustDummyImpl.h | 18 ++-- dtool/src/dtoolbase/atomicAdjustI386Impl.I | 32 +++--- dtool/src/dtoolbase/atomicAdjustI386Impl.h | 18 ++-- dtool/src/dtoolbase/atomicAdjustPosixImpl.I | 28 ++--- dtool/src/dtoolbase/atomicAdjustPosixImpl.h | 17 +-- dtool/src/dtoolbase/atomicAdjustWin32Impl.I | 28 ++--- dtool/src/dtoolbase/atomicAdjustWin32Impl.h | 18 ++-- dtool/src/dtoolbase/deletedBufferChain.I | 6 +- dtool/src/dtoolbase/deletedBufferChain.cxx | 10 +- dtool/src/dtoolbase/deletedBufferChain.h | 2 +- dtool/src/dtoolbase/memoryHook.I | 4 +- dtool/src/dtoolbase/memoryHook.cxx | 12 +-- dtool/src/dtoolbase/memoryHook.h | 8 +- dtool/src/dtoolbase/mutexSpinlockImpl.h | 2 +- dtool/src/dtoolbase/typeHandle.cxx | 4 +- dtool/src/dtoolbase/typeRegistryNode.h | 2 +- dtool/src/prc/configFlags.I | 6 +- dtool/src/prc/configFlags.cxx | 2 +- dtool/src/prc/configFlags.h | 8 +- dtool/src/prc/configVariableBool.h | 2 +- dtool/src/prc/configVariableDouble.h | 2 +- dtool/src/prc/configVariableEnum.h | 2 +- dtool/src/prc/configVariableFilename.h | 2 +- dtool/src/prc/configVariableInt.h | 2 +- dtool/src/prc/configVariableSearchPath.h | 2 +- dtool/src/prc/configVariableString.h | 2 +- dtool/src/prc/nativeNumericData.I | 100 +++++++++--------- dtool/src/prc/notifyCategory.h | 2 +- panda/src/express/nodeReferenceCount.h | 2 +- panda/src/express/referenceCount.h | 2 +- panda/src/net/connectionReader.h | 3 +- .../src/pipeline/conditionVarFullWin32Impl.h | 2 +- .../src/pipeline/conditionVarSpinlockImpl.cxx | 2 +- panda/src/pipeline/conditionVarSpinlockImpl.h | 2 +- panda/src/pipeline/test_atomic.cxx | 9 +- panda/src/pstatclient/pStatClient.h | 8 +- .../putil/cachedTypedWritableReferenceCount.h | 2 +- panda/src/putil/nodeCachedReferenceCount.h | 2 +- panda/src/putil/updateSeq.I | 36 +++---- panda/src/putil/updateSeq.h | 8 +- 41 files changed, 226 insertions(+), 217 deletions(-) diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I index 267b95d2c2..a400e1579c 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I @@ -23,7 +23,7 @@ // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustDummyImpl:: -inc(TVOLATILE PN_int32 &var) { +inc(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { ++var; } @@ -35,7 +35,7 @@ inc(TVOLATILE PN_int32 &var) { // is zero. //////////////////////////////////////////////////////////////////// INLINE bool AtomicAdjustDummyImpl:: -dec(TVOLATILE PN_int32 &var) { +dec(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return (--var) != 0; } @@ -46,7 +46,7 @@ dec(TVOLATILE PN_int32 &var) { // delta to be negative. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustDummyImpl:: -add(TVOLATILE PN_int32 &var, PN_int32 delta) { +add(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer delta) { var += delta; } @@ -56,9 +56,9 @@ add(TVOLATILE PN_int32 &var, PN_int32 delta) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustDummyImpl:: -set(TVOLATILE PN_int32 &var, PN_int32 new_value) { - PN_int32 orig_value = var; +INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +set(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer new_value) { + Integer orig_value = var; var = new_value; return orig_value; } @@ -72,8 +72,8 @@ set(TVOLATILE PN_int32 &var, PN_int32 new_value) { // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustDummyImpl:: -get(const TVOLATILE PN_int32 &var) { +INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +get(const TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return var; } @@ -114,10 +114,10 @@ get_ptr(void * const TVOLATILE &var) { // The caller can test for success by comparing // return_value == old_value. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustDummyImpl:: -compare_and_exchange(TVOLATILE PN_int32 &mem, PN_int32 old_value, - PN_int32 new_value) { - PN_int32 orig_value = mem; +INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, AtomicAdjustDummyImpl::Integer old_value, + AtomicAdjustDummyImpl::Integer new_value) { + Integer orig_value = mem; if (mem == old_value) { mem = new_value; } diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h index 81f9c9357c..6eb94c96f2 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -32,18 +32,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_DTOOL AtomicAdjustDummyImpl { public: - INLINE static void inc(TVOLATILE PN_int32 &var); - INLINE static bool dec(TVOLATILE PN_int32 &var); - INLINE static void add(TVOLATILE PN_int32 &var, PN_int32 delta); - INLINE static PN_int32 set(TVOLATILE PN_int32 &var, PN_int32 new_value); - INLINE static PN_int32 get(const TVOLATILE PN_int32 &var); + typedef int Integer; + + INLINE static void inc(TVOLATILE Integer &var); + INLINE static bool dec(TVOLATILE Integer &var); + INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + INLINE static Integer get(const TVOLATILE Integer &var); INLINE static void *set_ptr(void * TVOLATILE &var, void *new_value); INLINE static void *get_ptr(void * const TVOLATILE &var); - INLINE static PN_int32 compare_and_exchange(TVOLATILE PN_int32 &mem, - PN_int32 old_value, - PN_int32 new_value); + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + Integer old_value, + Integer new_value); INLINE static void *compare_and_exchange_ptr(void * TVOLATILE &mem, void *old_value, diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.I b/dtool/src/dtoolbase/atomicAdjustI386Impl.I index e1c95e8491..13dd729fce 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.I @@ -23,10 +23,10 @@ // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustI386Impl:: -inc(TVOLATILE PN_int32 &var) { +inc(TVOLATILE AtomicAdjustI386Impl::Integer &var) { #ifdef _M_IX86 // Windows case - TVOLATILE PN_int32 *var_ptr = &var; + TVOLATILE Integer *var_ptr = &var; __asm { mov edx, var_ptr; lock inc dword ptr [edx]; @@ -47,11 +47,11 @@ inc(TVOLATILE PN_int32 &var) { // is zero. //////////////////////////////////////////////////////////////////// INLINE bool AtomicAdjustI386Impl:: -dec(TVOLATILE PN_int32 &var) { +dec(TVOLATILE AtomicAdjustI386Impl::Integer &var) { unsigned char c; #ifdef _M_IX86 // Windows case - TVOLATILE PN_int32 *var_ptr = &var; + TVOLATILE Integer *var_ptr = &var; __asm { mov edx, var_ptr; lock dec dword ptr [edx]; @@ -73,8 +73,8 @@ dec(TVOLATILE PN_int32 &var) { // delta to be negative. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustI386Impl:: -add(TVOLATILE PN_int32 &var, PN_int32 delta) { - PN_int32 orig_value = var; +add(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer delta) { + Integer orig_value = var; while (compare_and_exchange(var, orig_value, orig_value + delta) != orig_value) { orig_value = var; } @@ -86,9 +86,9 @@ add(TVOLATILE PN_int32 &var, PN_int32 delta) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustI386Impl:: -set(TVOLATILE PN_int32 &var, PN_int32 new_value) { - PN_int32 orig_value = var; +INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: +set(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer new_value) { + Integer orig_value = var; var = new_value; return orig_value; } @@ -102,8 +102,8 @@ set(TVOLATILE PN_int32 &var, PN_int32 new_value) { // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustI386Impl:: -get(const TVOLATILE PN_int32 &var) { +INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: +get(const TVOLATILE AtomicAdjustI386Impl::Integer &var) { return var; } @@ -153,13 +153,13 @@ get_ptr(void * const TVOLATILE &var) { // return orig_value; // //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustI386Impl:: -compare_and_exchange(TVOLATILE PN_int32 &mem, PN_int32 old_value, - PN_int32 new_value) { - PN_int32 prev; +INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: +compare_and_exchange(TVOLATILE AtomicAdjustI386Impl::Integer &mem, AtomicAdjustI386Impl::Integer old_value, + AtomicAdjustI386Impl::Integer new_value) { + Integer prev; #ifdef _M_IX86 // Windows case - TVOLATILE PN_int32 *mem_ptr = &mem; + TVOLATILE Integer *mem_ptr = &mem; __asm { mov edx, mem_ptr; mov ecx, new_value; diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.h b/dtool/src/dtoolbase/atomicAdjustI386Impl.h index 7328505f2b..2716812585 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.h @@ -35,18 +35,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_DTOOL AtomicAdjustI386Impl { public: - INLINE static void inc(TVOLATILE PN_int32 &var); - INLINE static bool dec(TVOLATILE PN_int32 &var); - INLINE static void add(TVOLATILE PN_int32 &var, PN_int32 delta); - INLINE static PN_int32 set(TVOLATILE PN_int32 &var, PN_int32 new_value); - INLINE static PN_int32 get(const TVOLATILE PN_int32 &var); + typedef PN_int32 Integer; + + INLINE static void inc(TVOLATILE Integer &var); + INLINE static bool dec(TVOLATILE Integer &var); + INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + INLINE static Integer get(const TVOLATILE Integer &var); INLINE static void *set_ptr(void * TVOLATILE &var, void *new_value); INLINE static void *get_ptr(void * const TVOLATILE &var); - INLINE static PN_int32 compare_and_exchange(TVOLATILE PN_int32 &mem, - PN_int32 old_value, - PN_int32 new_value); + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + Integer old_value, + Integer new_value); INLINE static void *compare_and_exchange_ptr(void * TVOLATILE &mem, void *old_value, diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I index bac9ebf582..7c5ead2bff 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I @@ -23,7 +23,7 @@ // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustPosixImpl:: -inc(TVOLATILE PN_int32 &var) { +inc(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); ++var; pthread_mutex_unlock(&_mutex); @@ -37,9 +37,9 @@ inc(TVOLATILE PN_int32 &var) { // is zero. //////////////////////////////////////////////////////////////////// INLINE bool AtomicAdjustPosixImpl:: -dec(TVOLATILE PN_int32 &var) { +dec(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); - PN_int32 result = --var; + Integer result = --var; pthread_mutex_unlock(&_mutex); return (result != 0); } @@ -51,7 +51,7 @@ dec(TVOLATILE PN_int32 &var) { // delta to be negative. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustPosixImpl:: -add(TVOLATILE PN_int32 &var, PN_int32 delta) { +add(TVOLATILE AtomicAdjustPosixImpl::Integer &var, AtomicAdjustPosixImpl::Integer delta) { pthread_mutex_lock(&_mutex); var += delta; pthread_mutex_unlock(&_mutex); @@ -63,10 +63,10 @@ add(TVOLATILE PN_int32 &var, PN_int32 delta) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustPosixImpl:: -set(TVOLATILE PN_int32 &var, PN_int32 new_value) { +INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: +set(TVOLATILE AtomicAdjustPosixImpl::Integer &var, AtomicAdjustPosixImpl::Integer new_value) { pthread_mutex_lock(&_mutex); - PN_int32 orig_value = var; + Integer orig_value = var; var = new_value; pthread_mutex_unlock(&_mutex); return orig_value; @@ -81,10 +81,10 @@ set(TVOLATILE PN_int32 &var, PN_int32 new_value) { // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustPosixImpl:: -get(const TVOLATILE PN_int32 &var) { +INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: +get(const TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); - PN_int32 orig_value = var; + Integer orig_value = var; pthread_mutex_unlock(&_mutex); return orig_value; } @@ -140,11 +140,11 @@ get_ptr(void * const TVOLATILE &var) { // return orig_value; // //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustPosixImpl:: -compare_and_exchange(TVOLATILE PN_int32 &mem, PN_int32 old_value, - PN_int32 new_value) { +INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: +compare_and_exchange(TVOLATILE AtomicAdjustPosixImpl::Integer &mem, AtomicAdjustPosixImpl::Integer old_value, + AtomicAdjustPosixImpl::Integer new_value) { pthread_mutex_lock(&_mutex); - PN_int32 orig_value = mem; + Integer orig_value = mem; if (mem == old_value) { mem = new_value; } diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h index 41d9b071e0..744dae07a5 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h @@ -34,18 +34,19 @@ //////////////////////////////////////////////////////////////////// class EXPCL_DTOOL AtomicAdjustPosixImpl { public: - INLINE static void inc(TVOLATILE PN_int32 &var); - INLINE static bool dec(TVOLATILE PN_int32 &var); - INLINE static void add(TVOLATILE PN_int32 &var, PN_int32 delta); - INLINE static PN_int32 set(TVOLATILE PN_int32 &var, PN_int32 new_value); - INLINE static PN_int32 get(const TVOLATILE PN_int32 &var); + typedef int Integer; + INLINE static void inc(TVOLATILE Integer &var); + INLINE static bool dec(TVOLATILE Integer &var); + INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + INLINE static Integer get(const TVOLATILE Integer &var); INLINE static void *set_ptr(void * TVOLATILE &var, void *new_value); INLINE static void *get_ptr(void * const TVOLATILE &var); - INLINE static PN_int32 compare_and_exchange(TVOLATILE PN_int32 &mem, - PN_int32 old_value, - PN_int32 new_value); + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + Integer old_value, + Integer new_value); INLINE static void *compare_and_exchange_ptr(void * TVOLATILE &mem, void *old_value, diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I index c4c6791b70..4ccdaf0e44 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I @@ -23,8 +23,8 @@ // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustWin32Impl:: -inc(TVOLATILE PN_int32 &var) { - InterlockedIncrement((LONG *)&var); +inc(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { + InterlockedIncrement(&var); } //////////////////////////////////////////////////////////////////// @@ -35,8 +35,8 @@ inc(TVOLATILE PN_int32 &var) { // is zero. //////////////////////////////////////////////////////////////////// INLINE bool AtomicAdjustWin32Impl:: -dec(TVOLATILE PN_int32 &var) { - return (InterlockedDecrement((LONG *)&var) != 0); +dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { + return (InterlockedDecrement(var) != 0); } //////////////////////////////////////////////////////////////////// @@ -46,8 +46,8 @@ dec(TVOLATILE PN_int32 &var) { // delta to be negative. //////////////////////////////////////////////////////////////////// INLINE void AtomicAdjustWin32Impl:: -add(TVOLATILE PN_int32 &var, PN_int32 delta) { - PN_int32 orig_value = var; +add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer delta) { + AtomicAdjustWin32Impl::Integer orig_value = var; while (compare_and_exchange(var, orig_value, orig_value + delta) != orig_value) { orig_value = var; } @@ -59,9 +59,9 @@ add(TVOLATILE PN_int32 &var, PN_int32 delta) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustWin32Impl:: -set(TVOLATILE PN_int32 &var, PN_int32 new_value) { - return InterlockedExchange((LONG *)&var, new_value); +INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: +set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer new_value) { + return InterlockedExchange(&var, new_value); } //////////////////////////////////////////////////////////////////// @@ -73,8 +73,8 @@ set(TVOLATILE PN_int32 &var, PN_int32 new_value) { // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustWin32Impl:: -get(const TVOLATILE PN_int32 &var) { +INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: +get(const TVOLATILE AtomicAdjustWin32Impl::Integer &var) { return var; } @@ -124,9 +124,9 @@ get_ptr(void * const TVOLATILE &var) { // return orig_value; // //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustWin32Impl:: -compare_and_exchange(TVOLATILE PN_int32 &mem, PN_int32 old_value, - PN_int32 new_value) { +INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: +compare_and_exchange(TVOLATILE AtomicAdjustWin32Impl::Integer &mem, AtomicAdjustWin32Impl::Integer old_value, + AtomicAdjustWin32Impl::Integer new_value) { // Note that the AtomicAdjust parameter order is different from // Windows convention! return InterlockedCompareExchange((TVOLATILE LONG *)&mem, new_value, old_value); diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index 557179ad96..3f104d4259 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -35,18 +35,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_DTOOL AtomicAdjustWin32Impl { public: - INLINE static void inc(TVOLATILE PN_int32 &var); - INLINE static bool dec(TVOLATILE PN_int32 &var); - INLINE static void add(TVOLATILE PN_int32 &var, PN_int32 delta); - INLINE static PN_int32 set(TVOLATILE PN_int32 &var, PN_int32 new_value); - INLINE static PN_int32 get(const TVOLATILE PN_int32 &var); + typedef LONG Integer; + + INLINE static void inc(TVOLATILE Integer &var); + INLINE static bool dec(TVOLATILE Integer &var); + INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + INLINE static Integer get(const TVOLATILE Integer &var); INLINE static void *set_ptr(void * TVOLATILE &var, void *new_value); INLINE static void *get_ptr(void * const TVOLATILE &var); - INLINE static PN_int32 compare_and_exchange(TVOLATILE PN_int32 &mem, - PN_int32 old_value, - PN_int32 new_value); + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + Integer old_value, + Integer new_value); INLINE static void *compare_and_exchange_ptr(void * TVOLATILE &mem, void *old_value, diff --git a/dtool/src/dtoolbase/deletedBufferChain.I b/dtool/src/dtoolbase/deletedBufferChain.I index 4595b50eaa..6ac1262a1f 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.I +++ b/dtool/src/dtoolbase/deletedBufferChain.I @@ -62,8 +62,8 @@ INLINE void *DeletedBufferChain:: node_to_buffer(DeletedBufferChain::ObjectNode *node) { #ifdef USE_DELETEDCHAINFLAG // In development mode, we increment the pointer so that the - // returned data does not overlap our _flags member. - return (void *)(((PN_int32 *)node) + 1); + // returned data does not overlap our _flag member. + return (void *)(((AtomicAdjust::Integer *)node) + 1); #else return (void *)node; #endif // NDEBUG @@ -79,7 +79,7 @@ buffer_to_node(void *ptr) { #ifdef USE_DELETEDCHAINFLAG // In development mode, we decrement the pointer to undo the // increment we did above. - return (ObjectNode *)(((PN_int32 *)ptr) - 1); + return (ObjectNode *)(((AtomicAdjust::Integer *)ptr) - 1); #else return (ObjectNode *)ptr; #endif // NDEBUG diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index d93677cb26..d4100671ff 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -32,7 +32,7 @@ DeletedBufferChain(size_t buffer_size) { #ifdef USE_DELETEDCHAINFLAG // In development mode, we also need to reserve space for _flag. - _alloc_size += sizeof(PN_int32); + _alloc_size += sizeof(AtomicAdjust::Integer); #endif // NDEBUG // We must allocate at least this much space for bookkeeping @@ -62,7 +62,7 @@ allocate(size_t size, TypeHandle type_handle) { _lock.release(); #ifdef USE_DELETEDCHAINFLAG - assert(obj->_flag == (PN_int32)DCF_deleted); + assert(obj->_flag == (AtomicAdjust::Integer)DCF_deleted); obj->_flag = DCF_alive; #endif // NDEBUG @@ -115,14 +115,14 @@ deallocate(void *ptr, TypeHandle type_handle) { ObjectNode *obj = buffer_to_node(ptr); #ifdef USE_DELETEDCHAINFLAG - PN_int32 orig_flag = AtomicAdjust::compare_and_exchange(obj->_flag, DCF_alive, DCF_deleted); + AtomicAdjust::Integer orig_flag = AtomicAdjust::compare_and_exchange(obj->_flag, DCF_alive, DCF_deleted); // If this assertion is triggered, you double-deleted an object. - assert(orig_flag != (PN_int32)DCF_deleted); + assert(orig_flag != (AtomicAdjust::Integer)DCF_deleted); // If this assertion is triggered, you tried to delete an object // that was never allocated, or you have heap corruption. - assert(orig_flag == (PN_int32)DCF_alive); + assert(orig_flag == (AtomicAdjust::Integer)DCF_alive); #endif // NDEBUG _lock.lock(); diff --git a/dtool/src/dtoolbase/deletedBufferChain.h b/dtool/src/dtoolbase/deletedBufferChain.h index 43b9cc7fa8..5a370d3ae1 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.h +++ b/dtool/src/dtoolbase/deletedBufferChain.h @@ -85,7 +85,7 @@ private: // maintained out-of-band from the actual pointer returned, so we // can safely use this flag to indicate the difference between // allocated and freed pointers. - TVOLATILE PN_int32 _flag; + TVOLATILE AtomicAdjust::Integer _flag; #endif // This pointer sits within the buffer, in the same space diff --git a/dtool/src/dtoolbase/memoryHook.I b/dtool/src/dtoolbase/memoryHook.I index c0e29ed480..298ed62d70 100644 --- a/dtool/src/dtoolbase/memoryHook.I +++ b/dtool/src/dtoolbase/memoryHook.I @@ -27,7 +27,7 @@ INLINE void MemoryHook:: inc_heap(size_t size) { #ifdef DO_MEMORY_USAGE - AtomicAdjust::add(_requested_heap_size, (PN_int32)size); + AtomicAdjust::add(_requested_heap_size, (AtomicAdjust::Integer)size); #endif // DO_MEMORY_USAGE } @@ -42,7 +42,7 @@ INLINE void MemoryHook:: dec_heap(size_t size) { #ifdef DO_MEMORY_USAGE assert((int)size <= _requested_heap_size); - AtomicAdjust::add(_requested_heap_size, -(PN_int32)size); + AtomicAdjust::add(_requested_heap_size, -(AtomicAdjust::Integer)size); #endif // DO_MEMORY_USAGE } diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index b99938a6b2..90136e240e 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -201,7 +201,7 @@ heap_alloc_single(size_t size) { #ifdef DO_MEMORY_USAGE // In the DO_MEMORY_USAGE case, we want to track the total size of // allocated bytes on the heap. - AtomicAdjust::add(_total_heap_single_size, (PN_int32)size); + AtomicAdjust::add(_total_heap_single_size, (AtomicAdjust::Integer)size); if ((size_t)AtomicAdjust::get(_total_heap_single_size) + (size_t)AtomicAdjust::get(_total_heap_array_size) > _max_heap_size) { @@ -225,7 +225,7 @@ heap_free_single(void *ptr) { #ifdef DO_MEMORY_USAGE assert((int)size <= _total_heap_single_size); - AtomicAdjust::add(_total_heap_single_size, -(PN_int32)size); + AtomicAdjust::add(_total_heap_single_size, -(AtomicAdjust::Integer)size); #endif // DO_MEMORY_USAGE #ifdef MEMORY_HOOK_MALLOC_LOCK @@ -267,7 +267,7 @@ heap_alloc_array(size_t size) { #ifdef DO_MEMORY_USAGE // In the DO_MEMORY_USAGE case, we want to track the total size of // allocated bytes on the heap. - AtomicAdjust::add(_total_heap_array_size, (PN_int32)size); + AtomicAdjust::add(_total_heap_array_size, (AtomicAdjust::Integer)size); if ((size_t)AtomicAdjust::get(_total_heap_single_size) + (size_t)AtomicAdjust::get(_total_heap_array_size) > _max_heap_size) { @@ -290,8 +290,8 @@ heap_realloc_array(void *ptr, size_t size) { void *alloc = ptr_to_alloc(ptr, orig_size); #ifdef DO_MEMORY_USAGE - assert((PN_int32)orig_size <= _total_heap_array_size); - AtomicAdjust::add(_total_heap_array_size, (PN_int32)size-(PN_int32)orig_size); + assert((AtomicAdjust::Integer)orig_size <= _total_heap_array_size); + AtomicAdjust::add(_total_heap_array_size, (AtomicAdjust::Integer)size-(AtomicAdjust::Integer)orig_size); #endif // DO_MEMORY_USAGE #ifdef MEMORY_HOOK_MALLOC_LOCK @@ -323,7 +323,7 @@ heap_free_array(void *ptr) { #ifdef DO_MEMORY_USAGE assert((int)size <= _total_heap_array_size); - AtomicAdjust::add(_total_heap_array_size, -(PN_int32)size); + AtomicAdjust::add(_total_heap_array_size, -(AtomicAdjust::Integer)size); #endif // DO_MEMORY_USAGE #ifdef MEMORY_HOOK_MALLOC_LOCK diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index 88bb50a276..75f5a02361 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -78,10 +78,10 @@ private: #ifdef DO_MEMORY_USAGE protected: - TVOLATILE PN_int32 _total_heap_single_size; - TVOLATILE PN_int32 _total_heap_array_size; - TVOLATILE PN_int32 _requested_heap_size; - TVOLATILE PN_int32 _total_mmap_size; + TVOLATILE AtomicAdjust::Integer _total_heap_single_size; + TVOLATILE AtomicAdjust::Integer _total_heap_array_size; + TVOLATILE AtomicAdjust::Integer _requested_heap_size; + TVOLATILE AtomicAdjust::Integer _total_mmap_size; // If the allocated heap size crosses this threshold, we call // overflow_heap_size(). diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 34a641ab5f..cbb874c9e3 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -47,7 +47,7 @@ public: private: void do_lock(); - TVOLATILE PN_int32 _lock; + TVOLATILE AtomicAdjust::Integer _lock; }; #include "mutexSpinlockImpl.I" diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index ff7aed2cb7..619dac350f 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -58,7 +58,7 @@ inc_memory_usage(MemoryClass memory_class, int size) { if ((*this) != TypeHandle::none()) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); assert(rnode != (TypeRegistryNode *)NULL); - AtomicAdjust::add(rnode->_memory_usage[memory_class], (PN_int32)size); + AtomicAdjust::add(rnode->_memory_usage[memory_class], (AtomicAdjust::Integer)size); // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << rnode->_memory_usage[memory_class] << "\n"; assert(rnode->_memory_usage[memory_class] >= 0); } @@ -78,7 +78,7 @@ dec_memory_usage(MemoryClass memory_class, int size) { if ((*this) != TypeHandle::none()) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); assert(rnode != (TypeRegistryNode *)NULL); - AtomicAdjust::add(rnode->_memory_usage[memory_class], -(PN_int32)size); + AtomicAdjust::add(rnode->_memory_usage[memory_class], -(AtomicAdjust::Integer)size); if (rnode->_memory_usage[memory_class] < 0) { cerr << *this << ".dec(" << memory_class << ", " << size << ") -> " << rnode->_memory_usage[memory_class] << "\n"; } diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index 6b8fad2082..37fb55aa6e 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -55,7 +55,7 @@ public: Classes _child_classes; #ifdef DO_MEMORY_USAGE - PN_int32 _memory_usage[TypeHandle::MC_limit]; + AtomicAdjust::Integer _memory_usage[TypeHandle::MC_limit]; #endif static bool _paranoid_inheritance; diff --git a/dtool/src/prc/configFlags.I b/dtool/src/prc/configFlags.I index 734e2ea842..25437ec125 100644 --- a/dtool/src/prc/configFlags.I +++ b/dtool/src/prc/configFlags.I @@ -25,7 +25,7 @@ // local_modified value with the global_modified value). //////////////////////////////////////////////////////////////////// INLINE bool ConfigFlags:: -is_cache_valid(PN_int32 local_modified) { +is_cache_valid(AtomicAdjust::Integer local_modified) { return local_modified == _global_modified; } @@ -37,7 +37,7 @@ is_cache_valid(PN_int32 local_modified) { // calls invalidate_cache(). //////////////////////////////////////////////////////////////////// INLINE void ConfigFlags:: -mark_cache_valid(PN_int32 &local_modified) { +mark_cache_valid(AtomicAdjust::Integer &local_modified) { local_modified = _global_modified; } @@ -49,7 +49,7 @@ mark_cache_valid(PN_int32 &local_modified) { // indicate an invalid cache in the next call to // is_cache_valid(). //////////////////////////////////////////////////////////////////// -INLINE PN_int32 ConfigFlags:: +INLINE AtomicAdjust::Integer ConfigFlags:: initial_invalid_cache() { return _global_modified - 1; } diff --git a/dtool/src/prc/configFlags.cxx b/dtool/src/prc/configFlags.cxx index cd8ecc3e18..698b39a8a1 100644 --- a/dtool/src/prc/configFlags.cxx +++ b/dtool/src/prc/configFlags.cxx @@ -18,7 +18,7 @@ #include "configFlags.h" -PN_int32 ConfigFlags::_global_modified; +TVOLATILE AtomicAdjust::Integer ConfigFlags::_global_modified; //////////////////////////////////////////////////////////////////// // Function: ConfigFlags::Type output operator diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index 86e0a11ee5..9f4165c273 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -64,13 +64,13 @@ PUBLISHED: }; protected: - INLINE static bool is_cache_valid(PN_int32 local_modified); - INLINE static void mark_cache_valid(PN_int32 &local_modified); - INLINE static PN_int32 initial_invalid_cache(); + INLINE static bool is_cache_valid(AtomicAdjust::Integer local_modified); + INLINE static void mark_cache_valid(AtomicAdjust::Integer &local_modified); + INLINE static AtomicAdjust::Integer initial_invalid_cache(); INLINE static void invalidate_cache(); private: - static PN_int32 _global_modified; + static TVOLATILE AtomicAdjust::Integer _global_modified; }; ostream &operator << (ostream &out, ConfigFlags::ValueType type); diff --git a/dtool/src/prc/configVariableBool.h b/dtool/src/prc/configVariableBool.h index 1aa95b7133..581797a136 100644 --- a/dtool/src/prc/configVariableBool.h +++ b/dtool/src/prc/configVariableBool.h @@ -49,7 +49,7 @@ PUBLISHED: INLINE void set_word(int n, bool value); private: - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; bool _cache; }; diff --git a/dtool/src/prc/configVariableDouble.h b/dtool/src/prc/configVariableDouble.h index 042e70427b..df4e4a2d1d 100644 --- a/dtool/src/prc/configVariableDouble.h +++ b/dtool/src/prc/configVariableDouble.h @@ -54,7 +54,7 @@ private: void set_default_value(double default_value); private: - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; double _cache; }; diff --git a/dtool/src/prc/configVariableEnum.h b/dtool/src/prc/configVariableEnum.h index d6693d4f89..9687d05f40 100644 --- a/dtool/src/prc/configVariableEnum.h +++ b/dtool/src/prc/configVariableEnum.h @@ -67,7 +67,7 @@ private: bool _got_default_value; EnumType _default_value; - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; EnumType _cache; }; diff --git a/dtool/src/prc/configVariableFilename.h b/dtool/src/prc/configVariableFilename.h index 8050e4fa87..c2d78d603c 100644 --- a/dtool/src/prc/configVariableFilename.h +++ b/dtool/src/prc/configVariableFilename.h @@ -70,7 +70,7 @@ private: void reload_cache(); private: - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; Filename _cache; }; diff --git a/dtool/src/prc/configVariableInt.h b/dtool/src/prc/configVariableInt.h index b4c118d84f..2f12bf1570 100644 --- a/dtool/src/prc/configVariableInt.h +++ b/dtool/src/prc/configVariableInt.h @@ -54,7 +54,7 @@ private: void set_default_value(int default_value); private: - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; int _cache; }; diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 0ab4580874..dca36ee53d 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -79,7 +79,7 @@ private: DSearchPath _prefix, _postfix; - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; DSearchPath _cache; }; diff --git a/dtool/src/prc/configVariableString.h b/dtool/src/prc/configVariableString.h index 41e65ed9fd..6b84994e74 100644 --- a/dtool/src/prc/configVariableString.h +++ b/dtool/src/prc/configVariableString.h @@ -56,7 +56,7 @@ PUBLISHED: INLINE void set_word(int n, const string &value); private: - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; string _cache; }; diff --git a/dtool/src/prc/nativeNumericData.I b/dtool/src/prc/nativeNumericData.I index 625244a224..7b13a33ca2 100644 --- a/dtool/src/prc/nativeNumericData.I +++ b/dtool/src/prc/nativeNumericData.I @@ -70,54 +70,54 @@ get_data() const { return _source; } -///////////////////// -// this is for a intel compile .. it is native format and it is -// readable off word boundries -///////////////////////// -inline void TS_SetVal1(const PN_int8 * src, PN_int8 *dst) -{ - *dst = *src; -} -inline void TS_SetVal2(const char * src, char *dst) -{ - *(reinterpret_cast(dst)) = *(reinterpret_cast (src)); -} - -inline void TS_SetVal4(const char * src, char *dst) -{ - *(reinterpret_cast (dst)) = *(reinterpret_cast (src)); -} - - -inline void TS_SetVal8(const char * src, char *dst) -{ - *(reinterpret_cast(dst)) = *(reinterpret_cast(src)); -} - -template inline type TS_GetInteger(type &val,const char * _src) -{ - val = *(reinterpret_cast (_src)); - return val; -} - -template inline type TS_GetIntegerIncPtr(type &val,char *& _src) -{ - val = *(reinterpret_cast (_src)); - _src+= sizeof(type); - return val; -} - -template inline void TS_AddIntegerIncPtr(type val, char *& _dst) -{ - *(reinterpret_cast (_dst)) = val; - _dst+= sizeof(type); -} - -template inline void TS_AddInteger(type val, char * _dst) -{ - *(reinterpret_cast (_dst)) = val; -} - -#define TS_GetDirect(TT,SS) *((TT *)(SS)) -#define TS_GetDirectIncPtr(TT,SS) { _ptr += sizeof(TT); return *((TT *)(SS -sizeof(TT))); } +///////////////////// +// this is for a intel compile .. it is native format and it is +// readable off word boundries +///////////////////////// +inline void TS_SetVal1(const PN_int8 * src, PN_int8 *dst) +{ + *dst = *src; +} +inline void TS_SetVal2(const char * src, char *dst) +{ + *(reinterpret_cast(dst)) = *(reinterpret_cast (src)); +} + +inline void TS_SetVal4(const char * src, char *dst) +{ + *(reinterpret_cast (dst)) = *(reinterpret_cast (src)); +} + + +inline void TS_SetVal8(const char * src, char *dst) +{ + *(reinterpret_cast(dst)) = *(reinterpret_cast(src)); +} + +template inline type TS_GetInteger(type &val,const char * _src) +{ + val = *(reinterpret_cast (_src)); + return val; +} + +template inline type TS_GetIntegerIncPtr(type &val,char *& _src) +{ + val = *(reinterpret_cast (_src)); + _src+= sizeof(type); + return val; +} + +template inline void TS_AddIntegerIncPtr(type val, char *& _dst) +{ + *(reinterpret_cast (_dst)) = val; + _dst+= sizeof(type); +} + +template inline void TS_AddInteger(type val, char * _dst) +{ + *(reinterpret_cast (_dst)) = val; +} + +#define TS_GetDirect(TT,SS) *((TT *)(SS)) +#define TS_GetDirectIncPtr(TT,SS) { _ptr += sizeof(TT); return *((TT *)(SS -sizeof(TT))); } diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 75b75eae06..b8dd98b5cc 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -96,7 +96,7 @@ private: static long _server_delta; // not a time_t because server delta may be signed. - PN_int32 _local_modified; + AtomicAdjust::Integer _local_modified; NotifySeverity _severity_cache; friend class Notify; diff --git a/panda/src/express/nodeReferenceCount.h b/panda/src/express/nodeReferenceCount.h index 097a09268a..760046d4cd 100644 --- a/panda/src/express/nodeReferenceCount.h +++ b/panda/src/express/nodeReferenceCount.h @@ -61,7 +61,7 @@ protected: bool do_test_ref_count_integrity() const; private: - PN_int32 _node_ref_count; + AtomicAdjust::Integer _node_ref_count; public: static TypeHandle get_class_type() { diff --git a/panda/src/express/referenceCount.h b/panda/src/express/referenceCount.h index 62fcbda893..f37d568113 100644 --- a/panda/src/express/referenceCount.h +++ b/panda/src/express/referenceCount.h @@ -89,7 +89,7 @@ private: deleted_ref_count = -100, }; - PN_int32 _ref_count; + AtomicAdjust::Integer _ref_count; WeakReferenceList *_weak_list; public: diff --git a/panda/src/net/connectionReader.h b/panda/src/net/connectionReader.h index 175a5801d9..559546e3a0 100644 --- a/panda/src/net/connectionReader.h +++ b/panda/src/net/connectionReader.h @@ -28,6 +28,7 @@ #include "pvector.h" #include "pset.h" #include "socket_fdset.h" +#include "atomicAdjust.h" class NetDatagram; class ConnectionManager; @@ -155,7 +156,7 @@ private: // This is atomically updated with the index (in _threads) of the // thread that is currently waiting on the PR_Poll() call. It // contains -1 if no thread is so waiting. - PN_int32 _currently_polling_thread; + AtomicAdjust::Integer _currently_polling_thread; // These structures track the total set of sockets (connections) we // know about. diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.h b/panda/src/pipeline/conditionVarFullWin32Impl.h index e3b837bc3a..3e82416a64 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.h +++ b/panda/src/pipeline/conditionVarFullWin32Impl.h @@ -62,7 +62,7 @@ private: CRITICAL_SECTION *_external_mutex; HANDLE _event_signal; HANDLE _event_broadcast; - TVOLATILE PN_int32 _waiters_count; + TVOLATILE AtomicAdjust::Integer _waiters_count; }; #include "conditionVarFullWin32Impl.I" diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.cxx b/panda/src/pipeline/conditionVarSpinlockImpl.cxx index 684bd46764..160a654188 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.cxx +++ b/panda/src/pipeline/conditionVarSpinlockImpl.cxx @@ -29,7 +29,7 @@ //////////////////////////////////////////////////////////////////// void ConditionVarSpinlockImpl:: wait() { - PN_int32 current = _event; + AtomicAdjust::Integer current = _event; _mutex.release(); while (AtomicAdjust::get(_event) == current) { diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.h b/panda/src/pipeline/conditionVarSpinlockImpl.h index 8dc8b7062b..38b26d25fa 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.h +++ b/panda/src/pipeline/conditionVarSpinlockImpl.h @@ -50,7 +50,7 @@ public: private: MutexSpinlockImpl &_mutex; - TVOLATILE PN_int32 _event; + TVOLATILE AtomicAdjust::Integer _event; }; #include "conditionVarSpinlockImpl.I" diff --git a/panda/src/pipeline/test_atomic.cxx b/panda/src/pipeline/test_atomic.cxx index 14c416be63..56e79ab5d1 100755 --- a/panda/src/pipeline/test_atomic.cxx +++ b/panda/src/pipeline/test_atomic.cxx @@ -20,6 +20,7 @@ #include "thread.h" #include "pmutex.h" #include "mutexHolder.h" +#include "atomicAdjust.h" // The number of threads to spawn. static const int number_of_threads = 4; @@ -32,10 +33,10 @@ static const int number_of_iterations = 50000000; stuff; \ } -PN_int32 _inc_count = 0; -PN_int32 _dec_count = 0; -PN_int32 _net_count = 0; -PN_int32 _num_net_count_incremented = 0; +AtomicAdjust::Integer _inc_count = 0; +AtomicAdjust::Integer _dec_count = 0; +AtomicAdjust::Integer _net_count = 0; +AtomicAdjust::Integer _num_net_count_incremented = 0; class MyThread : public Thread { public: diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index c7879bf40b..328e5351da 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -194,8 +194,8 @@ private: }; typedef Collector *CollectorPointer; void *_collectors; // CollectorPointer *_collectors; - PN_int32 _collectors_size; // size of the allocated array - PN_int32 _num_collectors; // number of in-use elements within the array + AtomicAdjust::Integer _collectors_size; // size of the allocated array + AtomicAdjust::Integer _num_collectors; // number of in-use elements within the array // This defines a single thread, i.e. a separate chain of execution, // independent of all other threads. Timing and level data are @@ -222,8 +222,8 @@ private: }; typedef InternalThread *ThreadPointer; void *_threads; // ThreadPointer *_threads; - PN_int32 _threads_size; // size of the allocated array - PN_int32 _num_threads; // number of in-use elements within the array + AtomicAdjust::Integer _threads_size; // size of the allocated array + AtomicAdjust::Integer _num_threads; // number of in-use elements within the array PStatClientImpl *_impl; diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.h b/panda/src/putil/cachedTypedWritableReferenceCount.h index 570b8029ad..02ae2b3f35 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.h +++ b/panda/src/putil/cachedTypedWritableReferenceCount.h @@ -59,7 +59,7 @@ protected: bool do_test_ref_count_integrity() const; private: - PN_int32 _cache_ref_count; + AtomicAdjust::Integer _cache_ref_count; public: static TypeHandle get_class_type() { diff --git a/panda/src/putil/nodeCachedReferenceCount.h b/panda/src/putil/nodeCachedReferenceCount.h index 638165ffa1..763a0f8be6 100644 --- a/panda/src/putil/nodeCachedReferenceCount.h +++ b/panda/src/putil/nodeCachedReferenceCount.h @@ -87,7 +87,7 @@ protected: bool do_test_ref_count_integrity() const; private: - PN_int32 _node_ref_count; + AtomicAdjust::Integer _node_ref_count; public: static TypeHandle get_class_type() { diff --git a/panda/src/putil/updateSeq.I b/panda/src/putil/updateSeq.I index 0ec0b5b63b..93d20a776a 100644 --- a/panda/src/putil/updateSeq.I +++ b/panda/src/putil/updateSeq.I @@ -89,7 +89,7 @@ operator = (const UpdateSeq ©) { //////////////////////////////////////////////////////////////////// INLINE void UpdateSeq:: clear() { - AtomicAdjust::set(_seq, (PN_int32)SC_initial); + AtomicAdjust::set(_seq, (AtomicAdjust::Integer)SC_initial); } //////////////////////////////////////////////////////////////////// @@ -100,7 +100,7 @@ clear() { //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: is_initial() const { - return AtomicAdjust::get(_seq) == (PN_int32)SC_initial; + return AtomicAdjust::get(_seq) == (AtomicAdjust::Integer)SC_initial; } //////////////////////////////////////////////////////////////////// @@ -110,7 +110,7 @@ is_initial() const { //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: is_old() const { - return AtomicAdjust::get(_seq) == (PN_int32)SC_old; + return AtomicAdjust::get(_seq) == (AtomicAdjust::Integer)SC_old; } //////////////////////////////////////////////////////////////////// @@ -121,7 +121,7 @@ is_old() const { //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: is_fresh() const { - return AtomicAdjust::get(_seq) == (PN_int32)SC_fresh; + return AtomicAdjust::get(_seq) == (AtomicAdjust::Integer)SC_fresh; } //////////////////////////////////////////////////////////////////// @@ -203,16 +203,16 @@ operator >= (const UpdateSeq &other) const { //////////////////////////////////////////////////////////////////// INLINE UpdateSeq UpdateSeq:: operator ++ () { - PN_int32 old_seq = AtomicAdjust::get(_seq); - PN_int32 new_seq = old_seq + 1; + AtomicAdjust::Integer old_seq = AtomicAdjust::get(_seq); + AtomicAdjust::Integer new_seq = old_seq + 1; if (priv_is_special(new_seq)) { // Oops, wraparound. We don't want to confuse the new value // with our special cases. - new_seq = (PN_int32)SC_old + 1; + new_seq = (AtomicAdjust::Integer)SC_old + 1; } #ifdef HAVE_THREADS - PN_int32 result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); + AtomicAdjust::Integer result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); while (result != old_seq) { // Some other thread beat us to it; try again. old_seq = AtomicAdjust::get(_seq); @@ -220,7 +220,7 @@ operator ++ () { if (priv_is_special(new_seq)) { // Oops, wraparound. We don't want to confuse the new value // with our special cases. - new_seq = (PN_int32)SC_old + 1; + new_seq = (AtomicAdjust::Integer)SC_old + 1; } result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); } @@ -238,16 +238,16 @@ operator ++ () { //////////////////////////////////////////////////////////////////// INLINE UpdateSeq UpdateSeq:: operator ++ (int) { - PN_int32 old_seq = AtomicAdjust::get(_seq); - PN_int32 new_seq = old_seq + 1; + AtomicAdjust::Integer old_seq = AtomicAdjust::get(_seq); + AtomicAdjust::Integer new_seq = old_seq + 1; if (priv_is_special(new_seq)) { // Oops, wraparound. We don't want to confuse the new value // with our special cases. - new_seq = (PN_int32)SC_old + 1; + new_seq = (AtomicAdjust::Integer)SC_old + 1; } #ifdef HAVE_THREADS - PN_int32 result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); + AtomicAdjust::Integer result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); while (result != old_seq) { // Some other thread beat us to it; try again. old_seq = AtomicAdjust::get(_seq); @@ -255,7 +255,7 @@ operator ++ (int) { if (priv_is_special(new_seq)) { // Oops, wraparound. We don't want to confuse the new value // with our special cases. - new_seq = (PN_int32)SC_old + 1; + new_seq = (AtomicAdjust::Integer)SC_old + 1; } result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); } @@ -275,7 +275,7 @@ operator ++ (int) { //////////////////////////////////////////////////////////////////// INLINE void UpdateSeq:: output(ostream &out) const { - PN_int32 seq = AtomicAdjust::get(_seq); + AtomicAdjust::Integer seq = AtomicAdjust::get(_seq); switch (seq) { case SC_initial: out << "initial"; @@ -300,7 +300,7 @@ output(ostream &out) const { // Description: The private implementation of is_special(). //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: -priv_is_special(PN_int32 seq) { +priv_is_special(AtomicAdjust::Integer seq) { // This relies on the assumption that (~0 + 1) == 0. return (((unsigned int)seq + 1) <= 2); } @@ -311,7 +311,7 @@ priv_is_special(PN_int32 seq) { // Description: The private implementation of operator < (). //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: -priv_lt(PN_int32 a, PN_int32 b) { +priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b) { // The special cases of SC_initial or SC_old are less than all other // non-special numbers, and SC_initial is less than SC_old. The // special case of SC_fresh is greater than all other non-special @@ -328,7 +328,7 @@ priv_lt(PN_int32 a, PN_int32 b) { // Description: The private implementation of operator <= (). //////////////////////////////////////////////////////////////////// INLINE bool UpdateSeq:: -priv_le(PN_int32 a, PN_int32 b) { +priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b) { return (a == b) || priv_lt(a, b); } diff --git a/panda/src/putil/updateSeq.h b/panda/src/putil/updateSeq.h index dba1dc93d5..210ef4a692 100644 --- a/panda/src/putil/updateSeq.h +++ b/panda/src/putil/updateSeq.h @@ -74,9 +74,9 @@ PUBLISHED: INLINE void output(ostream &out) const; private: - INLINE static bool priv_is_special(PN_int32 seq); - INLINE static bool priv_lt(PN_int32 a, PN_int32 b); - INLINE static bool priv_le(PN_int32 a, PN_int32 b); + INLINE static bool priv_is_special(AtomicAdjust::Integer seq); + INLINE static bool priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b); + INLINE static bool priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b); private: enum SpecialCases { @@ -85,7 +85,7 @@ private: SC_fresh = ~(unsigned int)0, }; - PN_int32 _seq; + AtomicAdjust::Integer _seq; }; INLINE ostream &operator << (ostream &out, const UpdateSeq &value);