未验证 提交 5719a3db 编写于 作者: armink_ztl's avatar armink_ztl 提交者: GitHub

Merge pull request #1605 from pansila/master

Add list iterators over list elements
...@@ -140,6 +140,24 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) ...@@ -140,6 +140,24 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l)
#define rt_list_entry(node, type, member) \ #define rt_list_entry(node, type, member) \
rt_container_of(node, type, member) 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 * rt_list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop cursor. * @pos: the type * to use as a loop cursor.
...@@ -254,6 +272,14 @@ rt_inline int rt_slist_isempty(rt_slist_t *l) ...@@ -254,6 +272,14 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
#define rt_slist_entry(node, type, member) \ #define rt_slist_entry(node, type, member) \
rt_container_of(node, type, member) 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 * rt_slist_for_each_entry - iterate over single list of given type
* @pos: the type * to use as a loop cursor. * @pos: the type * to use as a loop cursor.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册