1 #ifndef LIST_H_87698769870987
2 #define LIST_H_87698769870987
5 struct dlist *next, *prev;
8 #define init_list_entry(ptr) \
10 (ptr)->prev = ptr; (ptr)->next = ptr; } \
12 #define declare_list(_name_) struct dlist _name_ = {&(_name_), &(_name_) }
14 static inline void list_add_head(struct dlist *new, struct dlist *list)
16 list->next->prev = new;
18 new->next = list->next;
22 static inline void list_add_tail(struct dlist *new, struct dlist *list)
24 list->prev->next = new;
25 new->prev = list->prev;
29 static inline void list_del(struct dlist *entry)
31 entry->next->prev = entry->prev;
32 entry->prev->next = entry->next;
35 static inline int list_empty(struct dlist *list)
37 return list->next == list;
40 #define list_get_first(listhead) \
43 #define list_get_next(_entry_) \
46 #define list_get_entry(entry, type, structmember) \
47 ((type *) ((char *)(entry) - (unsigned long)(&((type *)0)->structmember)))
49 #define list_iterate(entry, listhead) \
50 for(entry = (listhead)->next; entry != (listhead); entry = entry->next)
52 #define list_iterate_safe(entry, save, listhead) \
53 for(entry = (listhead)->next, save = entry->next; entry != (listhead); \
54 entry = save, save = save->next)
57 #endif /* #ifndef LIST_H_87698769870987 */