From: Mathieu Desnoyers Date: Fri, 18 May 2012 03:14:26 +0000 (-0400) Subject: Update return value of "set" operations X-Git-Tag: v0.7.0~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3daae22a68a6e74c99d39a8c6b628f5c9121c54a;p=urcu.git Update return value of "set" operations To follow the way the Linux kernel implements atomic_set(), we change some API functions so they don't return any value anymore. This is now the case for: uatomic_set() rcu_set_pointer() rcu_assign_pointer() This API change is very minor. In all instances of the Linux kernel using rcu_assign_pointer(), none currently care about its return value. However, we keep ABI compatibility: rcu_set_pointer_sym() still returns the "v" value, even though it is not used by its wrapper macro anymore. Reviewed-by: Paul E. McKenney Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-pointer.h b/urcu-pointer.h index dd64ec4..1e1e6bf 100644 --- a/urcu-pointer.h +++ b/urcu-pointer.h @@ -47,9 +47,9 @@ extern "C" { #define rcu_dereference _rcu_dereference /* - * rcu_cmpxchg_pointer(type **ptr, type *new, type *old) + * type *rcu_cmpxchg_pointer(type **ptr, type *new, type *old) * type *rcu_xchg_pointer(type **ptr, type *new) - * type *rcu_set_pointer(type **ptr, type *new) + * void rcu_set_pointer(type **ptr, type *new) * * RCU pointer updates. * @ptr: address of the pointer to modify @@ -94,20 +94,24 @@ extern void *rcu_xchg_pointer_sym(void **p, void *v); (_________p1); \ }) +/* + * Note: rcu_set_pointer_sym returns @v because we don't want to break + * the ABI. At the API level, rcu_set_pointer() now returns void. Use of + * the return value is therefore deprecated, and will cause a build + * error. + */ extern void *rcu_set_pointer_sym(void **p, void *v); #define rcu_set_pointer(p, v) \ - ({ \ + do { \ typeof(*(p)) _________pv = (v); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ - rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \ - _________pv)); \ - (_________p1); \ - }) + (void) rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \ + _________pv); \ + } while (0) #endif /* !_LGPL_SOURCE */ /* - * rcu_assign_pointer(type *ptr, type *new) + * void rcu_assign_pointer(type *ptr, type *new) * * Same as rcu_set_pointer, but takes the pointer to assign to rather than its * address as first parameter. Provided for compatibility with the Linux kernel diff --git a/urcu/static/urcu-pointer.h b/urcu/static/urcu-pointer.h index acd7cee..906caa0 100644 --- a/urcu/static/urcu-pointer.h +++ b/urcu/static/urcu-pointer.h @@ -102,13 +102,13 @@ extern "C" { #define _rcu_set_pointer(p, v) \ - ({ \ + do { \ typeof(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ cmm_wmb(); \ uatomic_set(p, _________pv); \ - }) + } while (0) /** * _rcu_assign_pointer - assign (publicize) a pointer to a new data structure diff --git a/urcu/uatomic/generic.h b/urcu/uatomic/generic.h index bfd9b68..9e2e780 100644 --- a/urcu/uatomic/generic.h +++ b/urcu/uatomic/generic.h @@ -29,7 +29,7 @@ extern "C" { #endif #ifndef uatomic_set -#define uatomic_set(addr, v) CMM_STORE_SHARED(*(addr), (v)) +#define uatomic_set(addr, v) ((void) CMM_STORE_SHARED(*(addr), (v))) #endif #ifndef uatomic_read