3f436a7375120366bca0898aafd3debdc45a48a5
[urcu.git] / urcu / map / urcu.h
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
37 #if !defined(RCU_MEMBARRIER) && !defined(RCU_SIGNAL) && !defined(RCU_MB)
38 #define RCU_MEMBARRIER
39 #endif
40
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
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
79
80 #define get_cpu_call_rcu_data get_cpu_call_rcu_data_memb
81 #define get_call_rcu_thread get_call_rcu_thread_memb
82 #define create_call_rcu_data create_call_rcu_data_memb
83 #define set_cpu_call_rcu_data set_cpu_call_rcu_data_memb
84 #define get_default_call_rcu_data get_default_call_rcu_data_memb
85 #define get_call_rcu_data get_call_rcu_data_memb
86 #define get_thread_call_rcu_data get_thread_call_rcu_data_memb
87 #define set_thread_call_rcu_data set_thread_call_rcu_data_memb
88 #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_memb
89 #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_memb
90 #define call_rcu call_rcu_memb
91
92 #define defer_rcu defer_rcu_memb
93 #define rcu_defer_register_thread rcu_defer_register_thread_memb
94 #define rcu_defer_unregister_thread rcu_defer_unregister_thread_memb
95 #define rcu_defer_barrier rcu_defer_barrier_memb
96 #define rcu_defer_barrier_thread rcu_defer_barrier_thread_memb
97
98 #elif defined(RCU_SIGNAL)
99
100 #define rcu_read_lock rcu_read_lock_sig
101 #define _rcu_read_lock _rcu_read_lock_sig
102 #define rcu_read_unlock rcu_read_unlock_sig
103 #define _rcu_read_unlock _rcu_read_unlock_sig
104 #define rcu_register_thread rcu_register_thread_sig
105 #define rcu_unregister_thread rcu_unregister_thread_sig
106 #define rcu_init rcu_init_sig
107 #define rcu_exit rcu_exit_sig
108 #define synchronize_rcu synchronize_rcu_sig
109 #define rcu_reader rcu_reader_sig
110 #define rcu_gp_ctr rcu_gp_ctr_sig
111
112 #define get_cpu_call_rcu_data get_cpu_call_rcu_data_sig
113 #define get_call_rcu_thread get_call_rcu_thread_sig
114 #define create_call_rcu_data create_call_rcu_data_sig
115 #define set_cpu_call_rcu_data set_cpu_call_rcu_data_sig
116 #define get_default_call_rcu_data get_default_call_rcu_data_sig
117 #define get_call_rcu_data get_call_rcu_data_sig
118 #define get_thread_call_rcu_data get_thread_call_rcu_data_sig
119 #define set_thread_call_rcu_data set_thread_call_rcu_data_sig
120 #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_sig
121 #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_sig
122 #define call_rcu call_rcu_sig
123
124 #define defer_rcu defer_rcu_sig
125 #define rcu_defer_register_thread rcu_defer_register_thread_sig
126 #define rcu_defer_unregister_thread rcu_defer_unregister_thread_sig
127 #define rcu_defer_barrier rcu_defer_barrier_sig
128 #define rcu_defer_barrier_thread rcu_defer_barrier_thread_sig
129
130 #elif defined(RCU_MB)
131
132 #define rcu_read_lock rcu_read_lock_mb
133 #define _rcu_read_lock _rcu_read_lock_mb
134 #define rcu_read_unlock rcu_read_unlock_mb
135 #define _rcu_read_unlock _rcu_read_unlock_mb
136 #define rcu_register_thread rcu_register_thread_mb
137 #define rcu_unregister_thread rcu_unregister_thread_mb
138 #define rcu_init rcu_init_mb
139 #define rcu_exit rcu_exit_mb
140 #define synchronize_rcu synchronize_rcu_mb
141 #define rcu_reader rcu_reader_mb
142 #define rcu_gp_ctr rcu_gp_ctr_mb
143
144 #define get_cpu_call_rcu_data get_cpu_call_rcu_data_mb
145 #define get_call_rcu_thread get_call_rcu_thread_mb
146 #define create_call_rcu_data create_call_rcu_data_mb
147 #define set_cpu_call_rcu_data set_cpu_call_rcu_data_mb
148 #define get_default_call_rcu_data get_default_call_rcu_data_mb
149 #define get_call_rcu_data get_call_rcu_data_mb
150 #define get_thread_call_rcu_data get_thread_call_rcu_data_mb
151 #define set_thread_call_rcu_data set_thread_call_rcu_data_mb
152 #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_mb
153 #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_mb
154 #define call_rcu call_rcu_mb
155
156 #define defer_rcu defer_rcu_mb
157 #define rcu_defer_register_thread rcu_defer_register_thread_mb
158 #define rcu_defer_unregister_thread rcu_defer_unregister_thread_mb
159 #define rcu_defer_barrier rcu_defer_barrier_mb
160 #define rcu_defer_barrier_thread rcu_defer_barrier_thread_mb
161
162 #else
163
164 #error "Undefined selection"
165
166 #endif
167
168 #endif /* _URCU_MAP_H */
This page took 0.036633 seconds and 3 git commands to generate.