1 // SPDX-FileCopyrightText: 2002 Free Software Foundation, Inc.
2 // SPDX-FileCopyrightText: 2009 Pierre-Marc Fournier
3 // SPDX-FileCopyrightText: 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 // SPDX-License-Identifier: LGPL-2.1-or-later
8 * (originally part of the GNU C Library)
9 * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
12 #ifndef _URCU_RCUHLIST_H
13 #define _URCU_RCUHLIST_H
15 #include <urcu/hlist.h>
16 #include <urcu/arch.h>
17 #include <urcu-pointer.h>
19 /* Add new element at the head of the list. */
21 void cds_hlist_add_head_rcu(struct cds_hlist_node
*newp
,
22 struct cds_hlist_head
*head
)
24 newp
->next
= head
->next
;
25 newp
->prev
= (struct cds_hlist_node
*)head
;
27 head
->next
->prev
= newp
;
28 rcu_assign_pointer(head
->next
, newp
);
31 /* Remove element from list. */
33 void cds_hlist_del_rcu(struct cds_hlist_node
*elem
)
36 elem
->next
->prev
= elem
->prev
;
37 CMM_STORE_SHARED(elem
->prev
->next
, elem
->next
);
41 * Iterate through elements of the list.
42 * This must be done while rcu_read_lock() is held.
44 #define cds_hlist_for_each_rcu(pos, head) \
45 for (pos = rcu_dereference((head)->next); (pos) != NULL; \
46 pos = rcu_dereference((pos)->next))
49 * cds_hlist_for_each_entry_rcu takes 4 arguments, while the Linux
50 * kernel API only takes 3.
51 * We implement cds_hlist_for_each_entry_rcu_2() to follow the Linux
54 #define cds_hlist_for_each_entry_rcu(entry, pos, head, member) \
55 for (pos = rcu_dereference((head)->next), \
56 entry = cds_hlist_entry(pos, __typeof__(*(entry)), member); \
58 pos = rcu_dereference((pos)->next), \
59 entry = cds_hlist_entry(pos, __typeof__(*(entry)), member))
61 #define cds_hlist_for_each_entry_rcu_2(entry, head, member) \
62 for (entry = cds_hlist_entry_safe(rcu_dereference((head)->next), \
63 __typeof__(*(entry)), member); \
65 entry = cds_hlist_entry_safe(rcu_dereference((entry)->member.next), \
66 __typeof__(*(entry)), member))
68 #endif /* _URCU_RCUHLIST_H */
This page took 0.031027 seconds and 4 git commands to generate.