datapath: Provide additional RCU backports.
[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 #include <linux/rcupdate.h>
11 #endif
12
13 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
14 #define hlist_del_init_rcu rpl_hlist_del_init_rcu
15 static inline void hlist_del_init_rcu(struct hlist_node *n)
16 {
17         if (!hlist_unhashed(n)) {
18                 __hlist_del(n);
19                 n->pprev = NULL;
20         }
21 }
22 #endif
23
24 #ifndef hlist_first_rcu
25 #define hlist_first_rcu(head)   (*((struct hlist_node __rcu **)(&(head)->first)))
26 #define hlist_next_rcu(node)    (*((struct hlist_node __rcu **)(&(node)->next)))
27 #define hlist_pprev_rcu(node)   (*((struct hlist_node __rcu **)((node)->pprev)))
28 #endif
29
30 #undef hlist_for_each_entry_rcu
31 #define hlist_for_each_entry_rcu(pos, head, member)                     \
32         for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
33                         typeof(*(pos)), member);                        \
34                 pos;                                                    \
35                 pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
36                         &(pos)->member)), typeof(*(pos)), member))
37
38 #endif