2 * Copyright (C) 2002 Free Software Foundation, Inc.
3 * (originally part of the GNU C Library)
4 * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
6 * Copyright (C) 2009 Pierre-Marc Fournier
7 * Conversion to RCU list.
8 * Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #ifndef _URCU_RCUHLIST_H
26 #define _URCU_RCUHLIST_H
28 #include <urcu/hlist.h>
29 #include <urcu/arch.h>
30 #include <urcu-pointer.h>
32 /* Add new element at the head of the list. */
34 void cds_hlist_add_head_rcu(struct cds_hlist_node
*newp
,
35 struct cds_hlist_head
*head
)
37 newp
->next
= head
->next
;
38 newp
->prev
= (struct cds_hlist_node
*)head
;
40 head
->next
->prev
= newp
;
41 rcu_assign_pointer(head
->next
, newp
);
44 /* Remove element from list. */
46 void cds_hlist_del_rcu(struct cds_hlist_node
*elem
)
49 elem
->next
->prev
= elem
->prev
;
50 CMM_STORE_SHARED(elem
->prev
->next
, elem
->next
);
54 * Iterate through elements of the list.
55 * This must be done while rcu_read_lock() is held.
57 #define cds_hlist_for_each_rcu(pos, head) \
58 for (pos = rcu_dereference((head)->next); pos != NULL; \
59 pos = rcu_dereference(pos->next))
62 * cds_hlist_for_each_entry_rcu takes 4 arguments, while the Linux
63 * kernel API only takes 3.
64 * We implement cds_hlist_for_each_entry_rcu_2() to follow the Linux
67 #define cds_hlist_for_each_entry_rcu(entry, pos, head, member) \
68 for (pos = rcu_dereference((head)->next), \
69 entry = cds_hlist_entry(pos, __typeof__(*entry), member); \
71 pos = rcu_dereference(pos->next), \
72 entry = cds_hlist_entry(pos, __typeof__(*entry), member))
74 #define cds_hlist_for_each_entry_rcu_2(entry, head, member) \
75 for (entry = cds_hlist_entry(rcu_dereference((head)->next), \
76 __typeof__(*entry), member); \
77 &entry->member != NULL; \
78 entry = cds_hlist_entry(rcu_dereference(entry->member.next), \
79 __typeof__(*entry), member))
81 #endif /* _URCU_RCUHLIST_H */
This page took 0.031015 seconds and 4 git commands to generate.