don't limit counters to 32-bit
This commit is contained in:
parent
80c18644be
commit
d85b062b2d
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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().
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
private:
|
||||
void do_lock();
|
||||
|
||||
TVOLATILE PN_int32 _lock;
|
||||
TVOLATILE AtomicAdjust::Integer _lock;
|
||||
};
|
||||
|
||||
#include "mutexSpinlockImpl.I"
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "configFlags.h"
|
||||
|
||||
PN_int32 ConfigFlags::_global_modified;
|
||||
TVOLATILE AtomicAdjust::Integer ConfigFlags::_global_modified;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigFlags::Type output operator
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ PUBLISHED:
|
|||
INLINE void set_word(int n, bool value);
|
||||
|
||||
private:
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
bool _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ private:
|
|||
void set_default_value(double default_value);
|
||||
|
||||
private:
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
double _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ private:
|
|||
bool _got_default_value;
|
||||
EnumType _default_value;
|
||||
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
EnumType _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ private:
|
|||
void reload_cache();
|
||||
|
||||
private:
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
Filename _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ private:
|
|||
void set_default_value(int default_value);
|
||||
|
||||
private:
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
int _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ private:
|
|||
|
||||
DSearchPath _prefix, _postfix;
|
||||
|
||||
PN_int32 _local_modified;
|
||||
AtomicAdjust::Integer _local_modified;
|
||||
DSearchPath _cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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<PN_int16 *>(dst)) = *(reinterpret_cast <const PN_int16 *>(src));
|
||||
}
|
||||
|
||||
inline void TS_SetVal4(const char * src, char *dst)
|
||||
{
|
||||
*(reinterpret_cast <PN_int32 *>(dst)) = *(reinterpret_cast <const PN_int32 *>(src));
|
||||
}
|
||||
|
||||
|
||||
inline void TS_SetVal8(const char * src, char *dst)
|
||||
{
|
||||
*(reinterpret_cast<PN_int64 *>(dst)) = *(reinterpret_cast<const PN_int64 *>(src));
|
||||
}
|
||||
|
||||
template<class type> inline type TS_GetInteger(type &val,const char * _src)
|
||||
{
|
||||
val = *(reinterpret_cast <const type *>(_src));
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class type> inline type TS_GetIntegerIncPtr(type &val,char *& _src)
|
||||
{
|
||||
val = *(reinterpret_cast <const type *>(_src));
|
||||
_src+= sizeof(type);
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class type> inline void TS_AddIntegerIncPtr(type val, char *& _dst)
|
||||
{
|
||||
*(reinterpret_cast <type *>(_dst)) = val;
|
||||
_dst+= sizeof(type);
|
||||
}
|
||||
|
||||
template<class type> inline void TS_AddInteger(type val, char * _dst)
|
||||
{
|
||||
*(reinterpret_cast <type *>(_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<PN_int16 *>(dst)) = *(reinterpret_cast <const PN_int16 *>(src));
|
||||
}
|
||||
|
||||
inline void TS_SetVal4(const char * src, char *dst)
|
||||
{
|
||||
*(reinterpret_cast <PN_int32 *>(dst)) = *(reinterpret_cast <const PN_int32 *>(src));
|
||||
}
|
||||
|
||||
|
||||
inline void TS_SetVal8(const char * src, char *dst)
|
||||
{
|
||||
*(reinterpret_cast<PN_int64 *>(dst)) = *(reinterpret_cast<const PN_int64 *>(src));
|
||||
}
|
||||
|
||||
template<class type> inline type TS_GetInteger(type &val,const char * _src)
|
||||
{
|
||||
val = *(reinterpret_cast <const type *>(_src));
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class type> inline type TS_GetIntegerIncPtr(type &val,char *& _src)
|
||||
{
|
||||
val = *(reinterpret_cast <const type *>(_src));
|
||||
_src+= sizeof(type);
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class type> inline void TS_AddIntegerIncPtr(type val, char *& _dst)
|
||||
{
|
||||
*(reinterpret_cast <type *>(_dst)) = val;
|
||||
_dst+= sizeof(type);
|
||||
}
|
||||
|
||||
template<class type> inline void TS_AddInteger(type val, char * _dst)
|
||||
{
|
||||
*(reinterpret_cast <type *>(_dst)) = val;
|
||||
}
|
||||
|
||||
#define TS_GetDirect(TT,SS) *((TT *)(SS))
|
||||
#define TS_GetDirectIncPtr(TT,SS) { _ptr += sizeof(TT); return *((TT *)(SS -sizeof(TT))); }
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ private:
|
|||
deleted_ref_count = -100,
|
||||
};
|
||||
|
||||
PN_int32 _ref_count;
|
||||
AtomicAdjust::Integer _ref_count;
|
||||
WeakReferenceList *_weak_list;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void ConditionVarSpinlockImpl::
|
||||
wait() {
|
||||
PN_int32 current = _event;
|
||||
AtomicAdjust::Integer current = _event;
|
||||
_mutex.release();
|
||||
|
||||
while (AtomicAdjust::get(_event) == current) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
private:
|
||||
MutexSpinlockImpl &_mutex;
|
||||
TVOLATILE PN_int32 _event;
|
||||
TVOLATILE AtomicAdjust::Integer _event;
|
||||
};
|
||||
|
||||
#include "conditionVarSpinlockImpl.I"
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue