diff options
Diffstat (limited to 'e2fsprogs/blkid/list.h')
-rw-r--r-- | e2fsprogs/blkid/list.h | 123 |
1 files changed, 8 insertions, 115 deletions
diff --git a/e2fsprogs/blkid/list.h b/e2fsprogs/blkid/list.h index cbf16a059..8b06d853b 100644 --- a/e2fsprogs/blkid/list.h +++ b/e2fsprogs/blkid/list.h | |||
@@ -6,12 +6,6 @@ | |||
6 | extern "C" { | 6 | extern "C" { |
7 | #endif | 7 | #endif |
8 | 8 | ||
9 | #ifdef __GNUC__ | ||
10 | #define _INLINE_ static __inline__ | ||
11 | #else /* For Watcom C */ | ||
12 | #define _INLINE_ static inline | ||
13 | #endif | ||
14 | |||
15 | /* | 9 | /* |
16 | * Simple doubly linked list implementation. | 10 | * Simple doubly linked list implementation. |
17 | * | 11 | * |
@@ -35,113 +29,14 @@ struct list_head { | |||
35 | (ptr)->next = (ptr); (ptr)->prev = (ptr); \ | 29 | (ptr)->next = (ptr); (ptr)->prev = (ptr); \ |
36 | } while (0) | 30 | } while (0) |
37 | 31 | ||
38 | /* | 32 | void __list_add(struct list_head * add, struct list_head * prev, struct list_head * next); |
39 | * Insert a new entry between two known consecutive entries. | 33 | void list_add(struct list_head *add, struct list_head *head); |
40 | * | 34 | void list_add_tail(struct list_head *add, struct list_head *head); |
41 | * This is only for internal list manipulation where we know | 35 | void __list_del(struct list_head * prev, struct list_head * next); |
42 | * the prev/next entries already! | 36 | void list_del(struct list_head *entry); |
43 | */ | 37 | void list_del_init(struct list_head *entry); |
44 | _INLINE_ void __list_add(struct list_head * add, | 38 | int list_empty(struct list_head *head); |
45 | struct list_head * prev, | 39 | void list_splice(struct list_head *list, struct list_head *head); |
46 | struct list_head * next) | ||
47 | { | ||
48 | next->prev = add; | ||
49 | add->next = next; | ||
50 | add->prev = prev; | ||
51 | prev->next = add; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * list_add - add a new entry | ||
56 | * @add: new entry to be added | ||
57 | * @head: list head to add it after | ||
58 | * | ||
59 | * Insert a new entry after the specified head. | ||
60 | * This is good for implementing stacks. | ||
61 | */ | ||
62 | _INLINE_ void list_add(struct list_head *add, struct list_head *head) | ||
63 | { | ||
64 | __list_add(add, head, head->next); | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * list_add_tail - add a new entry | ||
69 | * @add: new entry to be added | ||
70 | * @head: list head to add it before | ||
71 | * | ||
72 | * Insert a new entry before the specified head. | ||
73 | * This is useful for implementing queues. | ||
74 | */ | ||
75 | _INLINE_ void list_add_tail(struct list_head *add, struct list_head *head) | ||
76 | { | ||
77 | __list_add(add, head->prev, head); | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * Delete a list entry by making the prev/next entries | ||
82 | * point to each other. | ||
83 | * | ||
84 | * This is only for internal list manipulation where we know | ||
85 | * the prev/next entries already! | ||
86 | */ | ||
87 | _INLINE_ void __list_del(struct list_head * prev, | ||
88 | struct list_head * next) | ||
89 | { | ||
90 | next->prev = prev; | ||
91 | prev->next = next; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * list_del - deletes entry from list. | ||
96 | * @entry: the element to delete from the list. | ||
97 | * | ||
98 | * list_empty() on @entry does not return true after this, @entry is | ||
99 | * in an undefined state. | ||
100 | */ | ||
101 | _INLINE_ void list_del(struct list_head *entry) | ||
102 | { | ||
103 | __list_del(entry->prev, entry->next); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * list_del_init - deletes entry from list and reinitialize it. | ||
108 | * @entry: the element to delete from the list. | ||
109 | */ | ||
110 | _INLINE_ void list_del_init(struct list_head *entry) | ||
111 | { | ||
112 | __list_del(entry->prev, entry->next); | ||
113 | INIT_LIST_HEAD(entry); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * list_empty - tests whether a list is empty | ||
118 | * @head: the list to test. | ||
119 | */ | ||
120 | _INLINE_ int list_empty(struct list_head *head) | ||
121 | { | ||
122 | return head->next == head; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * list_splice - join two lists | ||
127 | * @list: the new list to add. | ||
128 | * @head: the place to add it in the first list. | ||
129 | */ | ||
130 | _INLINE_ void list_splice(struct list_head *list, struct list_head *head) | ||
131 | { | ||
132 | struct list_head *first = list->next; | ||
133 | |||
134 | if (first != list) { | ||
135 | struct list_head *last = list->prev; | ||
136 | struct list_head *at = head->next; | ||
137 | |||
138 | first->prev = head; | ||
139 | head->next = first; | ||
140 | |||
141 | last->next = at; | ||
142 | at->prev = last; | ||
143 | } | ||
144 | } | ||
145 | 40 | ||
146 | /** | 41 | /** |
147 | * list_entry - get the struct for this entry | 42 | * list_entry - get the struct for this entry |
@@ -171,8 +66,6 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head) | |||
171 | for (pos = (head)->next, pnext = pos->next; pos != (head); \ | 66 | for (pos = (head)->next, pnext = pos->next; pos != (head); \ |
172 | pos = pnext, pnext = pos->next) | 67 | pos = pnext, pnext = pos->next) |
173 | 68 | ||
174 | #undef _INLINE_ | ||
175 | |||
176 | #ifdef __cplusplus | 69 | #ifdef __cplusplus |
177 | } | 70 | } |
178 | #endif | 71 | #endif |