Fix get_cycles -> caa_get_cycles
[urcu.git] / urcu / rcuhlist.h
CommitLineData
5db941e8
MD
1/* Copyright (C) 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 Copyright (C) 2009 Pierre-Marc Fournier
6 Conversion to RCU list.
7 Copyright (C) 2010 Mathieu Desnoyers
8
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library; if not, write to the Free
21 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 02111-1307 USA. */
23
24#ifndef _URCU_RCUHLIST_H
25#define _URCU_RCUHLIST_H
26
27#include <urcu/hlist.h>
28#include <urcu/arch.h>
29#include <urcu-pointer.h>
30
31/* Add new element at the head of the list.
32 */
16aa9ee8
DG
33static inline void cds_hlist_add_head_rcu(struct cds_hlist_node *newp,
34 struct cds_hlist_head *head)
5db941e8
MD
35{
36 newp->next = head->next;
16aa9ee8 37 newp->prev = (struct cds_hlist_node *)head;
5481ddb3 38 cmm_smp_wmb();
5db941e8
MD
39 if (head->next)
40 head->next->prev = newp;
41 head->next = newp;
42}
43
44/* Remove element from list. */
16aa9ee8 45static inline void cds_hlist_del_rcu(struct cds_hlist_node *elem)
5db941e8
MD
46{
47 if (elem->next)
48 elem->next->prev = elem->prev;
49 elem->prev->next = elem->next;
50}
51
52
53/* Iterate through elements of the list.
54 * This must be done while rcu_read_lock() is held.
55 */
56
16aa9ee8 57#define cds_hlist_for_each_entry_rcu(entry, pos, head, member) \
5db941e8 58 for (pos = rcu_dereference((head)->next), \
16aa9ee8 59 entry = cds_hlist_entry(pos, typeof(*entry), member); \
5db941e8
MD
60 pos != NULL; \
61 pos = rcu_dereference(pos->next), \
16aa9ee8 62 entry = cds_hlist_entry(pos, typeof(*entry), member))
5db941e8
MD
63
64#endif /* _URCU_RCUHLIST_H */
This page took 0.024757 seconds and 4 git commands to generate.