| 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 | |
| 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. */ |
| 22 | |
| 23 | #ifndef _URCU_RCULIST_H |
| 24 | #define _URCU_RCULIST_H |
| 25 | |
| 26 | #include <urcu/list.h> |
| 27 | #include <urcu.h> |
| 28 | |
| 29 | /* Add new element at the head of the list. |
| 30 | */ |
| 31 | static inline void list_add_rcu(list_t *newp, list_t *head) |
| 32 | { |
| 33 | newp->next = head->next; |
| 34 | newp->prev = head; |
| 35 | smp_wmb(); |
| 36 | head->next->prev = newp; |
| 37 | head->next = newp; |
| 38 | } |
| 39 | |
| 40 | |
| 41 | /* Remove element from list. */ |
| 42 | static inline void list_del_rcu(list_t *elem) |
| 43 | { |
| 44 | elem->next->prev = elem->prev; |
| 45 | elem->prev->next = elem->next; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | /* Iterate through elements of the list. |
| 50 | * This must be done while rcu_read_lock() is held. |
| 51 | */ |
| 52 | |
| 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)) |
| 57 | |
| 58 | #endif /* _URCU_RCULIST_H */ |