SO_LINGER test
[corutils.git] / list.h
blob2f76787ab4d1d90b6a5d64def803e8346c53d826
1 /**
2 * Copied from linux kernel 3.1.0 include/linux/list.h and include/linux/types.h
3 * with some modifications and unused code removed
4 * License is GPLv2 only
5 */
7 struct list_head {
8 struct list_head *next, *prev;
9 };
11 static inline void init_list_head(struct list_head *list)
13 list->next = list;
14 list->prev = list;
18 * Insert a new entry between two known consecutive entries.
20 * This is only for internal list manipulation where we know
21 * the prev/next entries already!
23 static inline void __list_add(struct list_head *new,
24 struct list_head *prev,
25 struct list_head *next)
27 next->prev = new;
28 new->next = next;
29 new->prev = prev;
30 prev->next = new;
33 /**
34 * list_add - add a new entry
35 * @new: new entry to be added
36 * @head: list head to add it after
38 * Insert a new entry after the specified head.
39 * This is good for implementing stacks.
41 static inline void list_add(struct list_head *new, struct list_head *head)
43 __list_add(new, head, head->next);
47 /**
48 * list_add_tail - add a new entry
49 * @new: new entry to be added
50 * @head: list head to add it before
52 * Insert a new entry before the specified head.
53 * This is useful for implementing queues.
55 static inline void list_add_tail(struct list_head *new, struct list_head *head)
57 __list_add(new, head->prev, head);
61 * Delete a list entry by making the prev/next entries
62 * point to each other.
64 * This is only for internal list manipulation where we know
65 * the prev/next entries already!
67 static inline void __list_del(struct list_head * prev, struct list_head * next)
69 next->prev = prev;
70 prev->next = next;
73 static inline void list_del(struct list_head *entry)
75 __list_del(entry->prev, entry->next);
76 entry->next = 0;
77 entry->prev = 0;
80 /**
81 * list_empty - tests whether a list is empty
82 * @head: the list to test.
84 static inline int list_empty(const struct list_head *head)
86 return head->next == head;