20#ifndef ZEPHYR_INCLUDE_SYS_DLIST_H_
21#define ZEPHYR_INCLUDE_SYS_DLIST_H_
67#define SYS_DLIST_FOR_EACH_NODE(__dl, __dn) \
68 for (__dn = sys_dlist_peek_head(__dl); __dn != NULL; \
69 __dn = sys_dlist_peek_next(__dl, __dn))
91#define SYS_DLIST_ITERATE_FROM_NODE(__dl, __dn) \
92 for (__dn = __dn ? sys_dlist_peek_next_no_check(__dl, __dn) \
93 : sys_dlist_peek_head(__dl); \
95 __dn = sys_dlist_peek_next(__dl, __dn))
113#define SYS_DLIST_FOR_EACH_NODE_SAFE(__dl, __dn, __dns) \
114 for (__dn = sys_dlist_peek_head(__dl), \
115 __dns = sys_dlist_peek_next(__dl, __dn); \
116 __dn != NULL; __dn = __dns, \
117 __dns = sys_dlist_peek_next(__dl, __dn))
127#define SYS_DLIST_CONTAINER(__dn, __cn, __n) \
128 ((__dn != NULL) ? CONTAINER_OF(__dn, __typeof__(*__cn), __n) : NULL)
136#define SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n) \
137 SYS_DLIST_CONTAINER(sys_dlist_peek_head(__dl), __cn, __n)
146#define SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n) \
148 SYS_DLIST_CONTAINER(sys_dlist_peek_next(__dl, &(__cn->__n)), \
165#define SYS_DLIST_FOR_EACH_CONTAINER(__dl, __cn, __n) \
166 for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n); \
168 __cn = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n))
185#define SYS_DLIST_FOR_EACH_CONTAINER_SAFE(__dl, __cn, __cns, __n) \
186 for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n), \
187 __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n); \
188 __cn != NULL; __cn = __cns, \
189 __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n))
205#define SYS_DLIST_STATIC_INIT(ptr_to_list) { {(ptr_to_list)}, {(ptr_to_list)} }
231 return node->next != NULL;
245 return list->head == node;
259 return list->tail == node;
272 return list->head == list;
287 return list->head != list->tail;
332 return (node == list->tail) ? NULL : node->next;
366 return (node == list->head) ? NULL : node->prev;
456 node->next = successor;
458 successor->prev = node;
486 while ((
pos != NULL) && (cond(
pos,
data) == 0)) {
static bool sys_dlist_has_multiple_nodes(sys_dlist_t *list)
check if more than one node present
Definition: dlist.h:285
static void sys_dlist_remove(sys_dnode_t *node)
remove a specific node from a list
Definition: dlist.h:508
static void sys_dlist_append(sys_dlist_t *list, sys_dnode_t *node)
add node to tail of list
Definition: dlist.h:410
static sys_dnode_t * sys_dlist_peek_prev(sys_dlist_t *list, sys_dnode_t *node)
get a reference to the previous item in the list
Definition: dlist.h:380
static sys_dnode_t * sys_dlist_get(sys_dlist_t *list)
get the first node in a list
Definition: dlist.h:528
static bool sys_dlist_is_tail(sys_dlist_t *list, sys_dnode_t *node)
check if a node is the list's tail
Definition: dlist.h:257
struct _dnode sys_dnode_t
Definition: dlist.h:49
static void sys_dlist_insert_at(sys_dlist_t *list, sys_dnode_t *node, int(*cond)(sys_dnode_t *node, void *data), void *data)
insert node at position
Definition: dlist.h:478
static void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node)
add node to head of list
Definition: dlist.h:432
static sys_dnode_t * sys_dlist_peek_head(sys_dlist_t *list)
get a reference to the head item in the list
Definition: dlist.h:298
static sys_dnode_t * sys_dlist_peek_head_not_empty(sys_dlist_t *list)
get a reference to the head item in the list
Definition: dlist.h:313
static sys_dnode_t * sys_dlist_peek_next(sys_dlist_t *list, sys_dnode_t *node)
get a reference to the next item in the list
Definition: dlist.h:345
static bool sys_dlist_is_head(sys_dlist_t *list, sys_dnode_t *node)
check if a node is the list's head
Definition: dlist.h:243
static sys_dnode_t * sys_dlist_peek_prev_no_check(sys_dlist_t *list, sys_dnode_t *node)
get a reference to the previous item in the list, node is not NULL
Definition: dlist.h:363
static sys_dnode_t * sys_dlist_peek_next_no_check(sys_dlist_t *list, sys_dnode_t *node)
get a reference to the next item in the list, node is not NULL
Definition: dlist.h:329
static void sys_dlist_insert(sys_dnode_t *successor, sys_dnode_t *node)
Insert a node into a list.
Definition: dlist.h:451
struct _dnode sys_dlist_t
Definition: dlist.h:48
static bool sys_dlist_is_empty(sys_dlist_t *list)
check if the list is empty
Definition: dlist.h:270
static bool sys_dnode_is_linked(const sys_dnode_t *node)
check if a node is a member of any list
Definition: dlist.h:229
static sys_dnode_t * sys_dlist_peek_tail(sys_dlist_t *list)
get a reference to the tail item in the list
Definition: dlist.h:394
static void sys_dnode_init(sys_dnode_t *node)
initialize node to its state when not in a list
Definition: dlist.h:215
static void sys_dlist_init(sys_dlist_t *list)
initialize list to its empty state
Definition: dlist.h:199
static int pos
Definition: printk.c:11
static fdata_t data[2]
Definition: test_fifo_contexts.c:15