6 /* ideas for this picked from linux */
8 /* if you have an apparent problem with lists, check you didn't add the same
11 #define DEFINE_LIST(name) \
12 struct list name = { \
22 static inline void list_init(struct list
*list
)
28 static inline void list_add(struct list
*list
, struct list
*knew
)
30 knew
->next
= list
->next
;
32 list
->next
->prev
= knew
;
36 static inline void list_add_tail(struct list
*list
, struct list
*knew
)
39 knew
->prev
= list
->prev
;
40 list
->prev
->next
= knew
;
44 static inline void list_del(struct list
*todel
)
46 todel
->prev
->next
= todel
->next
;
47 todel
->next
->prev
= todel
->prev
;
48 todel
->prev
= todel
->next
= (struct list
*)MAGIC_LIST_INVALID
;
51 static inline int list_empty(struct list
*list
)
53 return list
== list
->next
;
56 #define list_entry(list, type, member) \
57 ({ (type*)((char*)list-(char*)&(((type*)0)->member)); })
59 #define list_for_each(list, iterator) \
60 for (iterator=(list)->next; iterator!=list; iterator=iterator->next)
62 #define list_for_each_safe(list, iterator, saved) \
63 for (iterator=(list)->next, saved=iterator->next; iterator!=list; iterator=saved, saved=iterator->next)