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:
parent
d29748258b
commit
eb6fe17baa
@ -72,6 +72,7 @@
|
|||||||
#define list_in_list(item) ((item)->prev != NULL)
|
#define list_in_list(item) ((item)->prev != NULL)
|
||||||
#define list_is_empty(list) ((list)->next == list)
|
#define list_is_empty(list) ((list)->next == list)
|
||||||
#define list_is_clear(list) ((list)->next == NULL)
|
#define list_is_clear(list) ((list)->next == NULL)
|
||||||
|
#define list_is_singular(list) ((list)->next == (list)->prev)
|
||||||
|
|
||||||
#define list_initialize(list) \
|
#define list_initialize(list) \
|
||||||
do \
|
do \
|
||||||
|
@ -290,6 +290,14 @@
|
|||||||
#define dq_inqueue(p, q) \
|
#define dq_inqueue(p, q) \
|
||||||
((p)->flink || dq_tail(q) == (p))
|
((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
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user