29 #ifndef _LINUX_LIST_H_
30 #define _LINUX_LIST_H_
44 #define LIST_HEAD_INIT(name) { &(name), &(name) }
46 #define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
57 return (head->
next == head);
61 list_is_first(
const struct list_head *list,
64 return list->
prev == head;
68 list_is_last(
const struct list_head *list,
71 return list->
next == head;
103 INIT_LIST_HEAD(entry);
106 #define list_entry(ptr, type, field) container_of(ptr, type, field)
107 #define list_first_entry(ptr, type, field) list_entry((ptr)->next, type, field)
108 #define list_last_entry(ptr, type, field) list_entry((ptr)->prev, type, field)
110 #define list_for_each(p, head) \
111 for (p = (head)->next; p != (head); p = p->next)
113 #define list_for_each_safe(p, n, head) \
114 for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
116 #define list_for_each_entry(p, h, field) \
117 for (p = list_first_entry(h, typeof(*p), field); &p->field != (h); \
118 p = list_entry(p->field.next, typeof(*p), field))
120 #define list_for_each_entry_safe(p, n, h, field) \
121 for (p = list_first_entry(h, typeof(*p), field), \
122 n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
123 p = n, n = list_entry(n->field.next, typeof(*n), field))
125 #define list_for_each_entry_reverse(p, h, field) \
126 for (p = list_last_entry(h, typeof(*p), field); &p->field != (h); \
127 p = list_entry(p->field.prev, typeof(*p), field))
129 #define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
130 #define list_for_each_prev_safe(p, n, h) for (p = (h)->prev, n = p->prev; p != (h); p = n, n = p->prev)
135 _list_add(_new, head, head->
next);
141 _list_add(_new, head->
prev, head);
148 list_add(list, head);
155 list_add_tail(entry, head);
165 if (list_empty(list))
179 _list_splice(list, head, head->
next);
185 _list_splice(list, head->
prev, head);
191 _list_splice(list, head, head->
next);
192 INIT_LIST_HEAD(list);
198 _list_splice(list, head->
prev, head);
199 INIT_LIST_HEAD(list);
struct list_head * next
Definition: list.h:40
struct list_head * prev
Definition: list.h:41