diff options
author | Chris Robinson <[email protected]> | 2014-08-03 00:26:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-08-03 00:26:21 -0700 |
commit | f5194a9d8e9ce58b0c1a082686ccf180ea66f8ad (patch) | |
tree | 4af7b454465d607a9465e849b6b75e02e84aef0e /include/atomic.h | |
parent | 659b3407162e2354c89ebdc9858c9a9fb39ad3d3 (diff) |
Use an ATOMIC_INIT macro instead of ATOMIC_LOAD_UNSAFE
Diffstat (limited to 'include/atomic.h')
-rw-r--r-- | include/atomic.h | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/include/atomic.h b/include/atomic.h index 55a3c439..d761890e 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -23,11 +23,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T _Atomic value; } +#define ATOMIC_INIT(_val, _newval) atomic_init(&(_val)->value, (_newval)) #define ATOMIC_INIT_STATIC(_newval) {ATOMIC_VAR_INIT(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) atomic_load_explicit(&(_val)->value, memory_order_relaxed) -#define ATOMIC_STORE_UNSAFE(_val, _newval) atomic_store_explicit(&(_val)->value, (_newval), memory_order_relaxed) - #define ATOMIC_LOAD(_val) atomic_load(&(_val)->value) #define ATOMIC_STORE(_val, _newval) atomic_store(&(_val)->value, (_newval)) @@ -51,13 +49,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) __extension__({(_val)->value;}) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) __extension__({ \ __typeof((_val)->value) _r = (_val)->value; \ __asm__ __volatile__("" ::: "memory"); \ @@ -132,13 +126,9 @@ inline void *ExchangePtr(XchgPtr *dest, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) __extension__({(_val)->value;}) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) __extension__({ \ __typeof((_val)->value) _r = (_val)->value; \ __asm__ __volatile__("" ::: "memory"); \ @@ -246,13 +236,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) ((_val)->value) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) ((_val)->value) #define ATOMIC_STORE(_val, _newval) do { \ (_val)->value = (_newval); \ @@ -312,7 +298,7 @@ typedef unsigned int uint; typedef ATOMIC(uint) RefCount; inline void InitRef(RefCount *ptr, uint value) -{ ATOMIC_STORE_UNSAFE(ptr, value); } +{ ATOMIC_INIT(ptr, value); } inline uint ReadRef(RefCount *ptr) { return ATOMIC_LOAD(ptr); } inline uint IncrementRef(RefCount *ptr) |