Commit | Line | Data |
---|---|---|
420e5b92 MD |
1 | #ifndef _URCU_QSBR_H |
2 | #define _URCU_QSBR_H | |
3 | ||
4 | /* | |
7ac06cef | 5 | * urcu-qsbr.h |
420e5b92 | 6 | * |
7ac06cef | 7 | * Userspace RCU QSBR header. |
420e5b92 | 8 | * |
7ac06cef | 9 | * LGPL-compatible code should include this header with : |
420e5b92 | 10 | * |
7ac06cef MD |
11 | * #define _LGPL_SOURCE |
12 | * #include <urcu.h> | |
420e5b92 MD |
13 | * |
14 | * This library is free software; you can redistribute it and/or | |
15 | * modify it under the terms of the GNU Lesser General Public | |
16 | * License as published by the Free Software Foundation; either | |
17 | * version 2.1 of the License, or (at your option) any later version. | |
18 | * | |
19 | * This library is distributed in the hope that it will be useful, | |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
22 | * Lesser General Public License for more details. | |
23 | * | |
24 | * You should have received a copy of the GNU Lesser General Public | |
25 | * License along with this library; if not, write to the Free Software | |
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
27 | * | |
28 | * IBM's contributions to this file may be relicensed under LGPLv2 or later. | |
29 | */ | |
30 | ||
31 | #include <stdlib.h> | |
32 | #include <pthread.h> | |
420e5b92 | 33 | |
375db287 MJ |
34 | #include <urcu/config.h> |
35 | ||
7e30abe3 | 36 | /* |
6cd23d47 | 37 | * See urcu/pointer.h and urcu/static/pointer.h for pointer |
af7c2dbe | 38 | * publication headers. |
7e30abe3 | 39 | */ |
6cd23d47 | 40 | #include <urcu/pointer.h> |
7e30abe3 | 41 | |
36bc70a8 MD |
42 | #ifdef __cplusplus |
43 | extern "C" { | |
67ecffc0 | 44 | #endif |
36bc70a8 | 45 | |
ee6fabe1 | 46 | #include <urcu/map/urcu-qsbr.h> |
5e77fc1f | 47 | |
14740b19 MD |
48 | #ifdef RCU_DEBUG /* For backward compatibility */ |
49 | #define DEBUG_RCU | |
50 | #endif | |
51 | ||
420e5b92 | 52 | /* |
7ac06cef | 53 | * Important ! |
420e5b92 | 54 | * |
7ac06cef MD |
55 | * Each thread containing read-side critical sections must be registered |
56 | * with rcu_register_thread() before calling rcu_read_lock(). | |
57 | * rcu_unregister_thread() should be called before the thread exits. | |
420e5b92 MD |
58 | */ |
59 | ||
7ac06cef | 60 | #ifdef _LGPL_SOURCE |
420e5b92 | 61 | |
af7c2dbe | 62 | #include <urcu/static/urcu-qsbr.h> |
420e5b92 MD |
63 | |
64 | /* | |
7ac06cef MD |
65 | * Mappings for static use of the userspace RCU library. |
66 | * Should only be used in LGPL-compatible code. | |
420e5b92 | 67 | */ |
420e5b92 | 68 | |
7e30abe3 MD |
69 | /* |
70 | * rcu_read_lock() | |
71 | * rcu_read_unlock() | |
72 | * | |
73 | * Mark the beginning and end of a read-side critical section. | |
5e77fc1f PM |
74 | * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread() |
75 | * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION. | |
7e30abe3 | 76 | */ |
4477a870 MD |
77 | #define urcu_qsbr_read_lock _urcu_qsbr_read_lock |
78 | #define urcu_qsbr_read_unlock _urcu_qsbr_read_unlock | |
79 | #define urcu_qsbr_read_ongoing _urcu_qsbr_read_ongoing | |
420e5b92 | 80 | |
4477a870 MD |
81 | #define urcu_qsbr_quiescent_state _urcu_qsbr_quiescent_state |
82 | #define urcu_qsbr_thread_offline _urcu_qsbr_thread_offline | |
83 | #define urcu_qsbr_thread_online _urcu_qsbr_thread_online | |
420e5b92 | 84 | |
7ac06cef | 85 | #else /* !_LGPL_SOURCE */ |
420e5b92 | 86 | |
420e5b92 | 87 | /* |
7ac06cef | 88 | * library wrappers to be used by non-LGPL compatible source code. |
420e5b92 | 89 | */ |
420e5b92 | 90 | |
727f819d MD |
91 | /* |
92 | * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them | |
93 | * in the LGPL header for any code to use. However, the debug version is not | |
94 | * nops and may contain sanity checks. To activate it, applications must be | |
d4e640c0 JR |
95 | * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications), or |
96 | * compiled against a urcu/config.h that has CONFIG_RCU_DEBUG defined. | |
97 | * This is the best trade-off between license/performance/code | |
98 | * triviality and library debugging & tracing features we could come up | |
99 | * with. | |
727f819d MD |
100 | */ |
101 | ||
d4e640c0 | 102 | #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) |
727f819d | 103 | |
4477a870 | 104 | static inline void urcu_qsbr_read_lock(void) |
727f819d MD |
105 | { |
106 | } | |
107 | ||
4477a870 | 108 | static inline void urcu_qsbr_read_unlock(void) |
727f819d MD |
109 | { |
110 | } | |
111 | ||
d4e640c0 | 112 | #else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ |
727f819d | 113 | |
4477a870 MD |
114 | extern void urcu_qsbr_read_lock(void); |
115 | extern void urcu_qsbr_read_unlock(void); | |
420e5b92 | 116 | |
d4e640c0 | 117 | #endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ |
727f819d | 118 | |
4477a870 MD |
119 | extern int urcu_qsbr_read_ongoing(void); |
120 | extern void urcu_qsbr_quiescent_state(void); | |
121 | extern void urcu_qsbr_thread_offline(void); | |
122 | extern void urcu_qsbr_thread_online(void); | |
420e5b92 | 123 | |
7ac06cef | 124 | #endif /* !_LGPL_SOURCE */ |
420e5b92 | 125 | |
4477a870 | 126 | extern void urcu_qsbr_synchronize_rcu(void); |
420e5b92 MD |
127 | |
128 | /* | |
129 | * Reader thread registration. | |
130 | */ | |
4477a870 MD |
131 | extern void urcu_qsbr_register_thread(void); |
132 | extern void urcu_qsbr_unregister_thread(void); | |
420e5b92 | 133 | |
67ecffc0 | 134 | #ifdef __cplusplus |
36bc70a8 MD |
135 | } |
136 | #endif | |
137 | ||
6cd23d47 MD |
138 | #include <urcu/call-rcu.h> |
139 | #include <urcu/defer.h> | |
140 | #include <urcu/flavor.h> | |
5e77fc1f | 141 | |
4477a870 MD |
142 | #ifndef URCU_API_MAP |
143 | #include <urcu/map/clear.h> | |
144 | #endif | |
145 | ||
420e5b92 | 146 | #endif /* _URCU_QSBR_H */ |