ncloader  0.1
 모두 데이타 구조 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 매크로 그룹들 페이지들
list.h
이 파일의 문서화 페이지로 가기
1 
18 #define LIST_HEAD_INIT(list) { &(list), &(list) }
19 
23 #define LIST_HEAD(list) struct list_head list = LIST_HEAD_INIT(list)
24 
28 #define LIST_NEXT(name) ((name)->next)
29 
33 #define LIST_PREV(name) ((name)->prev)
34 
38 struct list_head {
39  struct list_head *next;
40  struct list_head *prev;
41 };
42 
49 #define list_entry(ptr, type, member) \
50  container_of(ptr, type, member)
51 
55 #define list_first_entry(ptr, type, member) \
56  (((ptr)->next == (ptr)) ? NULL : \
57  list_entry((ptr)->next, type, member))
58 
62 #define list_for_each(pos, head) \
63  for (pos = (head)->next; \
64  prefetch(pos->next), pos != (head); pos = pos->next)
65 
69 #define list_for_each_prev(pos, head) \
70  for (pos = (head)->prev; \
71  prefetch(pos->prev), pos != (head); pos = pos->prev)
72 
76 #define list_for_each_safe(pos, n, head) \
77  for (pos = (head)->next, n = pos->next; \
78  pos != (head); pos = n, n = pos->next)
79 
83 #define list_for_each_prev_safe(pos, n, head) \
84  for (pos = (head)->prev, n = pos->prev; \
85  prefetch(pos->prev), pos != (head); pos = n, n = pos->prev)
86 
90 #define list_for_each_entry(pos, head, member) \
91  for (pos = list_entry((head)->next, typeof(*pos), member); \
92  prefetch(pos->member.next), &pos->member != (head); \
93  pos = list_entry(pos->member.next, typeof(*pos), member))
94 
100 static inline void INIT_LIST_HEAD(struct list_head *list)
101 {
102  list->next = list;
103  list->prev = list;
104 }
105 
109 static inline void __list_add(struct list_head *new,
110  struct list_head *prev, struct list_head *next)
111 {
112  next->prev = new;
113  new->next = next;
114  new->prev = prev;
115  prev->next = new;
116 }
117 
126 static inline void list_add(struct list_head *new, struct list_head *head)
127 {
128  __list_add(new, head, head->next);
129 }
130 
138 static inline void list_add_tail(struct list_head *new, struct list_head *head)
139 {
140  __list_add(new, head->prev, head);
141 }
142 
151 static inline void list_insert_after(struct list_head *new,
152  struct list_head *head)
153 {
154  new->next = head->next;
155  new->prev = head;
156 
157  new->next->prev = new;
158  head->next = new;
159 }
160 
169 static inline void list_insert_before(struct list_head *new,
170  struct list_head *head)
171 {
172  new->next = head;
173  new->prev = head->prev;
174 
175  new->prev->next = new;
176  head->prev = new;
177 }
178 
182 static inline void __list_del(struct list_head *prev, struct list_head *next)
183 {
184  next->prev = prev;
185  prev->next = next;
186 }
187 
194 static inline void list_del(struct list_head *entry)
195 {
196  __list_del(entry->prev, entry->next);
197  entry->next = NULL;
198  entry->prev = NULL;
199 }
200 
208 static inline void list_replace(struct list_head *new, struct list_head *old)
209 {
210  if (old->next)
211  old->next->prev = new;
212 
213  if (old->prev)
214  old->prev->next = new;
215 
216  new->next = old->next;
217  new->prev = old->prev;
218 }
219 
220 static inline void list_link(struct list_head *h_o_n, struct list_head *t_o_o)
221 {
222  struct list_head *h_o_o = t_o_o->next;
223  struct list_head *t_o_n = h_o_n->prev;
224 
225  t_o_o->next = h_o_n;
226  h_o_n->prev = t_o_o;
227 
228  h_o_o->prev = t_o_n;
229  t_o_n->next = h_o_o;
230 }
231