1 // SPDX-FileCopyrightText: 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 // SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation.
4 // SPDX-License-Identifier: LGPL-2.1-or-later
6 #ifndef _URCU_POINTER_H
7 #define _URCU_POINTER_H
10 * Userspace RCU header. Operations on pointers.
12 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
15 #include <urcu/compiler.h>
16 #include <urcu/arch.h>
17 #include <urcu/uatomic.h>
23 #if defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)
25 #include <urcu/static/pointer.h>
28 * rcu_dereference(ptr)
30 * Fetch a RCU-protected pointer. Typically used to copy the variable ptr to a
33 #define rcu_dereference _rcu_dereference
36 * type *rcu_cmpxchg_pointer(type **ptr, type *new, type *old)
37 * type *rcu_xchg_pointer(type **ptr, type *new)
38 * void rcu_set_pointer(type **ptr, type *new)
40 * RCU pointer updates.
41 * @ptr: address of the pointer to modify
42 * @new: new pointer value
43 * @old: old pointer value (expected)
45 * return: old pointer value
47 #define rcu_cmpxchg_pointer _rcu_cmpxchg_pointer
48 #define rcu_xchg_pointer _rcu_xchg_pointer
49 #define rcu_set_pointer _rcu_set_pointer
51 #else /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */
53 extern void *rcu_dereference_sym(void *p
);
54 #define rcu_dereference(p) \
57 __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \
58 rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \
62 extern void *rcu_cmpxchg_pointer_sym(void **p
, void *old
, void *_new
);
63 #define rcu_cmpxchg_pointer(p, old, _new) \
66 __typeof__(*(p)) _________pold = (old); \
67 __typeof__(*(p)) _________pnew = (_new); \
68 __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
69 rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
75 extern void *rcu_xchg_pointer_sym(void **p
, void *v
);
76 #define rcu_xchg_pointer(p, v) \
79 __typeof__(*(p)) _________pv = (v); \
80 __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
81 rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
87 * Note: rcu_set_pointer_sym returns @v because we don't want to break
88 * the ABI. At the API level, rcu_set_pointer() now returns void. Use of
89 * the return value is therefore deprecated, and will cause a build
92 extern void *rcu_set_pointer_sym(void **p
, void *v
);
93 #define rcu_set_pointer(p, v) \
95 __typeof__(*(p)) _________pv = (v); \
96 (void) rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \
100 #endif /* !(defined(_LGPL_SOURCE) || defined(URCU_INLINE_SMALL_FUNCTIONS)) */
103 * void rcu_assign_pointer(type *ptr, type *new)
105 * Same as rcu_set_pointer, but takes the pointer to assign to rather than its
106 * address as first parameter. Provided for compatibility with the Linux kernel
109 #define rcu_assign_pointer(p, v) rcu_set_pointer((&p), (v))
115 #endif /* _URCU_POINTER_H */
This page took 0.031362 seconds and 4 git commands to generate.