Commit | Line | Data |
---|---|---|
b57aee66 PM |
1 | #ifndef _URCU_CALL_RCU_H |
2 | #define _URCU_CALL_RCU_H | |
3 | ||
4 | /* | |
89d19b43 | 5 | * urcu/call-rcu.h |
b57aee66 | 6 | * |
89d19b43 | 7 | * Userspace RCU header - batch memory reclamation with kernel API |
b57aee66 PM |
8 | * |
9 | * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. | |
11 | * | |
89d19b43 MD |
12 | * This header is meant to be included indirectly through a liburcu |
13 | * flavor header. | |
b57aee66 PM |
14 | * |
15 | * This library is free software; you can redistribute it and/or | |
16 | * modify it under the terms of the GNU Lesser General Public | |
17 | * License as published by the Free Software Foundation; either | |
18 | * version 2.1 of the License, or (at your option) any later version. | |
19 | * | |
20 | * This library is distributed in the hope that it will be useful, | |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
23 | * Lesser General Public License for more details. | |
24 | * | |
25 | * You should have received a copy of the GNU Lesser General Public | |
26 | * License along with this library; if not, write to the Free Software | |
27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
28 | */ | |
29 | ||
30 | #include <stdlib.h> | |
31 | #include <pthread.h> | |
32 | ||
5161f31e | 33 | #include <urcu/wfcqueue.h> |
b57aee66 PM |
34 | |
35 | #ifdef __cplusplus | |
36 | extern "C" { | |
37 | #endif | |
38 | ||
39 | /* Note that struct call_rcu_data is opaque to callers. */ | |
40 | ||
41 | struct call_rcu_data; | |
42 | ||
43 | /* Flag values. */ | |
44 | ||
e85451a1 MD |
45 | #define URCU_CALL_RCU_RT (1U << 0) |
46 | #define URCU_CALL_RCU_RUNNING (1U << 1) | |
47 | #define URCU_CALL_RCU_STOP (1U << 2) | |
48 | #define URCU_CALL_RCU_STOPPED (1U << 3) | |
49 | #define URCU_CALL_RCU_PAUSE (1U << 4) | |
50 | #define URCU_CALL_RCU_PAUSED (1U << 5) | |
b57aee66 PM |
51 | |
52 | /* | |
53 | * The rcu_head data structure is placed in the structure to be freed | |
54 | * via call_rcu(). | |
55 | */ | |
56 | ||
57 | struct rcu_head { | |
5161f31e | 58 | struct cds_wfcq_node next; |
b57aee66 PM |
59 | void (*func)(struct rcu_head *head); |
60 | }; | |
61 | ||
62 | /* | |
63 | * Exported functions | |
f9da0936 | 64 | * |
dcb9c05a | 65 | * Important: see rcu-api.md in userspace-rcu documentation for |
37a9ce52 MD |
66 | * call_rcu family of functions usage detail, including the surrounding |
67 | * RCU usage required when using these primitives. | |
b57aee66 | 68 | */ |
618b2595 | 69 | |
f9da0936 MD |
70 | void call_rcu(struct rcu_head *head, |
71 | void (*func)(struct rcu_head *head)); | |
72 | ||
c1d2c60b MD |
73 | struct call_rcu_data *create_call_rcu_data(unsigned long flags, |
74 | int cpu_affinity); | |
f9da0936 MD |
75 | void call_rcu_data_free(struct call_rcu_data *crdp); |
76 | ||
b57aee66 | 77 | struct call_rcu_data *get_default_call_rcu_data(void); |
f9da0936 | 78 | struct call_rcu_data *get_cpu_call_rcu_data(int cpu); |
b57aee66 | 79 | struct call_rcu_data *get_thread_call_rcu_data(void); |
f9da0936 MD |
80 | struct call_rcu_data *get_call_rcu_data(void); |
81 | pthread_t get_call_rcu_thread(struct call_rcu_data *crdp); | |
82 | ||
b57aee66 | 83 | void set_thread_call_rcu_data(struct call_rcu_data *crdp); |
f9da0936 MD |
84 | int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp); |
85 | ||
b57aee66 | 86 | int create_all_cpu_call_rcu_data(unsigned long flags); |
7106ddf8 | 87 | void free_all_cpu_call_rcu_data(void); |
f9da0936 | 88 | |
666d90e8 MD |
89 | void call_rcu_before_fork(void); |
90 | void call_rcu_after_fork_parent(void); | |
7106ddf8 | 91 | void call_rcu_after_fork_child(void); |
b57aee66 | 92 | |
b7f721d9 MD |
93 | void rcu_barrier(void); |
94 | ||
67ecffc0 | 95 | #ifdef __cplusplus |
b57aee66 PM |
96 | } |
97 | #endif | |
98 | ||
99 | #endif /* _URCU_CALL_RCU_H */ |