|
Lines 74-80
Link Here
|
| 74 |
* linked so that an arbitrary element can be removed without a need to |
74 |
* linked so that an arbitrary element can be removed without a need to |
| 75 |
* traverse the list. New elements can be added to the list before or |
75 |
* traverse the list. New elements can be added to the list before or |
| 76 |
* after an existing element, at the head of the list, or at the end of |
76 |
* after an existing element, at the head of the list, or at the end of |
| 77 |
* the list. A tail queue may be traversed in either direction. |
77 |
* the list. A tail queue may be traversed in either direction. Tail |
|
|
78 |
* queues may be concated. |
| 78 |
* |
79 |
* |
| 79 |
* A circle queue is headed by a pair of pointers, one to the head of the |
80 |
* A circle queue is headed by a pair of pointers, one to the head of the |
| 80 |
* list and the other to the tail of the list. The elements are doubly |
81 |
* list and the other to the tail of the list. The elements are doubly |
|
Lines 82-88
Link Here
|
| 82 |
* traverse the list. New elements can be added to the list before or after |
83 |
* traverse the list. New elements can be added to the list before or after |
| 83 |
* an existing element, at the head of the list, or at the end of the list. |
84 |
* an existing element, at the head of the list, or at the end of the list. |
| 84 |
* A circle queue may be traversed in either direction, but has a more |
85 |
* A circle queue may be traversed in either direction, but has a more |
| 85 |
* complex end of list detection. |
86 |
* complex end of list detection. Circle queues may be concatenated. |
| 86 |
* |
87 |
* |
| 87 |
* For details on the use of these macros, see the queue(3) manual page. |
88 |
* For details on the use of these macros, see the queue(3) manual page. |
| 88 |
* |
89 |
* |
|
Lines 104-109
Link Here
|
| 104 |
* _INSERT_TAIL - - + + + |
105 |
* _INSERT_TAIL - - + + + |
| 105 |
* _REMOVE_HEAD + - + - - |
106 |
* _REMOVE_HEAD + - + - - |
| 106 |
* _REMOVE + + + + + |
107 |
* _REMOVE + + + + + |
|
|
108 |
* _CONCAT - - - + + |
| 107 |
* |
109 |
* |
| 108 |
*/ |
110 |
*/ |
| 109 |
|
111 |
|
|
Lines 387-392
Link Here
|
| 387 |
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ |
389 |
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ |
| 388 |
} while (0) |
390 |
} while (0) |
| 389 |
|
391 |
|
|
|
392 |
#define TAILQ_CONCAT(head1, head2, field) do { \ |
| 393 |
if (!TAILQ_EMPTY(head2)) { \ |
| 394 |
*(head1)->tqh_last = (head2)->tqh_first; \ |
| 395 |
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ |
| 396 |
(head1)->tqh_last = (head2)->tqh_last; \ |
| 397 |
TAILQ_INIT(head2); \ |
| 398 |
} \ |
| 399 |
} while (0) |
| 400 |
|
| 390 |
#define TAILQ_REMOVE(head, elm, field) do { \ |
401 |
#define TAILQ_REMOVE(head, elm, field) do { \ |
| 391 |
if (((elm)->field.tqe_next) != NULL) \ |
402 |
if (((elm)->field.tqe_next) != NULL) \ |
| 392 |
(elm)->field.tqe_next->field.tqe_prev = \ |
403 |
(elm)->field.tqe_next->field.tqe_prev = \ |
|
Lines 471-476
Link Here
|
| 471 |
else \ |
482 |
else \ |
| 472 |
(head)->cqh_last->field.cqe_next = (elm); \ |
483 |
(head)->cqh_last->field.cqe_next = (elm); \ |
| 473 |
(head)->cqh_last = (elm); \ |
484 |
(head)->cqh_last = (elm); \ |
|
|
485 |
} while (0) |
| 486 |
|
| 487 |
#define CIRCLEQ_CONCAT(head1, head2, field) do { \ |
| 488 |
if (!CIRCLEQ_EMPTY(head2)) { \ |
| 489 |
if (!CIRCLEQ_EMPTY(head1)) { \ |
| 490 |
(head1)->cqh_last->field.cqe_next = \ |
| 491 |
(head2)->cqh_first; \ |
| 492 |
(head2)->cqh_first->field.cqe_prev = \ |
| 493 |
(head1)->cqh_last; \ |
| 494 |
} else { \ |
| 495 |
(head1)->cqh_first = (head2)->cqh_first; \ |
| 496 |
(head2)->cqh_first->field.cqe_prev = \ |
| 497 |
(void *)(head1); \ |
| 498 |
} \ |
| 499 |
(head1)->cqh_last = (head2)->cqh_last; \ |
| 500 |
(head2)->cqh_last->field.cqe_next = \ |
| 501 |
(void *)(head1); \ |
| 502 |
CIRCLEQ_INIT(head2); \ |
| 503 |
} \ |
| 474 |
} while (0) |
504 |
} while (0) |
| 475 |
|
505 |
|
| 476 |
#define CIRCLEQ_LAST(head) ((head)->cqh_last) |
506 |
#define CIRCLEQ_LAST(head) ((head)->cqh_last) |