1 #ifndef ETHTOOL_LIST_H__ 2 #define ETHTOOL_LIST_H__ 3 4 #include <unistd.h> 5 6 /* Generic list utilities */ 7 8 struct list_head { 9 struct list_head *next, *prev; 10 }; 11 12 #define LIST_HEAD_INIT(name) { &(name), &(name) } 13 list_add(struct list_head * new,struct list_head * head)14static inline void list_add(struct list_head *new, struct list_head *head) 15 { 16 head->next->prev = new; 17 new->next = head->next; 18 new->prev = head; 19 head->next = new; 20 } 21 list_del(struct list_head * entry)22static inline void list_del(struct list_head *entry) 23 { 24 entry->next->prev = entry->prev; 25 entry->prev->next = entry->next; 26 entry->next = NULL; 27 entry->prev = NULL; 28 } 29 30 #define list_for_each_safe(pos, n, head) \ 31 for (pos = (head)->next, n = pos->next; pos != (head); \ 32 pos = n, n = pos->next) 33 34 #endif 35