 |
mTower
|
89 #define LIST_HEAD(name, type) \ 91 struct type *lh_first; \ 94 #define LIST_HEAD_INITIALIZER(head) \ 97 #define LIST_ENTRY(type) \ 99 struct type *le_next; \ 100 struct type **le_prev; \ 106 #if defined(_KERNEL) && defined(QUEUEDEBUG) 107 #define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ 108 if ((head)->lh_first && \ 109 (head)->lh_first->field.le_prev != &(head)->lh_first) \ 110 panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); 111 #define QUEUEDEBUG_LIST_OP(elm, field) \ 112 if ((elm)->field.le_next && \ 113 (elm)->field.le_next->field.le_prev != \ 114 &(elm)->field.le_next) \ 115 panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ 116 if (*(elm)->field.le_prev != (elm)) \ 117 panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__); 118 #define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ 119 (elm)->field.le_next = (void *)1L; \ 120 (elm)->field.le_prev = (void *)1L; 122 #define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) 123 #define QUEUEDEBUG_LIST_OP(elm, field) 124 #define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) 127 #define LIST_INIT(head) do { \ 128 (head)->lh_first = NULL; \ 131 #define LIST_INSERT_AFTER(listelm, elm, field) do { \ 132 QUEUEDEBUG_LIST_OP((listelm), field) \ 133 if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ 134 (listelm)->field.le_next->field.le_prev = \ 135 &(elm)->field.le_next; \ 136 (listelm)->field.le_next = (elm); \ 137 (elm)->field.le_prev = &(listelm)->field.le_next; \ 140 #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ 141 QUEUEDEBUG_LIST_OP((listelm), field) \ 142 (elm)->field.le_prev = (listelm)->field.le_prev; \ 143 (elm)->field.le_next = (listelm); \ 144 *(listelm)->field.le_prev = (elm); \ 145 (listelm)->field.le_prev = &(elm)->field.le_next; \ 148 #define LIST_INSERT_HEAD(head, elm, field) do { \ 149 QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ 150 if (((elm)->field.le_next = (head)->lh_first) != NULL) \ 151 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ 152 (head)->lh_first = (elm); \ 153 (elm)->field.le_prev = &(head)->lh_first; \ 156 #define LIST_REMOVE(elm, field) do { \ 157 QUEUEDEBUG_LIST_OP((elm), field) \ 158 if ((elm)->field.le_next != NULL) \ 159 (elm)->field.le_next->field.le_prev = \ 160 (elm)->field.le_prev; \ 161 *(elm)->field.le_prev = (elm)->field.le_next; \ 162 QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ 165 #define LIST_FOREACH(var, head, field) \ 166 for ((var) = ((head)->lh_first); \ 168 (var) = ((var)->field.le_next)) 173 #define LIST_EMPTY(head) ((head)->lh_first == NULL) 174 #define LIST_FIRST(head) ((head)->lh_first) 175 #define LIST_NEXT(elm, field) ((elm)->field.le_next) 180 #define SLIST_HEAD(name, type) \ 182 struct type *slh_first; \ 185 #define SLIST_HEAD_INITIALIZER(head) \ 188 #define SLIST_ENTRY(type) \ 190 struct type *sle_next; \ 196 #define SLIST_INIT(head) do { \ 197 (head)->slh_first = NULL; \ 200 #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ 201 (elm)->field.sle_next = (slistelm)->field.sle_next; \ 202 (slistelm)->field.sle_next = (elm); \ 205 #define SLIST_INSERT_HEAD(head, elm, field) do { \ 206 (elm)->field.sle_next = (head)->slh_first; \ 207 (head)->slh_first = (elm); \ 210 #define SLIST_REMOVE_HEAD(head, field) do { \ 211 (head)->slh_first = (head)->slh_first->field.sle_next; \ 214 #define SLIST_REMOVE(head, elm, type, field) do { \ 215 if ((head)->slh_first == (elm)) { \ 216 SLIST_REMOVE_HEAD((head), field); \ 219 struct type *curelm = (head)->slh_first; \ 220 while(curelm->field.sle_next != (elm)) \ 221 curelm = curelm->field.sle_next; \ 222 curelm->field.sle_next = \ 223 curelm->field.sle_next->field.sle_next; \ 227 #define SLIST_REMOVE_AFTER(slistelm, field) do { \ 228 (slistelm)->field.sle_next = \ 229 SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ 232 #define SLIST_FOREACH(var, head, field) \ 233 for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) 238 #define SLIST_EMPTY(head) ((head)->slh_first == NULL) 239 #define SLIST_FIRST(head) ((head)->slh_first) 240 #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) 245 #define STAILQ_HEAD(name, type) \ 247 struct type *stqh_first; \ 248 struct type **stqh_last; \ 251 #define STAILQ_HEAD_INITIALIZER(head) \ 252 { NULL, &(head).stqh_first } 254 #define STAILQ_ENTRY(type) \ 256 struct type *stqe_next; \ 262 #define STAILQ_INIT(head) do { \ 263 (head)->stqh_first = NULL; \ 264 (head)->stqh_last = &(head)->stqh_first; \ 267 #define STAILQ_INSERT_HEAD(head, elm, field) do { \ 268 if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ 269 (head)->stqh_last = &(elm)->field.stqe_next; \ 270 (head)->stqh_first = (elm); \ 273 #define STAILQ_INSERT_TAIL(head, elm, field) do { \ 274 (elm)->field.stqe_next = NULL; \ 275 *(head)->stqh_last = (elm); \ 276 (head)->stqh_last = &(elm)->field.stqe_next; \ 279 #define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ 280 if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ 281 (head)->stqh_last = &(elm)->field.stqe_next; \ 282 (listelm)->field.stqe_next = (elm); \ 285 #define STAILQ_REMOVE_HEAD(head, field) do { \ 286 if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ 287 (head)->stqh_last = &(head)->stqh_first; \ 290 #define STAILQ_REMOVE(head, elm, type, field) do { \ 291 if ((head)->stqh_first == (elm)) { \ 292 STAILQ_REMOVE_HEAD((head), field); \ 294 struct type *curelm = (head)->stqh_first; \ 295 while (curelm->field.stqe_next != (elm)) \ 296 curelm = curelm->field.stqe_next; \ 297 if ((curelm->field.stqe_next = \ 298 curelm->field.stqe_next->field.stqe_next) == NULL) \ 299 (head)->stqh_last = &(curelm)->field.stqe_next; \ 303 #define STAILQ_FOREACH(var, head, field) \ 304 for ((var) = ((head)->stqh_first); \ 306 (var) = ((var)->field.stqe_next)) 308 #define STAILQ_CONCAT(head1, head2) do { \ 309 if (!STAILQ_EMPTY((head2))) { \ 310 *(head1)->stqh_last = (head2)->stqh_first; \ 311 (head1)->stqh_last = (head2)->stqh_last; \ 312 STAILQ_INIT((head2)); \ 319 #define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) 320 #define STAILQ_FIRST(head) ((head)->stqh_first) 321 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) 326 #define SIMPLEQ_HEAD(name, type) \ 328 struct type *sqh_first; \ 329 struct type **sqh_last; \ 332 #define SIMPLEQ_HEAD_INITIALIZER(head) \ 333 { NULL, &(head).sqh_first } 335 #define SIMPLEQ_ENTRY(type) \ 337 struct type *sqe_next; \ 343 #define SIMPLEQ_INIT(head) do { \ 344 (head)->sqh_first = NULL; \ 345 (head)->sqh_last = &(head)->sqh_first; \ 348 #define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ 349 if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ 350 (head)->sqh_last = &(elm)->field.sqe_next; \ 351 (head)->sqh_first = (elm); \ 354 #define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ 355 (elm)->field.sqe_next = NULL; \ 356 *(head)->sqh_last = (elm); \ 357 (head)->sqh_last = &(elm)->field.sqe_next; \ 360 #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ 361 if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ 362 (head)->sqh_last = &(elm)->field.sqe_next; \ 363 (listelm)->field.sqe_next = (elm); \ 366 #define SIMPLEQ_REMOVE_HEAD(head, field) do { \ 367 if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ 368 (head)->sqh_last = &(head)->sqh_first; \ 371 #define SIMPLEQ_REMOVE(head, elm, type, field) do { \ 372 if ((head)->sqh_first == (elm)) { \ 373 SIMPLEQ_REMOVE_HEAD((head), field); \ 375 struct type *curelm = (head)->sqh_first; \ 376 while (curelm->field.sqe_next != (elm)) \ 377 curelm = curelm->field.sqe_next; \ 378 if ((curelm->field.sqe_next = \ 379 curelm->field.sqe_next->field.sqe_next) == NULL) \ 380 (head)->sqh_last = &(curelm)->field.sqe_next; \ 384 #define SIMPLEQ_FOREACH(var, head, field) \ 385 for ((var) = ((head)->sqh_first); \ 387 (var) = ((var)->field.sqe_next)) 392 #define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) 393 #define SIMPLEQ_FIRST(head) ((head)->sqh_first) 394 #define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) 399 #define _TAILQ_HEAD(name, type, qual) \ 401 qual type *tqh_first; \ 402 qual type *qual *tqh_last; \ 404 #define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) 406 #define TAILQ_HEAD_INITIALIZER(head) \ 407 { NULL, &(head).tqh_first } 409 #define _TAILQ_ENTRY(type, qual) \ 411 qual type *tqe_next; \ 412 qual type *qual *tqe_prev; \ 414 #define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) 419 #if defined(_KERNEL) && defined(QUEUEDEBUG) 420 #define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ 421 if ((head)->tqh_first && \ 422 (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ 423 panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); 424 #define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ 425 if (*(head)->tqh_last != NULL) \ 426 panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__); 427 #define QUEUEDEBUG_TAILQ_OP(elm, field) \ 428 if ((elm)->field.tqe_next && \ 429 (elm)->field.tqe_next->field.tqe_prev != \ 430 &(elm)->field.tqe_next) \ 431 panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ 432 if (*(elm)->field.tqe_prev != (elm)) \ 433 panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__); 434 #define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ 435 if ((elm)->field.tqe_next == NULL && \ 436 (head)->tqh_last != &(elm)->field.tqe_next) \ 437 panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \ 438 (head), (elm), __FILE__, __LINE__); 439 #define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ 440 (elm)->field.tqe_next = (void *)1L; \ 441 (elm)->field.tqe_prev = (void *)1L; 443 #define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) 444 #define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) 445 #define QUEUEDEBUG_TAILQ_OP(elm, field) 446 #define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) 447 #define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) 450 #define TAILQ_INIT(head) do { \ 451 (head)->tqh_first = NULL; \ 452 (head)->tqh_last = &(head)->tqh_first; \ 455 #define TAILQ_INSERT_HEAD(head, elm, field) do { \ 456 QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ 457 if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ 458 (head)->tqh_first->field.tqe_prev = \ 459 &(elm)->field.tqe_next; \ 461 (head)->tqh_last = &(elm)->field.tqe_next; \ 462 (head)->tqh_first = (elm); \ 463 (elm)->field.tqe_prev = &(head)->tqh_first; \ 466 #define TAILQ_INSERT_TAIL(head, elm, field) do { \ 467 QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ 468 (elm)->field.tqe_next = NULL; \ 469 (elm)->field.tqe_prev = (head)->tqh_last; \ 470 *(head)->tqh_last = (elm); \ 471 (head)->tqh_last = &(elm)->field.tqe_next; \ 474 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ 475 QUEUEDEBUG_TAILQ_OP((listelm), field) \ 476 if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ 477 (elm)->field.tqe_next->field.tqe_prev = \ 478 &(elm)->field.tqe_next; \ 480 (head)->tqh_last = &(elm)->field.tqe_next; \ 481 (listelm)->field.tqe_next = (elm); \ 482 (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ 485 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ 486 QUEUEDEBUG_TAILQ_OP((listelm), field) \ 487 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ 488 (elm)->field.tqe_next = (listelm); \ 489 *(listelm)->field.tqe_prev = (elm); \ 490 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ 493 #define TAILQ_REMOVE(head, elm, field) do { \ 494 QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ 495 QUEUEDEBUG_TAILQ_OP((elm), field) \ 496 if (((elm)->field.tqe_next) != NULL) \ 497 (elm)->field.tqe_next->field.tqe_prev = \ 498 (elm)->field.tqe_prev; \ 500 (head)->tqh_last = (elm)->field.tqe_prev; \ 501 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ 502 QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ 505 #define TAILQ_FOREACH(var, head, field) \ 506 for ((var) = ((head)->tqh_first); \ 508 (var) = ((var)->field.tqe_next)) 510 #define TAILQ_FOREACH_SAFE(var, head, field, next) \ 511 for ((var) = ((head)->tqh_first); \ 512 (var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \ 515 #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ 516 for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ 518 (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) 520 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ 521 for ((var) = TAILQ_LAST((head), headname); \ 522 (var) && ((prev) = TAILQ_PREV((var), headname, field), 1);\ 525 #define TAILQ_CONCAT(head1, head2, field) do { \ 526 if (!TAILQ_EMPTY(head2)) { \ 527 *(head1)->tqh_last = (head2)->tqh_first; \ 528 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ 529 (head1)->tqh_last = (head2)->tqh_last; \ 530 TAILQ_INIT((head2)); \ 537 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) 538 #define TAILQ_FIRST(head) ((head)->tqh_first) 539 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) 541 #define TAILQ_LAST(head, headname) \ 542 (*(((struct headname *)((head)->tqh_last))->tqh_last)) 543 #define TAILQ_PREV(elm, headname, field) \ 544 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) 549 #if defined(_KERNEL) && defined(QUEUEDEBUG) 550 #define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ 551 if ((head)->cqh_first != (void *)(head) && \ 552 (head)->cqh_first->field.cqe_prev != (void *)(head)) \ 553 panic("CIRCLEQ head forw %p %s:%d", (head), \ 554 __FILE__, __LINE__); \ 555 if ((head)->cqh_last != (void *)(head) && \ 556 (head)->cqh_last->field.cqe_next != (void *)(head)) \ 557 panic("CIRCLEQ head back %p %s:%d", (head), \ 559 #define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ 560 if ((elm)->field.cqe_next == (void *)(head)) { \ 561 if ((head)->cqh_last != (elm)) \ 562 panic("CIRCLEQ elm last %p %s:%d", (elm), \ 563 __FILE__, __LINE__); \ 565 if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ 566 panic("CIRCLEQ elm forw %p %s:%d", (elm), \ 567 __FILE__, __LINE__); \ 569 if ((elm)->field.cqe_prev == (void *)(head)) { \ 570 if ((head)->cqh_first != (elm)) \ 571 panic("CIRCLEQ elm first %p %s:%d", (elm), \ 572 __FILE__, __LINE__); \ 574 if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ 575 panic("CIRCLEQ elm prev %p %s:%d", (elm), \ 576 __FILE__, __LINE__); \ 578 #define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ 579 (elm)->field.cqe_next = (void *)1L; \ 580 (elm)->field.cqe_prev = (void *)1L; 582 #define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) 583 #define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) 584 #define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) 587 #define CIRCLEQ_HEAD(name, type) \ 589 struct type *cqh_first; \ 590 struct type *cqh_last; \ 593 #define CIRCLEQ_HEAD_INITIALIZER(head) \ 594 { (void *)&head, (void *)&head } 596 #define CIRCLEQ_ENTRY(type) \ 598 struct type *cqe_next; \ 599 struct type *cqe_prev; \ 605 #define CIRCLEQ_INIT(head) do { \ 606 (head)->cqh_first = (void *)(head); \ 607 (head)->cqh_last = (void *)(head); \ 610 #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ 611 QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ 612 QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ 613 (elm)->field.cqe_next = (listelm)->field.cqe_next; \ 614 (elm)->field.cqe_prev = (listelm); \ 615 if ((listelm)->field.cqe_next == (void *)(head)) \ 616 (head)->cqh_last = (elm); \ 618 (listelm)->field.cqe_next->field.cqe_prev = (elm); \ 619 (listelm)->field.cqe_next = (elm); \ 622 #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ 623 QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ 624 QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ 625 (elm)->field.cqe_next = (listelm); \ 626 (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ 627 if ((listelm)->field.cqe_prev == (void *)(head)) \ 628 (head)->cqh_first = (elm); \ 630 (listelm)->field.cqe_prev->field.cqe_next = (elm); \ 631 (listelm)->field.cqe_prev = (elm); \ 634 #define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ 635 QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ 636 (elm)->field.cqe_next = (head)->cqh_first; \ 637 (elm)->field.cqe_prev = (void *)(head); \ 638 if ((head)->cqh_last == (void *)(head)) \ 639 (head)->cqh_last = (elm); \ 641 (head)->cqh_first->field.cqe_prev = (elm); \ 642 (head)->cqh_first = (elm); \ 645 #define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ 646 QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ 647 (elm)->field.cqe_next = (void *)(head); \ 648 (elm)->field.cqe_prev = (head)->cqh_last; \ 649 if ((head)->cqh_first == (void *)(head)) \ 650 (head)->cqh_first = (elm); \ 652 (head)->cqh_last->field.cqe_next = (elm); \ 653 (head)->cqh_last = (elm); \ 656 #define CIRCLEQ_REMOVE(head, elm, field) do { \ 657 QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ 658 QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ 659 if ((elm)->field.cqe_next == (void *)(head)) \ 660 (head)->cqh_last = (elm)->field.cqe_prev; \ 662 (elm)->field.cqe_next->field.cqe_prev = \ 663 (elm)->field.cqe_prev; \ 664 if ((elm)->field.cqe_prev == (void *)(head)) \ 665 (head)->cqh_first = (elm)->field.cqe_next; \ 667 (elm)->field.cqe_prev->field.cqe_next = \ 668 (elm)->field.cqe_next; \ 669 QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ 672 #define CIRCLEQ_FOREACH(var, head, field) \ 673 for ((var) = ((head)->cqh_first); \ 674 (var) != (const void *)(head); \ 675 (var) = ((var)->field.cqe_next)) 677 #define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ 678 for ((var) = ((head)->cqh_last); \ 679 (var) != (const void *)(head); \ 680 (var) = ((var)->field.cqe_prev)) 685 #define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) 686 #define CIRCLEQ_FIRST(head) ((head)->cqh_first) 687 #define CIRCLEQ_LAST(head) ((head)->cqh_last) 688 #define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) 689 #define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) 691 #define CIRCLEQ_LOOP_NEXT(head, elm, field) \ 692 (((elm)->field.cqe_next == (void *)(head)) \ 693 ? ((head)->cqh_first) \ 694 : (elm->field.cqe_next)) 695 #define CIRCLEQ_LOOP_PREV(head, elm, field) \ 696 (((elm)->field.cqe_prev == (void *)(head)) \ 697 ? ((head)->cqh_last) \ 698 : (elm->field.cqe_prev))