| 1 |
/* $NetBSD: queue.h,v 1.9 2015/12/13 21:56:27 joerg Exp $ */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Copyright (c) 1991, 1993 |
| 5 |
* The Regents of the University of California. All rights reserved. |
| 6 |
* |
| 7 |
* Redistribution and use in source and binary forms, with or without |
| 8 |
* modification, are permitted provided that the following conditions |
| 9 |
* are met: |
| 10 |
* 1. Redistributions of source code must retain the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer. |
| 12 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
* documentation and/or other materials provided with the distribution. |
| 15 |
* 3. All advertising materials mentioning features or use of this software |
| 16 |
* must display the following acknowledgement: |
| 17 |
* This product includes software developed by the University of |
| 18 |
* California, Berkeley and its contributors. |
| 19 |
* 4. Neither the name of the University nor the names of its contributors |
| 20 |
* may be used to endorse or promote products derived from this software |
| 21 |
* without specific prior written permission. |
| 22 |
* |
| 23 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 24 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 25 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 27 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 29 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 31 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 32 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 33 |
* SUCH DAMAGE. |
| 34 |
* |
| 35 |
* @(#)queue.h 8.5 (Berkeley) 8/20/94 |
| 36 |
*/ |
| 37 |
|
| 38 |
#ifndef _NBCOMPAT_QUEUE_H |
| 39 |
#define _NBCOMPAT_QUEUE_H |
| 40 |
|
| 41 |
#if HAVE_SYS_QUEUE_H |
| 42 |
# include <sys/queue.h> |
| 43 |
#endif |
| 44 |
|
| 45 |
/* |
| 46 |
* Provide any macros missing from <sys/queue.h>. |
| 47 |
*/ |
| 48 |
|
| 49 |
#ifndef LIST_HEAD |
| 50 |
#define LIST_HEAD(name, type) \ |
| 51 |
struct name { \ |
| 52 |
struct type *lh_first; /* first element */ \ |
| 53 |
} |
| 54 |
#endif |
| 55 |
|
| 56 |
#ifndef LIST_HEAD_INITIALIZER |
| 57 |
#define LIST_HEAD_INITIALIZER(head) \ |
| 58 |
{ NULL } |
| 59 |
#endif |
| 60 |
|
| 61 |
#ifndef LIST_ENTRY |
| 62 |
#define LIST_ENTRY(type) \ |
| 63 |
struct { \ |
| 64 |
struct type *le_next; /* next element */ \ |
| 65 |
struct type **le_prev; /* address of previous next element */ \ |
| 66 |
} |
| 67 |
#endif |
| 68 |
|
| 69 |
#ifndef LIST_INIT |
| 70 |
#define LIST_INIT(head) do { \ |
| 71 |
(head)->lh_first = NULL; \ |
| 72 |
} while (/*CONSTCOND*/0) |
| 73 |
#endif |
| 74 |
|
| 75 |
#ifndef LIST_INSERT_AFTER |
| 76 |
#define LIST_INSERT_AFTER(listelm, elm, field) do { \ |
| 77 |
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ |
| 78 |
(listelm)->field.le_next->field.le_prev = \ |
| 79 |
&(elm)->field.le_next; \ |
| 80 |
(listelm)->field.le_next = (elm); \ |
| 81 |
(elm)->field.le_prev = &(listelm)->field.le_next; \ |
| 82 |
} while (/*CONSTCOND*/0) |
| 83 |
#endif |
| 84 |
|
| 85 |
#ifndef LIST_INSERT_BEFORE |
| 86 |
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ |
| 87 |
QUEUEDEBUG_LIST_OP((listelm), field) \ |
| 88 |
(elm)->field.le_prev = (listelm)->field.le_prev; \ |
| 89 |
(elm)->field.le_next = (listelm); \ |
| 90 |
*(listelm)->field.le_prev = (elm); \ |
| 91 |
(listelm)->field.le_prev = &(elm)->field.le_next; \ |
| 92 |
} while (/*CONSTCOND*/0) |
| 93 |
#endif |
| 94 |
|
| 95 |
#ifndef LIST_INSERT_HEAD |
| 96 |
#define LIST_INSERT_HEAD(head, elm, field) do { \ |
| 97 |
if (((elm)->field.le_next = (head)->lh_first) != NULL) \ |
| 98 |
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\ |
| 99 |
(head)->lh_first = (elm); \ |
| 100 |
(elm)->field.le_prev = &(head)->lh_first; \ |
| 101 |
} while (/*CONSTCOND*/0) |
| 102 |
#endif |
| 103 |
|
| 104 |
#ifndef LIST_REMOVE |
| 105 |
#define LIST_REMOVE(elm, field) do { \ |
| 106 |
if ((elm)->field.le_next != NULL) \ |
| 107 |
(elm)->field.le_next->field.le_prev = \ |
| 108 |
(elm)->field.le_prev; \ |
| 109 |
*(elm)->field.le_prev = (elm)->field.le_next; \ |
| 110 |
} while (/*CONSTCOND*/0) |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifndef LIST_FOREACH |
| 114 |
#define LIST_FOREACH(var, head, field) \ |
| 115 |
for ((var) = ((head)->lh_first); \ |
| 116 |
(var); \ |
| 117 |
(var) = ((var)->field.le_next)) |
| 118 |
#endif |
| 119 |
|
| 120 |
#ifndef LIST_EMPTY |
| 121 |
#define LIST_EMPTY(head) ((head)->lh_first == NULL) |
| 122 |
#endif |
| 123 |
#ifndef LIST_FIRST |
| 124 |
#define LIST_FIRST(head) ((head)->lh_first) |
| 125 |
#endif |
| 126 |
#ifndef LIST_NEXT |
| 127 |
#define LIST_NEXT(elm, field) ((elm)->field.le_next) |
| 128 |
#endif |
| 129 |
|
| 130 |
#ifndef SLIST_HEAD |
| 131 |
#define SLIST_HEAD(name, type) \ |
| 132 |
struct name { \ |
| 133 |
struct type *slh_first; /* first element */ \ |
| 134 |
} |
| 135 |
#endif |
| 136 |
|
| 137 |
#ifndef SLIST_HEAD_INITIALIZER |
| 138 |
#define SLIST_HEAD_INITIALIZER(head) \ |
| 139 |
{ NULL } |
| 140 |
#endif |
| 141 |
|
| 142 |
#ifndef SLIST_ENTRY |
| 143 |
#define SLIST_ENTRY(type) \ |
| 144 |
struct { \ |
| 145 |
struct type *sle_next; /* next element */ \ |
| 146 |
} |
| 147 |
#endif |
| 148 |
|
| 149 |
#ifndef SLIST_INIT |
| 150 |
#define SLIST_INIT(head) do { \ |
| 151 |
(head)->slh_first = NULL; \ |
| 152 |
} while (/*CONSTCOND*/0) |
| 153 |
#endif |
| 154 |
|
| 155 |
#ifndef SLIST_INSERT_AFTER |
| 156 |
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ |
| 157 |
(elm)->field.sle_next = (slistelm)->field.sle_next; \ |
| 158 |
(slistelm)->field.sle_next = (elm); \ |
| 159 |
} while (/*CONSTCOND*/0) |
| 160 |
#endif |
| 161 |
|
| 162 |
#ifndef SLIST_INSERT_HEAD |
| 163 |
#define SLIST_INSERT_HEAD(head, elm, field) do { \ |
| 164 |
(elm)->field.sle_next = (head)->slh_first; \ |
| 165 |
(head)->slh_first = (elm); \ |
| 166 |
} while (/*CONSTCOND*/0) |
| 167 |
#endif |
| 168 |
|
| 169 |
#ifndef SLIST_REMOVE_HEAD |
| 170 |
#define SLIST_REMOVE_HEAD(head, field) do { \ |
| 171 |
(head)->slh_first = (head)->slh_first->field.sle_next; \ |
| 172 |
} while (/*CONSTCOND*/0) |
| 173 |
#endif |
| 174 |
|
| 175 |
#ifndef SLIST_REMOVE |
| 176 |
#define SLIST_REMOVE(head, elm, type, field) do { \ |
| 177 |
if ((head)->slh_first == (elm)) { \ |
| 178 |
SLIST_REMOVE_HEAD((head), field); \ |
| 179 |
} \ |
| 180 |
else { \ |
| 181 |
struct type *curelm = (head)->slh_first; \ |
| 182 |
while(curelm->field.sle_next != (elm)) \ |
| 183 |
curelm = curelm->field.sle_next; \ |
| 184 |
curelm->field.sle_next = \ |
| 185 |
curelm->field.sle_next->field.sle_next; \ |
| 186 |
} \ |
| 187 |
} while (/*CONSTCOND*/0) |
| 188 |
#endif |
| 189 |
|
| 190 |
#ifndef SLIST_REMOVE_AFTER |
| 191 |
#define SLIST_REMOVE_AFTER(slistelm, field) do { \ |
| 192 |
(slistelm)->field.sle_next = \ |
| 193 |
SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ |
| 194 |
} while (/*CONSTCOND*/0) |
| 195 |
#endif |
| 196 |
|
| 197 |
#ifndef SLIST_FOREACH |
| 198 |
#define SLIST_FOREACH(var, head, field) \ |
| 199 |
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) |
| 200 |
#endif |
| 201 |
|
| 202 |
#ifndef SLIST_EMPTY |
| 203 |
#define SLIST_EMPTY(head) ((head)->slh_first == NULL) |
| 204 |
#endif |
| 205 |
|
| 206 |
#ifndef SLIST_FIRST |
| 207 |
#define SLIST_FIRST(head) ((head)->slh_first) |
| 208 |
#endif |
| 209 |
|
| 210 |
#ifndef SLIST_NEXT |
| 211 |
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) |
| 212 |
#endif |
| 213 |
|
| 214 |
#ifndef TAILQ_HEAD |
| 215 |
#define TAILQ_HEAD(name, type) \ |
| 216 |
struct name { \ |
| 217 |
struct type *tqh_first; /* first element */ \ |
| 218 |
struct type **tqh_last; /* addr of last next element */ \ |
| 219 |
} |
| 220 |
#endif |
| 221 |
|
| 222 |
#ifndef TAILQ_HEAD_INITIALIZER |
| 223 |
#define TAILQ_HEAD_INITIALIZER(head) \ |
| 224 |
{ NULL, &(head).tqh_first } |
| 225 |
#endif |
| 226 |
|
| 227 |
#ifndef TAILQ_ENTRY |
| 228 |
#define TAILQ_ENTRY(type) \ |
| 229 |
struct { \ |
| 230 |
struct type *tqe_next; /* next element */ \ |
| 231 |
struct type **tqe_prev; /* address of previous next element */ \ |
| 232 |
} |
| 233 |
#endif |
| 234 |
|
| 235 |
#ifndef TAILQ_INIT |
| 236 |
#define TAILQ_INIT(head) do { \ |
| 237 |
(head)->tqh_first = NULL; \ |
| 238 |
(head)->tqh_last = &(head)->tqh_first; \ |
| 239 |
} while (/*CONSTCOND*/0) |
| 240 |
#endif |
| 241 |
|
| 242 |
#ifndef TAILQ_INSERT_HEAD |
| 243 |
#define TAILQ_INSERT_HEAD(head, elm, field) do { \ |
| 244 |
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ |
| 245 |
(head)->tqh_first->field.tqe_prev = \ |
| 246 |
&(elm)->field.tqe_next; \ |
| 247 |
else \ |
| 248 |
(head)->tqh_last = &(elm)->field.tqe_next; \ |
| 249 |
(head)->tqh_first = (elm); \ |
| 250 |
(elm)->field.tqe_prev = &(head)->tqh_first; \ |
| 251 |
} while (/*CONSTCOND*/0) |
| 252 |
#endif |
| 253 |
|
| 254 |
#ifndef TAILQ_INSERT_TAIL |
| 255 |
#define TAILQ_INSERT_TAIL(head, elm, field) do { \ |
| 256 |
(elm)->field.tqe_next = NULL; \ |
| 257 |
(elm)->field.tqe_prev = (head)->tqh_last; \ |
| 258 |
*(head)->tqh_last = (elm); \ |
| 259 |
(head)->tqh_last = &(elm)->field.tqe_next; \ |
| 260 |
} while (/*CONSTCOND*/0) |
| 261 |
#endif |
| 262 |
|
| 263 |
#ifndef TAILQ_INSERT_AFTER |
| 264 |
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
| 265 |
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ |
| 266 |
(elm)->field.tqe_next->field.tqe_prev = \ |
| 267 |
&(elm)->field.tqe_next; \ |
| 268 |
else \ |
| 269 |
(head)->tqh_last = &(elm)->field.tqe_next; \ |
| 270 |
(listelm)->field.tqe_next = (elm); \ |
| 271 |
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ |
| 272 |
} while (/*CONSTCOND*/0) |
| 273 |
#endif |
| 274 |
|
| 275 |
#ifndef TAILQ_INSERT_BEFORE |
| 276 |
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ |
| 277 |
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ |
| 278 |
(elm)->field.tqe_next = (listelm); \ |
| 279 |
*(listelm)->field.tqe_prev = (elm); \ |
| 280 |
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ |
| 281 |
} while (/*CONSTCOND*/0) |
| 282 |
#endif |
| 283 |
|
| 284 |
#ifndef TAILQ_REMOVE |
| 285 |
#define TAILQ_REMOVE(head, elm, field) do { \ |
| 286 |
if (((elm)->field.tqe_next) != NULL) \ |
| 287 |
(elm)->field.tqe_next->field.tqe_prev = \ |
| 288 |
(elm)->field.tqe_prev; \ |
| 289 |
else \ |
| 290 |
(head)->tqh_last = (elm)->field.tqe_prev; \ |
| 291 |
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \ |
| 292 |
} while (/*CONSTCOND*/0) |
| 293 |
#endif |
| 294 |
|
| 295 |
#ifndef TAILQ_FOREACH |
| 296 |
#define TAILQ_FOREACH(var, head, field) \ |
| 297 |
for ((var) = ((head)->tqh_first); \ |
| 298 |
(var); \ |
| 299 |
(var) = ((var)->field.tqe_next)) |
| 300 |
#endif |
| 301 |
|
| 302 |
#ifndef TAILQ_FOREACH_SAFE |
| 303 |
#define TAILQ_FOREACH_SAFE(var, head, field, next) \ |
| 304 |
for ((var) = ((head)->tqh_first); \ |
| 305 |
(var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \ |
| 306 |
(var) = (next)) |
| 307 |
#endif |
| 308 |
|
| 309 |
#undef TAILQ_FOREACH_REVERSE |
| 310 |
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ |
| 311 |
for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ |
| 312 |
(var); \ |
| 313 |
(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) |
| 314 |
|
| 315 |
#ifndef TAILQ_EMPTY |
| 316 |
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) |
| 317 |
#endif |
| 318 |
#ifndef TAILQ_FIRST |
| 319 |
#define TAILQ_FIRST(head) ((head)->tqh_first) |
| 320 |
#endif |
| 321 |
#ifndef TAILQ_NEXT |
| 322 |
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) |
| 323 |
#endif |
| 324 |
|
| 325 |
#ifndef TAILQ_LAST |
| 326 |
#define TAILQ_LAST(head, headname) \ |
| 327 |
(*(((struct headname *)((head)->tqh_last))->tqh_last)) |
| 328 |
#endif |
| 329 |
|
| 330 |
#ifndef CIRCLEQ_HEAD |
| 331 |
#define CIRCLEQ_HEAD(name, type) \ |
| 332 |
struct name { \ |
| 333 |
struct type *cqh_first; /* first element */ \ |
| 334 |
struct type *cqh_last; /* last element */ \ |
| 335 |
} |
| 336 |
#endif |
| 337 |
|
| 338 |
#ifndef CIRCLEQ_HEAD_INITIALIZER |
| 339 |
#define CIRCLEQ_HEAD_INITIALIZER(head) \ |
| 340 |
{ (void *)&head, (void *)&head } |
| 341 |
#endif |
| 342 |
|
| 343 |
#ifndef CIRCLEQ_ENTRY |
| 344 |
#define CIRCLEQ_ENTRY(type) \ |
| 345 |
struct { \ |
| 346 |
struct type *cqe_next; /* next element */ \ |
| 347 |
struct type *cqe_prev; /* previous element */ \ |
| 348 |
} |
| 349 |
#endif |
| 350 |
|
| 351 |
/* |
| 352 |
* Circular queue functions. |
| 353 |
*/ |
| 354 |
#ifndef CIRCLEQ_INIT |
| 355 |
#define CIRCLEQ_INIT(head) do { \ |
| 356 |
(head)->cqh_first = (void *)(head); \ |
| 357 |
(head)->cqh_last = (void *)(head); \ |
| 358 |
} while (/*CONSTCOND*/0) |
| 359 |
#endif |
| 360 |
|
| 361 |
#ifndef CIRCLEQ_INSERT_AFTER |
| 362 |
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
| 363 |
(elm)->field.cqe_next = (listelm)->field.cqe_next; \ |
| 364 |
(elm)->field.cqe_prev = (listelm); \ |
| 365 |
if ((listelm)->field.cqe_next == (void *)(head)) \ |
| 366 |
(head)->cqh_last = (elm); \ |
| 367 |
else \ |
| 368 |
(listelm)->field.cqe_next->field.cqe_prev = (elm); \ |
| 369 |
(listelm)->field.cqe_next = (elm); \ |
| 370 |
} while (/*CONSTCOND*/0) |
| 371 |
#endif |
| 372 |
|
| 373 |
#ifndef CIRCLEQ_INSERT_BEFORE |
| 374 |
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ |
| 375 |
(elm)->field.cqe_next = (listelm); \ |
| 376 |
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ |
| 377 |
if ((listelm)->field.cqe_prev == (void *)(head)) \ |
| 378 |
(head)->cqh_first = (elm); \ |
| 379 |
else \ |
| 380 |
(listelm)->field.cqe_prev->field.cqe_next = (elm); \ |
| 381 |
(listelm)->field.cqe_prev = (elm); \ |
| 382 |
} while (/*CONSTCOND*/0) |
| 383 |
#endif |
| 384 |
|
| 385 |
#ifndef CIRCLEQ_INSERT_HEAD |
| 386 |
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ |
| 387 |
(elm)->field.cqe_next = (head)->cqh_first; \ |
| 388 |
(elm)->field.cqe_prev = (void *)(head); \ |
| 389 |
if ((head)->cqh_last == (void *)(head)) \ |
| 390 |
(head)->cqh_last = (elm); \ |
| 391 |
else \ |
| 392 |
(head)->cqh_first->field.cqe_prev = (elm); \ |
| 393 |
(head)->cqh_first = (elm); \ |
| 394 |
} while (/*CONSTCOND*/0) |
| 395 |
#endif |
| 396 |
|
| 397 |
#ifndef CIRCLEQ_INSERT_TAIL |
| 398 |
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ |
| 399 |
(elm)->field.cqe_next = (void *)(head); \ |
| 400 |
(elm)->field.cqe_prev = (head)->cqh_last; \ |
| 401 |
if ((head)->cqh_first == (void *)(head)) \ |
| 402 |
(head)->cqh_first = (elm); \ |
| 403 |
else \ |
| 404 |
(head)->cqh_last->field.cqe_next = (elm); \ |
| 405 |
(head)->cqh_last = (elm); \ |
| 406 |
} while (/*CONSTCOND*/0) |
| 407 |
#endif |
| 408 |
|
| 409 |
#ifndef CIRCLEQ_REMOVE |
| 410 |
#define CIRCLEQ_REMOVE(head, elm, field) do { \ |
| 411 |
if ((elm)->field.cqe_next == (void *)(head)) \ |
| 412 |
(head)->cqh_last = (elm)->field.cqe_prev; \ |
| 413 |
else \ |
| 414 |
(elm)->field.cqe_next->field.cqe_prev = \ |
| 415 |
(elm)->field.cqe_prev; \ |
| 416 |
if ((elm)->field.cqe_prev == (void *)(head)) \ |
| 417 |
(head)->cqh_first = (elm)->field.cqe_next; \ |
| 418 |
else \ |
| 419 |
(elm)->field.cqe_prev->field.cqe_next = \ |
| 420 |
(elm)->field.cqe_next; \ |
| 421 |
} while (/*CONSTCOND*/0) |
| 422 |
#endif |
| 423 |
|
| 424 |
#ifndef CIRCLEQ_FOREACH |
| 425 |
#define CIRCLEQ_FOREACH(var, head, field) \ |
| 426 |
for ((var) = ((head)->cqh_first); \ |
| 427 |
(var) != (const void *)(head); \ |
| 428 |
(var) = ((var)->field.cqe_next)) |
| 429 |
#endif |
| 430 |
|
| 431 |
#ifndef CIRCLEQ_FOREACH_REVERSE |
| 432 |
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ |
| 433 |
for ((var) = ((head)->cqh_last); \ |
| 434 |
(var) != (const void *)(head); \ |
| 435 |
(var) = ((var)->field.cqe_prev)) |
| 436 |
#endif |
| 437 |
|
| 438 |
#ifndef CIRCLEQ_EMPTY |
| 439 |
#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) |
| 440 |
#endif |
| 441 |
#ifndef CIRCLEQ_FIRST |
| 442 |
#define CIRCLEQ_FIRST(head) ((head)->cqh_first) |
| 443 |
#endif |
| 444 |
#ifndef CIRCLEQ_LAST |
| 445 |
#define CIRCLEQ_LAST(head) ((head)->cqh_last) |
| 446 |
#endif |
| 447 |
#ifndef CIRCLEQ_NEXT |
| 448 |
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) |
| 449 |
#endif |
| 450 |
#ifndef CIRCLEQ_PREV |
| 451 |
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) |
| 452 |
#endif |
| 453 |
|
| 454 |
#ifndef CIRCLEQ_LOOP_NEXT |
| 455 |
#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ |
| 456 |
(((elm)->field.cqe_next == (void *)(head)) \ |
| 457 |
? ((head)->cqh_first) \ |
| 458 |
: (elm->field.cqe_next)) |
| 459 |
#endif |
| 460 |
#ifndef CIRCLEQ_LOOP_PREV |
| 461 |
#define CIRCLEQ_LOOP_PREV(head, elm, field) \ |
| 462 |
(((elm)->field.cqe_prev == (void *)(head)) \ |
| 463 |
? ((head)->cqh_last) \ |
| 464 |
: (elm->field.cqe_prev)) |
| 465 |
#endif |
| 466 |
|
| 467 |
#endif /* !_NBCOMPAT_QUEUE_H */ |