urcu-pointer: add more type checking
[urcu.git] / urcu-pointer-static.h
index 06b8881a5ad3d1549f93f48ee977d1efde4a93d6..0a01f1ffc944550d3c66cdf9b8d5a53c2a5c8225 100644 (file)
  * should not be freed !).
  */
 
-#define _rcu_cmpxchg_pointer(p, old, _new)             \
-       ({                                              \
-               if (!__builtin_constant_p(_new) ||      \
-                   ((_new) != NULL))                   \
-                       wmb();                          \
-               uatomic_cmpxchg(p, old, _new);          \
+#define _rcu_cmpxchg_pointer(p, old, _new)                             \
+       ({                                                              \
+               typeof(*p) _________pold = (old);                       \
+               typeof(*p) _________pnew = (_new);                      \
+               if (!__builtin_constant_p(_new) ||                      \
+                   ((_new) != NULL))                                   \
+                       wmb();                                          \
+               uatomic_cmpxchg(p, _________pold, _________pnew);       \
        })
 
 /**
 
 #define _rcu_xchg_pointer(p, v)                                \
        ({                                              \
+               typeof(*p) _________pv = (v);           \
                if (!__builtin_constant_p(v) ||         \
                    ((v) != NULL))                      \
                        wmb();                          \
-               uatomic_xchg(p, v);                     \
+               uatomic_xchg(p, _________pv);           \
        })
 
 
 #define _rcu_set_pointer(p, v)                         \
        ({                                              \
+               typeof(*p) _________pv = (v);           \
                if (!__builtin_constant_p(v) ||         \
                    ((v) != NULL))                      \
                        wmb();                          \
-               STORE_SHARED(*(p), v);                  \
+               STORE_SHARED(*(p), _________pv);        \
        })
 
 /**
This page took 0.022554 seconds and 4 git commands to generate.