This source file includes following definitions.
- INIT_LIST_HEAD
- __list_add
- list_add
- __list_del
- __list_del_entry
- list_del
1
2 #ifndef _LIST_H
3 #define _LIST_H
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 struct list_head {
20 struct list_head *next, *prev;
21 };
22
23 #define LIST_HEAD_INIT(name) { &(name), &(name) }
24
25 #define LIST_HEAD(name) \
26 struct list_head name = LIST_HEAD_INIT(name)
27
28 static inline void INIT_LIST_HEAD(struct list_head *list)
29 {
30 list->next = list;
31 list->prev = list;
32 }
33
34
35
36
37
38
39
40 static inline void __list_add(struct list_head *new,
41 struct list_head *prev,
42 struct list_head *next)
43 {
44 next->prev = new;
45 new->next = next;
46 new->prev = prev;
47 prev->next = new;
48 }
49
50
51
52
53
54
55
56
57
58 static inline void list_add(struct list_head *new, struct list_head *head)
59 {
60 __list_add(new, head, head->next);
61 }
62
63
64
65
66
67
68
69
70 static inline void __list_del(struct list_head * prev, struct list_head * next)
71 {
72 next->prev = prev;
73 prev->next = next;
74 }
75
76 #define POISON_POINTER_DELTA 0
77 #define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
78 #define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
79
80
81
82
83
84
85
86 static inline void __list_del_entry(struct list_head *entry)
87 {
88 __list_del(entry->prev, entry->next);
89 }
90
91 static inline void list_del(struct list_head *entry)
92 {
93 __list_del(entry->prev, entry->next);
94 entry->next = LIST_POISON1;
95 entry->prev = LIST_POISON2;
96 }
97
98
99
100
101
102
103
104 #define list_entry(ptr, type, member) \
105 container_of(ptr, type, member)
106
107
108
109
110
111 #define list_for_each(pos, head) \
112 for (pos = (head)->next; pos != (head); pos = pos->next)
113
114
115
116
117
118
119
120 #define list_for_each_safe(pos, n, head) \
121 for (pos = (head)->next, n = pos->next; pos != (head); \
122 pos = n, n = pos->next)
123
124 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
125
126
127
128
129
130
131
132
133 #define container_of(ptr, type, member) ({ \
134 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
135 (type *)( (char *)__mptr - offsetof(type,member) );})
136
137 #endif