Commit | Line | Data |
---|---|---|
c3f74cb2 MD |
1 | #ifndef _URCU_RCULFSTACK_H |
2 | #define _URCU_RCULFSTACK_H | |
3 | ||
453629a9 MD |
4 | /* |
5 | * rculfstack.h | |
6 | * | |
7 | * Userspace RCU library - Lock-Free RCU Stack | |
8 | * | |
9 | * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
11 | * This library is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License as published by the Free Software Foundation; either | |
14 | * version 2.1 of the License, or (at your option) any later version. | |
15 | * | |
16 | * This library is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | * Lesser General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU Lesser General Public | |
22 | * License along with this library; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
24 | */ | |
25 | ||
0e2e9380 MD |
26 | #ifdef __cplusplus |
27 | extern "C" { | |
28 | #endif | |
29 | ||
16aa9ee8 DG |
30 | struct cds_lfs_node_rcu { |
31 | struct cds_lfs_node_rcu *next; | |
453629a9 MD |
32 | }; |
33 | ||
16aa9ee8 DG |
34 | struct cds_lfs_stack_rcu { |
35 | struct cds_lfs_node_rcu *head; | |
453629a9 MD |
36 | }; |
37 | ||
b6a37eac | 38 | #ifdef _LGPL_SOURCE |
453629a9 | 39 | |
af7c2dbe | 40 | #include <urcu/static/rculfstack.h> |
453629a9 | 41 | |
16aa9ee8 | 42 | #define cds_lfs_node_init_rcu _cds_lfs_node_init_rcu |
c5f52d0c MD |
43 | #define cds_lfs_init_rcu _cds_lfs_init_rcu |
44 | #define cds_lfs_push_rcu _cds_lfs_push_rcu | |
16aa9ee8 | 45 | #define cds_lfs_pop_rcu _cds_lfs_pop_rcu |
453629a9 | 46 | |
b6a37eac MD |
47 | #else /* !_LGPL_SOURCE */ |
48 | ||
16aa9ee8 DG |
49 | extern void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node); |
50 | extern void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s); | |
51 | extern void cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *node); | |
453629a9 | 52 | |
1c1e940e | 53 | /* |
d9b52143 MD |
54 | * Should be called under rcu read lock critical section. |
55 | * | |
1c1e940e | 56 | * The caller must wait for a grace period to pass before freeing the returned |
16aa9ee8 | 57 | * node or modifying the cds_lfs_node_rcu structure. |
1c1e940e MD |
58 | * Returns NULL if stack is empty. |
59 | */ | |
16aa9ee8 | 60 | extern struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s); |
453629a9 | 61 | |
b6a37eac | 62 | #endif /* !_LGPL_SOURCE */ |
c3f74cb2 | 63 | |
0e2e9380 MD |
64 | #ifdef __cplusplus |
65 | } | |
66 | #endif | |
67 | ||
c3f74cb2 | 68 | #endif /* _URCU_RCULFSTACK_H */ |