f43c9d8c1e679c344bdb289b445fdd99ed0c466d
4 * Userspace RCU library - Lock-Free RCU Stack
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #if (!defined(_GNU_SOURCE) && !defined(_LGPL_SOURCE))
24 #error "Dynamic loader LGPL wrappers not implemented yet"
28 struct rcu_lfs_node
*next
;
31 struct rcu_lfs_stack
{
32 struct rcu_lfs_node
*head
;
35 void rcu_lfs_node_init(struct rcu_lfs_node
*node
)
39 void rcu_lfs_init(struct rcu_lfs_stack
*s
)
44 void rcu_lfs_push(struct rcu_lfs_stack
*s
, struct rcu_lfs_node
*node
)
48 struct rcu_lfs_node
*head
= rcu_dereference(s
->head
);
52 * uatomic_cmpxchg() implicit memory barrier orders earlier
53 * stores to node before publication.
55 if (uatomic_cmpxchg(&s
->head
, head
, node
) == head
) {
59 /* Failure to prepend. Retry. */
66 rcu_lfs_pop(struct rcu_lfs_stack
*s
)
70 struct rcu_lfs_node
*head
= rcu_dereference(s
->head
);
73 struct rcu_lfs_node
*next
= rcu_dereference(head
->next
);
75 if (uatomic_cmpxchg(&s
->head
, head
, next
) == head
) {
79 /* Concurrent modification. Retry. */
This page took 0.035094 seconds and 3 git commands to generate.