urcu-pointer: add more type checking v0.2.2
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Mon, 5 Oct 2009 22:05:31 +0000 (18:05 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Mon, 5 Oct 2009 22:05:31 +0000 (18:05 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu-pointer-static.h
urcu-pointer.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);        \
        })
 
 /**
index d3718b020e070d95724db18513c022d784a136a0..b10aa13a4ad5c9689f7364476b263531e86e4278 100644 (file)
@@ -71,24 +71,29 @@ 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 =                                     \
-                       rcu_cmpxchg_pointer_sym((void **)(p), (old), (_new));\
+                       rcu_cmpxchg_pointer_sym((void **)(p), _________pold, \
+                                               _________pnew);              \
                (_________p1);                                               \
        })
 
 extern void *rcu_xchg_pointer_sym(void **p, void *v);
 #define rcu_xchg_pointer(p, v)                                              \
        ({                                                                   \
+               typeof(*p) _________pv = (v);                                \
                typeof(*p) _________p1 =                                     \
-                       rcu_xchg_pointer_sym((void **)(p), (v));             \
+                       rcu_xchg_pointer_sym((void **)(p), _________pv);     \
                (_________p1);                                               \
        })
 
 extern void *rcu_set_pointer_sym(void **p, void *v);
 #define rcu_set_pointer(p, v)                                               \
        ({                                                                   \
+               typeof(*p) _________pv = (v);                                \
                typeof(*p) _________p1 =                                     \
-                       rcu_set_pointer_sym((void **)(p), (v));              \
+                       rcu_set_pointer_sym((void **)(p), _________pv);      \
        })
 
 #endif /* !_LGPL_SOURCE */
This page took 0.029306 seconds and 4 git commands to generate.