diff options
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | OpenAL32/alError.c | 2 | ||||
-rw-r--r-- | common/atomic.c | 2 | ||||
-rw-r--r-- | include/atomic.h | 14 |
4 files changed, 7 insertions, 13 deletions
@@ -2191,7 +2191,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) } origctx = context; - if(ATOMIC_COMPARE_EXCHANGE(ALCcontext*, &GlobalContext, &origctx, NULL)) + if(ATOMIC_COMPARE_EXCHANGE_STRONG(ALCcontext*, &GlobalContext, &origctx, NULL)) ALCcontext_DecRef(context); ALCdevice_Lock(device); diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index e43c7b45..875e118a 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -46,7 +46,7 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode) raise(SIGTRAP); #endif } - (void)ATOMIC_COMPARE_EXCHANGE(ALenum, &Context->LastError, &curerr, errorCode); + (void)ATOMIC_COMPARE_EXCHANGE_STRONG(ALenum, &Context->LastError, &curerr, errorCode); } AL_API ALenum AL_APIENTRY alGetError(void) diff --git a/common/atomic.c b/common/atomic.c index ab258e8e..90654628 100644 --- a/common/atomic.c +++ b/common/atomic.c @@ -8,8 +8,6 @@ extern inline void InitRef(RefCount *ptr, uint value); extern inline uint ReadRef(RefCount *ptr); extern inline uint IncrementRef(RefCount *ptr); extern inline uint DecrementRef(RefCount *ptr); -extern inline uint ExchangeRef(RefCount *ptr, uint newval); -extern inline uint CompExchangeRef(RefCount *ptr, uint oldval, uint newval); extern inline int ExchangeInt(volatile int *ptr, int newval); extern inline void *ExchangePtr(XchgPtr *ptr, void *newval); diff --git a/include/atomic.h b/include/atomic.h index 9067e845..ab7b73be 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -39,7 +39,7 @@ inline void *CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) #define ATOMIC_SUB(T, _val, _decr) atomic_fetch_sub(&(_val)->value, (_decr)) #define ATOMIC_EXCHANGE(T, _val, _newval) atomic_exchange(&(_val)->value, (_newval)) -#define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) \ +#define ATOMIC_COMPARE_EXCHANGE_STRONG(T, _val, _oldval, _newval) \ atomic_compare_exchange_strong(&(_val)->value, (_oldval), (_newval)) /* Atomics using GCC intrinsics */ @@ -87,7 +87,7 @@ inline void *CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ __sync_lock_test_and_set(&(_val)->value, (_newval)); \ }) -#define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) __extension__({ \ +#define ATOMIC_COMPARE_EXCHANGE_STRONG(T, _val, _oldval, _newval) __extension__({ \ static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ __typeof(*_oldval) _old = *(_oldval); \ *(_oldval) = __sync_val_compare_and_swap(&(_val)->value, _old, (_newval)); \ @@ -184,7 +184,7 @@ inline void *CompExchangePtr(XchgPtr *dest, void *oldval, void *newval) else if(sizeof(T) == 8) WRAP_XCHG("q", _r, &(_val)->value, (_newval)); \ _r; \ }) -#define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) __extension__({ \ +#define ATOMIC_COMPARE_EXCHANGE_STRONG(T, _val, _oldval, _newval) __extension__({ \ static_assert(sizeof(T)==4 || sizeof(T)==8, "Type "#T" has incorrect size!"); \ static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ __typeof(*_oldval) _old = *(_oldval); \ @@ -289,7 +289,7 @@ int _al_invalid_atomic_size(); /* not defined */ ((sizeof(T)==4) ? WRAP_XCHG(T, AtomicSwap32, &(_val)->value, (_newval)) : \ (sizeof(T)==8) ? WRAP_XCHG(T, AtomicSwap64, &(_val)->value, (_newval)) : \ (T)_al_invalid_atomic_size()) -#define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) \ +#define ATOMIC_COMPARE_EXCHANGE_STRONG(T, _val, _oldval, _newval) \ ((sizeof(T)==4) ? WRAP_CMPXCHG(T, CompareAndSwap32, &(_val)->value, (_newval), (_oldval)) : \ (sizeof(T)==8) ? WRAP_CMPXCHG(T, CompareAndSwap64, &(_val)->value, (_newval), (_oldval)) : \ (bool)_al_invalid_atomic_size()) @@ -312,7 +312,7 @@ int _al_invalid_atomic_size(); /* not defined */ #define ATOMIC_SUB(T, _val, _decr) (0) #define ATOMIC_EXCHANGE(T, _val, _newval) (0) -#define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) (0) +#define ATOMIC_COMPARE_EXCHANGE_STRONG(T, _val, _oldval, _newval) (0) #endif @@ -327,10 +327,6 @@ inline uint IncrementRef(RefCount *ptr) { return ATOMIC_ADD(uint, ptr, 1)+1; } inline uint DecrementRef(RefCount *ptr) { return ATOMIC_SUB(uint, ptr, 1)-1; } -inline uint ExchangeRef(RefCount *ptr, uint newval) -{ return ATOMIC_EXCHANGE(uint, ptr, newval); } -inline uint CompExchangeRef(RefCount *ptr, uint oldval, uint newval) -{ (void)ATOMIC_COMPARE_EXCHANGE(uint, ptr, &oldval, newval); return oldval; } #ifdef __cplusplus } |