1 #ifndef _URCU_RCULFSTACK_STATIC_H
2 #define _URCU_RCULFSTACK_STATIC_H
7 * Userspace RCU library - Lock-Free RCU Stack
9 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfstack.h for linking
12 * dynamically with the userspace rcu library.
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.
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.
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
29 #include <urcu/uatomic.h>
36 void _cds_lfs_node_init_rcu(struct cds_lfs_node_rcu
*node
)
41 void _cds_lfs_init_rcu(struct cds_lfs_stack_rcu
*s
)
47 void _cds_lfs_push_rcu(struct cds_lfs_stack_rcu
*s
, struct cds_lfs_node_rcu
*node
)
49 struct cds_lfs_node_rcu
*head
= NULL
;
52 struct cds_lfs_node_rcu
*old_head
= head
;
56 * uatomic_cmpxchg() implicit memory barrier orders earlier
57 * stores to node before publication.
59 head
= uatomic_cmpxchg(&s
->head
, old_head
, node
);
66 * Should be called under rcu read-side lock.
68 * The caller must wait for a grace period to pass before freeing the returned
69 * node or modifying the cds_lfs_node_rcu structure.
70 * Returns NULL if stack is empty.
73 struct cds_lfs_node_rcu
*
74 _cds_lfs_pop_rcu(struct cds_lfs_stack_rcu
*s
)
77 struct cds_lfs_node_rcu
*head
;
79 head
= rcu_dereference(s
->head
);
81 struct cds_lfs_node_rcu
*next
= rcu_dereference(head
->next
);
83 if (uatomic_cmpxchg(&s
->head
, head
, next
) == head
) {
86 /* Concurrent modification. Retry. */
100 #endif /* _URCU_RCULFSTACK_STATIC_H */
This page took 0.031314 seconds and 4 git commands to generate.