X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fatomics.h;h=ce2177df5c2805200a8bef4bff11793af65aacca;hb=f58571ee6f7b0460392ee6a7f86be2e07e747390;hp=8084bdc77d474ef73781544fd88c670a6b626264;hpb=19515acddc343d1680d4a5d27f39456999498591;p=vpp.git diff --git a/src/vppinfra/atomics.h b/src/vppinfra/atomics.h index 8084bdc77d4..ce2177df5c2 100644 --- a/src/vppinfra/atomics.h +++ b/src/vppinfra/atomics.h @@ -37,12 +37,19 @@ #define clib_atomic_cmp_and_swap(addr,old,new) __sync_val_compare_and_swap(addr, old, new) #define clib_atomic_bool_cmp_and_swap(addr,old,new) __sync_bool_compare_and_swap(addr, old, new) -#define clib_atomic_test_and_set(a) __sync_lock_test_and_set(a, 1) -#define clib_atomic_release(a) __sync_lock_release(a) +#define clib_atomic_cmp_and_swap_acq_relax_n(addr,exp,new,weak) __atomic_compare_exchange_n ((addr), (exp), (new), (weak), __ATOMIC_ACQUIRE, __ATOMIC_RELAXED) +#define clib_atomic_test_and_set(a) __atomic_exchange_n(a, 1, __ATOMIC_ACQUIRE) +#define clib_atomic_release(a) __atomic_store_n(a, 0, __ATOMIC_RELEASE) + +#define clib_atomic_fence_rel() __atomic_thread_fence(__ATOMIC_RELEASE); + +#define clib_atomic_load_relax_n(a) __atomic_load_n((a), __ATOMIC_RELAXED) #define clib_atomic_load_acq_n(a) __atomic_load_n((a), __ATOMIC_ACQUIRE) #define clib_atomic_store_rel_n(a, b) __atomic_store_n ((a), (b), __ATOMIC_RELEASE) + #define clib_atomic_swap_acq_n(a, b) __atomic_exchange_n ((a), (b), __ATOMIC_ACQUIRE) +#define clib_atomic_swap_rel_n(a, b) __atomic_exchange_n ((a), (b), __ATOMIC_RELEASE) #define clib_atomic_fetch_add_rel(a, b) __atomic_fetch_add((a), (b), __ATOMIC_RELEASE) #define clib_atomic_fetch_sub_rel(a, b) __atomic_fetch_sub((a), (b), __ATOMIC_RELEASE)