@@ -46,6 +46,35 @@ static inline void nl_list_add_head(struct nl_list_head *obj,
4646 __nl_list_add (obj , head , head -> next );
4747}
4848
49+ static inline void nl_list_insert_before (struct nl_list_head * obj ,
50+ struct nl_list_head * ref )
51+ {
52+ __nl_list_add (obj , ref -> prev , ref );
53+ }
54+
55+ static inline void nl_list_insert_after (struct nl_list_head * obj ,
56+ struct nl_list_head * ref )
57+ {
58+ __nl_list_add (obj , ref , ref -> next );
59+ }
60+
61+ static inline void nl_list_insert_list_after (struct nl_list_head * head ,
62+ struct nl_list_head * ref )
63+ {
64+ ref -> next -> prev = head -> prev ;
65+ head -> prev -> next = ref -> next ;
66+ ref -> next = head -> next ;
67+ head -> next -> prev = ref ;
68+ head -> next = head ;
69+ head -> prev = head ;
70+ }
71+
72+ static inline void nl_list_join (struct nl_list_head * head_1 ,
73+ struct nl_list_head * head_2 )
74+ {
75+ nl_list_insert_list_after (head_2 , head_1 -> prev );
76+ }
77+
4978static inline void nl_list_del (struct nl_list_head * obj )
5079{
5180 obj -> next -> prev = obj -> prev ;
@@ -76,17 +105,31 @@ static inline int nl_list_empty(struct nl_list_head *head)
76105#define nl_list_first_entry (head , type , member ) \
77106 nl_list_entry((head)->next, type, member)
78107
108+ #define nl_list_last_entry (head , type , member ) \
109+ nl_list_entry((head)->prev, type, member)
110+
79111#define nl_list_for_each_entry (pos , head , member ) \
80112 for (pos = nl_list_entry((head)->next, __typeof__(*pos), member); \
81113 &(pos)->member != (head); \
82114 (pos) = nl_list_entry((pos)->member.next, __typeof__(*(pos)), member))
83115
116+ #define nl_list_for_each_entry_reverse (pos , head , member ) \
117+ for (pos = nl_list_entry((head)->prev, __typeof__(*pos), member); \
118+ &(pos)->member != (head); \
119+ (pos) = nl_list_entry((pos)->member.prev, __typeof__(*(pos)), member))
120+
84121#define nl_list_for_each_entry_safe (pos , n , head , member ) \
85122 for (pos = nl_list_entry((head)->next, __typeof__(*pos), member), \
86123 n = nl_list_entry(pos->member.next, __typeof__(*pos), member); \
87124 &(pos)->member != (head); \
88125 pos = n, n = nl_list_entry(n->member.next, __typeof__(*n), member))
89126
127+ #define nl_list_for_each_entry_safe_reverse (pos , n , head , member ) \
128+ for (pos = nl_list_entry((head)->prev, __typeof__(*pos), member), \
129+ n = nl_list_entry(pos->member.prev, __typeof__(*pos), member); \
130+ &(pos)->member != (head); \
131+ pos = n, n = nl_list_entry(n->member.prev, __typeof__(*n), member))
132+
90133#define nl_init_list_head (head ) \
91134 do { (head)->next = (head); (head)->prev = (head); } while (0)
92135
0 commit comments