5 #ifndef FIRM_ADT_LIST_H
6 #define FIRM_ADT_LIST_H
32 #define LIST_HEAD_INIT(name) { &(name), &(name) }
35 #define LIST_HEAD(name) \
36 struct list_head name = LIST_HEAD_INIT(name)
39 #define INIT_LIST_HEAD(ptr) do { \
40 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
48 #define _list_container_of(ptr, type, member) \
49 ((type *) ((char *) (ptr) - offsetof(type, member)))
62 next->prev = new_node;
63 new_node->next = next;
64 new_node->prev = prev;
65 prev->next = new_node;
162 return head->next == head;
219 #define list_entry(ptr, type, member) \
220 _list_container_of(ptr, type, member)
227 #define list_for_each(pos, head) \
228 for (pos = (head)->next; pos != (head); pos = pos->next)
235 #define list_for_each_prev(pos, head) \
236 for (pos = (head)->prev; pos != (head); pos = pos->prev)
244 #define list_for_each_safe(pos, n, head) \
245 for (pos = (head)->next, n = pos->next; pos != (head); \
246 pos = n, n = pos->next)
255 #define list_for_each_entry(type, pos, head, member) \
256 for (type *pos = list_entry((head)->next, type, member); \
257 &pos->member != (head); \
258 pos = list_entry(pos->member.next, type, member))
267 #define list_for_each_entry_reverse(type, pos, head, member) \
268 for (type *pos = list_entry((head)->prev, type, member); \
269 &pos->member != (head); \
270 pos = list_entry(pos->member.prev, type, member))
281 #define list_for_each_entry_safe(type, pos, n, head, member) \
282 for (type *pos = list_entry((head)->next, type, member), \
283 *n = list_entry(pos->member.next, type, member); \
284 &pos->member != (head); \
285 pos = n, n = list_entry(n->member.next, type, member))
static void __list_del(struct list_head *prev, struct list_head *next)
Deletes a list entry by making the prev/next entries point to each other.
struct list_head list_head
List Header.
static void list_del(struct list_head *entry)
Deletes entry from list.
static void __list_splice(struct list_head *list, struct list_head *head)
Join two nonempty lists.
static void list_move_tail(struct list_head *list, struct list_head *head)
Deletes from one list and add as another's tail.
static void list_add(struct list_head *new_node, struct list_head *head)
Adds a new entry.
static void list_move(struct list_head *list, struct list_head *head)
Deletes from one list and add as another's head.
static void list_del_init(struct list_head *entry)
Deletes entry from list and reinitialize it.
static void list_splice(struct list_head *list, struct list_head *head)
list_splice - join two lists
#define INIT_LIST_HEAD(ptr)
Initializes a list header.
static void __list_add(struct list_head *new_node, struct list_head *prev, struct list_head *next)
Inserts a new entry between two known consecutive entries.
static void list_add_tail(struct list_head *new_node, struct list_head *head)
Adds a new entry.
static void list_splice_init(struct list_head *list, struct list_head *head)
list_splice_init - join two lists and reinitialize the emptied list.
static int list_empty(const struct list_head *head)
Tests whether a list is empty.