17#ifndef __RT_SERVICE_H__
18#define __RT_SERVICE_H__
36#define rt_container_of(ptr, type, member) \
37 ((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))
43#define RT_LIST_OBJECT_INIT(object) { &(object), &(object) }
112 unsigned int len = 0;
129#define rt_list_entry(node, type, member) \
130 rt_container_of(node, type, member)
137#define rt_list_for_each(pos, head) \
138 for (pos = (head)->next; pos != (head); pos = pos->next)
146#define rt_list_for_each_safe(pos, n, head) \
147 for (pos = (head)->next, n = pos->next; pos != (head); \
148 pos = n, n = pos->next)
156#define rt_list_for_each_entry(pos, head, member) \
157 for (pos = rt_list_entry((head)->next, rt_typeof(*pos), member); \
158 &pos->member != (head); \
159 pos = rt_list_entry(pos->member.next, rt_typeof(*pos), member))
168#define rt_list_for_each_entry_safe(pos, n, head, member) \
169 for (pos = rt_list_entry((head)->next, rt_typeof(*pos), member), \
170 n = rt_list_entry(pos->member.next, rt_typeof(*pos), member); \
171 &pos->member != (head); \
172 pos = n, n = rt_list_entry(n->member.next, rt_typeof(*n), member))
182#define rt_list_first_entry(ptr, type, member) \
183 rt_list_entry((ptr)->next, type, member)
185#define RT_SLIST_OBJECT_INIT(object) { RT_NULL }
202 while (node->
next) node = node->
next;
217 unsigned int len = 0;
246 while (node->
next && node->
next != n) node = node->
next;
282#define rt_slist_entry(node, type, member) \
283 rt_container_of(node, type, member)
290#define rt_slist_for_each(pos, head) \
291 for (pos = (head)->next; pos != RT_NULL; pos = pos->next)
299#define rt_slist_for_each_entry(pos, head, member) \
300 for (pos = ((head)->next == (RT_NULL) ? (RT_NULL) : rt_slist_entry((head)->next, rt_typeof(*pos), member)); \
301 pos != (RT_NULL) && &pos->member != (RT_NULL); \
302 pos = (pos->member.next == (RT_NULL) ? (RT_NULL) : rt_slist_entry(pos->member.next, rt_typeof(*pos), member)))
312#define rt_slist_first_entry(ptr, type, member) \
313 rt_slist_entry((ptr)->next, type, member)
323#define rt_slist_tail_entry(ptr, type, member) \
324 rt_slist_entry(rt_slist_tail(ptr), type, member)
rt_inline void rt_list_remove(rt_list_t *n)
remove node from list.
rt_inline void rt_slist_insert(rt_slist_t *l, rt_slist_t *n)
rt_inline void rt_slist_init(rt_slist_t *l)
initialize a single list
rt_inline rt_slist_t * rt_slist_tail(rt_slist_t *l)
rt_inline rt_slist_t * rt_slist_first(rt_slist_t *l)
rt_inline int rt_list_isempty(const rt_list_t *l)
tests whether a list is empty
rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n)
insert a node before a list
rt_inline rt_slist_t * rt_slist_pop(rt_slist_t *l)
rt_inline unsigned int rt_slist_len(const rt_slist_t *l)
rt_inline void rt_list_init(rt_list_t *l)
initialize a list
rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
insert a node after a list
rt_inline rt_slist_t * rt_slist_next(rt_slist_t *n)
rt_inline rt_slist_t * rt_slist_remove(rt_slist_t *l, rt_slist_t *n)
rt_inline int rt_slist_isempty(rt_slist_t *l)
rt_inline void rt_slist_append(rt_slist_t *l, rt_slist_t *n)
rt_inline unsigned int rt_list_len(const rt_list_t *l)
get the list length
struct rt_list_node rt_list_t
struct rt_slist_node rt_slist_t
struct rt_list_node * next
struct rt_list_node * prev
struct rt_slist_node * next