Commit | Line | Data |
---|---|---|
5e77fc1f PM |
1 | #ifndef _URCU_MAP_H |
2 | #define _URCU_MAP_H | |
3 | ||
4 | /* | |
5 | * urcu-map.h | |
6 | * | |
7 | * Userspace RCU header -- name mapping to allow multiple flavors to be | |
8 | * used in the same executable. | |
9 | * | |
10 | * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
11 | * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. | |
12 | * | |
13 | * LGPL-compatible code should include this header with : | |
14 | * | |
15 | * #define _LGPL_SOURCE | |
16 | * #include <urcu.h> | |
17 | * | |
18 | * This library is free software; you can redistribute it and/or | |
19 | * modify it under the terms of the GNU Lesser General Public | |
20 | * License as published by the Free Software Foundation; either | |
21 | * version 2.1 of the License, or (at your option) any later version. | |
22 | * | |
23 | * This library is distributed in the hope that it will be useful, | |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 | * Lesser General Public License for more details. | |
27 | * | |
28 | * You should have received a copy of the GNU Lesser General Public | |
29 | * License along with this library; if not, write to the Free Software | |
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
31 | * | |
32 | * IBM's contributions to this file may be relicensed under LGPLv2 or later. | |
33 | */ | |
34 | ||
35 | /* Mapping macros to allow multiple flavors in a single binary. */ | |
36 | ||
0376e7b2 | 37 | #if !defined(RCU_MEMBARRIER) && !defined(RCU_SIGNAL) && !defined(RCU_MB) |
052fdaee | 38 | #define RCU_MEMBARRIER |
0376e7b2 PM |
39 | #endif |
40 | ||
4a0b347a MD |
41 | /* |
42 | * RCU_MEMBARRIER is only possibly available on Linux. Fallback to | |
43 | * RCU_MB | |
44 | * otherwise. | |
45 | */ | |
46 | #if !defined(__linux__) && defined(RCU_MEMBARRIER) | |
47 | #undef RCU_MEMBARRIER | |
48 | #define RCU_MB | |
49 | #endif | |
50 | ||
51 | #ifdef RCU_MEMBARRIER | |
52 | #include <syscall.h> | |
53 | ||
54 | /* If the headers do not support SYS_membarrier, statically use RCU_MB */ | |
55 | #ifdef SYS_membarrier | |
56 | # define MEMBARRIER_EXPEDITED (1 << 0) | |
57 | # define MEMBARRIER_DELAYED (1 << 1) | |
58 | # define MEMBARRIER_QUERY (1 << 16) | |
59 | # define membarrier(...) syscall(SYS_membarrier, __VA_ARGS__) | |
60 | #else | |
61 | # undef RCU_MEMBARRIER | |
62 | # define RCU_MB | |
63 | #endif | |
64 | #endif | |
65 | ||
5e77fc1f PM |
66 | #ifdef RCU_MEMBARRIER |
67 | ||
68 | #define rcu_read_lock rcu_read_lock_memb | |
69 | #define _rcu_read_lock _rcu_read_lock_memb | |
70 | #define rcu_read_unlock rcu_read_unlock_memb | |
71 | #define _rcu_read_unlock _rcu_read_unlock_memb | |
72 | #define rcu_register_thread rcu_register_thread_memb | |
73 | #define rcu_unregister_thread rcu_unregister_thread_memb | |
74 | #define rcu_init rcu_init_memb | |
75 | #define rcu_exit rcu_exit_memb | |
76 | #define synchronize_rcu synchronize_rcu_memb | |
77 | #define rcu_reader rcu_reader_memb | |
78 | #define rcu_gp_ctr rcu_gp_ctr_memb | |
1de4df4b | 79 | #define rcu_gp_futex rcu_gp_futex_memb |
5e77fc1f PM |
80 | |
81 | #define get_cpu_call_rcu_data get_cpu_call_rcu_data_memb | |
82 | #define get_call_rcu_thread get_call_rcu_thread_memb | |
83 | #define create_call_rcu_data create_call_rcu_data_memb | |
84 | #define set_cpu_call_rcu_data set_cpu_call_rcu_data_memb | |
85 | #define get_default_call_rcu_data get_default_call_rcu_data_memb | |
86 | #define get_call_rcu_data get_call_rcu_data_memb | |
87 | #define get_thread_call_rcu_data get_thread_call_rcu_data_memb | |
88 | #define set_thread_call_rcu_data set_thread_call_rcu_data_memb | |
89 | #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_memb | |
90 | #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_memb | |
91 | #define call_rcu call_rcu_memb | |
1de4df4b MD |
92 | #define call_rcu_data_free call_rcu_data_free_memb |
93 | #define call_rcu_before_fork call_rcu_before_fork_memb | |
94 | #define call_rcu_after_fork_parent call_rcu_after_fork_parent_memb | |
95 | #define call_rcu_after_fork_child call_rcu_after_fork_child_memb | |
5e77fc1f | 96 | |
0376e7b2 PM |
97 | #define defer_rcu defer_rcu_memb |
98 | #define rcu_defer_register_thread rcu_defer_register_thread_memb | |
99 | #define rcu_defer_unregister_thread rcu_defer_unregister_thread_memb | |
100 | #define rcu_defer_barrier rcu_defer_barrier_memb | |
101 | #define rcu_defer_barrier_thread rcu_defer_barrier_thread_memb | |
1de4df4b | 102 | #define rcu_defer_exit rcu_defer_exit_memb |
0376e7b2 | 103 | |
541d828d LJ |
104 | #define rcu_flavor rcu_flavor_memb |
105 | ||
1de4df4b MD |
106 | #define rcu_yield_active rcu_yield_active_memb |
107 | #define rcu_rand_yield rcu_rand_yield_memb | |
108 | ||
109 | /* Specific to MEMBARRIER flavor */ | |
110 | #define rcu_has_sys_membarrier rcu_has_sys_membarrier_memb | |
111 | ||
5e77fc1f PM |
112 | #elif defined(RCU_SIGNAL) |
113 | ||
114 | #define rcu_read_lock rcu_read_lock_sig | |
115 | #define _rcu_read_lock _rcu_read_lock_sig | |
116 | #define rcu_read_unlock rcu_read_unlock_sig | |
117 | #define _rcu_read_unlock _rcu_read_unlock_sig | |
118 | #define rcu_register_thread rcu_register_thread_sig | |
119 | #define rcu_unregister_thread rcu_unregister_thread_sig | |
120 | #define rcu_init rcu_init_sig | |
121 | #define rcu_exit rcu_exit_sig | |
122 | #define synchronize_rcu synchronize_rcu_sig | |
123 | #define rcu_reader rcu_reader_sig | |
124 | #define rcu_gp_ctr rcu_gp_ctr_sig | |
1de4df4b | 125 | #define rcu_gp_futex rcu_gp_futex_sig |
5e77fc1f PM |
126 | |
127 | #define get_cpu_call_rcu_data get_cpu_call_rcu_data_sig | |
128 | #define get_call_rcu_thread get_call_rcu_thread_sig | |
129 | #define create_call_rcu_data create_call_rcu_data_sig | |
130 | #define set_cpu_call_rcu_data set_cpu_call_rcu_data_sig | |
131 | #define get_default_call_rcu_data get_default_call_rcu_data_sig | |
132 | #define get_call_rcu_data get_call_rcu_data_sig | |
133 | #define get_thread_call_rcu_data get_thread_call_rcu_data_sig | |
134 | #define set_thread_call_rcu_data set_thread_call_rcu_data_sig | |
135 | #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_sig | |
136 | #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_sig | |
137 | #define call_rcu call_rcu_sig | |
1de4df4b MD |
138 | #define call_rcu_data_free call_rcu_data_free_sig |
139 | #define call_rcu_before_fork call_rcu_before_fork_sig | |
140 | #define call_rcu_after_fork_parent call_rcu_after_fork_parent_sig | |
141 | #define call_rcu_after_fork_child call_rcu_after_fork_child_sig | |
5e77fc1f | 142 | |
0376e7b2 PM |
143 | #define defer_rcu defer_rcu_sig |
144 | #define rcu_defer_register_thread rcu_defer_register_thread_sig | |
145 | #define rcu_defer_unregister_thread rcu_defer_unregister_thread_sig | |
146 | #define rcu_defer_barrier rcu_defer_barrier_sig | |
147 | #define rcu_defer_barrier_thread rcu_defer_barrier_thread_sig | |
1de4df4b | 148 | #define rcu_defer_exit rcu_defer_exit_sig |
0376e7b2 | 149 | |
541d828d LJ |
150 | #define rcu_flavor rcu_flavor_sig |
151 | ||
1de4df4b MD |
152 | #define rcu_yield_active rcu_yield_active_sig |
153 | #define rcu_rand_yield rcu_rand_yield_sig | |
154 | ||
5e77fc1f PM |
155 | #elif defined(RCU_MB) |
156 | ||
157 | #define rcu_read_lock rcu_read_lock_mb | |
158 | #define _rcu_read_lock _rcu_read_lock_mb | |
159 | #define rcu_read_unlock rcu_read_unlock_mb | |
160 | #define _rcu_read_unlock _rcu_read_unlock_mb | |
161 | #define rcu_register_thread rcu_register_thread_mb | |
162 | #define rcu_unregister_thread rcu_unregister_thread_mb | |
163 | #define rcu_init rcu_init_mb | |
164 | #define rcu_exit rcu_exit_mb | |
165 | #define synchronize_rcu synchronize_rcu_mb | |
166 | #define rcu_reader rcu_reader_mb | |
167 | #define rcu_gp_ctr rcu_gp_ctr_mb | |
1de4df4b | 168 | #define rcu_gp_futex rcu_gp_futex_mb |
5e77fc1f PM |
169 | |
170 | #define get_cpu_call_rcu_data get_cpu_call_rcu_data_mb | |
171 | #define get_call_rcu_thread get_call_rcu_thread_mb | |
172 | #define create_call_rcu_data create_call_rcu_data_mb | |
173 | #define set_cpu_call_rcu_data set_cpu_call_rcu_data_mb | |
174 | #define get_default_call_rcu_data get_default_call_rcu_data_mb | |
175 | #define get_call_rcu_data get_call_rcu_data_mb | |
176 | #define get_thread_call_rcu_data get_thread_call_rcu_data_mb | |
177 | #define set_thread_call_rcu_data set_thread_call_rcu_data_mb | |
178 | #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_mb | |
179 | #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_mb | |
180 | #define call_rcu call_rcu_mb | |
1de4df4b MD |
181 | #define call_rcu_data_free call_rcu_data_free_mb |
182 | #define call_rcu_before_fork call_rcu_before_fork_mb | |
183 | #define call_rcu_after_fork_parent call_rcu_after_fork_parent_mb | |
184 | #define call_rcu_after_fork_child call_rcu_after_fork_child_mb | |
5e77fc1f | 185 | |
0376e7b2 PM |
186 | #define defer_rcu defer_rcu_mb |
187 | #define rcu_defer_register_thread rcu_defer_register_thread_mb | |
188 | #define rcu_defer_unregister_thread rcu_defer_unregister_thread_mb | |
189 | #define rcu_defer_barrier rcu_defer_barrier_mb | |
190 | #define rcu_defer_barrier_thread rcu_defer_barrier_thread_mb | |
1de4df4b | 191 | #define rcu_defer_exit rcu_defer_exit_mb |
0376e7b2 | 192 | |
541d828d LJ |
193 | #define rcu_flavor rcu_flavor_mb |
194 | ||
1de4df4b MD |
195 | #define rcu_yield_active rcu_yield_active_mb |
196 | #define rcu_rand_yield rcu_rand_yield_mb | |
197 | ||
0376e7b2 PM |
198 | #else |
199 | ||
200 | #error "Undefined selection" | |
201 | ||
5e77fc1f PM |
202 | #endif |
203 | ||
204 | #endif /* _URCU_MAP_H */ |