cleanup: include/: move misc/slist.h to sys/slist.h
move misc/slist.h to sys/slist.h and create a shim for backward-compatibility. No functional changes to the headers. A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES. Related to #16539 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
5c0516bce3
commit
536dd5a71f
31 changed files with 449 additions and 434 deletions
|
@ -26,7 +26,7 @@
|
|||
#include <soc.h>
|
||||
#include <sys/sys_io.h>
|
||||
#include <sys/__assert.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <misc/speculation.h>
|
||||
|
||||
#include "gpio_utils.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
/* Error codes for Error response PDU */
|
||||
#define BT_ATT_ERR_INVALID_HANDLE 0x01
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <stddef.h>
|
||||
#include <device.h>
|
||||
#include <sys/__assert.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define ZEPHYR_INCLUDE_DRIVERS_GPIO_H_
|
||||
|
||||
#include <sys/__assert.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <sys/__assert.h>
|
||||
#include <sched_priq.h>
|
||||
#include <sys/dlist.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <sys/sflist.h>
|
||||
#include <misc/util.h>
|
||||
#include <sys/mempool_base.h>
|
||||
|
|
|
@ -1,416 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief 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.
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_MISC_SLIST_H_
|
||||
#define ZEPHYR_INCLUDE_MISC_SLIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "list_gen.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#ifndef CONFIG_COMPAT_INCLUDES
|
||||
#warning "This header file has moved, include <sys/slist.h> instead."
|
||||
#endif
|
||||
|
||||
|
||||
struct _snode {
|
||||
struct _snode *next;
|
||||
};
|
||||
|
||||
typedef struct _snode sys_snode_t;
|
||||
|
||||
struct _slist {
|
||||
sys_snode_t *head;
|
||||
sys_snode_t *tail;
|
||||
};
|
||||
|
||||
typedef struct _slist sys_slist_t;
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \
|
||||
Z_GENLIST_FOR_EACH_NODE(slist, __sl, __sn)
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
* it contains the starting node, or NULL to start from the head
|
||||
*/
|
||||
#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn) \
|
||||
Z_GENLIST_ITERATE_FROM_NODE(slist, __sl, __sn)
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
* @param __sns A sys_snode_t pointer for the loop to run safely
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \
|
||||
Z_GENLIST_FOR_EACH_NODE_SAFE(slist, __sl, __sn, __sns)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to resolve the container of a list node
|
||||
* Note: it is safe to use with NULL pointer nodes
|
||||
*
|
||||
* @param __ln A pointer on a sys_node_t to get its container
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \
|
||||
Z_GENLIST_CONTAINER(__ln, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek container of the list head
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to peek
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_PEEK_HEAD_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek container of the list tail
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to peek
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_PEEK_TAIL_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek the next container
|
||||
*
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \
|
||||
Z_GENLIST_PEEK_NEXT_CONTAINER(slist, __cn, __n)
|
||||
|
||||
/**
|
||||
* @brief 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>
|
||||
* }
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __cn A pointer to peek each entry of the list
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_FOR_EACH_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/**
|
||||
* @brief 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>
|
||||
* }
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __cn A pointer to peek each entry of the list
|
||||
* @param __cns A pointer for the loop to run safely
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n) \
|
||||
Z_GENLIST_FOR_EACH_CONTAINER_SAFE(slist, __sl, __cn, __cns, __n)
|
||||
|
||||
|
||||
/*
|
||||
* Required function definitions for the list_gen.h interface
|
||||
*
|
||||
* These are the only functions that do not treat the list/node pointers
|
||||
* as completely opaque types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize a list
|
||||
*
|
||||
* @param list A pointer on the list to initialize
|
||||
*/
|
||||
static inline void sys_slist_init(sys_slist_t *list)
|
||||
{
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
#define SYS_SLIST_STATIC_INIT(ptr_to_list) {NULL, NULL}
|
||||
|
||||
static inline sys_snode_t *z_snode_next_peek(sys_snode_t *node)
|
||||
{
|
||||
return node->next;
|
||||
}
|
||||
|
||||
static inline void z_snode_next_set(sys_snode_t *parent, sys_snode_t *child)
|
||||
{
|
||||
parent->next = child;
|
||||
}
|
||||
|
||||
static inline void z_slist_head_set(sys_slist_t *list, sys_snode_t *node)
|
||||
{
|
||||
list->head = node;
|
||||
}
|
||||
|
||||
static inline void z_slist_tail_set(sys_slist_t *list, sys_snode_t *node)
|
||||
{
|
||||
list->tail = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Peek the first node from the list
|
||||
*
|
||||
* @param list A point on the list to peek the first node from
|
||||
*
|
||||
* @return A pointer on the first node of the list (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_head(sys_slist_t *list)
|
||||
{
|
||||
return list->head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Peek the last node from the list
|
||||
*
|
||||
* @param list A point on the list to peek the last node from
|
||||
*
|
||||
* @return A pointer on the last node of the list (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_tail(sys_slist_t *list)
|
||||
{
|
||||
return list->tail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Derived, generated APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test if the given list is empty
|
||||
*
|
||||
* @param list A pointer on the list to test
|
||||
*
|
||||
* @return a boolean, true if it's empty, false otherwise
|
||||
*/
|
||||
static inline bool sys_slist_is_empty(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_IS_EMPTY(slist)
|
||||
|
||||
/**
|
||||
* @brief Peek the next node from current node, node is not NULL
|
||||
*
|
||||
* Faster then sys_slist_peek_next() if node is known not to be NULL.
|
||||
*
|
||||
* @param node A pointer on the node where to peek the next node
|
||||
*
|
||||
* @return a pointer on the next node (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_next_no_check(sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PEEK_NEXT_NO_CHECK(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Peek the next node from current node
|
||||
*
|
||||
* @param node A pointer on the node where to peek the next node
|
||||
*
|
||||
* @return a pointer on the next node (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_next(sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PEEK_NEXT(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Prepend a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to prepend
|
||||
*/
|
||||
static inline void sys_slist_prepend(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PREPEND(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Append a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to append
|
||||
*/
|
||||
static inline void sys_slist_append(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_APPEND(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief 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 @a list.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* FIXME: Why are the element parameters void *?
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param head A pointer to the first element of the list to append
|
||||
* @param tail A pointer to the last element of the list to append
|
||||
*/
|
||||
static inline void sys_slist_append_list(sys_slist_t *list,
|
||||
void *head, void *tail);
|
||||
|
||||
Z_GENLIST_APPEND_LIST(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief merge two slists, appending the second one to the first
|
||||
*
|
||||
* When the operation is completed, the appending list is empty.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param list_to_append A pointer to the list to append.
|
||||
*/
|
||||
static inline void sys_slist_merge_slist(sys_slist_t *list,
|
||||
sys_slist_t *list_to_append);
|
||||
|
||||
Z_GENLIST_MERGE_LIST(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Insert a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param prev A pointer on the previous node
|
||||
* @param node A pointer on the node to insert
|
||||
*/
|
||||
static inline void sys_slist_insert(sys_slist_t *list,
|
||||
sys_snode_t *prev,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_INSERT(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Fetch and remove the first node of the given list
|
||||
*
|
||||
* List must be known to be non-empty.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
*
|
||||
* @return A pointer to the first node of the list
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_get_not_empty(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_GET_NOT_EMPTY(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Fetch and remove the first node of the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
*
|
||||
* @return A pointer to the first node of the list (or NULL if empty)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_get(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_GET(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Remove a node
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param prev_node A pointer on the previous node
|
||||
* (can be NULL, which means the node is the list's head)
|
||||
* @param node A pointer on the node to remove
|
||||
*/
|
||||
static inline void sys_slist_remove(sys_slist_t *list,
|
||||
sys_snode_t *prev_node,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_REMOVE(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Find and remove a node from a list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to remove from the list
|
||||
*
|
||||
* @return true if node was removed
|
||||
*/
|
||||
static inline bool sys_slist_find_and_remove(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_FIND_AND_REMOVE(slist, snode)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <sys/slist.h>
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_MISC_SLIST_H_ */
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <net/net_ip.h>
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -22,7 +22,7 @@ extern "C" {
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#include <net/net_core.h>
|
||||
#include <net/hostname.h>
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_PTHREAD_IPC
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
typedef u32_t pthread_once_t;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <misc/util.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
416
include/sys/slist.h
Normal file
416
include/sys/slist.h
Normal file
|
@ -0,0 +1,416 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief 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.
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_SYS_SLIST_H_
|
||||
#define ZEPHYR_INCLUDE_SYS_SLIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "list_gen.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct _snode {
|
||||
struct _snode *next;
|
||||
};
|
||||
|
||||
typedef struct _snode sys_snode_t;
|
||||
|
||||
struct _slist {
|
||||
sys_snode_t *head;
|
||||
sys_snode_t *tail;
|
||||
};
|
||||
|
||||
typedef struct _slist sys_slist_t;
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \
|
||||
Z_GENLIST_FOR_EACH_NODE(slist, __sl, __sn)
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
* it contains the starting node, or NULL to start from the head
|
||||
*/
|
||||
#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn) \
|
||||
Z_GENLIST_ITERATE_FROM_NODE(slist, __sl, __sn)
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __sn A sys_snode_t pointer to peek each node of the list
|
||||
* @param __sns A sys_snode_t pointer for the loop to run safely
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \
|
||||
Z_GENLIST_FOR_EACH_NODE_SAFE(slist, __sl, __sn, __sns)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to resolve the container of a list node
|
||||
* Note: it is safe to use with NULL pointer nodes
|
||||
*
|
||||
* @param __ln A pointer on a sys_node_t to get its container
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \
|
||||
Z_GENLIST_CONTAINER(__ln, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek container of the list head
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to peek
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_PEEK_HEAD_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek container of the list tail
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to peek
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_PEEK_TAIL_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/*
|
||||
* @brief Provide the primitive to peek the next container
|
||||
*
|
||||
* @param __cn Container struct type pointer
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \
|
||||
Z_GENLIST_PEEK_NEXT_CONTAINER(slist, __cn, __n)
|
||||
|
||||
/**
|
||||
* @brief 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>
|
||||
* }
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __cn A pointer to peek each entry of the list
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \
|
||||
Z_GENLIST_FOR_EACH_CONTAINER(slist, __sl, __cn, __n)
|
||||
|
||||
/**
|
||||
* @brief 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>
|
||||
* }
|
||||
*
|
||||
* @param __sl A pointer on a sys_slist_t to iterate on
|
||||
* @param __cn A pointer to peek each entry of the list
|
||||
* @param __cns A pointer for the loop to run safely
|
||||
* @param __n The field name of sys_node_t within the container struct
|
||||
*/
|
||||
#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n) \
|
||||
Z_GENLIST_FOR_EACH_CONTAINER_SAFE(slist, __sl, __cn, __cns, __n)
|
||||
|
||||
|
||||
/*
|
||||
* Required function definitions for the list_gen.h interface
|
||||
*
|
||||
* These are the only functions that do not treat the list/node pointers
|
||||
* as completely opaque types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize a list
|
||||
*
|
||||
* @param list A pointer on the list to initialize
|
||||
*/
|
||||
static inline void sys_slist_init(sys_slist_t *list)
|
||||
{
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
#define SYS_SLIST_STATIC_INIT(ptr_to_list) {NULL, NULL}
|
||||
|
||||
static inline sys_snode_t *z_snode_next_peek(sys_snode_t *node)
|
||||
{
|
||||
return node->next;
|
||||
}
|
||||
|
||||
static inline void z_snode_next_set(sys_snode_t *parent, sys_snode_t *child)
|
||||
{
|
||||
parent->next = child;
|
||||
}
|
||||
|
||||
static inline void z_slist_head_set(sys_slist_t *list, sys_snode_t *node)
|
||||
{
|
||||
list->head = node;
|
||||
}
|
||||
|
||||
static inline void z_slist_tail_set(sys_slist_t *list, sys_snode_t *node)
|
||||
{
|
||||
list->tail = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Peek the first node from the list
|
||||
*
|
||||
* @param list A point on the list to peek the first node from
|
||||
*
|
||||
* @return A pointer on the first node of the list (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_head(sys_slist_t *list)
|
||||
{
|
||||
return list->head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Peek the last node from the list
|
||||
*
|
||||
* @param list A point on the list to peek the last node from
|
||||
*
|
||||
* @return A pointer on the last node of the list (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_tail(sys_slist_t *list)
|
||||
{
|
||||
return list->tail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Derived, generated APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test if the given list is empty
|
||||
*
|
||||
* @param list A pointer on the list to test
|
||||
*
|
||||
* @return a boolean, true if it's empty, false otherwise
|
||||
*/
|
||||
static inline bool sys_slist_is_empty(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_IS_EMPTY(slist)
|
||||
|
||||
/**
|
||||
* @brief Peek the next node from current node, node is not NULL
|
||||
*
|
||||
* Faster then sys_slist_peek_next() if node is known not to be NULL.
|
||||
*
|
||||
* @param node A pointer on the node where to peek the next node
|
||||
*
|
||||
* @return a pointer on the next node (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_next_no_check(sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PEEK_NEXT_NO_CHECK(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Peek the next node from current node
|
||||
*
|
||||
* @param node A pointer on the node where to peek the next node
|
||||
*
|
||||
* @return a pointer on the next node (or NULL if none)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_peek_next(sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PEEK_NEXT(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Prepend a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to prepend
|
||||
*/
|
||||
static inline void sys_slist_prepend(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_PREPEND(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Append a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to append
|
||||
*/
|
||||
static inline void sys_slist_append(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_APPEND(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief 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 @a list.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* FIXME: Why are the element parameters void *?
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param head A pointer to the first element of the list to append
|
||||
* @param tail A pointer to the last element of the list to append
|
||||
*/
|
||||
static inline void sys_slist_append_list(sys_slist_t *list,
|
||||
void *head, void *tail);
|
||||
|
||||
Z_GENLIST_APPEND_LIST(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief merge two slists, appending the second one to the first
|
||||
*
|
||||
* When the operation is completed, the appending list is empty.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param list_to_append A pointer to the list to append.
|
||||
*/
|
||||
static inline void sys_slist_merge_slist(sys_slist_t *list,
|
||||
sys_slist_t *list_to_append);
|
||||
|
||||
Z_GENLIST_MERGE_LIST(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Insert a node to the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param prev A pointer on the previous node
|
||||
* @param node A pointer on the node to insert
|
||||
*/
|
||||
static inline void sys_slist_insert(sys_slist_t *list,
|
||||
sys_snode_t *prev,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_INSERT(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Fetch and remove the first node of the given list
|
||||
*
|
||||
* List must be known to be non-empty.
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
*
|
||||
* @return A pointer to the first node of the list
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_get_not_empty(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_GET_NOT_EMPTY(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Fetch and remove the first node of the given list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
*
|
||||
* @return A pointer to the first node of the list (or NULL if empty)
|
||||
*/
|
||||
static inline sys_snode_t *sys_slist_get(sys_slist_t *list);
|
||||
|
||||
Z_GENLIST_GET(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Remove a node
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param prev_node A pointer on the previous node
|
||||
* (can be NULL, which means the node is the list's head)
|
||||
* @param node A pointer on the node to remove
|
||||
*/
|
||||
static inline void sys_slist_remove(sys_slist_t *list,
|
||||
sys_snode_t *prev_node,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_REMOVE(slist, snode)
|
||||
|
||||
/**
|
||||
* @brief Find and remove a node from a list
|
||||
*
|
||||
* This and other sys_slist_*() functions are not thread safe.
|
||||
*
|
||||
* @param list A pointer on the list to affect
|
||||
* @param node A pointer on the node to remove from the list
|
||||
*
|
||||
* @return true if node was removed
|
||||
*/
|
||||
static inline bool sys_slist_find_and_remove(sys_slist_t *list,
|
||||
sys_snode_t *node);
|
||||
|
||||
Z_GENLIST_FIND_AND_REMOVE(slist, snode)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_SYS_SLIST_H_ */
|
|
@ -20,7 +20,7 @@
|
|||
#include <wait_q.h>
|
||||
#include <ksched.h>
|
||||
#include <syscall_handler.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <sys/dlist.h>
|
||||
#include <misc/util.h>
|
||||
#include <sys/__assert.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <posix/pthread.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#define PTHREAD_INIT_FLAGS PTHREAD_CANCEL_ENABLE
|
||||
#define PTHREAD_CANCELED ((void *) -1)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
|
||||
|
||||
#include "arm_mpu_mem_cfg.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
|
||||
|
||||
#include "mpu_mem_cfg.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "lll.h"
|
||||
|
||||
#if defined(CONFIG_BT_LL_SW)
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include "ctrl.h"
|
||||
#define ull_adv_is_enabled ll_adv_is_enabled
|
||||
#define ull_scan_is_enabled ll_scan_is_enabled
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <sys/atomic.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <misc/util.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <misc/stack.h>
|
||||
#include <sys/__assert.h>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <errno.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <misc/util.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <misc/stack.h>
|
||||
#include <sys/__assert.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __NET_6LO_H
|
||||
#define __NET_6LO_H
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#include <net/net_pkt.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
LOG_MODULE_REGISTER(net_icmpv4, CONFIG_NET_ICMPV4_LOG_LEVEL);
|
||||
|
||||
#include <errno.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
LOG_MODULE_REGISTER(net_icmpv6, CONFIG_NET_ICMPV6_LOG_LEVEL);
|
||||
|
||||
#include <errno.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __ICMPV6_H
|
||||
#define __ICMPV6_H
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#include <net/net_ip.h>
|
||||
|
|
|
@ -12,7 +12,7 @@ LOG_MODULE_REGISTER(net_mgmt, CONFIG_NET_MGMT_EVENT_LOG_LEVEL);
|
|||
#include <linker/sections.h>
|
||||
|
||||
#include <misc/util.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <net/net_mgmt.h>
|
||||
|
||||
#include "net_private.h"
|
||||
|
|
|
@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(net_route, CONFIG_NET_ROUTE_LOG_LEVEL);
|
|||
#include <kernel.h>
|
||||
#include <limits.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_core.h>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define __ROUTE_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
#include <net/net_ip.h>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
|
||||
#if defined(CONFIG_NET_ARP)
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __NET_IEEE802154_FRAGMENT_H__
|
||||
#define __NET_IEEE802154_FRAGMENT_H__
|
||||
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#include <net/net_pkt.h>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
static sys_slist_t test_list;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#ifndef __TEST_LIFO_USAGE_H__
|
||||
#define __TEST_LIFO_USAGE_H__
|
||||
#include <misc/slist.h>
|
||||
#include <sys/slist.h>
|
||||
|
||||
typedef struct ldata {
|
||||
sys_snode_t snode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue