Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
sflist.h File Reference

Single-linked list implementation. More...

#include <stddef.h>
#include <stdbool.h>
#include <sys/__assert.h>
#include "list_gen.h"

Go to the source code of this file.

Macros

#define SYS_SFLIST_FOR_EACH_NODE(__sl, __sn)    Z_GENLIST_FOR_EACH_NODE(sflist, __sl, __sn)
 Provide the primitive to iterate on a list Note: the loop is unsafe and thus __sn should not be removed. More...
 
#define SYS_SFLIST_ITERATE_FROM_NODE(__sl, __sn)    Z_GENLIST_ITERATE_FROM_NODE(sflist, __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. More...
 
#define SYS_SFLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns)    Z_GENLIST_FOR_EACH_NODE_SAFE(sflist, __sl, __sn, __sns)
 Provide the primitive to safely iterate on a list Note: __sn can be removed, it will not break the loop. More...
 
#define SYS_SFLIST_CONTAINER(__ln, __cn, __n)    Z_GENLIST_CONTAINER(__ln, __cn, __n)
 
#define SYS_SFLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n)    Z_GENLIST_PEEK_HEAD_CONTAINER(sflist, __sl, __cn, __n)
 
#define SYS_SFLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n)    Z_GENLIST_PEEK_TAIL_CONTAINER(sflist, __sl, __cn, __n)
 
#define SYS_SFLIST_PEEK_NEXT_CONTAINER(__cn, __n)    Z_GENLIST_PEEK_NEXT_CONTAINER(sflist, __cn, __n)
 
#define SYS_SFLIST_FOR_EACH_CONTAINER(__sl, __cn, __n)    Z_GENLIST_FOR_EACH_CONTAINER(sflist, __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. More...
 
#define SYS_SFLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n)    Z_GENLIST_FOR_EACH_CONTAINER_SAFE(sflist, __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. More...
 
#define SYS_SFLIST_STATIC_INIT(ptr_to_list)   {NULL, NULL}
 
#define SYS_SFLIST_FLAGS_MASK   0x3UL
 

Typedefs

typedef uint32_t unative_t
 
typedef struct _sfnode sys_sfnode_t
 
typedef struct _sflist sys_sflist_t
 

Functions

static void sys_sflist_init (sys_sflist_t *list)
 Initialize a list. More...
 
static uint8_t sys_sfnode_flags_get (sys_sfnode_t *node)
 Fetch flags value for a particular sfnode. More...
 
static sys_sfnode_tsys_sflist_peek_head (sys_sflist_t *list)
 Peek the first node from the list. More...
 
static sys_sfnode_tsys_sflist_peek_tail (sys_sflist_t *list)
 Peek the last node from the list. More...
 
static void sys_sfnode_init (sys_sfnode_t *node, uint8_t flags)
 Initialize an sflist node. More...
 
static void sys_sfnode_flags_set (sys_sfnode_t *node, uint8_t flags)
 Set flags value for an sflist node. More...
 
static bool sys_sflist_is_empty (sys_sflist_t *list)
 Test if the given list is empty. More...
 
static sys_sfnode_tsys_sflist_peek_next_no_check (sys_sfnode_t *node)
 Peek the next node from current node, node is not NULL. More...
 
static sys_sfnode_tsys_sflist_peek_next (sys_sfnode_t *node)
 Peek the next node from current node. More...
 
static void sys_sflist_prepend (sys_sflist_t *list, sys_sfnode_t *node)
 Prepend a node to the given list. More...
 
static void sys_sflist_append (sys_sflist_t *list, sys_sfnode_t *node)
 Append a node to the given list. More...
 
static void sys_sflist_append_list (sys_sflist_t *list, void *head, void *tail)
 Append a list to the given list. More...
 
static void sys_sflist_merge_sflist (sys_sflist_t *list, sys_sflist_t *list_to_append)
 merge two sflists, appending the second one to the first More...
 
static void sys_sflist_insert (sys_sflist_t *list, sys_sfnode_t *prev, sys_sfnode_t *node)
 Insert a node to the given list. More...
 
static sys_sfnode_tsys_sflist_get_not_empty (sys_sflist_t *list)
 Fetch and remove the first node of the given list. More...
 
static sys_sfnode_tsys_sflist_get (sys_sflist_t *list)
 Fetch and remove the first node of the given list. More...
 
static void sys_sflist_remove (sys_sflist_t *list, sys_sfnode_t *prev_node, sys_sfnode_t *node)
 Remove a node. More...
 
static bool sys_sflist_find_and_remove (sys_sflist_t *list, sys_sfnode_t *node)
 Find and remove a node from a list. More...
 

Detailed Description

Single-linked list implementation.

Single-linked list implementation using inline macros/functions. This API is not thread safe, and thus if a list is used across threads, calls to functions must be protected with synchronization primitives.

Typedef Documentation

◆ sys_sflist_t

typedef struct _sflist sys_sflist_t

◆ sys_sfnode_t

typedef struct _sfnode sys_sfnode_t

◆ unative_t