1
2
3
4
5 #define DLNODE(ptype) \
6 struct { \
7 ptype * dl_prev; \
8 ptype * dl_next; \
9 }
10
11 #define DNODE_SINGLE(node) {(node),(node)}
12 #define DNODE_NULL {0,0}
13
14 #define DLIST_INIT(listnam) \
15 (listnam).dl_prev = &(listnam); \
16 (listnam).dl_last = &(listnam);
17
18 #define DLIST_NEXT(listnam) listnam.dl_next
19 #define DLIST_PREV(listnam) listnam.dl_prev
20
21 #define DLIST_INSERT_AFTER(node, new, listnam) do { \
22 (new)->listnam.dl_prev = (node); \
23 (new)->listnam.dl_next = (node)->listnam.dl_next; \
24 (node)->listnam.dl_next->listnam.dl_prev = (new); \
25 (node)->listnam.dl_next = (new); \
26 } while (0)
27
28 #define DLIST_INSERT_BEFORE(node, new, listnam) do { \
29 (new)->listnam.dl_next = (node); \
30 (new)->listnam.dl_prev = (node)->listnam.dl_prev; \
31 (node)->listnam.dl_prev->listnam.dl_next = (new); \
32 (node)->listnam.dl_prev = (new); \
33 } while (0)
34
35 #define DLIST_DELETE(node, listnam) do { \
36 node->listnam.dl_prev->listnam.dl_next = \
37 node->listnam.dl_next; \
38 node->listnam.dl_next->listnam.dl_prev = \
39 node->listnam.dl_prev; \
40 } while (0)