From: Nathael Pajani Date: Thu, 21 Sep 2023 22:27:48 +0000 (+0200) Subject: Add list_exactly_one() and list_more_than_one() utility functions X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=48c73d2d49bfb4d0576bf6aae9d84307699e045c;p=soft%2Flpc122x%2Fcore Add list_exactly_one() and list_more_than_one() utility functions --- diff --git a/include/lib/list.h b/include/lib/list.h index 41f3678..fda023c 100644 --- a/include/lib/list.h +++ b/include/lib/list.h @@ -132,6 +132,24 @@ static inline int list_empty(const struct list_head* head) return head->next == head; } +/** + * list_exactly_one - tests whether a list has exactly one element + * @head: the list to test. + */ +static inline int list_exactly_one(const struct list_head* head) +{ + return head->next == head->prev; +} + +/** + * list_more_than_one - tests whether a list has more than one element + * @head: the list to test. + */ +static inline int list_more_than_one(const struct list_head* head) +{ + return head->next != head->prev; +} + /** * list_rotate_left - rotate the list to the left * @head: the head of the list