forked from lichao2014/name_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.h
48 lines (38 loc) · 1.33 KB
/
list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _LIST_H_INCLUDED
#define _LIST_H_INCLUDED
#include <stdlib.h>
#include "comm.h"
struct list_t {
struct list_t *prev;
struct list_t *next;
};
#define list_init(l) \
do { \
(l)->prev = (l)->next = NULL; \
} while (0)
#define list_empty(l) \
(l)->prev == (l)->next
#define list_insert_after(l, i) \
do { \
(i)->prev = (l); \
(i)->next = (l)->next; \
(l)->next = (i); \
} while(0)
#define list_insert_before(l, i) \
do { \
(i)->prev = (l)->prev; \
(i)->next = (l); \
(l)->prev = (i); \
} while(0)
#define list_del(i) \
do { \
if ((i)->next) { \
(i)->next->prev = (i)->prev; \
} \
if ((i)->prev) { \
(i)->prev->next = (i)->next; \
} \
} while (0)
#define list_of(i, T, m) \
container_of(i, T, m)
#endif //!_LIST_H_INCLUDED