Build system: use SPDX identifiers
[urcu.git] / include / urcu / urcu-qsbr.h
CommitLineData
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>
111bda8f 33#include <stdbool.h>
420e5b92 34
375db287
MJ
35#include <urcu/config.h>
36
7e30abe3 37/*
6cd23d47 38 * See urcu/pointer.h and urcu/static/pointer.h for pointer
af7c2dbe 39 * publication headers.
7e30abe3 40 */
6cd23d47 41#include <urcu/pointer.h>
111bda8f 42#include <urcu/urcu-poll.h>
7e30abe3 43
36bc70a8
MD
44#ifdef __cplusplus
45extern "C" {
67ecffc0 46#endif
36bc70a8 47
ee6fabe1 48#include <urcu/map/urcu-qsbr.h>
5e77fc1f 49
14740b19
MD
50#ifdef RCU_DEBUG /* For backward compatibility */
51#define DEBUG_RCU
52#endif
53
420e5b92 54/*
7ac06cef 55 * Important !
420e5b92 56 *
7ac06cef
MD
57 * Each thread containing read-side critical sections must be registered
58 * with rcu_register_thread() before calling rcu_read_lock().
59 * rcu_unregister_thread() should be called before the thread exits.
420e5b92
MD
60 */
61
7ac06cef 62#ifdef _LGPL_SOURCE
420e5b92 63
af7c2dbe 64#include <urcu/static/urcu-qsbr.h>
420e5b92
MD
65
66/*
7ac06cef
MD
67 * Mappings for static use of the userspace RCU library.
68 * Should only be used in LGPL-compatible code.
420e5b92 69 */
420e5b92 70
7e30abe3
MD
71/*
72 * rcu_read_lock()
73 * rcu_read_unlock()
74 *
75 * Mark the beginning and end of a read-side critical section.
5e77fc1f
PM
76 * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread()
77 * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION.
7e30abe3 78 */
4477a870
MD
79#define urcu_qsbr_read_lock _urcu_qsbr_read_lock
80#define urcu_qsbr_read_unlock _urcu_qsbr_read_unlock
81#define urcu_qsbr_read_ongoing _urcu_qsbr_read_ongoing
420e5b92 82
4477a870
MD
83#define urcu_qsbr_quiescent_state _urcu_qsbr_quiescent_state
84#define urcu_qsbr_thread_offline _urcu_qsbr_thread_offline
85#define urcu_qsbr_thread_online _urcu_qsbr_thread_online
420e5b92 86
7ac06cef 87#else /* !_LGPL_SOURCE */
420e5b92 88
420e5b92 89/*
7ac06cef 90 * library wrappers to be used by non-LGPL compatible source code.
420e5b92 91 */
420e5b92 92
727f819d
MD
93/*
94 * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them
95 * in the LGPL header for any code to use. However, the debug version is not
96 * nops and may contain sanity checks. To activate it, applications must be
d4e640c0
JR
97 * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications), or
98 * compiled against a urcu/config.h that has CONFIG_RCU_DEBUG defined.
99 * This is the best trade-off between license/performance/code
100 * triviality and library debugging & tracing features we could come up
101 * with.
727f819d
MD
102 */
103
d4e640c0 104#if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG))
727f819d 105
4477a870 106static inline void urcu_qsbr_read_lock(void)
727f819d
MD
107{
108}
109
4477a870 110static inline void urcu_qsbr_read_unlock(void)
727f819d
MD
111{
112}
113
d4e640c0 114#else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
727f819d 115
4477a870
MD
116extern void urcu_qsbr_read_lock(void);
117extern void urcu_qsbr_read_unlock(void);
420e5b92 118
d4e640c0 119#endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
727f819d 120
4477a870
MD
121extern int urcu_qsbr_read_ongoing(void);
122extern void urcu_qsbr_quiescent_state(void);
123extern void urcu_qsbr_thread_offline(void);
124extern void urcu_qsbr_thread_online(void);
420e5b92 125
7ac06cef 126#endif /* !_LGPL_SOURCE */
420e5b92 127
4477a870 128extern void urcu_qsbr_synchronize_rcu(void);
420e5b92 129
111bda8f
MD
130/*
131 * RCU grace period polling API.
132 */
133extern struct urcu_gp_poll_state urcu_qsbr_start_poll_synchronize_rcu(void);
134extern bool urcu_qsbr_poll_state_synchronize_rcu(struct urcu_gp_poll_state state);
135
420e5b92
MD
136/*
137 * Reader thread registration.
138 */
4477a870
MD
139extern void urcu_qsbr_register_thread(void);
140extern void urcu_qsbr_unregister_thread(void);
420e5b92 141
67ecffc0 142#ifdef __cplusplus
36bc70a8
MD
143}
144#endif
145
6cd23d47
MD
146#include <urcu/call-rcu.h>
147#include <urcu/defer.h>
148#include <urcu/flavor.h>
5e77fc1f 149
4477a870
MD
150#ifndef URCU_API_MAP
151#include <urcu/map/clear.h>
152#endif
153
420e5b92 154#endif /* _URCU_QSBR_H */
This page took 0.056594 seconds and 4 git commands to generate.