nuttx/list/queue: add helper macro list/sq/dq_is_singular()

add helper macro list/sq/dq_is_singular() to tests whether a list has just one entry.

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an 2024-03-06 14:00:48 +08:00 committed by Xiang Xiao
parent d29748258b
commit eb6fe17baa
2 changed files with 12 additions and 3 deletions

View File

@ -72,6 +72,7 @@
#define list_in_list(item) ((item)->prev != NULL)
#define list_is_empty(list) ((list)->next == list)
#define list_is_clear(list) ((list)->next == NULL)
#define list_is_singular(list) ((list)->next == (list)->prev)
#define list_initialize(list) \
do \

View File

@ -290,6 +290,14 @@
#define dq_inqueue(p, q) \
((p)->flink || dq_tail(q) == (p))
/* sq/dq_is_singular - tests whether a list has just one entry. */
#define sq_is_singular(q) \
(!sq_empty(q) && (q)->head->flink == NULL)
#define dq_is_singular(q) \
(!dq_empty(q) && (q)->head->flink == NULL)
/****************************************************************************
* Public Type Definitions
****************************************************************************/