Fix: memory leak in urcu-checker
[userspace-rcu.git] / urcu-pointer.h
index 1e1e6bf8a157dff00edcfda519a773b1e0a4a32d..6c79c58fe9e6293a41772bba1d2a91aad8b503be 100644 (file)
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
 #include <urcu/uatomic.h>
+#include <urcu/urcu-checker.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif 
 
-#ifdef _LGPL_SOURCE
+#if defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)
 
 #include <urcu/static/urcu-pointer.h>
 
@@ -44,7 +45,11 @@ extern "C" {
  * Fetch a RCU-protected pointer. Typically used to copy the variable ptr to a
  * local variable.
  */
-#define rcu_dereference                _rcu_dereference
+#define rcu_dereference(p)                             \
+       ({                                              \
+               rcu_read_ongoing_check_debug(__func__); \
+               _rcu_dereference(p);                    \
+       })
 
 /*
  * type *rcu_cmpxchg_pointer(type **ptr, type *new, type *old)
@@ -62,12 +67,12 @@ extern "C" {
 #define rcu_xchg_pointer       _rcu_xchg_pointer
 #define rcu_set_pointer                _rcu_set_pointer
 
-#else /* !_LGPL_SOURCE */
+#else /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */
 
 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 +80,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,8 +92,8 @@ 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);                                               \
@@ -103,12 +108,12 @@ extern void *rcu_xchg_pointer_sym(void **p, void *v);
 extern void *rcu_set_pointer_sym(void **p, void *v);
 #define rcu_set_pointer(p, v)                                               \
        do {                                                                 \
-               typeof(*(p)) _________pv = (v);                              \
+               __typeof__(*(p)) _________pv = (v);                          \
                (void) rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p),      \
                                            _________pv);                    \
        } while (0)
 
-#endif /* !_LGPL_SOURCE */
+#endif /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */
 
 /*
  * void rcu_assign_pointer(type *ptr, type *new)
This page took 0.023965 seconds and 4 git commands to generate.