NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
slist.h File Reference

Single-linked list implementation. More...

Go to the source code of this file.

Macros

#define SYS_SLIST_FOR_EACH_NODE(__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)
 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)
 Provide the primitive to safely iterate on a list Note: __sn can be removed, it will not break the loop.
 
#define SYS_SLIST_FOR_EACH_CONTAINER(__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)
 Provide the primitive to safely iterate on a list under a container Note: __cn can be detached, it will not break the loop.
 

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.

Macro Definition Documentation

◆ SYS_SLIST_FOR_EACH_CONTAINER

#define SYS_SLIST_FOR_EACH_CONTAINER (   __sl,
  __cn,
  __n 
)
Value:
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n); __cn; \
__cn = SYS_SLIST_PEEK_NEXT_CONTAINER(__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.

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

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

◆ SYS_SLIST_FOR_EACH_CONTAINER_SAFE

#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE (   __sl,
  __cn,
  __cns,
  __n 
)
Value:
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n), \
__cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n); __cn; \
__cn = __cns, __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n))

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_SLIST_FOR_EACH_NODE_SAFE(l, c, cn, n) {
    <user code>
}
Parameters
__slA pointer on a sys_slist_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_node_t within the container struct

◆ SYS_SLIST_FOR_EACH_NODE

#define SYS_SLIST_FOR_EACH_NODE (   __sl,
  __sn 
)
Value:
for (__sn = sys_slist_peek_head(__sl); __sn; \
__sn = sys_slist_peek_next(__sn))

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_SLIST_FOR_EACH_NODE(l, n) {
    <user code>
}

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

Parameters
__slA pointer on a sys_slist_t to iterate on
__snA sys_snode_t pointer to peek each node of the list

◆ SYS_SLIST_FOR_EACH_NODE_SAFE

#define SYS_SLIST_FOR_EACH_NODE_SAFE (   __sl,
  __sn,
  __sns 
)
Value:
for (__sn = sys_slist_peek_head(__sl), \
__sns = sys_slist_peek_next(__sn); \
__sn; __sn = __sns, \
__sns = sys_slist_peek_next(__sn))

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_SLIST_FOR_EACH_NODE_SAFE(l, n, s) {
    <user code>
}

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

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

◆ SYS_SLIST_ITERATE_FROM_NODE

#define SYS_SLIST_ITERATE_FROM_NODE (   __sl,
  __sn 
)
Value:
for (__sn = __sn ? sys_slist_peek_next_no_check(__sn) \
: sys_slist_peek_head(__sl); \
__sn; \
__sn = sys_slist_peek_next(__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.

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

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

Like SYS_SLIST_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_SLIST_*() macros are not thread safe.

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