hostsim enhancements
[aversive.git] / include / aversive / queue.h
1 /*
2  * Copyright (c) 1991, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)queue.h     8.5 (Berkeley) 8/20/94
34  * $FreeBSD: src/sys/sys/queue.h,v 1.32.2.7 2002/04/17 14:21:02 des Exp $
35  */
36
37 #ifndef _AVERSIVE_QUEUE_H_
38 #define _AVERSIVE_QUEUE_H_
39
40 #ifndef __offsetof
41 #define __offsetof(type, field)  ((size_t)(&(type *)0)->field))
42 #endif
43
44 /*
45  * This file defines five types of data structures: singly-linked lists,
46  * singly-linked tail queues, lists, tail queues, and circular queues.
47  *
48  * A singly-linked list is headed by a single forward pointer. The elements
49  * are singly linked for minimum space and pointer manipulation overhead at
50  * the expense of O(n) removal for arbitrary elements. New elements can be
51  * added to the list after an existing element or at the head of the list.
52  * Elements being removed from the head of the list should use the explicit
53  * macro for this purpose for optimum efficiency. A singly-linked list may
54  * only be traversed in the forward direction.  Singly-linked lists are ideal
55  * for applications with large datasets and few or no removals or for
56  * implementing a LIFO queue.
57  *
58  * A singly-linked tail queue is headed by a pair of pointers, one to the
59  * head of the list and the other to the tail of the list. The elements are
60  * singly linked for minimum space and pointer manipulation overhead at the
61  * expense of O(n) removal for arbitrary elements. New elements can be added
62  * to the list after an existing element, at the head of the list, or at the
63  * end of the list. Elements being removed from the head of the tail queue
64  * should use the explicit macro for this purpose for optimum efficiency.
65  * A singly-linked tail queue may only be traversed in the forward direction.
66  * Singly-linked tail queues are ideal for applications with large datasets
67  * and few or no removals or for implementing a FIFO 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 tail queue is headed by a pair of pointers, one to the head of the
77  * list and the other to the tail of the list. The elements are doubly
78  * linked so that an arbitrary element can be removed without a need to
79  * traverse the list. New elements can be added to the list before or
80  * after an existing element, at the head of the list, or at the end of
81  * the list. A tail queue may be traversed in either direction.
82  *
83  * A circle 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 after
87  * an existing element, at the head of the list, or at the end of the list.
88  * A circle queue may be traversed in either direction, but has a more
89  * complex end of list detection.
90  *
91  * For details on the use of these macros, see the queue(3) manual page.
92  *
93  *
94  *                      SLIST   LIST    STAILQ  TAILQ   CIRCLEQ
95  * _HEAD                +       +       +       +       +
96  * _HEAD_INITIALIZER    +       +       +       +       +
97  * _ENTRY               +       +       +       +       +
98  * _INIT                +       +       +       +       +
99  * _EMPTY               +       +       +       +       +
100  * _FIRST               +       +       +       +       +
101  * _NEXT                +       +       +       +       +
102  * _PREV                -       -       -       +       +
103  * _LAST                -       -       +       +       +
104  * _FOREACH             +       +       +       +       +
105  * _FOREACH_REVERSE     -       -       -       +       +
106  * _INSERT_HEAD         +       +       +       +       +
107  * _INSERT_BEFORE       -       +       -       +       +
108  * _INSERT_AFTER        +       +       +       +       +
109  * _INSERT_TAIL         -       -       +       +       +
110  * _REMOVE_HEAD         +       -       +       -       -
111  * _REMOVE              +       +       +       +       +
112  *
113  */
114
115 /*
116  * Singly-linked List declarations.
117  */
118 #define SLIST_HEAD(name, type)                                          \
119 struct name {                                                           \
120         struct type *slh_first; /* first element */                     \
121 }
122
123 #define SLIST_HEAD_INITIALIZER(head)                                    \
124         { NULL }
125  
126 #define SLIST_ENTRY(type)                                               \
127 struct {                                                                \
128         struct type *sle_next;  /* next element */                      \
129 }
130  
131 /*
132  * Singly-linked List functions.
133  */
134 #define SLIST_EMPTY(head)       ((head)->slh_first == NULL)
135
136 #define SLIST_FIRST(head)       ((head)->slh_first)
137
138 #define SLIST_FOREACH(var, head, field)                                 \
139         for ((var) = SLIST_FIRST((head));                               \
140             (var);                                                      \
141             (var) = SLIST_NEXT((var), field))
142
143 #define SLIST_INIT(head) do {                                           \
144         SLIST_FIRST((head)) = NULL;                                     \
145 } while (0)
146
147 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
148         SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);       \
149         SLIST_NEXT((slistelm), field) = (elm);                          \
150 } while (0)
151
152 #define SLIST_INSERT_HEAD(head, elm, field) do {                        \
153         SLIST_NEXT((elm), field) = SLIST_FIRST((head));                 \
154         SLIST_FIRST((head)) = (elm);                                    \
155 } while (0)
156
157 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
158
159 #define SLIST_REMOVE(head, elm, type, field) do {                       \
160         if (SLIST_FIRST((head)) == (elm)) {                             \
161                 SLIST_REMOVE_HEAD((head), field);                       \
162         }                                                               \
163         else {                                                          \
164                 struct type *curelm = SLIST_FIRST((head));              \
165                 while (SLIST_NEXT(curelm, field) != (elm))              \
166                         curelm = SLIST_NEXT(curelm, field);             \
167                 SLIST_NEXT(curelm, field) =                             \
168                     SLIST_NEXT(SLIST_NEXT(curelm, field), field);       \
169         }                                                               \
170 } while (0)
171
172 #define SLIST_REMOVE_HEAD(head, field) do {                             \
173         SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
174 } while (0)
175
176 /*
177  * Singly-linked Tail queue declarations.
178  */
179 #define STAILQ_HEAD(name, type)                                         \
180 struct name {                                                           \
181         struct type *stqh_first;/* first element */                     \
182         struct type **stqh_last;/* addr of last next element */         \
183 }
184
185 #define STAILQ_HEAD_INITIALIZER(head)                                   \
186         { NULL, &(head).stqh_first }
187
188 #define STAILQ_ENTRY(type)                                              \
189 struct {                                                                \
190         struct type *stqe_next; /* next element */                      \
191 }
192
193 /*
194  * Singly-linked Tail queue functions.
195  */
196 #define STAILQ_EMPTY(head)      ((head)->stqh_first == NULL)
197
198 #define STAILQ_FIRST(head)      ((head)->stqh_first)
199
200 #define STAILQ_FOREACH(var, head, field)                                \
201         for((var) = STAILQ_FIRST((head));                               \
202            (var);                                                       \
203            (var) = STAILQ_NEXT((var), field))
204
205 #define STAILQ_INIT(head) do {                                          \
206         STAILQ_FIRST((head)) = NULL;                                    \
207         (head)->stqh_last = &STAILQ_FIRST((head));                      \
208 } while (0)
209
210 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {               \
211         if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
212                 (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
213         STAILQ_NEXT((tqelm), field) = (elm);                            \
214 } while (0)
215
216 #define STAILQ_INSERT_HEAD(head, elm, field) do {                       \
217         if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
218                 (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
219         STAILQ_FIRST((head)) = (elm);                                   \
220 } while (0)
221
222 #define STAILQ_INSERT_TAIL(head, elm, field) do {                       \
223         STAILQ_NEXT((elm), field) = NULL;                               \
224         *(head)->stqh_last = (elm);                                     \
225         (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
226 } while (0)
227
228 #define STAILQ_LAST(head, type, field)                                  \
229         (STAILQ_EMPTY(head) ?                                           \
230                 NULL :                                                  \
231                 ((struct type *)                                        \
232                 ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
233
234 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
235
236 #define STAILQ_REMOVE(head, elm, type, field) do {                      \
237         if (STAILQ_FIRST((head)) == (elm)) {                            \
238                 STAILQ_REMOVE_HEAD(head, field);                        \
239         }                                                               \
240         else {                                                          \
241                 struct type *curelm = STAILQ_FIRST((head));             \
242                 while (STAILQ_NEXT(curelm, field) != (elm))             \
243                         curelm = STAILQ_NEXT(curelm, field);            \
244                 if ((STAILQ_NEXT(curelm, field) =                       \
245                      STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
246                         (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
247         }                                                               \
248 } while (0)
249
250 #define STAILQ_REMOVE_HEAD(head, field) do {                            \
251         if ((STAILQ_FIRST((head)) =                                     \
252              STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)         \
253                 (head)->stqh_last = &STAILQ_FIRST((head));              \
254 } while (0)
255
256 #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {                 \
257         if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
258                 (head)->stqh_last = &STAILQ_FIRST((head));              \
259 } while (0)
260
261 /*
262  * List declarations.
263  */
264 #define LIST_HEAD(name, type)                                           \
265 struct name {                                                           \
266         struct type *lh_first;  /* first element */                     \
267 }
268
269 #define LIST_HEAD_INITIALIZER(head)                                     \
270         { NULL }
271
272 #define LIST_ENTRY(type)                                                \
273 struct {                                                                \
274         struct type *le_next;   /* next element */                      \
275         struct type **le_prev;  /* address of previous next element */  \
276 }
277
278 /*
279  * List functions.
280  */
281
282 #define LIST_EMPTY(head)        ((head)->lh_first == NULL)
283
284 #define LIST_FIRST(head)        ((head)->lh_first)
285
286 #define LIST_FOREACH(var, head, field)                                  \
287         for ((var) = LIST_FIRST((head));                                \
288             (var);                                                      \
289             (var) = LIST_NEXT((var), field))
290
291 #define LIST_INIT(head) do {                                            \
292         LIST_FIRST((head)) = NULL;                                      \
293 } while (0)
294
295 #define LIST_INSERT_AFTER(listelm, elm, field) do {                     \
296         if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
297                 LIST_NEXT((listelm), field)->field.le_prev =            \
298                     &LIST_NEXT((elm), field);                           \
299         LIST_NEXT((listelm), field) = (elm);                            \
300         (elm)->field.le_prev = &LIST_NEXT((listelm), field);            \
301 } while (0)
302
303 #define LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
304         (elm)->field.le_prev = (listelm)->field.le_prev;                \
305         LIST_NEXT((elm), field) = (listelm);                            \
306         *(listelm)->field.le_prev = (elm);                              \
307         (listelm)->field.le_prev = &LIST_NEXT((elm), field);            \
308 } while (0)
309
310 #define LIST_INSERT_HEAD(head, elm, field) do {                         \
311         if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)     \
312                 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
313         LIST_FIRST((head)) = (elm);                                     \
314         (elm)->field.le_prev = &LIST_FIRST((head));                     \
315 } while (0)
316
317 #define LIST_NEXT(elm, field)   ((elm)->field.le_next)
318
319 #define LIST_REMOVE(elm, field) do {                                    \
320         if (LIST_NEXT((elm), field) != NULL)                            \
321                 LIST_NEXT((elm), field)->field.le_prev =                \
322                     (elm)->field.le_prev;                               \
323         *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
324 } while (0)
325
326 /*
327  * Tail queue declarations.
328  */
329 #define TAILQ_HEAD(name, type)                                          \
330 struct name {                                                           \
331         struct type *tqh_first; /* first element */                     \
332         struct type **tqh_last; /* addr of last next element */         \
333 }
334
335 #define TAILQ_HEAD_INITIALIZER(head)                                    \
336         { NULL, &(head).tqh_first }
337
338 #define TAILQ_ENTRY(type)                                               \
339 struct {                                                                \
340         struct type *tqe_next;  /* next element */                      \
341         struct type **tqe_prev; /* address of previous next element */  \
342 }
343
344 /*
345  * Tail queue functions.
346  */
347 #define TAILQ_EMPTY(head)       ((head)->tqh_first == NULL)
348
349 #define TAILQ_FIRST(head)       ((head)->tqh_first)
350
351 #define TAILQ_FOREACH(var, head, field)                                 \
352         for ((var) = TAILQ_FIRST((head));                               \
353             (var);                                                      \
354             (var) = TAILQ_NEXT((var), field))
355
356 #define TAILQ_FOREACH_REVERSE(var, head, headname, field)               \
357         for ((var) = TAILQ_LAST((head), headname);                      \
358             (var);                                                      \
359             (var) = TAILQ_PREV((var), headname, field))
360
361 #define TAILQ_INIT(head) do {                                           \
362         TAILQ_FIRST((head)) = NULL;                                     \
363         (head)->tqh_last = &TAILQ_FIRST((head));                        \
364 } while (0)
365
366 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {              \
367         if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
368                 TAILQ_NEXT((elm), field)->field.tqe_prev =              \
369                     &TAILQ_NEXT((elm), field);                          \
370         else                                                            \
371                 (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
372         TAILQ_NEXT((listelm), field) = (elm);                           \
373         (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);          \
374 } while (0)
375
376 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \
377         (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
378         TAILQ_NEXT((elm), field) = (listelm);                           \
379         *(listelm)->field.tqe_prev = (elm);                             \
380         (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);          \
381 } while (0)
382
383 #define TAILQ_INSERT_HEAD(head, elm, field) do {                        \
384         if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
385                 TAILQ_FIRST((head))->field.tqe_prev =                   \
386                     &TAILQ_NEXT((elm), field);                          \
387         else                                                            \
388                 (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
389         TAILQ_FIRST((head)) = (elm);                                    \
390         (elm)->field.tqe_prev = &TAILQ_FIRST((head));                   \
391 } while (0)
392
393 #define TAILQ_INSERT_TAIL(head, elm, field) do {                        \
394         TAILQ_NEXT((elm), field) = NULL;                                \
395         (elm)->field.tqe_prev = (head)->tqh_last;                       \
396         *(head)->tqh_last = (elm);                                      \
397         (head)->tqh_last = &TAILQ_NEXT((elm), field);                   \
398 } while (0)
399
400 #define TAILQ_LAST(head, headname)                                      \
401         (*(((struct headname *)((head)->tqh_last))->tqh_last))
402
403 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
404
405 #define TAILQ_PREV(elm, headname, field)                                \
406         (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
407
408 #define TAILQ_REMOVE(head, elm, field) do {                             \
409         if ((TAILQ_NEXT((elm), field)) != NULL)                         \
410                 TAILQ_NEXT((elm), field)->field.tqe_prev =              \
411                     (elm)->field.tqe_prev;                              \
412         else                                                            \
413                 (head)->tqh_last = (elm)->field.tqe_prev;               \
414         *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);              \
415 } while (0)
416
417 /*
418  * Circular queue declarations.
419  */
420 #define CIRCLEQ_HEAD(name, type)                                        \
421 struct name {                                                           \
422         struct type *cqh_first;         /* first element */             \
423         struct type *cqh_last;          /* last element */              \
424 }
425
426 #define CIRCLEQ_HEAD_INITIALIZER(head)                                  \
427         { (void *)&(head), (void *)&(head) }
428
429 #define CIRCLEQ_ENTRY(type)                                             \
430 struct {                                                                \
431         struct type *cqe_next;          /* next element */              \
432         struct type *cqe_prev;          /* previous element */          \
433 }
434
435 /*
436  * Circular queue functions.
437  */
438 #define CIRCLEQ_EMPTY(head)     ((head)->cqh_first == (void *)(head))
439
440 #define CIRCLEQ_FIRST(head)     ((head)->cqh_first)
441
442 #define CIRCLEQ_FOREACH(var, head, field)                               \
443         for ((var) = CIRCLEQ_FIRST((head));                             \
444             (var) != (void *)(head) || ((var) = NULL);                  \
445             (var) = CIRCLEQ_NEXT((var), field))
446
447 #define CIRCLEQ_FOREACH_REVERSE(var, head, field)                       \
448         for ((var) = CIRCLEQ_LAST((head));                              \
449             (var) != (void *)(head) || ((var) = NULL);                  \
450             (var) = CIRCLEQ_PREV((var), field))
451
452 #define CIRCLEQ_INIT(head) do {                                         \
453         CIRCLEQ_FIRST((head)) = (void *)(head);                         \
454         CIRCLEQ_LAST((head)) = (void *)(head);                          \
455 } while (0)
456
457 #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {            \
458         CIRCLEQ_NEXT((elm), field) = CIRCLEQ_NEXT((listelm), field);    \
459         CIRCLEQ_PREV((elm), field) = (listelm);                         \
460         if (CIRCLEQ_NEXT((listelm), field) == (void *)(head))           \
461                 CIRCLEQ_LAST((head)) = (elm);                           \
462         else                                                            \
463                 CIRCLEQ_PREV(CIRCLEQ_NEXT((listelm), field), field) = (elm);\
464         CIRCLEQ_NEXT((listelm), field) = (elm);                         \
465 } while (0)
466
467 #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {           \
468         CIRCLEQ_NEXT((elm), field) = (listelm);                         \
469         CIRCLEQ_PREV((elm), field) = CIRCLEQ_PREV((listelm), field);    \
470         if (CIRCLEQ_PREV((listelm), field) == (void *)(head))           \
471                 CIRCLEQ_FIRST((head)) = (elm);                          \
472         else                                                            \
473                 CIRCLEQ_NEXT(CIRCLEQ_PREV((listelm), field), field) = (elm);\
474         CIRCLEQ_PREV((listelm), field) = (elm);                         \
475 } while (0)
476
477 #define CIRCLEQ_INSERT_HEAD(head, elm, field) do {                      \
478         CIRCLEQ_NEXT((elm), field) = CIRCLEQ_FIRST((head));             \
479         CIRCLEQ_PREV((elm), field) = (void *)(head);                    \
480         if (CIRCLEQ_LAST((head)) == (void *)(head))                     \
481                 CIRCLEQ_LAST((head)) = (elm);                           \
482         else                                                            \
483                 CIRCLEQ_PREV(CIRCLEQ_FIRST((head)), field) = (elm);     \
484         CIRCLEQ_FIRST((head)) = (elm);                                  \
485 } while (0)
486
487 #define CIRCLEQ_INSERT_TAIL(head, elm, field) do {                      \
488         CIRCLEQ_NEXT((elm), field) = (void *)(head);                    \
489         CIRCLEQ_PREV((elm), field) = CIRCLEQ_LAST((head));              \
490         if (CIRCLEQ_FIRST((head)) == (void *)(head))                    \
491                 CIRCLEQ_FIRST((head)) = (elm);                          \
492         else                                                            \
493                 CIRCLEQ_NEXT(CIRCLEQ_LAST((head)), field) = (elm);      \
494         CIRCLEQ_LAST((head)) = (elm);                                   \
495 } while (0)
496
497 #define CIRCLEQ_LAST(head)      ((head)->cqh_last)
498
499 #define CIRCLEQ_NEXT(elm,field) ((elm)->field.cqe_next)
500
501 #define CIRCLEQ_PREV(elm,field) ((elm)->field.cqe_prev)
502
503 #define CIRCLEQ_REMOVE(head, elm, field) do {                           \
504         if (CIRCLEQ_NEXT((elm), field) == (void *)(head))               \
505                 CIRCLEQ_LAST((head)) = CIRCLEQ_PREV((elm), field);      \
506         else                                                            \
507                 CIRCLEQ_PREV(CIRCLEQ_NEXT((elm), field), field) =       \
508                     CIRCLEQ_PREV((elm), field);                         \
509         if (CIRCLEQ_PREV((elm), field) == (void *)(head))               \
510                 CIRCLEQ_FIRST((head)) = CIRCLEQ_NEXT((elm), field);     \
511         else                                                            \
512                 CIRCLEQ_NEXT(CIRCLEQ_PREV((elm), field), field) =       \
513                     CIRCLEQ_NEXT((elm), field);                         \
514 } while (0)
515
516
517 #endif /* !_AVERSIVE_QUEUE_H_ */