urcu-bp: use mremap
[urcu.git] / urcu / rculist.h
CommitLineData
63ff4873
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.
7a50dcf7 4
63ff4873
MD
5 Copyright (C) 2009 Pierre-Marc Fournier
6 Conversion to RCU list.
7
8 The GNU C 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.
12
13 The GNU C 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.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 02111-1307 USA. */
7a50dcf7 22
63ff4873
MD
23#ifndef _URCU_RCULIST_H
24#define _URCU_RCULIST_H
25
26#include <urcu/list.h>
7a50dcf7 27#include <urcu.h>
7a50dcf7 28
63ff4873 29/* Add new element at the head of the list.
7a50dcf7 30 */
63ff4873 31static inline void list_add_rcu(list_t *newp, list_t *head)
7a50dcf7 32{
63ff4873
MD
33 newp->next = head->next;
34 newp->prev = head;
7a50dcf7 35 smp_wmb();
63ff4873
MD
36 head->next->prev = newp;
37 head->next = newp;
7a50dcf7
MD
38}
39
7a50dcf7 40
63ff4873
MD
41/* Remove element from list. */
42static inline void list_del_rcu(list_t *elem)
7a50dcf7 43{
63ff4873
MD
44 elem->next->prev = elem->prev;
45 elem->prev->next = elem->next;
7a50dcf7
MD
46}
47
7a50dcf7 48
63ff4873
MD
49/* Iterate through elements of the list.
50 * This must be done while rcu_read_lock() is held.
7a50dcf7 51 */
7a50dcf7 52
63ff4873
MD
53#define list_for_each_entry_rcu(pos, head, member) \
54 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), member); \
55 &pos->member != (head); \
56 pos = list_entry(rcu_dereference(pos->member.next), typeof(*pos), member))
7a50dcf7 57
63ff4873 58#endif /* _URCU_RCULIST_H */
This page took 0.024841 seconds and 4 git commands to generate.