7d359d4ce34ce7dc5a02cfd0c3207f1ec9c1d720
[urcu.git] / urcu / rculfstack.h
1 #ifndef _URCU_RCULFSTACK_H
2 #define _URCU_RCULFSTACK_H
3
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
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 struct cds_lfs_node_rcu {
31 struct cds_lfs_node_rcu *next;
32 };
33
34 struct cds_lfs_stack_rcu {
35 struct cds_lfs_node_rcu *head;
36 };
37
38 #ifdef _LGPL_SOURCE
39
40 #include <urcu/static/rculfstack.h>
41
42 #define cds_lfs_node_init_rcu_qsbr _cds_lfs_node_init_rcu
43 #define cds_lfs_init_rcu_qsbr _cds_lfs_init_rcu
44 #define cds_lfs_push_rcu_qsbr _cds_lfs_push_rcu
45 #define cds_lfs_pop_rcu_qsbr _cds_lfs_pop_rcu
46
47 #define cds_lfs_node_init_rcu_bp _cds_lfs_node_init_rcu
48 #define cds_lfs_init_rcu_bp _cds_lfs_init_rcu
49 #define cds_lfs_push_rcu_bp _cds_lfs_push_rcu
50 #define cds_lfs_pop_rcu_bp _cds_lfs_pop_rcu
51
52 #define cds_lfs_node_init_rcu_memb _cds_lfs_node_init_rcu
53 #define cds_lfs_init_rcu_memb _cds_lfs_init_rcu
54 #define cds_lfs_push_rcu_memb _cds_lfs_push_rcu
55 #define cds_lfs_pop_rcu_memb _cds_lfs_pop_rcu
56
57 #define cds_lfs_node_init_rcu_mb _cds_lfs_node_init_rcu
58 #define cds_lfs_init_rcu_mb _cds_lfs_init_rcu
59 #define cds_lfs_push_rcu_mb _cds_lfs_push_rcu
60 #define cds_lfs_pop_rcu_mb _cds_lfs_pop_rcu
61
62 #define cds_lfs_node_init_rcu_sig _cds_lfs_node_init_rcu
63 #define cds_lfs_init_rcu_sig _cds_lfs_init_rcu
64 #define cds_lfs_push_rcu_sig _cds_lfs_push_rcu
65 #define cds_lfs_pop_rcu_sig _cds_lfs_pop_rcu
66
67 #else /* !_LGPL_SOURCE */
68
69 extern void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node);
70 extern void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s);
71 extern int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
72 struct cds_lfs_node_rcu *node);
73
74 /*
75 * Should be called under rcu read lock critical section.
76 *
77 * The caller must wait for a grace period to pass before freeing the returned
78 * node or modifying the cds_lfs_node_rcu structure.
79 * Returns NULL if stack is empty.
80 */
81 extern struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s);
82
83 #endif /* !_LGPL_SOURCE */
84
85 #ifdef __cplusplus
86 }
87 #endif
88
89 #endif /* _URCU_RCULFSTACK_H */
This page took 0.029998 seconds and 3 git commands to generate.