o list.h: implement list_for_each_entry_safe

parent 4c45b3bf
...@@ -296,6 +296,19 @@ static inline void list_splice_init(struct list_head *list, ...@@ -296,6 +296,19 @@ static inline void list_splice_init(struct list_head *list,
pos = list_entry(pos->member.next, typeof(*pos), member), \ pos = list_entry(pos->member.next, typeof(*pos), member), \
prefetch(pos->member.next)) prefetch(pos->member.next))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @pos: the type * to use as a loop counter.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
/** /**
* list_for_each_rcu - iterate over an rcu-protected list * list_for_each_rcu - iterate over an rcu-protected list
* @pos: the &struct list_head to use as a loop counter. * @pos: the &struct list_head to use as a loop counter.
......
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