35#define as_linked_list list_node_t list_node
38#define LIST_HEAD_INIT(container) { .prev = &(container), .next = &(container) }
41#define LIST_NODE_INIT(container) LIST_HEAD_INIT(container.list_node)
46#define list_entry(node, type) container_of((node), type, list_node)
51#define list_prev_entry(item, type) list_entry(list_node(item)->prev, type)
56#define list_next_entry(item, type) list_entry(list_node(item)->next, type)
62#define list_node_next_entry(node, type) container_of((node)->next, type, list_node)
68#define list_node(element) (&((element)->list_node))
70#define list_prepend(element, item) list_node_prepend(list_node(element), list_node(item))
71#define list_append(element, item) list_node_append(list_node(element), list_node(item))
72#define list_insert_before(element, item) list_node_insert_before(list_node(element), list_node(item))
73#define list_insert_after(element, item) list_node_insert_after(list_node(element), list_node(item))
74#define list_remove(element) list_node_remove(list_node(element))
83#define list_foreach(t, v, h) \
84 for (__typeof(list_entry(&(h), t)) v = list_entry((h).next, t), __next = list_next_entry(v, t); list_node(v) != &(h); v = __next, __next = list_next_entry(v, t))
86#define list_foreach_reverse(t, v, h) \
87 for (__typeof(list_entry(&(h), t)) v = list_entry((h).prev, t), __next = list_prev_entry(v, t); list_node(v) != &(h); v = __next, __next = list_prev_entry(v, t))
89#define list_node_foreach(v, h) for (list_node_t *v = (h)->next, *__next = v->next; v != (h); v = __next, __next = v->next)
90#define list_node_foreach_reverse(v, h) for (list_node_t *v = (h)->prev, *__next = v->prev; v != (h); v = __next, __next = v->prev)
92#define list_headless_foreach(t, v, h) \
93 for (__typeof(&(h)) v = &(h), __next = list_next_entry(v, t), __head = NULL; (v) != __head; \
94 v = __next, __next = list_next_entry(v, t), __head = __head == NULL ? &(h) : __head)
96#define list_headless_foreach_reverse(t, v, h) \
97 for (__typeof(h) v = (h), __next = list_prev_entry(v, t), __head = NULL; (v) != __head; \
98 v = __next, __next = list_prev_entry(v, t), __head = __head == NULL ? (h) : __head)
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
MOSAPI list_node_t * list_node_pop(list_node_t *head)
MOSAPI void list_node_append(list_node_t *head, list_node_t *item)
MOSAPI void list_node_insert_before(list_node_t *element, list_node_t *item)
MOSAPI void list_node_prepend(list_node_t *head, list_node_t *item)
list_node_t list_head
A linked list head.
MOSAPI bool list_is_empty(const list_node_t *head)
MOSAPI void list_node_remove(list_node_t *link)
MOSAPI void list_node_insert_after(list_node_t *element, list_node_t *item)