Added headers and macros to support IB core on RHEL7.4
[compat-rdma/compat.git] / include / linux / list.h
1 #ifndef COMPAT_LIST_H
2 #define COMPAT_LIST_H
3
4 #include_next <linux/list.h>
5
6 /* Include the autogenerated header file */
7 #include "../../compat/config.h"
8
9 #ifdef HAVE_HLIST_FOR_EACH_ENTRY_3_PARAMS
10 #define compat_hlist_for_each_entry_safe(pos, n, head, member)  \
11         hlist_for_each_entry_safe(pos, n, head, member)
12
13 #define compat_hlist_for_each_entry(pos, head, member)          \
14         hlist_for_each_entry(pos, head, member)
15
16 #define COMPAT_HL_NODE
17 #else
18 #define compat_hlist_for_each_entry_safe(pos, n, head, member)  \
19         hlist_for_each_entry_safe(pos, hlnode, n, head, member)
20
21 #define compat_hlist_for_each_entry(pos, head, member)          \
22         hlist_for_each_entry(pos, hlnode, head, member)         \
23
24 #define COMPAT_HL_NODE struct hlist_node *hlnode;
25 #endif
26
27 #ifndef list_prev_entry
28 #define list_prev_entry(pos, member) \
29         list_entry((pos)->member.prev, typeof(*(pos)), member)
30 #endif
31
32 #ifndef list_next_entry
33 #define list_next_entry(pos, member) \
34         list_entry((pos)->member.next, typeof(*(pos)), member)
35 #endif
36
37 #ifndef list_first_entry_or_null
38 #define list_first_entry_or_null(ptr, type, member) \
39         (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
40 #endif
41 #endif /* COMPAT_LIST_H */