47#define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) })
59#define spa_list_is_empty(l) ((l)->next == (l))
85#define spa_list_first(head, type, member) \
86 SPA_CONTAINER_OF((head)->next, type, member)
88#define spa_list_last(head, type, member) \
89 SPA_CONTAINER_OF((head)->prev, type, member)
91#define spa_list_append(list, item) \
92 spa_list_insert((list)->prev, item)
94#define spa_list_prepend(list, item) \
95 spa_list_insert(list, item)
97#define spa_list_is_end(pos, head, member) \
98 (&(pos)->member == (head))
100#define spa_list_next(pos, member) \
101 SPA_CONTAINER_OF((pos)->member.next, __typeof__(*(pos)), member)
103#define spa_list_prev(pos, member) \
104 SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*(pos)), member)
106#define spa_list_consume(pos, head, member) \
107 for ((pos) = spa_list_first(head, __typeof__(*(pos)), member); \
108 !spa_list_is_empty(head); \
109 (pos) = spa_list_first(head, __typeof__(*(pos)), member))
111#define spa_list_for_each_next(pos, head, curr, member) \
112 for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \
113 !spa_list_is_end(pos, head, member); \
114 (pos) = spa_list_next(pos, member))
116#define spa_list_for_each_prev(pos, head, curr, member) \
117 for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \
118 !spa_list_is_end(pos, head, member); \
119 (pos) = spa_list_prev(pos, member))
121#define spa_list_for_each(pos, head, member) \
122 spa_list_for_each_next(pos, head, head, member)
124#define spa_list_for_each_reverse(pos, head, member) \
125 spa_list_for_each_prev(pos, head, head, member)
127#define spa_list_for_each_safe_next(pos, tmp, head, curr, member) \
128 for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \
129 (tmp) = spa_list_next(pos, member), \
130 !spa_list_is_end(pos, head, member); \
133#define spa_list_for_each_safe_prev(pos, tmp, head, curr, member) \
134 for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \
135 (tmp) = spa_list_prev(pos, member), \
136 !spa_list_is_end(pos, head, member); \
139#define spa_list_for_each_safe(pos, tmp, head, member) \
140 spa_list_for_each_safe_next(pos, tmp, head, head, member)
142#define spa_list_for_each_safe_reverse(pos, tmp, head, member) \
143 spa_list_for_each_safe_prev(pos, tmp, head, head, member)
145#define spa_list_cursor_start(cursor, head, member) \
146 spa_list_prepend(head, &(cursor).member)
148#define spa_list_for_each_cursor(pos, cursor, head, member) \
149 for((pos) = spa_list_first(&(cursor).member, __typeof__(*(pos)), member); \
150 spa_list_remove(&(pos)->member), \
151 spa_list_append(&(cursor).member, &(pos)->member), \
152 !spa_list_is_end(pos, head, member); \
153 (pos) = spa_list_next(&(cursor), member))
155#define spa_list_cursor_end(cursor, member) \
156 spa_list_remove(&(cursor).member)
static void spa_list_insert(struct spa_list *list, struct spa_list *elem)
Definition: list.h:67
static int spa_list_is_initialized(struct spa_list *list)
Definition: list.h:60
static void spa_list_init(struct spa_list *list)
Definition: list.h:55
static void spa_list_remove(struct spa_list *elem)
Definition: list.h:85
#define spa_list_is_empty(l)
Definition: list.h:65
#define SPA_LIST_INIT(list)
Definition: list.h:53
static void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
Definition: list.h:75
struct spa_list * prev
Definition: list.h:49
struct spa_list * next
Definition: list.h:48