Commit 00a8a8c1 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[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.
parent 23f7ec50
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment