ReactOS 0.4.15-dev-8390-g075894b
list.h
Go to the documentation of this file.
1#ifndef __LINUX_LIST_H__
2#define __LINUX_LIST_H__
3
4/*
5 * Simple doubly linked list implementation.
6 *
7 * Some of the internal functions ("__xxx") are useful when
8 * manipulating whole lists rather than single entries, as
9 * sometimes we already know the next/prev entries and we can
10 * generate better code by using them directly rather than
11 * using the generic single-entry routines.
12 */
13
14#define prefetch(a) ((void *)a)
15
16struct list_head {
17 struct list_head *next, *prev;
18};
19
20#define LIST_HEAD_INIT(name) { &(name), &(name) }
21
22#define LIST_HEAD(name) \
23 struct list_head name = LIST_HEAD_INIT(name)
24
25static inline void INIT_LIST_HEAD(struct list_head *list)
26{
27 list->next = list;
28 list->prev = list;
29}
30
31/*
32 * Insert a new entry between two known consecutive entries.
33 *
34 * This is only for internal list manipulation where we know
35 * the prev/next entries already!
36 */
37static inline void __list_add(struct list_head * new,
38 struct list_head * prev,
39 struct list_head * next)
40{
41 next->prev = new;
42 new->next = next;
43 new->prev = prev;
44 prev->next = new;
45}
46
55static inline void list_add(struct list_head *new, struct list_head *head)
56{
57 __list_add(new, head, head->next);
58}
59
68static inline void list_add_tail(struct list_head *new, struct list_head *head)
69{
70 __list_add(new, head->prev, head);
71}
72
73/*
74 * Delete a list entry by making the prev/next entries
75 * point to each other.
76 *
77 * This is only for internal list manipulation where we know
78 * the prev/next entries already!
79 */
80static inline void __list_del(struct list_head * prev, struct list_head * next)
81{
82 next->prev = prev;
83 prev->next = next;
84}
85
91static inline void list_del(struct list_head *entry)
92{
93 __list_del(entry->prev, entry->next);
94}
95
100static inline void list_del_init(struct list_head *entry)
101{
102 __list_del(entry->prev, entry->next);
104}
105
111static inline void list_move(struct list_head *list, struct list_head *head)
112{
115}
116
122static inline void list_move_tail(struct list_head *list,
123 struct list_head *head)
124{
127}
128
133static inline int list_empty(struct list_head *head)
134{
135 return head->next == head;
136}
137
138static inline int list_empty_careful(const struct list_head *head)
139{
140 struct list_head *next = head->next;
141 return (next == head) && (next == head->prev);
142}
143
144static inline void __list_splice(struct list_head *list,
145 struct list_head *head)
146{
147 struct list_head *first = list->next;
148 struct list_head *last = list->prev;
149 struct list_head *at = head->next;
150
151 first->prev = head;
152 head->next = first;
153
154 last->next = at;
155 at->prev = last;
156}
157
163static inline void list_splice(struct list_head *list, struct list_head *head)
164{
165 if (!list_empty(list))
167}
168
176static inline void list_splice_init(struct list_head *list,
177 struct list_head *head)
178{
179 if (!list_empty(list)) {
182 }
183}
184
191#define list_entry(ptr, type, member) \
192 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
193
199#define list_for_each(pos, head) \
200 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
201 pos = pos->next, prefetch(pos->next))
202
209#define list_for_each_safe(pos, n, head) \
210 for (pos = (head)->next, n = pos->next; pos != (head); \
211 pos = n, n = pos->next)
212
213#ifndef list_for_each_prev
219#define list_for_each_prev(pos, head) \
220 for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
221 pos = pos->prev, prefetch(pos->prev))
222
223#endif /* list_for_each_prev */
224
225#ifndef list_for_each_entry
232#define list_for_each_entry(pos, head, type, member) \
233 for (pos = list_entry((head)->next, type, member), \
234 prefetch(pos->member.next); \
235 &pos->member != (head); \
236 pos = list_entry(pos->member.next, type, member), \
237 prefetch(pos->member.next))
238#endif /* list_for_each_entry */
239
240#ifndef list_for_each_entry_safe
248#define list_for_each_entry_safe(pos, n, head, type, member) \
249 for (pos = list_entry((head)->next, type, member), \
250 n = list_entry(pos->member.next, type, member); \
251 &pos->member != (head); \
252 pos = n, n = list_entry(n->member.next, type, member))
253#endif /* list_for_each_entry_safe */
254
255#endif /* __LINUX_LIST_H__ */
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
static int list_empty_careful(const struct list_head *head)
Definition: list.h:138
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
#define list
Definition: rosglue.h:35
Definition: list.h:15
struct list_head * next
Definition: list.h:16
struct list_head * prev
Definition: list.h:16