Commit | Line | Data |
---|---|---|
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> | |
3cd243cb MD |
27 | #include <urcu/arch.h> |
28 | #include <urcu-pointer.h> | |
7a50dcf7 | 29 | |
63ff4873 | 30 | /* Add new element at the head of the list. |
7a50dcf7 | 31 | */ |
63ff4873 | 32 | static inline void list_add_rcu(list_t *newp, list_t *head) |
7a50dcf7 | 33 | { |
63ff4873 MD |
34 | newp->next = head->next; |
35 | newp->prev = head; | |
7a50dcf7 | 36 | smp_wmb(); |
63ff4873 MD |
37 | head->next->prev = newp; |
38 | head->next = newp; | |
7a50dcf7 MD |
39 | } |
40 | ||
7a50dcf7 | 41 | |
63ff4873 MD |
42 | /* Remove element from list. */ |
43 | static inline void list_del_rcu(list_t *elem) | |
7a50dcf7 | 44 | { |
63ff4873 MD |
45 | elem->next->prev = elem->prev; |
46 | elem->prev->next = elem->next; | |
7a50dcf7 MD |
47 | } |
48 | ||
7a50dcf7 | 49 | |
63ff4873 MD |
50 | /* Iterate through elements of the list. |
51 | * This must be done while rcu_read_lock() is held. | |
7a50dcf7 | 52 | */ |
7a50dcf7 | 53 | |
63ff4873 MD |
54 | #define list_for_each_entry_rcu(pos, head, member) \ |
55 | for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), member); \ | |
56 | &pos->member != (head); \ | |
57 | pos = list_entry(rcu_dereference(pos->member.next), typeof(*pos), member)) | |
7a50dcf7 | 58 | |
63ff4873 | 59 | #endif /* _URCU_RCULIST_H */ |