uatomic/x86: Remove redundant memory barriers
[urcu.git] / include / urcu / urcu-qsbr.h
CommitLineData
d3d3857f
MJ
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
420e5b92
MD
6#ifndef _URCU_QSBR_H
7#define _URCU_QSBR_H
8
9/*
7ac06cef 10 * Userspace RCU QSBR header.
420e5b92 11 *
7ac06cef 12 * LGPL-compatible code should include this header with :
420e5b92 13 *
7ac06cef
MD
14 * #define _LGPL_SOURCE
15 * #include <urcu.h>
420e5b92 16 *
420e5b92
MD
17 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
18 */
19
20#include <stdlib.h>
21#include <pthread.h>
111bda8f 22#include <stdbool.h>
420e5b92 23
375db287
MJ
24#include <urcu/config.h>
25
7e30abe3 26/*
6cd23d47 27 * See urcu/pointer.h and urcu/static/pointer.h for pointer
af7c2dbe 28 * publication headers.
7e30abe3 29 */
6cd23d47 30#include <urcu/pointer.h>
111bda8f 31#include <urcu/urcu-poll.h>
7e30abe3 32
36bc70a8
MD
33#ifdef __cplusplus
34extern "C" {
67ecffc0 35#endif
36bc70a8 36
ee6fabe1 37#include <urcu/map/urcu-qsbr.h>
5e77fc1f 38
14740b19
MD
39#ifdef RCU_DEBUG /* For backward compatibility */
40#define DEBUG_RCU
41#endif
42
420e5b92 43/*
7ac06cef 44 * Important !
420e5b92 45 *
7ac06cef
MD
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.
420e5b92
MD
49 */
50
7ac06cef 51#ifdef _LGPL_SOURCE
420e5b92 52
af7c2dbe 53#include <urcu/static/urcu-qsbr.h>
420e5b92
MD
54
55/*
7ac06cef
MD
56 * Mappings for static use of the userspace RCU library.
57 * Should only be used in LGPL-compatible code.
420e5b92 58 */
420e5b92 59
7e30abe3
MD
60/*
61 * rcu_read_lock()
62 * rcu_read_unlock()
63 *
64 * Mark the beginning and end of a read-side critical section.
5e77fc1f
PM
65 * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread()
66 * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION.
7e30abe3 67 */
4477a870
MD
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
420e5b92 71
4477a870
MD
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
420e5b92 75
7ac06cef 76#else /* !_LGPL_SOURCE */
420e5b92 77
420e5b92 78/*
7ac06cef 79 * library wrappers to be used by non-LGPL compatible source code.
420e5b92 80 */
420e5b92 81
727f819d
MD
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
d4e640c0
JR
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.
727f819d
MD
91 */
92
d4e640c0 93#if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG))
727f819d 94
4477a870 95static inline void urcu_qsbr_read_lock(void)
727f819d
MD
96{
97}
98
4477a870 99static inline void urcu_qsbr_read_unlock(void)
727f819d
MD
100{
101}
102
d4e640c0 103#else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
727f819d 104
4477a870
MD
105extern void urcu_qsbr_read_lock(void);
106extern void urcu_qsbr_read_unlock(void);
420e5b92 107
d4e640c0 108#endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */
727f819d 109
4477a870
MD
110extern int urcu_qsbr_read_ongoing(void);
111extern void urcu_qsbr_quiescent_state(void);
112extern void urcu_qsbr_thread_offline(void);
113extern void urcu_qsbr_thread_online(void);
420e5b92 114
7ac06cef 115#endif /* !_LGPL_SOURCE */
420e5b92 116
4477a870 117extern void urcu_qsbr_synchronize_rcu(void);
420e5b92 118
111bda8f
MD
119/*
120 * RCU grace period polling API.
121 */
122extern struct urcu_gp_poll_state urcu_qsbr_start_poll_synchronize_rcu(void);
123extern bool urcu_qsbr_poll_state_synchronize_rcu(struct urcu_gp_poll_state state);
124
420e5b92
MD
125/*
126 * Reader thread registration.
127 */
4477a870
MD
128extern void urcu_qsbr_register_thread(void);
129extern void urcu_qsbr_unregister_thread(void);
420e5b92 130
67ecffc0 131#ifdef __cplusplus
36bc70a8
MD
132}
133#endif
134
6cd23d47
MD
135#include <urcu/call-rcu.h>
136#include <urcu/defer.h>
137#include <urcu/flavor.h>
5e77fc1f 138
4477a870
MD
139#ifndef URCU_API_MAP
140#include <urcu/map/clear.h>
141#endif
142
420e5b92 143#endif /* _URCU_QSBR_H */
This page took 0.056086 seconds and 4 git commands to generate.