datapath: Backport simplified hlist iterators.
[sliver-openvswitch.git] / datapath / linux / compat / include / linux / rculist.h
1 #ifndef __LINUX_RCULIST_WRAPPER_H
2 #define __LINUX_RCULIST_WRAPPER_H
3
4 #include <linux/version.h>
5 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
6 #include_next <linux/rculist.h>
7 #else
8 /* Prior to 2.6.26, the contents of rculist.h were part of list.h. */
9 #include <linux/list.h>
10 #endif
11
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
13 #define hlist_del_init_rcu rpl_hlist_del_init_rcu
14 static inline void hlist_del_init_rcu(struct hlist_node *n)
15 {
16         if (!hlist_unhashed(n)) {
17                 __hlist_del(n);
18                 n->pprev = NULL;
19         }
20 }
21 #endif
22
23 #undef hlist_for_each_entry_rcu
24 #define hlist_for_each_entry_rcu(pos, head, member)                     \
25         for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
26                         typeof(*(pos)), member);                        \
27                 pos;                                                    \
28                 pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
29                         &(pos)->member)), typeof(*(pos)), member))
30
31 #endif