16 #define container_of(ptr, type, member) \
17 ((type *) ((void *) ptr - offsetof(type, member)))
26 #define list_entry(ptr, type, member) container_of(ptr, type, member)
35 #define list_first_entry(ptr, type, member) \
36 list_entry((ptr)->next, type, member)
44 #define list_prev_entry(pos, member) \
45 list_entry((pos)->member.prev, typeof(*(pos)), member)
53 #define list_next_entry(pos, member) \
54 list_entry((pos)->member.next, typeof(*(pos)), member)
62 #define list_entry_is_head(pos, head, member) (&pos->member == (head))
70 #define list_for_each(pos, head) \
71 for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next)
79 #define list_for_each_safe(pos, _next, head) \
80 for (pos = (head)->next, _next = (pos)->next; (pos) != (head); \
81 (pos) = _next, _next = (pos)->next)
90 #define list_for_each_entry(pos, head, member) \
91 for (pos = list_first_entry(head, __typeof__(*pos), member); \
92 &pos->member != (head); pos = list_next_entry(pos, member))
99 #define LIST_HEAD_INIT(name) \
101 .prev = (&name), .next = (&name) \
109 #define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
void list_add(struct list_head *new, struct list_head *head)
Add new list member to the list.
Definition: list.c:31
int list_empty(struct list_head *head)
Check if the list is empty.
Definition: list.c:9
void list_move(struct list_head *list, struct list_head *new_head)
Move a list member from original list to another.
Definition: list.c:39
void list_del_init(struct list_head *entry)
Delete and force initialize a list member from its list.
Definition: list.c:25
int list_is_last(const struct list_head *list, const struct list_head *head)
Check if the list object is the last of the list.
Definition: list.c:14
void list_del(struct list_head *entry)
Delete a list item from its list.
Definition: list.c:19
void INIT_LIST_HEAD(struct list_head *list)
Initialize the list head.
Definition: list.c:3