annotate src/lib/llist.h @ 22664:fea53c2725c0

director: Fix director_max_parallel_moves/kicks type Should be uint, not time.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 09 Nov 2017 12:24:16 +0200
parents 46e47e4082d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 #ifndef LLIST_H
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 #define LLIST_H
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 /* Doubly linked list */
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
5 #define DLLIST_PREPEND_FULL(list, item, prev, next) STMT_START { \
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 (item)->prev = NULL; \
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 (item)->next = *(list); \
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 if (*(list) != NULL) (*(list))->prev = (item); \
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 *(list) = (item); \
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 } STMT_END
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
12 #define DLLIST_PREPEND(list, item) \
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
13 DLLIST_PREPEND_FULL(list, item, prev, next)
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
14
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
15 #define DLLIST_REMOVE_FULL(list, item, prev, next) STMT_START { \
17577
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
16 if ((item)->prev != NULL) \
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
17 (item)->prev->next = (item)->next; \
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
18 else if ((*list) == item) \
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 *(list) = (item)->next; \
10261
16d40abb75b8 DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.
Timo Sirainen <tss@iki.fi>
parents: 7118
diff changeset
20 if ((item)->next != NULL) { \
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 (item)->next->prev = (item)->prev; \
10261
16d40abb75b8 DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.
Timo Sirainen <tss@iki.fi>
parents: 7118
diff changeset
22 (item)->next = NULL; \
16d40abb75b8 DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.
Timo Sirainen <tss@iki.fi>
parents: 7118
diff changeset
23 } \
16d40abb75b8 DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.
Timo Sirainen <tss@iki.fi>
parents: 7118
diff changeset
24 (item)->prev = NULL; \
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 } STMT_END
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
27 #define DLLIST_REMOVE(list, item) \
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
28 DLLIST_REMOVE_FULL(list, item, prev, next)
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
29
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
30 /* Doubly linked list with head and tail */
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
31 #define DLLIST2_PREPEND_FULL(head, tail, item, prev, next) STMT_START { \
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
32 (item)->prev = NULL; \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
33 (item)->next = *(head); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
34 if (*(head) != NULL) (*(head))->prev = (item); else (*tail) = (item); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
35 *(head) = (item); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
36 } STMT_END
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
37
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
38 #define DLLIST2_PREPEND(head, tail, item) \
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
39 DLLIST2_PREPEND_FULL(head, tail, item, prev, next)
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
40
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
41 #define DLLIST2_APPEND_FULL(head, tail, item, prev, next) STMT_START { \
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
42 (item)->prev = *(tail); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
43 (item)->next = NULL; \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
44 if (*(tail) != NULL) (*(tail))->next = (item); else (*head) = (item); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
45 *(tail) = (item); \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
46 } STMT_END
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
47
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
48 #define DLLIST2_APPEND(head, tail, item) \
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
49 DLLIST2_APPEND_FULL(head, tail, item, prev, next)
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
50
16296
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
51 #define DLLIST2_INSERT_AFTER_FULL(head, tail, after, item, prev, next) \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
52 STMT_START { \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
53 (item)->prev = (after); \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
54 (item)->next = (after)->next; \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
55 (after)->next = (item); \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
56 if (*(tail) == (after)) \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
57 *(tail) = (item); \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
58 } STMT_END
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
59
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
60 #define DLLIST2_INSERT_AFTER(head, tail, after, item) \
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
61 DLLIST2_INSERT_AFTER_FULL(head, tail, after, item, prev, next)
bafcb428167b liblib: Added DLLIST2_INSERT_AFTER_FULL()
Stephan Bosch <stephan@rename-it.nl>
parents: 13288
diff changeset
62
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
63 #define DLLIST2_REMOVE_FULL(head, tail, item, prev, next) STMT_START { \
17577
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
64 if ((item)->prev != NULL) \
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
65 (item)->prev->next = (item)->next; \
17577
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
66 else if (*(head) == item) \
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
67 *(head) = (item)->next; \
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
68 if ((item)->next != NULL) { \
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
69 (item)->next->prev = (item)->prev; \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
70 (item)->next = NULL; \
17577
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
71 } else if ((*tail) == item) \
46e47e4082d8 lib: DLLIST*_REMOVE*() no longer breaks the linked list if we try to remove item that doesn't exist there.
Timo Sirainen <tss@iki.fi>
parents: 16296
diff changeset
72 *(tail) = (item)->prev; \
10262
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
73 (item)->prev = NULL; \
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
74 } STMT_END
07e0e2b4abe1 Added DLLIST2_*() functions for doubly linked list with head and tail.
Timo Sirainen <tss@iki.fi>
parents: 10261
diff changeset
75
13288
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
76 #define DLLIST2_REMOVE(head, tail, item) \
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
77 DLLIST2_REMOVE_FULL(head, tail, item, prev, next)
eaee3b8a98cf liblib: Added _FULL versions of all linked list handling macros with prev and next params.
Timo Sirainen <tss@iki.fi>
parents: 10262
diff changeset
78
7118
b626d8975193 Added macros for handling a doubly linked list.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 #endif