*
* Userspace RCU header. Operations on pointers.
*
- * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
*
* This library is free software; you can redistribute it and/or
#include <urcu/compiler.h>
#include <urcu/arch.h>
-#include <urcu/arch_uatomic.h>
+#include <urcu/uatomic.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifdef _LGPL_SOURCE
-#include <urcu-pointer-static.h>
+#include <urcu/static/urcu-pointer.h>
/*
* rcu_dereference(ptr)
#else /* !_LGPL_SOURCE */
-extern void *rcu_dereference(void *p);
+extern void *rcu_dereference_sym(void *p);
+#define rcu_dereference(p) \
+ ({ \
+ typeof(p) _________p1 = URCU_FORCE_CAST(typeof(p), \
+ rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \
+ (_________p1); \
+ })
extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new);
-#define rcu_cmpxchg_pointer(p, old, _new) \
- rcu_cmpxchg_pointer_sym((void **)(p), (old), (_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),\
+ _________pold, \
+ _________pnew)); \
+ (_________p1); \
+ })
extern void *rcu_xchg_pointer_sym(void **p, void *v);
-#define rcu_xchg_pointer(p, v) \
- rcu_xchg_pointer_sym((void **)(p), (v))
+#define rcu_xchg_pointer(p, v) \
+ ({ \
+ typeof(*(p)) _________pv = (v); \
+ typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \
+ rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
+ _________pv)); \
+ (_________p1); \
+ })
extern void *rcu_set_pointer_sym(void **p, void *v);
-#define rcu_set_pointer(p, v) \
- rcu_set_pointer_sym((void **)(p), (v))
-
-extern void *rcu_assign_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); \
+ })
#endif /* !_LGPL_SOURCE */
*/
#define rcu_assign_pointer(p, v) rcu_set_pointer((&p), (v))
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _URCU_POINTER_H */