21bc2f4c5b3f586e181e04a2ea8830ab84d63320
1 #ifndef _LTTNG_UST_URCU_POINTER_H
2 #define _LTTNG_UST_URCU_POINTER_H
7 * Userspace RCU header. Operations on pointers.
9 * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
29 #include <urcu/compiler.h>
30 #include <urcu/arch.h>
31 #include <urcu/uatomic.h>
37 #if defined(_LGPL_SOURCE) || defined(LTTNG_UST_URCU_INLINE_SMALL_FUNCTIONS)
39 #include <lttng/urcu/static/pointer.h>
42 * lttng_ust_rcu_dereference(ptr)
44 * Fetch a RCU-protected pointer. Typically used to copy the variable ptr to a
47 #define lttng_ust_rcu_dereference _lttng_ust_rcu_dereference
50 * type *lttng_ust_rcu_cmpxchg_pointer(type **ptr, type *new, type *old)
51 * type *lttng_ust_rcu_xchg_pointer(type **ptr, type *new)
52 * void lttng_ust_rcu_set_pointer(type **ptr, type *new)
54 * RCU pointer updates.
55 * @ptr: address of the pointer to modify
56 * @new: new pointer value
57 * @old: old pointer value (expected)
59 * return: old pointer value
61 #define lttng_ust_rcu_cmpxchg_pointer _lttng_ust_rcu_cmpxchg_pointer
62 #define lttng_ust_rcu_xchg_pointer _lttng_ust_rcu_xchg_pointer
63 #define lttng_ust_rcu_set_pointer _lttng_ust_rcu_set_pointer
65 #else /* !(defined(_LGPL_SOURCE) || defined(LTTNG_UST_URCU_INLINE_SMALL_FUNCTIONS)) */
67 extern void *lttng_ust_rcu_dereference_sym(void *p
);
68 #define lttng_ust_rcu_dereference(p) \
71 __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \
72 lttng_ust_rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \
76 extern void *lttng_ust_rcu_cmpxchg_pointer_sym(void **p
, void *old
, void *_new
);
77 #define lttng_ust_rcu_cmpxchg_pointer(p, old, _new) \
80 __typeof__(*(p)) _________pold = (old); \
81 __typeof__(*(p)) _________pnew = (_new); \
82 __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
83 lttng_ust_rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
89 extern void *lttng_ust_rcu_xchg_pointer_sym(void **p
, void *v
);
90 #define lttng_ust_rcu_xchg_pointer(p, v) \
93 __typeof__(*(p)) _________pv = (v); \
94 __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \
95 lttng_ust_rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \
101 * Note: lttng_ust_rcu_set_pointer_sym returns @v because we don't want to break
102 * the ABI. At the API level, lttng_ust_rcu_set_pointer() now returns void. Use of
103 * the return value is therefore deprecated, and will cause a build
106 extern void *lttng_ust_rcu_set_pointer_sym(void **p
, void *v
);
107 #define lttng_ust_rcu_set_pointer(p, v) \
109 __typeof__(*(p)) _________pv = (v); \
110 (void) lttng_ust_rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \
114 #endif /* !(defined(_LGPL_SOURCE) || defined(LTTNG_UST_URCU_INLINE_SMALL_FUNCTIONS)) */
117 * void lttng_ust_rcu_assign_pointer(type *ptr, type *new)
119 * Same as lttng_ust_rcu_set_pointer, but takes the pointer to assign to rather than its
120 * address as first parameter. Provided for compatibility with the Linux kernel
123 #define lttng_ust_rcu_assign_pointer(p, v) lttng_ust_rcu_set_pointer((&p), (v))
129 #endif /* _LTTNG_UST_URCU_POINTER_H */
This page took 0.03157 seconds and 3 git commands to generate.