Dash:
[t2-trunk.git] / package / base / musl / queue.h.patch
blob5577b0fb53edc730f09f71b5d6c6dce503ad6b26
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/musl/queue.h.patch
3 # Copyright (C) 2021 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
15 as needed by libtirpc:
16 clnt_bcast.c:43:10: fatal error: sys/queue.h: No such file or directory
18 --- /dev/null 2021-10-10 17:05:32.683916122 +0200
19 +++ musl-1.2.2/include/sys/queue.h 2021-10-10 18:48:57.538546284 +0200
20 @@ -0,0 +1,574 @@
21 +/*
22 + * Copyright (c) 1991, 1993
23 + * The Regents of the University of California. All rights reserved.
24 + *
25 + * Redistribution and use in source and binary forms, with or without
26 + * modification, are permitted provided that the following conditions
27 + * are met:
28 + * 1. Redistributions of source code must retain the above copyright
29 + * notice, this list of conditions and the following disclaimer.
30 + * 2. Redistributions in binary form must reproduce the above copyright
31 + * notice, this list of conditions and the following disclaimer in the
32 + * documentation and/or other materials provided with the distribution.
33 + * 3. Neither the name of the University nor the names of its contributors
34 + * may be used to endorse or promote products derived from this software
35 + * without specific prior written permission.
36 + *
37 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
38 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
41 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 + * SUCH DAMAGE.
48 + *
49 + * @(#)queue.h 8.5 (Berkeley) 8/20/94
50 + */
52 +#ifndef _SYS_QUEUE_H_
53 +#define _SYS_QUEUE_H_
55 +/*
56 + * This file defines five types of data structures: singly-linked lists,
57 + * lists, simple queues, tail queues, and circular queues.
58 + *
59 + * A singly-linked list is headed by a single forward pointer. The
60 + * elements are singly linked for minimum space and pointer manipulation
61 + * overhead at the expense of O(n) removal for arbitrary elements. New
62 + * elements can be added to the list after an existing element or at the
63 + * head of the list. Elements being removed from the head of the list
64 + * should use the explicit macro for this purpose for optimum
65 + * efficiency. A singly-linked list may only be traversed in the forward
66 + * direction. Singly-linked lists are ideal for applications with large
67 + * datasets and few or no removals or for implementing a LIFO queue.
68 + *
69 + * A list is headed by a single forward pointer (or an array of forward
70 + * pointers for a hash table header). The elements are doubly linked
71 + * so that an arbitrary element can be removed without a need to
72 + * traverse the list. New elements can be added to the list before
73 + * or after an existing element or at the head of the list. A list
74 + * may only be traversed in the forward direction.
75 + *
76 + * A simple queue is headed by a pair of pointers, one the head of the
77 + * list and the other to the tail of the list. The elements are singly
78 + * linked to save space, so elements can only be removed from the
79 + * head of the list. New elements can be added to the list after
80 + * an existing element, at the head of the list, or at the end of the
81 + * list. A simple queue may only be traversed in the forward direction.
82 + *
83 + * A tail queue is headed by a pair of pointers, one to the head of the
84 + * list and the other to the tail of the list. The elements are doubly
85 + * linked so that an arbitrary element can be removed without a need to
86 + * traverse the list. New elements can be added to the list before or
87 + * after an existing element, at the head of the list, or at the end of
88 + * the list. A tail queue may be traversed in either direction.
89 + *
90 + * A circle queue is headed by a pair of pointers, one to the head of the
91 + * list and the other to the tail of the list. The elements are doubly
92 + * linked so that an arbitrary element can be removed without a need to
93 + * traverse the list. New elements can be added to the list before or after
94 + * an existing element, at the head of the list, or at the end of the list.
95 + * A circle queue may be traversed in either direction, but has a more
96 + * complex end of list detection.
97 + *
98 + * For details on the use of these macros, see the queue(3) manual page.
99 + */
102 + * List definitions.
103 + */
104 +#define LIST_HEAD(name, type) \
105 +struct name { \
106 + struct type *lh_first; /* first element */ \
109 +#define LIST_HEAD_INITIALIZER(head) \
110 + { NULL }
112 +#define LIST_ENTRY(type) \
113 +struct { \
114 + struct type *le_next; /* next element */ \
115 + struct type **le_prev; /* address of previous next element */ \
119 + * List functions.
120 + */
121 +#define LIST_INIT(head) do { \
122 + (head)->lh_first = NULL; \
123 +} while (/*CONSTCOND*/0)
125 +#define LIST_INSERT_AFTER(listelm, elm, field) do { \
126 + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
127 + (listelm)->field.le_next->field.le_prev = \
128 + &(elm)->field.le_next; \
129 + (listelm)->field.le_next = (elm); \
130 + (elm)->field.le_prev = &(listelm)->field.le_next; \
131 +} while (/*CONSTCOND*/0)
133 +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
134 + (elm)->field.le_prev = (listelm)->field.le_prev; \
135 + (elm)->field.le_next = (listelm); \
136 + *(listelm)->field.le_prev = (elm); \
137 + (listelm)->field.le_prev = &(elm)->field.le_next; \
138 +} while (/*CONSTCOND*/0)
140 +#define LIST_INSERT_HEAD(head, elm, field) do { \
141 + if (((elm)->field.le_next = (head)->lh_first) != NULL) \
142 + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
143 + (head)->lh_first = (elm); \
144 + (elm)->field.le_prev = &(head)->lh_first; \
145 +} while (/*CONSTCOND*/0)
147 +#define LIST_REMOVE(elm, field) do { \
148 + if ((elm)->field.le_next != NULL) \
149 + (elm)->field.le_next->field.le_prev = \
150 + (elm)->field.le_prev; \
151 + *(elm)->field.le_prev = (elm)->field.le_next; \
152 +} while (/*CONSTCOND*/0)
154 +#define LIST_FOREACH(var, head, field) \
155 + for ((var) = ((head)->lh_first); \
156 + (var); \
157 + (var) = ((var)->field.le_next))
160 + * List access methods.
161 + */
162 +#define LIST_EMPTY(head) ((head)->lh_first == NULL)
163 +#define LIST_FIRST(head) ((head)->lh_first)
164 +#define LIST_NEXT(elm, field) ((elm)->field.le_next)
168 + * Singly-linked List definitions.
169 + */
170 +#define SLIST_HEAD(name, type) \
171 +struct name { \
172 + struct type *slh_first; /* first element */ \
175 +#define SLIST_HEAD_INITIALIZER(head) \
176 + { NULL }
178 +#define SLIST_ENTRY(type) \
179 +struct { \
180 + struct type *sle_next; /* next element */ \
184 + * Singly-linked List functions.
185 + */
186 +#define SLIST_INIT(head) do { \
187 + (head)->slh_first = NULL; \
188 +} while (/*CONSTCOND*/0)
190 +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
191 + (elm)->field.sle_next = (slistelm)->field.sle_next; \
192 + (slistelm)->field.sle_next = (elm); \
193 +} while (/*CONSTCOND*/0)
195 +#define SLIST_INSERT_HEAD(head, elm, field) do { \
196 + (elm)->field.sle_next = (head)->slh_first; \
197 + (head)->slh_first = (elm); \
198 +} while (/*CONSTCOND*/0)
200 +#define SLIST_REMOVE_HEAD(head, field) do { \
201 + (head)->slh_first = (head)->slh_first->field.sle_next; \
202 +} while (/*CONSTCOND*/0)
204 +#define SLIST_REMOVE(head, elm, type, field) do { \
205 + if ((head)->slh_first == (elm)) { \
206 + SLIST_REMOVE_HEAD((head), field); \
207 + } \
208 + else { \
209 + struct type *curelm = (head)->slh_first; \
210 + while(curelm->field.sle_next != (elm)) \
211 + curelm = curelm->field.sle_next; \
212 + curelm->field.sle_next = \
213 + curelm->field.sle_next->field.sle_next; \
214 + } \
215 +} while (/*CONSTCOND*/0)
217 +#define SLIST_FOREACH(var, head, field) \
218 + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
221 + * Singly-linked List access methods.
222 + */
223 +#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
224 +#define SLIST_FIRST(head) ((head)->slh_first)
225 +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
229 + * Singly-linked Tail queue declarations.
230 + */
231 +#define STAILQ_HEAD(name, type) \
232 +struct name { \
233 + struct type *stqh_first; /* first element */ \
234 + struct type **stqh_last; /* addr of last next element */ \
237 +#define STAILQ_HEAD_INITIALIZER(head) \
238 + { NULL, &(head).stqh_first }
240 +#define STAILQ_ENTRY(type) \
241 +struct { \
242 + struct type *stqe_next; /* next element */ \
246 + * Singly-linked Tail queue functions.
247 + */
248 +#define STAILQ_INIT(head) do { \
249 + (head)->stqh_first = NULL; \
250 + (head)->stqh_last = &(head)->stqh_first; \
251 +} while (/*CONSTCOND*/0)
253 +#define STAILQ_INSERT_HEAD(head, elm, field) do { \
254 + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
255 + (head)->stqh_last = &(elm)->field.stqe_next; \
256 + (head)->stqh_first = (elm); \
257 +} while (/*CONSTCOND*/0)
259 +#define STAILQ_INSERT_TAIL(head, elm, field) do { \
260 + (elm)->field.stqe_next = NULL; \
261 + *(head)->stqh_last = (elm); \
262 + (head)->stqh_last = &(elm)->field.stqe_next; \
263 +} while (/*CONSTCOND*/0)
265 +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
266 + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
267 + (head)->stqh_last = &(elm)->field.stqe_next; \
268 + (listelm)->field.stqe_next = (elm); \
269 +} while (/*CONSTCOND*/0)
271 +#define STAILQ_REMOVE_HEAD(head, field) do { \
272 + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
273 + (head)->stqh_last = &(head)->stqh_first; \
274 +} while (/*CONSTCOND*/0)
276 +#define STAILQ_REMOVE(head, elm, type, field) do { \
277 + if ((head)->stqh_first == (elm)) { \
278 + STAILQ_REMOVE_HEAD((head), field); \
279 + } else { \
280 + struct type *curelm = (head)->stqh_first; \
281 + while (curelm->field.stqe_next != (elm)) \
282 + curelm = curelm->field.stqe_next; \
283 + if ((curelm->field.stqe_next = \
284 + curelm->field.stqe_next->field.stqe_next) == NULL) \
285 + (head)->stqh_last = &(curelm)->field.stqe_next; \
286 + } \
287 +} while (/*CONSTCOND*/0)
289 +#define STAILQ_FOREACH(var, head, field) \
290 + for ((var) = ((head)->stqh_first); \
291 + (var); \
292 + (var) = ((var)->field.stqe_next))
294 +#define STAILQ_CONCAT(head1, head2) do { \
295 + if (!STAILQ_EMPTY((head2))) { \
296 + *(head1)->stqh_last = (head2)->stqh_first; \
297 + (head1)->stqh_last = (head2)->stqh_last; \
298 + STAILQ_INIT((head2)); \
299 + } \
300 +} while (/*CONSTCOND*/0)
303 + * Singly-linked Tail queue access methods.
304 + */
305 +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
306 +#define STAILQ_FIRST(head) ((head)->stqh_first)
307 +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
311 + * Simple queue definitions.
312 + */
313 +#define SIMPLEQ_HEAD(name, type) \
314 +struct name { \
315 + struct type *sqh_first; /* first element */ \
316 + struct type **sqh_last; /* addr of last next element */ \
319 +#define SIMPLEQ_HEAD_INITIALIZER(head) \
320 + { NULL, &(head).sqh_first }
322 +#define SIMPLEQ_ENTRY(type) \
323 +struct { \
324 + struct type *sqe_next; /* next element */ \
328 + * Simple queue functions.
329 + */
330 +#define SIMPLEQ_INIT(head) do { \
331 + (head)->sqh_first = NULL; \
332 + (head)->sqh_last = &(head)->sqh_first; \
333 +} while (/*CONSTCOND*/0)
335 +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
336 + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
337 + (head)->sqh_last = &(elm)->field.sqe_next; \
338 + (head)->sqh_first = (elm); \
339 +} while (/*CONSTCOND*/0)
341 +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
342 + (elm)->field.sqe_next = NULL; \
343 + *(head)->sqh_last = (elm); \
344 + (head)->sqh_last = &(elm)->field.sqe_next; \
345 +} while (/*CONSTCOND*/0)
347 +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
348 + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
349 + (head)->sqh_last = &(elm)->field.sqe_next; \
350 + (listelm)->field.sqe_next = (elm); \
351 +} while (/*CONSTCOND*/0)
353 +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
354 + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
355 + (head)->sqh_last = &(head)->sqh_first; \
356 +} while (/*CONSTCOND*/0)
358 +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
359 + if ((head)->sqh_first == (elm)) { \
360 + SIMPLEQ_REMOVE_HEAD((head), field); \
361 + } else { \
362 + struct type *curelm = (head)->sqh_first; \
363 + while (curelm->field.sqe_next != (elm)) \
364 + curelm = curelm->field.sqe_next; \
365 + if ((curelm->field.sqe_next = \
366 + curelm->field.sqe_next->field.sqe_next) == NULL) \
367 + (head)->sqh_last = &(curelm)->field.sqe_next; \
368 + } \
369 +} while (/*CONSTCOND*/0)
371 +#define SIMPLEQ_FOREACH(var, head, field) \
372 + for ((var) = ((head)->sqh_first); \
373 + (var); \
374 + (var) = ((var)->field.sqe_next))
377 + * Simple queue access methods.
378 + */
379 +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
380 +#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
381 +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
385 + * Tail queue definitions.
386 + */
387 +#define _TAILQ_HEAD(name, type, qual) \
388 +struct name { \
389 + qual type *tqh_first; /* first element */ \
390 + qual type *qual *tqh_last; /* addr of last next element */ \
392 +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
394 +#define TAILQ_HEAD_INITIALIZER(head) \
395 + { NULL, &(head).tqh_first }
397 +#define _TAILQ_ENTRY(type, qual) \
398 +struct { \
399 + qual type *tqe_next; /* next element */ \
400 + qual type *qual *tqe_prev; /* address of previous next element */\
402 +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
405 + * Tail queue functions.
406 + */
407 +#define TAILQ_INIT(head) do { \
408 + (head)->tqh_first = NULL; \
409 + (head)->tqh_last = &(head)->tqh_first; \
410 +} while (/*CONSTCOND*/0)
412 +#define TAILQ_INSERT_HEAD(head, elm, field) do { \
413 + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
414 + (head)->tqh_first->field.tqe_prev = \
415 + &(elm)->field.tqe_next; \
416 + else \
417 + (head)->tqh_last = &(elm)->field.tqe_next; \
418 + (head)->tqh_first = (elm); \
419 + (elm)->field.tqe_prev = &(head)->tqh_first; \
420 +} while (/*CONSTCOND*/0)
422 +#define TAILQ_INSERT_TAIL(head, elm, field) do { \
423 + (elm)->field.tqe_next = NULL; \
424 + (elm)->field.tqe_prev = (head)->tqh_last; \
425 + *(head)->tqh_last = (elm); \
426 + (head)->tqh_last = &(elm)->field.tqe_next; \
427 +} while (/*CONSTCOND*/0)
429 +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
430 + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
431 + (elm)->field.tqe_next->field.tqe_prev = \
432 + &(elm)->field.tqe_next; \
433 + else \
434 + (head)->tqh_last = &(elm)->field.tqe_next; \
435 + (listelm)->field.tqe_next = (elm); \
436 + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
437 +} while (/*CONSTCOND*/0)
439 +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
440 + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
441 + (elm)->field.tqe_next = (listelm); \
442 + *(listelm)->field.tqe_prev = (elm); \
443 + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
444 +} while (/*CONSTCOND*/0)
446 +#define TAILQ_REMOVE(head, elm, field) do { \
447 + if (((elm)->field.tqe_next) != NULL) \
448 + (elm)->field.tqe_next->field.tqe_prev = \
449 + (elm)->field.tqe_prev; \
450 + else \
451 + (head)->tqh_last = (elm)->field.tqe_prev; \
452 + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
453 +} while (/*CONSTCOND*/0)
455 +#define TAILQ_FOREACH(var, head, field) \
456 + for ((var) = ((head)->tqh_first); \
457 + (var); \
458 + (var) = ((var)->field.tqe_next))
460 +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
461 + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
462 + (var); \
463 + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
465 +#define TAILQ_CONCAT(head1, head2, field) do { \
466 + if (!TAILQ_EMPTY(head2)) { \
467 + *(head1)->tqh_last = (head2)->tqh_first; \
468 + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
469 + (head1)->tqh_last = (head2)->tqh_last; \
470 + TAILQ_INIT((head2)); \
471 + } \
472 +} while (/*CONSTCOND*/0)
475 + * Tail queue access methods.
476 + */
477 +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
478 +#define TAILQ_FIRST(head) ((head)->tqh_first)
479 +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
481 +#define TAILQ_LAST(head, headname) \
482 + (*(((struct headname *)((head)->tqh_last))->tqh_last))
483 +#define TAILQ_PREV(elm, headname, field) \
484 + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
488 + * Circular queue definitions.
489 + */
490 +#define CIRCLEQ_HEAD(name, type) \
491 +struct name { \
492 + struct type *cqh_first; /* first element */ \
493 + struct type *cqh_last; /* last element */ \
496 +#define CIRCLEQ_HEAD_INITIALIZER(head) \
497 + { (void *)&head, (void *)&head }
499 +#define CIRCLEQ_ENTRY(type) \
500 +struct { \
501 + struct type *cqe_next; /* next element */ \
502 + struct type *cqe_prev; /* previous element */ \
506 + * Circular queue functions.
507 + */
508 +#define CIRCLEQ_INIT(head) do { \
509 + (head)->cqh_first = (void *)(head); \
510 + (head)->cqh_last = (void *)(head); \
511 +} while (/*CONSTCOND*/0)
513 +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
514 + (elm)->field.cqe_next = (listelm)->field.cqe_next; \
515 + (elm)->field.cqe_prev = (listelm); \
516 + if ((listelm)->field.cqe_next == (void *)(head)) \
517 + (head)->cqh_last = (elm); \
518 + else \
519 + (listelm)->field.cqe_next->field.cqe_prev = (elm); \
520 + (listelm)->field.cqe_next = (elm); \
521 +} while (/*CONSTCOND*/0)
523 +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
524 + (elm)->field.cqe_next = (listelm); \
525 + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
526 + if ((listelm)->field.cqe_prev == (void *)(head)) \
527 + (head)->cqh_first = (elm); \
528 + else \
529 + (listelm)->field.cqe_prev->field.cqe_next = (elm); \
530 + (listelm)->field.cqe_prev = (elm); \
531 +} while (/*CONSTCOND*/0)
533 +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
534 + (elm)->field.cqe_next = (head)->cqh_first; \
535 + (elm)->field.cqe_prev = (void *)(head); \
536 + if ((head)->cqh_last == (void *)(head)) \
537 + (head)->cqh_last = (elm); \
538 + else \
539 + (head)->cqh_first->field.cqe_prev = (elm); \
540 + (head)->cqh_first = (elm); \
541 +} while (/*CONSTCOND*/0)
543 +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
544 + (elm)->field.cqe_next = (void *)(head); \
545 + (elm)->field.cqe_prev = (head)->cqh_last; \
546 + if ((head)->cqh_first == (void *)(head)) \
547 + (head)->cqh_first = (elm); \
548 + else \
549 + (head)->cqh_last->field.cqe_next = (elm); \
550 + (head)->cqh_last = (elm); \
551 +} while (/*CONSTCOND*/0)
553 +#define CIRCLEQ_REMOVE(head, elm, field) do { \
554 + if ((elm)->field.cqe_next == (void *)(head)) \
555 + (head)->cqh_last = (elm)->field.cqe_prev; \
556 + else \
557 + (elm)->field.cqe_next->field.cqe_prev = \
558 + (elm)->field.cqe_prev; \
559 + if ((elm)->field.cqe_prev == (void *)(head)) \
560 + (head)->cqh_first = (elm)->field.cqe_next; \
561 + else \
562 + (elm)->field.cqe_prev->field.cqe_next = \
563 + (elm)->field.cqe_next; \
564 +} while (/*CONSTCOND*/0)
566 +#define CIRCLEQ_FOREACH(var, head, field) \
567 + for ((var) = ((head)->cqh_first); \
568 + (var) != (const void *)(head); \
569 + (var) = ((var)->field.cqe_next))
571 +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
572 + for ((var) = ((head)->cqh_last); \
573 + (var) != (const void *)(head); \
574 + (var) = ((var)->field.cqe_prev))
577 + * Circular queue access methods.
578 + */
579 +#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
580 +#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
581 +#define CIRCLEQ_LAST(head) ((head)->cqh_last)
582 +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
583 +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
585 +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
586 + (((elm)->field.cqe_next == (void *)(head)) \
587 + ? ((head)->cqh_first) \
588 + : (elm->field.cqe_next))
589 +#define CIRCLEQ_LOOP_PREV(head, elm, field) \
590 + (((elm)->field.cqe_prev == (void *)(head)) \
591 + ? ((head)->cqh_last) \
592 + : (elm->field.cqe_prev))
594 +#endif /* sys/queue.h */