[RTSERVICE] Add rt_list_for_each_entry_safe macros definition.

This commit is contained in:
weety 2017-11-05 22:36:46 +08:00
parent 86b9875d5e
commit ed90b9d415
1 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,19 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l)
&pos->member != (head); \
pos = rt_list_entry(pos->member.next, typeof(*pos), member))
/**
* rt_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 cursor.
* @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 rt_list_for_each_entry_safe(pos, n, head, member) \
for (pos = rt_list_entry((head)->next, typeof(*pos), member), \
n = rt_list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = rt_list_entry(n->member.next, typeof(*n), member))
/**
* rt_list_first_entry - get the first element from a list
* @ptr: the list head to take the element from.