diff options
author | Chris Robinson <[email protected]> | 2018-11-13 20:26:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-13 20:26:32 -0800 |
commit | a5f68c21214e6f85ade835cd29045026797ac2a4 (patch) | |
tree | 3b995975906303cfc42b8dc3054f3bbed632dbbb /common/atomic.h | |
parent | 5867c7b8c213aa47659e7c6e6cafddc643d9ea76 (diff) |
Avoid using ATOMIC_FLAG
Although it cant potentially be better than a regular atomic, it presents
compatibility issues when non-C11 atomics are mixed with C++
Diffstat (limited to 'common/atomic.h')
-rw-r--r-- | common/atomic.h | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/common/atomic.h b/common/atomic.h index 17e616bb..2c81f62f 100644 --- a/common/atomic.h +++ b/common/atomic.h @@ -43,8 +43,6 @@ using std::memory_order_release; using std::memory_order_acq_rel; using std::memory_order_seq_cst; -using std::atomic_flag; - using std::atomic_init; using std::atomic_load_explicit; using std::atomic_store_explicit; @@ -53,8 +51,6 @@ using std::atomic_fetch_sub_explicit; using std::atomic_exchange_explicit; using std::atomic_compare_exchange_strong_explicit; using std::atomic_compare_exchange_weak_explicit; -using std::atomic_flag_test_and_set_explicit; -using std::atomic_flag_clear_explicit; using std::atomic_thread_fence; #else @@ -79,11 +75,9 @@ extern "C" { #define almemory_order_seq_cst memory_order_seq_cst #define ATOMIC(T) _Atomic(T) -#define ATOMIC_FLAG atomic_flag #define ATOMIC_INIT atomic_init #define ATOMIC_INIT_STATIC ATOMIC_VAR_INIT -/*#define ATOMIC_FLAG_INIT ATOMIC_FLAG_INIT*/ #define ATOMIC_LOAD atomic_load_explicit #define ATOMIC_STORE atomic_store_explicit @@ -95,9 +89,6 @@ extern "C" { #define ATOMIC_COMPARE_EXCHANGE_STRONG atomic_compare_exchange_strong_explicit #define ATOMIC_COMPARE_EXCHANGE_WEAK atomic_compare_exchange_weak_explicit -#define ATOMIC_FLAG_TEST_AND_SET atomic_flag_test_and_set_explicit -#define ATOMIC_FLAG_CLEAR atomic_flag_clear_explicit - #define ATOMIC_THREAD_FENCE atomic_thread_fence /* Atomics using GCC intrinsics */ @@ -113,11 +104,9 @@ enum almemory_order { }; #define ATOMIC(T) struct { T volatile value; } -#define ATOMIC_FLAG ATOMIC(int) #define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_FLAG_INIT ATOMIC_INIT_STATIC(0) #define ATOMIC_LOAD(_val, _MO) __extension__({ \ __typeof((_val)->value) _r = (_val)->value; \ @@ -142,15 +131,6 @@ enum almemory_order { *(_oldval) == _o; \ }) -#define ATOMIC_FLAG_TEST_AND_SET(_val, _MO) __extension__({ \ - __asm__ __volatile__("" ::: "memory"); \ - __sync_lock_test_and_set(&(_val)->value, 1); \ -}) -#define ATOMIC_FLAG_CLEAR(_val, _MO) __extension__({ \ - __sync_lock_release(&(_val)->value); \ - __asm__ __volatile__("" ::: "memory"); \ -}) - #define ATOMIC_THREAD_FENCE(order) do { \ enum { must_be_constant = (order) }; \ @@ -421,16 +401,6 @@ void *_al_invalid_atomic_ptr_size(); /* not defined */ #define ATOMIC_COMPARE_EXCHANGE_PTR_WEAK ATOMIC_COMPARE_EXCHANGE_PTR_STRONG #endif -/* If no ATOMIC_FLAG is defined, simulate one with an atomic int using exchange - * and store ops. - */ -#ifndef ATOMIC_FLAG -#define ATOMIC_FLAG ATOMIC(int) -#define ATOMIC_FLAG_INIT ATOMIC_INIT_STATIC(0) -#define ATOMIC_FLAG_TEST_AND_SET(_val, _MO) ATOMIC_EXCHANGE(_val, 1, _MO) -#define ATOMIC_FLAG_CLEAR(_val, _MO) ATOMIC_STORE(_val, 0, _MO) -#endif - #define ATOMIC_LOAD_SEQ(_val) ATOMIC_LOAD(_val, almemory_order_seq_cst) #define ATOMIC_STORE_SEQ(_val, _newval) ATOMIC_STORE(_val, _newval, almemory_order_seq_cst) |