X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-pointer-static.h;h=c8ac7f0c0861a2d80e20e935dddf99303693fa75;hp=06b8881a5ad3d1549f93f48ee977d1efde4a93d6;hb=5481ddb381061bda64aebc039900d21cac6a6caf;hpb=b1048d48b166d50e10d1eb3a1e512a7bffb2a265 diff --git a/urcu-pointer-static.h b/urcu-pointer-static.h index 06b8881..c8ac7f0 100644 --- a/urcu-pointer-static.h +++ b/urcu-pointer-static.h @@ -9,7 +9,7 @@ * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu-pointer.h for * linking dynamically with the userspace rcu library. * - * Copyright (c) 2009 Mathieu Desnoyers + * Copyright (c) 2009 Mathieu Desnoyers * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. * * This library is free software; you can redistribute it and/or @@ -32,7 +32,11 @@ #include #include #include -#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /** * _rcu_dereference - reads (copy) a RCU-protected pointer to a local variable @@ -59,7 +63,7 @@ #define _rcu_dereference(p) ({ \ typeof(p) _________p1 = LOAD_SHARED(p); \ - smp_read_barrier_depends(); \ + cmm_smp_read_barrier_depends(); \ (_________p1); \ }) @@ -71,12 +75,14 @@ * 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)) \ + cmm_wmb(); \ + uatomic_cmpxchg(p, _________pold, _________pnew); \ }) /** @@ -87,19 +93,21 @@ #define _rcu_xchg_pointer(p, v) \ ({ \ + typeof(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ - wmb(); \ - uatomic_xchg(p, v); \ + cmm_wmb(); \ + 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); \ + cmm_wmb(); \ + uatomic_set(p, _________pv); \ }) /** @@ -117,4 +125,8 @@ #define _rcu_assign_pointer(p, v) _rcu_set_pointer(&(p), v) +#ifdef __cplusplus +} +#endif + #endif /* _URCU_POINTER_STATIC_H */