| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef _Node_List_h_
- #define _Node_List_h_
- typedef struct node_list {
- struct node_list *next;
- struct node_list *prev;
- }node_list_t;
- #define LIST_HEAD_INIT(name) { &(name), &(name) }
- #define LIST_HEAD(name) \
- struct node_list name = LIST_HEAD_INIT(name)
- static inline void init_list_node(struct node_list *list)
- {
- list->next = list;
- list->prev = list;
- }
- static inline void INIT_LIST_HEAD(struct node_list *list)
- {
- list->next = list;
- list->prev = list;
- }
- /*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
- static inline void __list_add(struct node_list *node, struct node_list *prev, struct node_list *next)
- {
- next->prev = node;
- node->next = next;
- node->prev = prev;
- prev->next = node;
- }
- static inline void list_add_head(struct node_list *head, struct node_list *node) {
- __list_add(node, head, head->next);
- }
- static inline void list_add_tail(struct node_list *head, struct node_list *node)
- {
- __list_add(node, head->prev, head);
- }
- static inline void __list_del(struct node_list * prev, struct node_list * next)
- {
- next->prev = prev;
- prev->next = next;
- }
- /**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty() on entry does not return true after this, the entry is
- * in an undefined state.
- */
- static inline void __list_del_entry(struct node_list *entry)
- {
- __list_del(entry->prev, entry->next);
- }
- static inline void list_del(struct node_list *entry)
- {
- __list_del_entry(entry);
- }
- /**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
- static inline int list_empty(const struct node_list *head)
- {
- return head->next == head;
- }
- #define list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
- #define list_for_each_safe(pos, n, head) \
- for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
- #define list_add list_add_tail
- #endif //_Node_List_h_
|