summaryrefslogtreecommitdiff
path: root/include/linux/list.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2002-08-27 20:38:10 -0700
committerLinus Torvalds <torvalds@penguin.transmeta.com>2002-08-27 20:38:10 -0700
commit00a8a8c135d8f6df9c51110e37a0252f8fd61097 (patch)
tree88fcf9fb067bf457cede5b353a35b2475e2dbd54 /include/linux/list.h
parent23f7ec5079bceb5e2aa28e1ac5cc0851ceedcaa3 (diff)
[PATCH] list_for_each_entry
This adds list_for_each_entry, which is the equivalent of list_for_each and list_entry, except only one variable is needed.
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 3bc81f885ce1..913c93c44286 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -211,6 +211,19 @@ static inline void list_splice_init(list_t *list, list_t *head)
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
+/**
+ * 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.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ prefetch(pos->member.next); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next))
+
#endif /* __KERNEL__ || _LVM_H_INCLUDE */
#endif