From c7553e7849955f99a8edaa95fd02af7489e18fd3 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Sat, 3 Dec 2022 14:40:35 +0100 Subject: [PATCH] plist.h: add some reverse macros --- 2022/include/plist.h | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/2022/include/plist.h b/2022/include/plist.h index 85da7e9..fc0bb3d 100644 --- a/2022/include/plist.h +++ b/2022/include/plist.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* adaptation of kernel's + * + */ + /* * Descending-priority-sorted double-linked list * @@ -157,7 +162,7 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head); * @pos: the type * to use as a loop counter * @head: the head for your list */ -#define plist_for_each_reverse(pos, head) \ +#define plist_for_each_reverse(pos, head) \ list_for_each_entry_reverse(pos, &(head)->node_list, node_list) /** @@ -167,9 +172,20 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head); * * Continue to iterate over plist, continuing after the current position. */ -#define plist_for_each_continue(pos, head) \ +#define plist_for_each_continue(pos, head) \ list_for_each_entry_continue(pos, &(head)->node_list, node_list) +/** + * plist_for_each_continue_reverse - continue iteration over the plist + * @pos: the type * to use as a loop cursor + * @head: the head for your list + * + * Continue to iterate backwards over plist, continuing after the current + * position. + */ +#define plist_for_each_continue_reverse(pos, head) \ + list_for_each_entry_continue_reverse(pos, &(head)->node_list, node_list) + /** * plist_for_each_safe - iterate safely over a plist of given type * @pos: the type * to use as a loop counter @@ -178,9 +194,20 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head); * * Iterate over a plist of given type, safe against removal of list entry. */ -#define plist_for_each_safe(pos, n, head) \ +#define plist_for_each_safe(pos, n, head) \ list_for_each_entry_safe(pos, n, &(head)->node_list, node_list) +/** + * plist_for_each_safe_reverse - iterate backwards safely over a plist of given type + * @pos: the type * to use as a loop counter + * @n: another type * to use as temporary storage + * @head: the head for your list + * + * Iterate backwards over a plist of given type, safe against removal of list entry. + */ +#define plist_for_each_safe_reverse(pos, n, head) \ + list_for_each_entry_safe_reverse(pos, n, &(head)->node_list, node_list) + /** * plist_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop counter @@ -197,7 +224,7 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head); * @mem: the name of the list_head within the struct */ #define plist_for_each_entry_reverse(pos, head, mem) \ - list_for_each_entry(pos, &(head)->node_list, mem.node_list) + list_for_each_entry_reverse(pos, &(head)->node_list, mem.node_list) /** * plist_for_each_entry_continue - continue iteration over list of given type