add some reverse() macros

This commit is contained in:
2022-12-03 16:10:59 +01:00
parent a0e204d7ab
commit 4c8f0f3f72

View File

@@ -1,4 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* adaptation of kernel's <linux/plist.h>
*
*/
/*
* Descending-priority-sorted double-linked list
*
@@ -152,6 +157,14 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head);
#define plist_for_each(pos, head) \
list_for_each_entry(pos, &(head)->node_list, node_list)
/**
* plist_for_each_reverse - iterate backwards over the plist
* @pos: the type * to use as a loop counter
* @head: the head for your list
*/
#define plist_for_each_reverse(pos, head) \
list_for_each_entry_reverse(pos, &(head)->node_list, node_list)
/**
* plist_for_each_continue - continue iteration over the plist
* @pos: the type * to use as a loop cursor
@@ -159,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
@@ -170,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
@@ -182,6 +217,15 @@ extern void plist_requeue(struct plist_node *node, struct plist_head *head);
#define plist_for_each_entry(pos, head, mem) \
list_for_each_entry(pos, &(head)->node_list, mem.node_list)
/**
* plist_for_each_entry_reverse - iterate backwards over list of given type
* @pos: the type * to use as a loop counter
* @head: the head for your list
* @mem: the name of the list_head within the struct
*/
#define plist_for_each_entry_reverse(pos, head, mem) \
list_for_each_entry_reverse(pos, &(head)->node_list, mem.node_list)
/**
* plist_for_each_entry_continue - continue iteration over list of given type
* @pos: the type * to use as a loop cursor