diff options
| author | weety <[email protected]> | 2017-11-05 22:36:46 +0800 |
|---|---|---|
| committer | weety <[email protected]> | 2017-11-05 22:36:46 +0800 |
| commit | ed90b9d415763e22323f11755b63d32141842fb1 (patch) | |
| tree | 4e5439624edf609fe4867a486a13784532061e8f | |
| parent | 86b9875d5eea034d96206b464e28cd6e8e6460b0 (diff) | |
[RTSERVICE] Add rt_list_for_each_entry_safe macros definition.
| -rw-r--r-- | include/rtservice.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/rtservice.h b/include/rtservice.h index 2c6682076d..2bf1fbe1d6 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -142,6 +142,19 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) 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. * @type: the type of the struct this is embedded in. |
