Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
slist.h File Reference
#include <stddef.h>
#include <stdbool.h>
#include "list_gen.h"

Go to the source code of this file.

Macros

#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn)    Z_GENLIST_FOR_EACH_NODE(slist, __sl, __sn)
 Provide the primitive to iterate on a list Note: the loop is unsafe and thus __sn should not be removed.
 
#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn)    Z_GENLIST_ITERATE_FROM_NODE(slist, __sl, __sn)
 Provide the primitive to iterate on a list, from a node in the list Note: the loop is unsafe and thus __sn should not be removed.
 
#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns)    Z_GENLIST_FOR_EACH_NODE_SAFE(slist, __sl, __sn, __sns)
 Provide the primitive to safely iterate on a list Note: __sn can be removed, it will not break the loop.
 
#define SYS_SLIST_CONTAINER(__ln, __cn, __n)    Z_GENLIST_CONTAINER(__ln, __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_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n)    Z_GENLIST_PEEK_HEAD_CONTAINER(slist, __sl, __cn, __n)
 Provide the primitive to peek container of the list head.
 
#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n)    Z_GENLIST_PEEK_TAIL_CONTAINER(slist, __sl, __cn, __n)
 Provide the primitive to peek container of the list tail.
 
#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n)    Z_GENLIST_PEEK_NEXT_CONTAINER(slist, __cn, __n)
 Provide the primitive to peek the next container.
 
#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n)    Z_GENLIST_FOR_EACH_CONTAINER(slist, __sl, __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_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n)    Z_GENLIST_FOR_EACH_CONTAINER_SAFE(slist, __sl, __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_SLIST_STATIC_INIT(ptr_to_list)   {NULL, NULL}
 Statically initialize a single-linked list.
 

Typedefs

typedef struct _snode sys_snode_t
 Single-linked list node structure.
 
typedef struct _slist sys_slist_t
 Single-linked list structure.
 

Functions

static void sys_slist_init (sys_slist_t *list)
 Initialize a list.
 
static sys_snode_tsys_slist_peek_head (sys_slist_t *list)
 Peek the first node from the list.
 
static sys_snode_tsys_slist_peek_tail (sys_slist_t *list)
 Peek the last node from the list.
 
static bool sys_slist_is_empty (sys_slist_t *list)
 Test if the given list is empty.
 
static sys_snode_tsys_slist_peek_next_no_check (sys_snode_t *node)
 Peek the next node from current node, node is not NULL.
 
static sys_snode_tsys_slist_peek_next (sys_snode_t *node)
 Peek the next node from current node.
 
static void sys_slist_prepend (sys_slist_t *list, sys_snode_t *node)
 Prepend a node to the given list.
 
static void sys_slist_append (sys_slist_t *list, sys_snode_t *node)
 Append a node to the given list.
 
static void sys_slist_append_list (sys_slist_t *list, void *head, void *tail)
 Append a list to the given list.
 
static void sys_slist_merge_slist (sys_slist_t *list, sys_slist_t *list_to_append)
 merge two slists, appending the second one to the first
 
static void sys_slist_insert (sys_slist_t *list, sys_snode_t *prev, sys_snode_t *node)
 Insert a node to the given list.
 
static sys_snode_tsys_slist_get_not_empty (sys_slist_t *list)
 Fetch and remove the first node of the given list.
 
static sys_snode_tsys_slist_get (sys_slist_t *list)
 Fetch and remove the first node of the given list.
 
static void sys_slist_remove (sys_slist_t *list, sys_snode_t *prev_node, sys_snode_t *node)
 Remove a node.
 
static bool sys_slist_find_and_remove (sys_slist_t *list, sys_snode_t *node)
 Find and remove a node from a list.
 
static bool sys_slist_find (sys_slist_t *list, sys_snode_t *node, sys_snode_t **prev)
 Find if a node is already linked in a singly linked list.
 
static size_t sys_slist_len (sys_slist_t *list)
 Compute the size of the given list in O(n) time.