X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fuatomic%2Farm.h;fp=urcu%2Fuatomic%2Farm.h;h=40411066cf6c1a63764eca978d29661d42c94d37;hb=027476ea9c652d07f892bbf9e6d350eae2a63174;hp=e0016b8e3153572caac53956df86a5b612481c0c;hpb=8bf9d59bbd7b9b98a8223b06c800d295b8507bdf;p=urcu.git diff --git a/urcu/uatomic/arm.h b/urcu/uatomic/arm.h index e0016b8..4041106 100644 --- a/urcu/uatomic/arm.h +++ b/urcu/uatomic/arm.h @@ -26,13 +26,27 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif /* xchg */ -#define uatomic_xchg(addr, v) __sync_lock_test_and_set(addr, v) + +/* + * Based on [1], __sync_lock_test_and_set() is not a full barrier, but + * instead only an acquire barrier. Given that uatomic_xchg() acts as + * both release and acquire barriers, we therefore need to have our own + * release barrier before this operation. + * + * [1] https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + */ +#define uatomic_xchg(addr, v) \ + ({ \ + cmm_smp_mb(); \ + __sync_lock_test_and_set(addr, v); \ + }) #ifdef __cplusplus }