ReactOS 0.4.15-dev-8219-ge8b88cf
list.h
Go to the documentation of this file.
1 #ifndef _LINUX_LIST_H
2 #define _LINUX_LIST_H
3
4
5 /*
6 * Simple doubly linked list implementation.
7 *
8 * Some of the internal functions ("__xxx") are useful when
9 * manipulating whole lists rather than single entries, as
10 * sometimes we already know the next/prev entries and we can
11 * generate better code by using them directly rather than
12 * using the generic single-entry routines.
13 */
14
15 struct list_head {
16 struct list_head *next, *prev;
17 };
18
19 #define LIST_HEAD_INIT(name) { &(name), &(name) }
20
21 #define LIST_HEAD(name) \
22 struct list_head name = LIST_HEAD_INIT(name)
23
24 #define INIT_LIST_HEAD(ptr) do { \
25 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
26 } while (0)
27
28
29 /*
30 * Insert a new entry between two known consecutive entries.
31 *
32 * This is only for internal list manipulation where we know
33 * the prev/next entries already!
34 */
35 static inline void __list_add(struct list_head *new,
36 struct list_head *prev,
37 struct list_head *next)
38 {
39 next->prev = new;
40 new->next = next;
41 new->prev = prev;
42 prev->next = new;
43 }
44
53 static inline void list_add(struct list_head *new, struct list_head *head)
54 {
55 __list_add(new, head, head->next);
56 }
57
66 static inline void list_add_tail(struct list_head *new, struct list_head *head)
67 {
68 __list_add(new, head->prev, head);
69 }
70
71 /*
72 * Delete a list entry by making the prev/next entries
73 * point to each other.
74 *
75 * This is only for internal list manipulation where we know
76 * the prev/next entries already!
77 */
78 static inline void __list_del(struct list_head *prev, struct list_head *next)
79 {
80 next->prev = prev;
81 prev->next = next;
82 }
83
89 static inline void list_del(struct list_head *entry)
90 {
91 __list_del(entry->prev, entry->next);
92 entry->next = (void *) 0;
93 entry->prev = (void *) 0;
94 }
95
100 static inline void list_del_init(struct list_head *entry)
101 {
102 __list_del(entry->prev, entry->next);
104 }
105
111 static inline void list_move(struct list_head *list, struct list_head *head)
112 {
115 }
116
122 static inline void list_move_tail(struct list_head *list,
123 struct list_head *head)
124 {
127 }
128
133 static inline int list_empty(struct list_head *head)
134 {
135 return head->next == head;
136 }
137
138 static inline void __list_splice(struct list_head *list,
139 struct list_head *head)
140 {
141 struct list_head *first = list->next;
142 struct list_head *last = list->prev;
143 struct list_head *at = head->next;
144
145 first->prev = head;
146 head->next = first;
147
148 last->next = at;
149 at->prev = last;
150 }
151
157 static inline void list_splice(struct list_head *list, struct list_head *head)
158 {
159 if (!list_empty(list))
161 }
162
170 static inline void list_splice_init(struct list_head *list,
171 struct list_head *head)
172 {
173 if (!list_empty(list)) {
176 }
177 }
178
185 #define list_entry(ptr, type, member) \
186 ((type *)((char *)(ptr)-(uintptr_t)(&((type *)0)->member)))
187
193 #define list_for_each(pos, head) \
194 for (pos = (head)->next; pos != (head); \
195 pos = pos->next)
201 #define list_for_each_prev(pos, head) \
202 for (pos = (head)->prev; pos != (head); \
203 pos = pos->prev)
204
211 #define list_for_each_safe(pos, n, head) \
212 for (pos = (head)->next, n = pos->next; pos != (head); \
213 pos = n, n = pos->next)
214
221 #define list_for_each_entry(pos, head, member) \
222 for (pos = list_entry((head)->next, typeof(*pos), member); \
223 &pos->member != (head); \
224 pos = list_entry(pos->member.next, typeof(*pos), member))
225
233 #define list_for_each_entry_safe(pos, n, head, member) \
234 for (pos = list_entry((head)->next, typeof(*pos), member), \
235 n = list_entry(pos->member.next, typeof(*pos), member); \
236 &pos->member != (head); \
237 pos = n, n = list_entry(n->member.next, typeof(*n), member))
238
246 #define list_for_each_entry_continue(pos, head, member) \
247 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
248 &pos->member != (head); \
249 pos = list_entry(pos->member.next, typeof(*pos), member))
250
251 #endif
struct outqueuenode * head
Definition: adnsresfilter.c:66
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_add(struct list_entry *entry, struct list_entry *prev, struct list_entry *next)
Definition: list.h:64
Definition: list.h:37
struct list * next
Definition: list.h:38
struct list * prev
Definition: list.h:39
#define INIT_LIST_HEAD(ptr)
Definition: list.h:24
static void list_move_tail(struct list_head *list, struct list_head *head)
Definition: list.h:122
static void __list_del(struct list_head *prev, struct list_head *next)
Definition: list.h:78
static void __list_splice(struct list_head *list, struct list_head *head)
Definition: list.h:138
static void list_splice(struct list_head *list, struct list_head *head)
Definition: list.h:157
static void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
Definition: list.h:35
static void list_splice_init(struct list_head *list, struct list_head *head)
Definition: list.h:170
static void list_del(struct list_head *entry)
Definition: list.h:89
static void list_del_init(struct list_head *entry)
Definition: list.h:100
static void list_move(struct list_head *list, struct list_head *head)
Definition: list.h:111
const GLint * first
Definition: glext.h:5794
uint32_t entry
Definition: isohybrid.c:63
static UINT UINT last
Definition: font.c:45
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: list.h:15
struct list_head * next
Definition: list.h:16
struct list_head * prev
Definition: list.h:16