X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-pointer-static.h;h=c0533c9d3281af0f613e7490ce18e67594bf75e4;hp=06b8881a5ad3d1549f93f48ee977d1efde4a93d6;hb=e156285068a631eaafa643d9e930b31780468d00;hpb=b1048d48b166d50e10d1eb3a1e512a7bffb2a265 diff --git a/urcu-pointer-static.h b/urcu-pointer-static.h index 06b8881..c0533c9 100644 --- a/urcu-pointer-static.h +++ b/urcu-pointer-static.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include /** * _rcu_dereference - reads (copy) a RCU-protected pointer to a local variable @@ -71,12 +71,17 @@ * should not be freed !). */ -#define _rcu_cmpxchg_pointer(p, old, _new) \ - ({ \ - if (!__builtin_constant_p(_new) || \ - ((_new) != NULL)) \ - wmb(); \ - uatomic_cmpxchg(p, old, _new); \ +#define _rcu_cmpxchg_pointer(p, old, _new) \ + ({ \ + typeof(*p) _________pold = (old); \ + typeof(*p) _________pnew = (_new); \ + if (!__builtin_constant_p(_new) || \ + ((_new) != NULL)) \ + wmb(); \ + (likely(URCU_CAS_AVAIL()) ? \ + (uatomic_cmpxchg(p, _________pold, _________pnew)) : \ + (compat_uatomic_cmpxchg(p, _________pold, \ + _________pnew))) \ }) /** @@ -87,19 +92,21 @@ #define _rcu_xchg_pointer(p, v) \ ({ \ + typeof(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ wmb(); \ - uatomic_xchg(p, v); \ + uatomic_xchg(p, _________pv); \ }) #define _rcu_set_pointer(p, v) \ ({ \ + typeof(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ wmb(); \ - STORE_SHARED(*(p), v); \ + STORE_SHARED(*(p), _________pv); \ }) /**