diff options
| author | 朱天龙 (Armink) <[email protected]> | 2018-07-11 17:56:26 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-07-11 17:56:26 +0800 |
| commit | 5719a3db3aa1c151df8de35fdf9aff131582da94 (patch) | |
| tree | fb69576d32ce28a10963f72534853bfbbf070d8a /include | |
| parent | f94cae368063fe47ed70ed985d117091a00f8e66 (diff) | |
| parent | 754b36383947a191bbc0ada7fb5e22cf56120a13 (diff) | |
Merge pull request #1605 from pansila/master
Add list iterators over list elements
Diffstat (limited to 'include')
| -rw-r--r-- | include/rtservice.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/rtservice.h b/include/rtservice.h index f909f17f86..0bfa424338 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -141,6 +141,24 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) rt_container_of(node, type, member) /** + * rt_list_for_each - iterate over a list + * @pos: the rt_list_t * to use as a loop cursor. + * @head: the head for your list. + */ +#define rt_list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * rt_list_for_each_safe - iterate over a list safe against removal of list entry + * @pos: the rt_list_t * to use as a loop cursor. + * @n: another rt_list_t * to use as temporary storage + * @head: the head for your list. + */ +#define rt_list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + +/** * rt_list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your list. @@ -255,6 +273,14 @@ rt_inline int rt_slist_isempty(rt_slist_t *l) rt_container_of(node, type, member) /** + * rt_slist_for_each - iterate over a single list + * @pos: the rt_slist_t * to use as a loop cursor. + * @head: the head for your single list. + */ +#define rt_slist_for_each(pos, head) \ + for (pos = (head)->next; pos != RT_NULL; pos = pos->next) + +/** * rt_slist_for_each_entry - iterate over single list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your single list. |
