Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Flagged Single-linked list

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
 

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

Macro Definition Documentation

◆ SYS_SFLIST_CONTAINER

#define SYS_SFLIST_CONTAINER (   __ln,
  __cn,
  __n 
)     Z_GENLIST_CONTAINER(__ln, __cn, __n)

◆ SYS_SFLIST_FLAGS_MASK

#define SYS_SFLIST_FLAGS_MASK   0x3UL

◆ SYS_SFLIST_FOR_EACH_CONTAINER

#define SYS_SFLIST_FOR_EACH_CONTAINER (   __sl,
  __cn,
  __n 
)     Z_GENLIST_FOR_EACH_CONTAINER(sflist, __sl, __cn, __n)

#include <include/sys/sflist.h>

Provide the primitive to iterate on a list under a container Note: the loop is unsafe and thus __cn should not be detached.

User MUST add the loop statement curly braces enclosing its own code:

SYS_SFLIST_FOR_EACH_CONTAINER(l, c, n) {
    <user code>
}
Parameters
__slA pointer on a sys_sflist_t to iterate on
__cnA pointer to peek each entry of the list
__nThe field name of sys_sfnode_t within the container struct

◆ SYS_SFLIST_FOR_EACH_CONTAINER_SAFE

#define SYS_SFLIST_FOR_EACH_CONTAINER_SAFE (   __sl,
  __cn,
  __cns,
  __n 
)     Z_GENLIST_FOR_EACH_CONTAINER_SAFE(sflist, __sl, __cn, __cns, __n)

#include <include/sys/sflist.h>

Provide the primitive to safely iterate on a list under a container Note: __cn can be detached, it will not break the loop.

User MUST add the loop statement curly braces enclosing its own code:

SYS_SFLIST_FOR_EACH_NODE_SAFE(l, c, cn, n) {
    <user code>
}
Parameters
__slA pointer on a sys_sflist_t to iterate on
__cnA pointer to peek each entry of the list
__cnsA pointer for the loop to run safely
__nThe field name of sys_sfnode_t within the container struct

◆ SYS_SFLIST_FOR_EACH_NODE

#define SYS_SFLIST_FOR_EACH_NODE (   __sl,
  __sn 
)     Z_GENLIST_FOR_EACH_NODE(sflist, __sl, __sn)

#include <include/sys/sflist.h>

Provide the primitive to iterate on a list Note: the loop is unsafe and thus __sn should not be removed.

User MUST add the loop statement curly braces enclosing its own code:

SYS_SFLIST_FOR_EACH_NODE(l, n) {
    <user code>
}

This and other SYS_SFLIST_*() macros are not thread safe.

Parameters
__slA pointer on a sys_sflist_t to iterate on
__snA sys_sfnode_t pointer to peek each node of the list

◆ SYS_SFLIST_FOR_EACH_NODE_SAFE

#define SYS_SFLIST_FOR_EACH_NODE_SAFE (   __sl,
  __sn,
  __sns 
)     Z_GENLIST_FOR_EACH_NODE_SAFE(sflist, __sl, __sn, __sns)

#include <include/sys/sflist.h>

Provide the primitive to safely iterate on a list Note: __sn can be removed, it will not break the loop.

User MUST add the loop statement curly braces enclosing its own code:

SYS_SFLIST_FOR_EACH_NODE_SAFE(l, n, s) {
    <user code>
}

This and other SYS_SFLIST_*() macros are not thread safe.

Parameters
__slA pointer on a sys_sflist_t to iterate on
__snA sys_sfnode_t pointer to peek each node of the list
__snsA sys_sfnode_t pointer for the loop to run safely

◆ SYS_SFLIST_ITERATE_FROM_NODE

#define SYS_SFLIST_ITERATE_FROM_NODE (   __sl,
  __sn 
)     Z_GENLIST_ITERATE_FROM_NODE(sflist, __sl, __sn)

#include <include/sys/sflist.h>

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.

User MUST add the loop statement curly braces enclosing its own code:

SYS_SFLIST_ITERATE_FROM_NODE(l, n) {
    <user code>
}

Like SYS_SFLIST_FOR_EACH_NODE(), but __dn already contains a node in the list where to start searching for the next entry from. If NULL, it starts from the head.

This and other SYS_SFLIST_*() macros are not thread safe.

Parameters
__slA pointer on a sys_sflist_t to iterate on
__snA sys_sfnode_t pointer to peek each node of the list it contains the starting node, or NULL to start from the head

◆ SYS_SFLIST_PEEK_HEAD_CONTAINER

#define SYS_SFLIST_PEEK_HEAD_CONTAINER (   __sl,
  __cn,
  __n 
)     Z_GENLIST_PEEK_HEAD_CONTAINER(sflist, __sl, __cn, __n)

◆ SYS_SFLIST_PEEK_NEXT_CONTAINER

#define SYS_SFLIST_PEEK_NEXT_CONTAINER (   __cn,
  __n 
)     Z_GENLIST_PEEK_NEXT_CONTAINER(sflist, __cn, __n)

◆ SYS_SFLIST_PEEK_TAIL_CONTAINER

#define SYS_SFLIST_PEEK_TAIL_CONTAINER (   __sl,
  __cn,
  __n 
)     Z_GENLIST_PEEK_TAIL_CONTAINER(sflist, __sl, __cn, __n)

◆ SYS_SFLIST_STATIC_INIT

#define SYS_SFLIST_STATIC_INIT (   ptr_to_list)    {NULL, NULL}

Function Documentation

◆ sys_sflist_append()

static void sys_sflist_append ( sys_sflist_t list,
sys_sfnode_t node 
)
inlinestatic

#include <include/sys/sflist.h>

Append a node to the given list.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
nodeA pointer on the node to append

◆ sys_sflist_append_list()

static void sys_sflist_append_list ( sys_sflist_t list,
void head,
void tail 
)
inlinestatic

#include <include/sys/sflist.h>

Append a list to the given list.

Append a singly-linked, NULL-terminated list consisting of nodes containing the pointer to the next node as the first element of a node, to list. This and other sys_sflist_*() functions are not thread safe.

FIXME: Why are the element parameters void *?

Parameters
listA pointer on the list to affect
headA pointer to the first element of the list to append
tailA pointer to the last element of the list to append

◆ sys_sflist_find_and_remove()

static bool sys_sflist_find_and_remove ( sys_sflist_t list,
sys_sfnode_t node 
)
inlinestatic

#include <include/sys/sflist.h>

Find and remove a node from a list.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
nodeA pointer on the node to remove from the list
Returns
true if node was removed

◆ sys_sflist_get()

static sys_sfnode_t * sys_sflist_get ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Fetch and remove the first node of the given list.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
Returns
A pointer to the first node of the list (or NULL if empty)

◆ sys_sflist_get_not_empty()

static sys_sfnode_t * sys_sflist_get_not_empty ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Fetch and remove the first node of the given list.

List must be known to be non-empty. This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
Returns
A pointer to the first node of the list

◆ sys_sflist_init()

static void sys_sflist_init ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Initialize a list.

Parameters
listA pointer on the list to initialize

◆ sys_sflist_insert()

static void sys_sflist_insert ( sys_sflist_t list,
sys_sfnode_t prev,
sys_sfnode_t node 
)
inlinestatic

#include <include/sys/sflist.h>

Insert a node to the given list.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
prevA pointer on the previous node
nodeA pointer on the node to insert

◆ sys_sflist_is_empty()

static bool sys_sflist_is_empty ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Test if the given list is empty.

Parameters
listA pointer on the list to test
Returns
a boolean, true if it's empty, false otherwise

◆ sys_sflist_merge_sflist()

static void sys_sflist_merge_sflist ( sys_sflist_t list,
sys_sflist_t list_to_append 
)
inlinestatic

#include <include/sys/sflist.h>

merge two sflists, appending the second one to the first

When the operation is completed, the appending list is empty. This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
list_to_appendA pointer to the list to append.

◆ sys_sflist_peek_head()

static sys_sfnode_t * sys_sflist_peek_head ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Peek the first node from the list.

Parameters
listA point on the list to peek the first node from
Returns
A pointer on the first node of the list (or NULL if none)

◆ sys_sflist_peek_next()

static sys_sfnode_t * sys_sflist_peek_next ( sys_sfnode_t node)
inlinestatic

#include <include/sys/sflist.h>

Peek the next node from current node.

Parameters
nodeA pointer on the node where to peek the next node
Returns
a pointer on the next node (or NULL if none)

◆ sys_sflist_peek_next_no_check()

static sys_sfnode_t * sys_sflist_peek_next_no_check ( sys_sfnode_t node)
inlinestatic

#include <include/sys/sflist.h>

Peek the next node from current node, node is not NULL.

Faster then sys_sflist_peek_next() if node is known not to be NULL.

Parameters
nodeA pointer on the node where to peek the next node
Returns
a pointer on the next node (or NULL if none)

◆ sys_sflist_peek_tail()

static sys_sfnode_t * sys_sflist_peek_tail ( sys_sflist_t list)
inlinestatic

#include <include/sys/sflist.h>

Peek the last node from the list.

Parameters
listA point on the list to peek the last node from
Returns
A pointer on the last node of the list (or NULL if none)

◆ sys_sflist_prepend()

static void sys_sflist_prepend ( sys_sflist_t list,
sys_sfnode_t node 
)
inlinestatic

#include <include/sys/sflist.h>

Prepend a node to the given list.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
nodeA pointer on the node to prepend

◆ sys_sflist_remove()

static void sys_sflist_remove ( sys_sflist_t list,
sys_sfnode_t prev_node,
sys_sfnode_t node 
)
inlinestatic

#include <include/sys/sflist.h>

Remove a node.

This and other sys_sflist_*() functions are not thread safe.

Parameters
listA pointer on the list to affect
prev_nodeA pointer on the previous node (can be NULL, which means the node is the list's head)
nodeA pointer on the node to remove

◆ sys_sfnode_flags_get()

static uint8_t sys_sfnode_flags_get ( sys_sfnode_t node)
inlinestatic

#include <include/sys/sflist.h>

Fetch flags value for a particular sfnode.

Parameters
nodeA pointer to the node to fetch flags from
Returns
The value of flags, which will be between 0 and 3

◆ sys_sfnode_flags_set()

static void sys_sfnode_flags_set ( sys_sfnode_t node,
uint8_t  flags 
)
inlinestatic

#include <include/sys/sflist.h>

Set flags value for an sflist node.

Set a flags value for this slist node, which can be a value between 0 and 3. These flags will persist even if the node is moved around within a list, removed, or transplanted to a different slist.

Parameters
nodeA pointer to the node to set the flags on
flagsA value between 0 and 3 to set the flags value

◆ sys_sfnode_init()

static void sys_sfnode_init ( sys_sfnode_t node,
uint8_t  flags 
)
inlinestatic

#include <include/sys/sflist.h>

Initialize an sflist node.

Set an initial flags value for this slist node, which can be a value between 0 and 3. These flags will persist even if the node is moved around within a list, removed, or transplanted to a different slist.

This is ever so slightly faster than sys_sfnode_flags_set() and should only be used on a node that hasn't been added to any list.

Parameters
nodeA pointer to the node to set the flags on
flagsA value between 0 and 3 to set the flags value