Lines Matching refs:head

49  * head of the list.  Elements being removed from the head of the list
59 * or after an existing element or at the head of the list. A list
62 * A simple queue is headed by a pair of pointers, one the head of the
65 * head of the list. New elements can be added to the list after
66 * an existing element, at the head of the list, or at the end of the
69 * A tail queue is headed by a pair of pointers, one to the head of the
73 * after an existing element, at the head of the list, or at the end of
76 * A circle queue is headed by a pair of pointers, one to the head of the
80 * an existing element, at the head of the list, or at the end of the list.
95 #define LIST_HEAD_INITIALIZER(head) \
108 #define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \
109 if ((head)->lh_first && \
110 (head)->lh_first->field.le_prev != &(head)->lh_first) \
111 panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
123 #define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field)
128 #define LIST_INIT(head) do { \
129 (head)->lh_first = NULL; \
149 #define LIST_INSERT_HEAD(head, elm, field) do { \
150 QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \
151 if (((elm)->field.le_next = (head)->lh_first) != NULL) \
152 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
153 (head)->lh_first = (elm); \
154 (elm)->field.le_prev = &(head)->lh_first; \
166 #define LIST_FOREACH(var, head, field) \
167 for ((var) = ((head)->lh_first); \
174 #define LIST_EMPTY(head) ((head)->lh_first == NULL)
175 #define LIST_FIRST(head) ((head)->lh_first)
186 #define SLIST_HEAD_INITIALIZER(head) \
197 #define SLIST_EMPTY(head) ((head)->slh_first == NULL)
198 #define SLIST_FIRST(head) ((head)->slh_first)
201 #define SLIST_FOREACH(var, head, field) \
202 for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
204 #define SLIST_INIT(head) do { \
205 (head)->slh_first = NULL; \
213 #define SLIST_INSERT_HEAD(head, elm, field) do { \
214 (elm)->field.sle_next = (head)->slh_first; \
215 (head)->slh_first = (elm); \
220 #define SLIST_REMOVE_HEAD(head, field) do { \
221 (head)->slh_first = (head)->slh_first->field.sle_next; \
224 #define SLIST_REMOVE(head, elm, type, field) do { \
225 if ((head)->slh_first == (elm)) { \
226 SLIST_REMOVE_HEAD((head), field); \
229 struct type *curelm = (head)->slh_first; \
246 #define SIMPLEQ_HEAD_INITIALIZER(head) \
247 { NULL, &(head).sqh_first }
257 #define SIMPLEQ_INIT(head) do { \
258 (head)->sqh_first = NULL; \
259 (head)->sqh_last = &(head)->sqh_first; \
262 #define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
263 if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
264 (head)->sqh_last = &(elm)->field.sqe_next; \
265 (head)->sqh_first = (elm); \
268 #define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
270 *(head)->sqh_last = (elm); \
271 (head)->sqh_last = &(elm)->field.sqe_next; \
274 #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
276 (head)->sqh_last = &(elm)->field.sqe_next; \
280 #define SIMPLEQ_REMOVE_HEAD(head, field) do { \
281 if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
282 (head)->sqh_last = &(head)->sqh_first; \
285 #define SIMPLEQ_REMOVE(head, elm, type, field) do { \
286 if ((head)->sqh_first == (elm)) { \
287 SIMPLEQ_REMOVE_HEAD((head), field); \
289 struct type *curelm = (head)->sqh_first; \
294 (head)->sqh_last = &(curelm)->field.sqe_next; \
298 #define SIMPLEQ_FOREACH(var, head, field) \
299 for ((var) = ((head)->sqh_first); \
306 #define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
307 #define SIMPLEQ_FIRST(head) ((head)->sqh_first)
319 #define TAILQ_HEAD_INITIALIZER(head) \
320 { NULL, &(head).tqh_first }
332 #define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \
333 if ((head)->tqh_first && \
334 (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \
335 panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
336 #define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \
337 if (*(head)->tqh_last != NULL) \
338 panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__);
350 #define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)
351 #define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)
356 #define TAILQ_INIT(head) do { \
357 (head)->tqh_first = NULL; \
358 (head)->tqh_last = &(head)->tqh_first; \
361 #define TAILQ_INSERT_HEAD(head, elm, field) do { \
362 QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \
363 if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
364 (head)->tqh_first->field.tqe_prev = \
367 (head)->tqh_last = &(elm)->field.tqe_next; \
368 (head)->tqh_first = (elm); \
369 (elm)->field.tqe_prev = &(head)->tqh_first; \
372 #define TAILQ_INSERT_TAIL(head, elm, field) do { \
373 QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \
375 (elm)->field.tqe_prev = (head)->tqh_last; \
376 *(head)->tqh_last = (elm); \
377 (head)->tqh_last = &(elm)->field.tqe_next; \
380 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
386 (head)->tqh_last = &(elm)->field.tqe_next; \
399 #define TAILQ_REMOVE(head, elm, field) do { \
405 (head)->tqh_last = (elm)->field.tqe_prev; \
413 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
414 #define TAILQ_FIRST(head) ((head)->tqh_first)
417 #define TAILQ_LAST(head, headname) \
418 (*(((struct headname *)((head)->tqh_last))->tqh_last))
422 #define TAILQ_FOREACH(var, head, field) \
423 for ((var) = ((head)->tqh_first); \
427 #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
428 for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
441 #define CIRCLEQ_HEAD_INITIALIZER(head) \
442 { (void *)&head, (void *)&head }
453 #define CIRCLEQ_INIT(head) do { \
454 (head)->cqh_first = (void *)(head); \
455 (head)->cqh_last = (void *)(head); \
458 #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
461 if ((listelm)->field.cqe_next == (void *)(head)) \
462 (head)->cqh_last = (elm); \
468 #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
471 if ((listelm)->field.cqe_prev == (void *)(head)) \
472 (head)->cqh_first = (elm); \
478 #define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
479 (elm)->field.cqe_next = (head)->cqh_first; \
480 (elm)->field.cqe_prev = (void *)(head); \
481 if ((head)->cqh_last == (void *)(head)) \
482 (head)->cqh_last = (elm); \
484 (head)->cqh_first->field.cqe_prev = (elm); \
485 (head)->cqh_first = (elm); \
488 #define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
489 (elm)->field.cqe_next = (void *)(head); \
490 (elm)->field.cqe_prev = (head)->cqh_last; \
491 if ((head)->cqh_first == (void *)(head)) \
492 (head)->cqh_first = (elm); \
494 (head)->cqh_last->field.cqe_next = (elm); \
495 (head)->cqh_last = (elm); \
498 #define CIRCLEQ_REMOVE(head, elm, field) do { \
499 if ((elm)->field.cqe_next == (void *)(head)) \
500 (head)->cqh_last = (elm)->field.cqe_prev; \
504 if ((elm)->field.cqe_prev == (void *)(head)) \
505 (head)->cqh_first = (elm)->field.cqe_next; \
511 #define CIRCLEQ_FOREACH(var, head, field) \
512 for ((var) = ((head)->cqh_first); \
513 (var) != (void *)(head); \
516 #define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
517 for ((var) = ((head)->cqh_last); \
518 (var) != (void *)(head); \
524 #define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
525 #define CIRCLEQ_FIRST(head) ((head)->cqh_first)
526 #define CIRCLEQ_LAST(head) ((head)->cqh_last)