mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Add most useful relaxed and acquire-relase stdatomic convenience macros
The header file <isc/atomic.h> now contains convenience macros for most useful explicit memory ordering for C11 stdatomics, only relaxed and acquire-release semantics is being used. These macros SHOULD be used instead of atomic_<func>_explicit functions.
This commit is contained in:
@@ -21,7 +21,36 @@
|
||||
* We define a few additional macros to make things easier
|
||||
*/
|
||||
|
||||
#define atomic_store_relaxed(o, v) atomic_store_explicit((o), \
|
||||
(v), \
|
||||
memory_order_relaxed)
|
||||
#define atomic_load_relaxed(o) atomic_load_explicit((o), memory_order_relaxed)
|
||||
/* Relaxed Memory Ordering */
|
||||
|
||||
#define atomic_store_relaxed(o, v) \
|
||||
atomic_store_explicit((o), (v), memory_order_relaxed)
|
||||
#define atomic_load_relaxed(o) \
|
||||
atomic_load_explicit((o), memory_order_relaxed)
|
||||
#define atomic_fetch_add_relaxed(o, v) \
|
||||
atomic_fetch_add_explicit((o), (v), memory_order_relaxed)
|
||||
#define atomic_fetch_sub_relaxed(o, v) \
|
||||
atomic_fetch_sub_explicit((o), (v), memory_order_relaxed)
|
||||
#define atomic_exchange_relaxed(o, v) \
|
||||
atomic_exchange_explicit((o), (v), memory_order_relaxed)
|
||||
#define atomic_compare_exchange_weak_relaxed(o, e, d) \
|
||||
atomic_compare_exchange_weak_explicit((o), (e), (d), \
|
||||
memory_order_relaxed, \
|
||||
memory_order_relaxed)
|
||||
|
||||
/* Acquire-Release Memory Ordering */
|
||||
|
||||
#define atomic_store_release(o, v) \
|
||||
atomic_store_explicit((o), (v), memory_order_release)
|
||||
#define atomic_load_acquire(o) \
|
||||
atomic_load_explicit((o), memory_order_acquire)
|
||||
#define atomic_fetch_add_acquire(o, v) \
|
||||
atomic_fetch_add_explicit((o), (v), memory_order_acquire)
|
||||
#define atomic_fetch_sub_release(o, v) \
|
||||
atomic_fetch_sub_explicit((o), (v), memory_order_release)
|
||||
#define atomic_exchange_acq_rel(o, v) \
|
||||
atomic_exchange_explicit((o), (v), memory_order_acq_rel)
|
||||
#define atomic_compare_exchange_weak_acq_rel(o, e, d) \
|
||||
atomic_compare_exchange_weak_explicit((o), (e), (d), \
|
||||
memory_order_acq_rel, \
|
||||
memory_order_acquire)
|
||||
|
Reference in New Issue
Block a user