Add support for custom memory allocators for rculfhash
[urcu.git] / include / urcu / urcu-qsbr.h
1 // SPDX-FileCopyrightText: 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 // SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation.
3 //
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5
6 #ifndef _URCU_QSBR_H
7 #define _URCU_QSBR_H
8
9 /*
10 * Userspace RCU QSBR header.
11 *
12 * LGPL-compatible code should include this header with :
13 *
14 * #define _LGPL_SOURCE
15 * #include <urcu.h>
16 *
17 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
18 */
19
20 #include <stdlib.h>
21 #include <pthread.h>
22 #include <stdbool.h>
23
24 #include <urcu/config.h>
25
26 /*
27 * See urcu/pointer.h and urcu/static/pointer.h for pointer
28 * publication headers.
29 */
30 #include <urcu/pointer.h>
31 #include <urcu/urcu-poll.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <urcu/map/urcu-qsbr.h>
38
39 #ifdef RCU_DEBUG /* For backward compatibility */
40 #define DEBUG_RCU
41 #endif
42
43 /*
44 * Important !
45 *
46 * Each thread containing read-side critical sections must be registered
47 * with rcu_register_thread() before calling rcu_read_lock().
48 * rcu_unregister_thread() should be called before the thread exits.
49 */
50
51 #ifdef _LGPL_SOURCE
52
53 #include <urcu/static/urcu-qsbr.h>
54
55 /*
56 * Mappings for static use of the userspace RCU library.
57 * Should only be used in LGPL-compatible code.
58 */
59
60 /*
61 * rcu_read_lock()
62 * rcu_read_unlock()
63 *
64 * Mark the beginning and end of a read-side critical section.
65 * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread()
66 * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION.
67 */
68 #define urcu_qsbr_read_lock _urcu_qsbr_read_lock
69 #define urcu_qsbr_read_unlock _urcu_qsbr_read_unlock
70 #define urcu_qsbr_read_ongoing _urcu_qsbr_read_ongoing
71
72 #define urcu_qsbr_quiescent_state _urcu_qsbr_quiescent_state
73 #define urcu_qsbr_thread_offline _urcu_qsbr_thread_offline
74 #define urcu_qsbr_thread_online _urcu_qsbr_thread_online
75
76 #else /* !_LGPL_SOURCE */
77
78 /*
79 * library wrappers to be used by non-LGPL compatible source code.
80 */
81
82 /*
83 * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them
84 * in the LGPL header for any code to use. However, the debug version is not
85 * nops and may contain sanity checks. To activate it, applications must be
86 * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications), or
87 * compiled against a urcu/config.h that has CONFIG_RCU_DEBUG defined.
88 * This is the best trade-off between license/performance/code
89 * triviality and library debugging & tracing features we could come up
90 * with.
91 */
92
93 #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG))
94
95 static inline void urcu_qsbr_read_lock(void)
96 {
97 }
98
99 static inline void urcu_qsbr_read_unlock(void)
100 {
101 }
102
103 #else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
104
105 extern void urcu_qsbr_read_lock(void);
106 extern void urcu_qsbr_read_unlock(void);
107
108 #endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
109
110 extern int urcu_qsbr_read_ongoing(void);
111 extern void urcu_qsbr_quiescent_state(void);
112 extern void urcu_qsbr_thread_offline(void);
113 extern void urcu_qsbr_thread_online(void);
114
115 #endif /* !_LGPL_SOURCE */
116
117 extern void urcu_qsbr_synchronize_rcu(void);
118
119 /*
120 * RCU grace period polling API.
121 */
122 extern struct urcu_gp_poll_state urcu_qsbr_start_poll_synchronize_rcu(void);
123 extern bool urcu_qsbr_poll_state_synchronize_rcu(struct urcu_gp_poll_state state);
124
125 /*
126 * Reader thread registration.
127 */
128 extern void urcu_qsbr_register_thread(void);
129 extern void urcu_qsbr_unregister_thread(void);
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #include <urcu/call-rcu.h>
136 #include <urcu/defer.h>
137 #include <urcu/flavor.h>
138
139 #ifndef URCU_API_MAP
140 #include <urcu/map/clear.h>
141 #endif
142
143 #endif /* _URCU_QSBR_H */
This page took 0.035383 seconds and 4 git commands to generate.