X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-qsbr-static.h;h=c0467cd0e1606c87a522e56d2299716cf6402b3e;hp=22a93b2fd7a823d21c76cbbd1ad5c6bf3b0495e4;hb=4d78cb54f60eac305d4b7e9e1ff90bb968634756;hpb=47d2f29ead2c92123069ebf7b84c6e48cf91612a diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 22a93b2..c0467cd 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -244,6 +244,22 @@ static inline void _rcu_thread_online(void) STORE_SHARED(p, v); \ }) +/** + * _rcu_cmpxchg_pointer - same as rcu_assign_pointer, but tests if the pointer + * is as expected by "old". If succeeds, returns the previous pointer to the + * data structure, which can be safely freed after waiting for a quiescent state + * using synchronize_rcu(). If fails (unexpected value), returns old (which + * should not be freed !). + */ + +#define _rcu_cmpxchg_pointer(p, old, _new) \ + ({ \ + if (!__builtin_constant_p(_new) || \ + ((_new) != NULL)) \ + wmb(); \ + cmpxchg(p, old, _new); \ + }) + /** * _rcu_xchg_pointer - same as rcu_assign_pointer, but returns the previous * pointer to the data structure, which can be safely freed after waiting for a