From 4fe5bbb2df856cdc83a13648e943c27f44c71e48 Mon Sep 17 00:00:00 2001 From: John Anthony Date: Sun, 16 Jun 2013 01:18:03 +0100 Subject: Newer version of generic list --- list.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/list.h b/list.h index 060d02e..936fbac 100644 --- a/list.h +++ b/list.h @@ -214,6 +214,16 @@ list_splice_init(struct list_head *list, struct list_head *head) { for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) +/** + * list_for_each_safe_reverse - iterate list backwards safely + * @pos: the &struct list_head to use as a loop counter. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ +#define list_for_each_safe_reverse(pos, n, head) \ + for (pos = (head)->prev, n = pos->prev; pos != (head); \ + pos = n, n = pos->prev) + /** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop counter. @@ -225,6 +235,17 @@ list_splice_init(struct list_head *list, struct list_head *head) { &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) +/** + * list_for_each_entry_reverse - iterate list of given type backwards + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry_reverse(pos, head, member) \ + for (pos = list_entry((head)->prev, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.prev, typeof(*pos), member)) + /** * list_for_each_entry_safe - iterate list entries safe against removal * @pos: the type * to use as a loop counter. -- cgit v1.2.3