doc/examples: cds_lfht_destroy
[urcu.git] / urcu-pointer.h
index dd64ec4128fadb2f7b39971a0d975c891c0a6013..03bfe793c6aaf339a03d7aa0e64bed0b105a8646 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
@@ -67,7 +67,7 @@ extern "C" {
 extern void *rcu_dereference_sym(void *p);
 #define rcu_dereference(p)                                                  \
        ({                                                                   \
-               typeof(p) _________p1 = URCU_FORCE_CAST(typeof(p),           \
+               __typeof__(p) _________p1 =     URCU_FORCE_CAST(__typeof__(p), \
                        rcu_dereference_sym(URCU_FORCE_CAST(void *, p)));    \
                (_________p1);                                               \
        })
@@ -75,10 +75,10 @@ extern void *rcu_dereference_sym(void *p);
 extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new);
 #define rcu_cmpxchg_pointer(p, old, _new)                                   \
        ({                                                                   \
-               typeof(*(p)) _________pold = (old);                          \
-               typeof(*(p)) _________pnew = (_new);                         \
-               typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)),     \
-                       rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p),\
+               __typeof__(*(p)) _________pold = (old);                      \
+               __typeof__(*(p)) _________pnew = (_new);                     \
+               __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
+                       rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
                                                _________pold,               \
                                                _________pnew));             \
                (_________p1);                                               \
@@ -87,27 +87,31 @@ extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new);
 extern void *rcu_xchg_pointer_sym(void **p, void *v);
 #define rcu_xchg_pointer(p, v)                                              \
        ({                                                                   \
-               typeof(*(p)) _________pv = (v);                              \
-               typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)),     \
+               __typeof__(*(p)) _________pv = (v);                          \
+               __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
                        rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p),    \
                                             _________pv));                  \
                (_________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)                                               \
-       ({                                                                   \
-               typeof(*(p)) _________pv = (v);                              \
-               typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)),     \
-                       rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p),     \
-                                           _________pv));                   \
-               (_________p1);                                               \
-       })
+       do {                                                                 \
+               __typeof__(*(p)) _________pv = (v);                          \
+               (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
This page took 0.024199 seconds and 4 git commands to generate.