Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dlist.h File Reference
#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define SYS_DLIST_FOR_EACH_NODE(__dl, __dn)
 Provide the primitive to iterate on a list Note: the loop is unsafe and thus __dn should not be removed.
 
#define SYS_DLIST_ITERATE_FROM_NODE(__dl, __dn)
 Provide the primitive to iterate on a list, from a node in the list Note: the loop is unsafe and thus __dn should not be removed.
 
#define SYS_DLIST_FOR_EACH_NODE_SAFE(__dl, __dn, __dns)
 Provide the primitive to safely iterate on a list Note: __dn can be removed, it will not break the loop.
 
#define SYS_DLIST_CONTAINER(__dn, __cn, __n)
 Provide the primitive to resolve the container of a list node Note: it is safe to use with NULL pointer nodes.
 
#define SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n)
 Provide the primitive to peek container of the list head.
 
#define SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n)
 Provide the primitive to peek the next container.
 
#define SYS_DLIST_FOR_EACH_CONTAINER(__dl, __cn, __n)
 Provide the primitive to iterate on a list under a container Note: the loop is unsafe and thus __cn should not be detached.
 
#define SYS_DLIST_FOR_EACH_CONTAINER_SAFE(__dl, __cn, __cns, __n)
 Provide the primitive to safely iterate on a list under a container Note: __cn can be detached, it will not break the loop.
 
#define SYS_DLIST_STATIC_INIT(ptr_to_list)
 Static initializer for a doubly-linked list.
 

Typedefs

typedef struct _dnode sys_dlist_t
 Doubly-linked list structure.
 
typedef struct _dnode sys_dnode_t
 Doubly-linked list node structure.
 

Functions

static void sys_dlist_init (sys_dlist_t *list)
 initialize list to its empty state
 
static void sys_dnode_init (sys_dnode_t *node)
 initialize node to its state when not in a list
 
static bool sys_dnode_is_linked (const sys_dnode_t *node)
 check if a node is a member of any list
 
static bool sys_dlist_is_head (sys_dlist_t *list, sys_dnode_t *node)
 check if a node is the list's head
 
static bool sys_dlist_is_tail (sys_dlist_t *list, sys_dnode_t *node)
 check if a node is the list's tail
 
static bool sys_dlist_is_empty (sys_dlist_t *list)
 check if the list is empty
 
static bool sys_dlist_has_multiple_nodes (sys_dlist_t *list)
 check if more than one node present
 
static sys_dnode_tsys_dlist_peek_head (sys_dlist_t *list)
 get a reference to the head item in the list
 
static sys_dnode_tsys_dlist_peek_head_not_empty (sys_dlist_t *list)
 get a reference to the head item in the list
 
static sys_dnode_tsys_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
 
static sys_dnode_tsys_dlist_peek_next (sys_dlist_t *list, sys_dnode_t *node)
 get a reference to the next item in the list
 
static sys_dnode_tsys_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
 
static sys_dnode_tsys_dlist_peek_prev (sys_dlist_t *list, sys_dnode_t *node)
 get a reference to the previous item in the list
 
static sys_dnode_tsys_dlist_peek_tail (sys_dlist_t *list)
 get a reference to the tail item in the list
 
static void sys_dlist_append (sys_dlist_t *list, sys_dnode_t *node)
 add node to tail of list
 
static void sys_dlist_prepend (sys_dlist_t *list, sys_dnode_t *node)
 add node to head of list
 
static void sys_dlist_insert (sys_dnode_t *successor, sys_dnode_t *node)
 Insert a node into a list.
 
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
 
static void sys_dlist_remove (sys_dnode_t *node)
 remove a specific node from a list
 
static sys_dnode_tsys_dlist_get (sys_dlist_t *list)
 get the first node in a list
 
static size_t sys_dlist_len (sys_dlist_t *list)
 Compute the size of the given list in O(n) time.