1 #ifndef _URCU_POINTER_H
2 #define _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_arch.h>
39 #include <urcu-pointer-static.h>
42 * rcu_dereference(ptr)
44 * Fetch a RCU-protected pointer. Typically used to copy the variable ptr to a
47 #define rcu_dereference _rcu_dereference
50 * rcu_cmpxchg_pointer(type **ptr, type *new, type *old)
51 * type *rcu_xchg_pointer(type **ptr, type *new)
52 * type *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 rcu_cmpxchg_pointer _rcu_cmpxchg_pointer
62 #define rcu_xchg_pointer _rcu_xchg_pointer
63 #define rcu_set_pointer _rcu_set_pointer
65 #else /* !_LGPL_SOURCE */
67 extern void *rcu_dereference_sym(void *p
);
68 #define rcu_dereference(p) \
70 typeof(p) _________p1 = \
71 rcu_dereference_sym((void *)(p)); \
75 extern void *rcu_cmpxchg_pointer_sym(void **p
, void *old
, void *_new
);
76 #define rcu_cmpxchg_pointer(p, old, _new) \
78 typeof(*p) _________pold = (old); \
79 typeof(*p) _________pnew = (_new); \
80 typeof(*p) _________p1 = \
81 rcu_cmpxchg_pointer_sym((void **)(p), _________pold, \
86 extern void *rcu_xchg_pointer_sym(void **p
, void *v
);
87 #define rcu_xchg_pointer(p, v) \
89 typeof(*p) _________pv = (v); \
90 typeof(*p) _________p1 = \
91 rcu_xchg_pointer_sym((void **)(p), _________pv); \
95 extern void *rcu_set_pointer_sym(void **p
, void *v
);
96 #define rcu_set_pointer(p, v) \
98 typeof(*p) _________pv = (v); \
99 typeof(*p) _________p1 = \
100 rcu_set_pointer_sym((void **)(p), _________pv); \
103 #endif /* !_LGPL_SOURCE */
106 * rcu_assign_pointer(type *ptr, type *new)
108 * Same as rcu_set_pointer, but takes the pointer to assign to rather than its
109 * address as first parameter. Provided for compatibility with the Linux kernel
112 #define rcu_assign_pointer(p, v) rcu_set_pointer((&p), (v))
118 #endif /* _URCU_POINTER_H */
This page took 0.031164 seconds and 4 git commands to generate.