Update return value of "set" operations
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 18 May 2012 03:14:26 +0000 (23:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 18 May 2012 03:14:26 +0000 (23:14 -0400)
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 <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu-pointer.h
urcu/static/urcu-pointer.h
urcu/uatomic/generic.h

index dd64ec4128fadb2f7b39971a0d975c891c0a6013..1e1e6bf8a157dff00edcfda519a773b1e0a4a32d 100644 (file)
@@ -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
index acd7cee1f0677554794f238e945715e1e4bd3b10..906caa009c708c13cc2f9a6b0c1e989416e3aed7 100644 (file)
@@ -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
index bfd9b68f3b14bac2617ede3e51f8285090b05d77..9e2e78086c220b7286c508403069d5aa3b27e246 100644 (file)
@@ -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
This page took 0.030724 seconds and 4 git commands to generate.