1
2#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD)
3#define BLKID_LIST_H 1
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
10
11
12
13
14
15
16
17
18
19struct list_head {
20 struct list_head *next, *prev;
21};
22
23#define LIST_HEAD_INIT(name) { &(name), &(name) }
24
25#define LIST_HEAD(name) \
26 struct list_head name = LIST_HEAD_INIT(name)
27
28#define INIT_LIST_HEAD(ptr) do { \
29 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
30} while (0)
31
32void __list_add(struct list_head * add, struct list_head * prev, struct list_head * next);
33void list_add(struct list_head *add, struct list_head *head);
34void list_add_tail(struct list_head *add, struct list_head *head);
35void __list_del(struct list_head * prev, struct list_head * next);
36void list_del(struct list_head *entry);
37void list_del_init(struct list_head *entry);
38int list_empty(struct list_head *head);
39void list_splice(struct list_head *list, struct list_head *head);
40
41
42
43
44
45
46
47#define list_entry(ptr, type, member) \
48 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
49
50
51
52
53
54
55#define list_for_each(pos, head) \
56 for (pos = (head)->next; pos != (head); pos = pos->next)
57
58
59
60
61
62
63
64
65#define list_for_each_safe(pos, pnext, head) \
66 for (pos = (head)->next, pnext = pos->next; pos != (head); \
67 pos = pnext, pnext = pos->next)
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif
74