diff options
author | Chris Robinson <[email protected]> | 2014-08-01 02:47:46 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-08-01 02:47:46 -0700 |
commit | 659b3407162e2354c89ebdc9858c9a9fb39ad3d3 (patch) | |
tree | 3ddb43f130a7cdd0720e9375cc172427eee08ee1 | |
parent | 1c1e878be75d9fae097dab56766ce51229f68477 (diff) |
Use the right type for atomic compare-exchange
-rw-r--r-- | include/atomic.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/atomic.h b/include/atomic.h index 3cde46df..55a3c439 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -83,9 +83,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) }) #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)); \ - *(_oldval) == _old; \ + T _o = *(_oldval); \ + *(_oldval) = __sync_val_compare_and_swap(&(_val)->value, _o, (_newval)); \ + *(_oldval) == _o; \ }) /* Atomics using x86/x86-64 GCC inline assembly */ @@ -175,7 +175,7 @@ inline void *ExchangePtr(XchgPtr *dest, void *newval) #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); \ + T _old = *(_oldval); \ if(sizeof(T) == 4) WRAP_CMPXCHG("l", *(_oldval), &(_val)->value, _old, (T)(_newval)); \ else if(sizeof(T) == 8) WRAP_CMPXCHG("q", *(_oldval), &(_val)->value, _old, (T)(_newval)); \ *(_oldval) == _old; \ |