Changes for kernel and Busybox
[tomato.git] / release / src / router / busybox / e2fsprogs / blkid / list.c
blob04d61a19baddaed01dc4280a399b5eb25dbe74c5
1 /* vi: set sw=4 ts=4: */
3 #include "list.h"
5 /*
6 * Insert a new entry between two known consecutive entries.
8 * This is only for internal list manipulation where we know
9 * the prev/next entries already!
11 void __list_add(struct list_head * add,
12 struct list_head * prev,
13 struct list_head * next)
15 next->prev = add;
16 add->next = next;
17 add->prev = prev;
18 prev->next = add;
22 * list_add - add a new entry
23 * @add: new entry to be added
24 * @head: list head to add it after
26 * Insert a new entry after the specified head.
27 * This is good for implementing stacks.
29 void list_add(struct list_head *add, struct list_head *head)
31 __list_add(add, head, head->next);
35 * list_add_tail - add a new entry
36 * @add: new entry to be added
37 * @head: list head to add it before
39 * Insert a new entry before the specified head.
40 * This is useful for implementing queues.
42 void list_add_tail(struct list_head *add, struct list_head *head)
44 __list_add(add, head->prev, head);
48 * Delete a list entry by making the prev/next entries
49 * point to each other.
51 * This is only for internal list manipulation where we know
52 * the prev/next entries already!
54 void __list_del(struct list_head * prev, struct list_head * next)
56 next->prev = prev;
57 prev->next = next;
61 * list_del - deletes entry from list.
62 * @entry: the element to delete from the list.
64 * list_empty() on @entry does not return true after this, @entry is
65 * in an undefined state.
67 void list_del(struct list_head *entry)
69 __list_del(entry->prev, entry->next);
73 * list_del_init - deletes entry from list and reinitialize it.
74 * @entry: the element to delete from the list.
76 void list_del_init(struct list_head *entry)
78 __list_del(entry->prev, entry->next);
79 INIT_LIST_HEAD(entry);
83 * list_empty - tests whether a list is empty
84 * @head: the list to test.
86 int list_empty(struct list_head *head)
88 return head->next == head;
92 * list_splice - join two lists
93 * @list: the new list to add.
94 * @head: the place to add it in the first list.
96 void list_splice(struct list_head *list, struct list_head *head)
98 struct list_head *first = list->next;
100 if (first != list) {
101 struct list_head *last = list->prev;
102 struct list_head *at = head->next;
104 first->prev = head;
105 head->next = first;
107 last->next = at;
108 at->prev = last;