include/structures/list.h View source View on GitHub
struct list_head {
struct list_head *next;
};
struct slist_node {
struct slist_node *next;
};
struct slist_head {
struct slist_node *first;
struct slist_node *last;
};
void INIT_LIST_HEAD(struct list_head *list);
void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next);
void list_add(struct list_head *new, struct list_head *head);
void list_add_tail(struct list_head *new, struct list_head *head);
void __list_del(struct list_head *prev, struct list_head *next);
void list_del(struct list_head *entry);
void list_del_init(struct list_head *entry);
int list_empty(const struct list_head *head);
struct list_head list_peek_front(struct list_head *head);
struct list_head list_peek_tail(struct list_head *head);
struct list_head list_pop_front(struct list_head *head);
struct list_head list_pop_front_init(struct list_head *head);
struct list_head list_pop_tail(struct list_head *head);
struct list_head list_pop_tail_init(struct list_head *head);
void __list_splice(const struct list_head *list, struct list_head *prev, struct list_head *next);
void list_splice_init(struct list_head *src, struct list_head *dst);
void list_splice_tail_init(struct list_head *list, struct list_head *head);
void list_sort(struct list_head *head, int (*cmp)(struct list_head *, struct list_head *));
void slist_head_init(struct slist_head *h);
int slist_empty(const struct slist_head *h);
void slist_push_head(struct slist_head *h, struct slist_node *n);
void slist_push_tail(struct slist_head *h, struct slist_node *n);
struct slist_node slist_pop_head(struct slist_head *h);
void slist_remove_node_after(struct slist_head *h, struct slist_node *prev, struct slist_node *target);
#define LIST_HEAD_INIT(name) {&(name), &(name)}
#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
#define list_entry(ptr, type, member) \
((type *) ((char *) (ptr) - (offsetof(type, member))))
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
#define list_for_each_entry_safe_continue(pos, n, head, member) \
for (pos = list_entry(pos->member.next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))