Skip to content

Commit 1428c6d

Browse files
committed
shims: flesh out generic_sys_queue.h further
The 1121 merge introduced additional usage of sys/queue.h. Flesh out the shims header further to repair the build on Windows.
1 parent fdc684b commit 1428c6d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/shims/generic_sys_queue.h

+42
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,46 @@
8989
} \
9090
} while(0)
9191

92+
#define TAILQ_HEAD_INITIALIZER(head) \
93+
{ NULL, (head).tq_first }
94+
95+
#define TAILQ_CONCAT(head1, head2, field) do { \
96+
if (!TAILQ_EMPTY(head2)) { \
97+
(head1)->tq_last = (head2)->tq_first; \
98+
(head1)->tq_first->field.te_prev = (head1)->tq_last; \
99+
(head1)->tq_last = (head2)->tq_last; \
100+
TAILQ_INIT((head2)); \
101+
} \
102+
} while (0)
103+
104+
#define LIST_HEAD(name, type) struct name { \
105+
struct type *lh_first; \
106+
}
107+
108+
#define LIST_ENTRY(type) struct { \
109+
struct type *le_next; \
110+
struct type *le_prev; \
111+
}
112+
113+
#define LIST_FIRST(head) ((head)->lh_first)
114+
115+
#define LIST_FOREACH(var, head, field) \
116+
for ((var) = LIST_FIRST((head)); \
117+
(var); \
118+
(var) = LIST_NEXT((var), field))
119+
120+
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
121+
122+
#define LIST_REMOVE(elm, field) do { \
123+
if (LIST_NEXT((elm), field) != NULL) \
124+
LIST_NEXT((elm), field)->field.le_prev = (elm)->field.le_prev; \
125+
} while (0)
126+
127+
#define LIST_INSERT_HEAD(head, elm, field) do { \
128+
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
129+
LIST_FIRST((head))->field.le_prev = LIST_NEXT((elm), field); \
130+
LIST_FIRST((head)) = (elm); \
131+
(elm)->field.le_prev = LIST_FIRST((head)); \
132+
} while (0)
133+
92134
#endif // __DISPATCH_SHIMS_SYS_QUEUE__

0 commit comments

Comments
 (0)