summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Anthony <johnanthony@lavabit.com>2013-06-16 01:18:03 +0100
committerJohn Anthony <johnanthony@lavabit.com>2013-06-16 01:18:03 +0100
commit4fe5bbb2df856cdc83a13648e943c27f44c71e48 (patch)
treea90728404ddef7d4bd625156d71153d5bc74a69f
parentb0485d66a69701cbc7d3a5316142ee599ef3db19 (diff)
downloadnyancat-4fe5bbb2df856cdc83a13648e943c27f44c71e48.tar.gz
nyancat-4fe5bbb2df856cdc83a13648e943c27f44c71e48.tar.bz2
nyancat-4fe5bbb2df856cdc83a13648e943c27f44c71e48.zip
Newer version of generic list
-rw-r--r--list.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/list.h b/list.h
index 060d02e..936fbac 100644
--- a/list.h
+++ b/list.h
@@ -215,6 +215,16 @@ list_splice_init(struct list_head *list, struct list_head *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.
* @head: the head for your list.
@@ -226,6 +236,17 @@ list_splice_init(struct list_head *list, struct list_head *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.
* @n: another type * to use as temporary storage