29 #ifndef _LINUX_LIST_H_
30 #define _LINUX_LIST_H_
38 #define container_of(ptr, type, member) \
40 const __typeof__(((type *) NULL)->member) *__mptr = (ptr); \
41 (type *) ((char *) __mptr - offsetof(type, member)); \
45 #ifndef container_of_safe
46 #define container_of_safe(ptr, type, member) \
48 const __typeof__(((type *) NULL)->member) *__mptr = (ptr); \
49 __mptr ? (type *)((char *) __mptr - offsetof(type, member)) : NULL; \
58 #define LIST_HEAD_INIT(name) { &(name), &(name) }
60 #define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
71 return (head->
next == head);
78 return list->
prev == head;
85 return list->
next == head;
120 #define list_entry(ptr, type, field) container_of(ptr, type, field)
121 #define list_first_entry(ptr, type, field) list_entry((ptr)->next, type, field)
122 #define list_last_entry(ptr, type, field) list_entry((ptr)->prev, type, field)
123 #define list_next_entry(pos, member) list_entry((pos)->member.next, typeof(*(pos)), member)
124 #define list_entry_is_h(p, h, field) (&p->field == (h))
126 #define list_for_each(p, head) \
127 for (p = (head)->next; p != (head); p = p->next)
129 #define list_for_each_safe(p, n, head) \
130 for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
132 #define list_for_each_entry(p, h, field) \
133 for (p = list_first_entry(h, __typeof__(*p), field); &p->field != (h); \
134 p = list_entry(p->field.next, __typeof__(*p), field))
136 #define list_for_each_entry_continue(p, h, field) \
137 for (p = list_next_entry(p, field); \
138 !list_entry_is_h(p, h, field); \
139 p = list_next_entry(p, field))
141 #define list_for_each_entry_continue_reverse(p, h, field) \
142 for (p = list_prev_entry(p, field); \
143 !list_entry_is_h(p, h, field); \
144 p = list_prev_entry(p, field))
146 #define list_for_each_entry_safe(p, n, h, field) \
147 for (p = list_first_entry(h, __typeof__(*p), field), \
148 n = list_entry(p->field.next, __typeof__(*p), field); &p->field != (h);\
149 p = n, n = list_entry(n->field.next, __typeof__(*n), field))
151 #define list_for_each_entry_reverse(p, h, field) \
152 for (p = list_last_entry(h, __typeof__(*p), field); &p->field != (h); \
153 p = list_entry(p->field.prev, __typeof__(*p), field))
155 #define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
156 #define list_for_each_prev_safe(p, n, h) for (p = (h)->prev, n = p->prev; p != (h); p = n, n = p->prev)
static void list_splice(const struct list_head *list, struct list_head *head)
static void list_splice_tail_init(struct list_head *list, struct list_head *head)
static void _list_splice(const struct list_head *list, struct list_head *prev, struct list_head *next)
static void list_move_tail(struct list_head *entry, struct list_head *head)
static bool list_is_first(const struct list_head *list, const struct list_head *head)
static void list_add_tail(struct list_head *_new, struct list_head *head)
static bool list_empty(const struct list_head *head)
static void list_add(struct list_head *_new, struct list_head *head)
static void list_splice_init(struct list_head *list, struct list_head *head)
static void _list_add(struct list_head *_new, struct list_head *prev, struct list_head *next)
static void list_del(struct list_head *entry)
static bool list_is_last(const struct list_head *list, const struct list_head *head)
static void _list_del(struct list_head *entry)
static void list_del_init(struct list_head *entry)
static void list_splice_tail(struct list_head *list, struct list_head *head)
static void INIT_LIST_HEAD(struct list_head *list)
static void list_move(struct list_head *list, struct list_head *head)