diff --git a/include/nuttx/list.h b/include/nuttx/list.h index b3b4309374..cadbccc335 100644 --- a/include/nuttx/list.h +++ b/include/nuttx/list.h @@ -69,9 +69,10 @@ #define LIST_INITIAL_VALUE(list) { &(list), &(list) } #define LIST_INITIAL_CLEARED_VALUE { NULL, NULL } -#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_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 \ diff --git a/include/nuttx/queue.h b/include/nuttx/queue.h index 159f548e49..6a07d6a4dc 100644 --- a/include/nuttx/queue.h +++ b/include/nuttx/queue.h @@ -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 ****************************************************************************/