diff options
author | 1997-11-06 05:58:00 +0000 | |
---|---|---|
committer | 1997-11-06 05:58:00 +0000 | |
commit | 07feb63c29dabe2798f31749f3e8a89dc96eee83 (patch) | |
tree | d13e0c3a511d6f2ef321c9972bd6f67a6912631c /sys/sys/queue.h | |
parent | temp <machine_btop() fix (diff) | |
download | wireguard-openbsd-07feb63c29dabe2798f31749f3e8a89dc96eee83.tar.xz wireguard-openbsd-07feb63c29dabe2798f31749f3e8a89dc96eee83.zip |
Updates for VFS Lite 2 + soft update.
Diffstat (limited to 'sys/sys/queue.h')
-rw-r--r-- | sys/sys/queue.h | 113 |
1 files changed, 66 insertions, 47 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 1ce02639ac3..d8f139a8413 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.h,v 1.6 1997/10/06 20:21:10 deraadt Exp $ */ +/* $OpenBSD: queue.h,v 1.7 1997/11/06 05:59:10 csapuntz Exp $ */ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ /* @@ -62,7 +62,7 @@ * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may only be traversed in the forward direction. + * the list. A tail queue may be traversed in either direction. * * A circle queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly @@ -81,7 +81,7 @@ #define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ -} +} #define LIST_ENTRY(type) \ struct { \ @@ -89,41 +89,45 @@ struct { \ struct type **le_prev; /* address of previous next element */ \ } +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) +#define LIST_END(head) NULL + /* * List functions. */ -#define LIST_INIT(head) { \ +#define LIST_INIT(head) do { \ (head)->lh_first = NULL; \ -} +} while (0) -#define LIST_INSERT_AFTER(listelm, elm, field) { \ +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ &(elm)->field.le_next; \ (listelm)->field.le_next = (elm); \ (elm)->field.le_prev = &(listelm)->field.le_next; \ -} +} while (0) -#define LIST_INSERT_BEFORE(listelm, elm, field) { \ +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_next = (listelm); \ *(listelm)->field.le_prev = (elm); \ (listelm)->field.le_prev = &(elm)->field.le_next; \ -} +} while (0) -#define LIST_INSERT_HEAD(head, elm, field) { \ +#define LIST_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.le_next = (head)->lh_first) != NULL) \ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ (head)->lh_first = (elm); \ (elm)->field.le_prev = &(head)->lh_first; \ -} +} while (0) -#define LIST_REMOVE(elm, field) { \ +#define LIST_REMOVE(elm, field) do { \ if ((elm)->field.le_next != NULL) \ (elm)->field.le_next->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = (elm)->field.le_next; \ -} +} while (0) /* * Simple queue definitions. @@ -142,33 +146,33 @@ struct { \ /* * Simple queue functions. */ -#define SIMPLEQ_INIT(head) { \ +#define SIMPLEQ_INIT(head) do { \ (head)->sqh_first = NULL; \ (head)->sqh_last = &(head)->sqh_first; \ -} +} while (0) -#define SIMPLEQ_INSERT_HEAD(head, elm, field) { \ +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ (head)->sqh_last = &(elm)->field.sqe_next; \ (head)->sqh_first = (elm); \ -} +} while (0) -#define SIMPLEQ_INSERT_TAIL(head, elm, field) { \ +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.sqe_next = NULL; \ *(head)->sqh_last = (elm); \ (head)->sqh_last = &(elm)->field.sqe_next; \ -} +} while (0) -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) { \ +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ (head)->sqh_last = &(elm)->field.sqe_next; \ (listelm)->field.sqe_next = (elm); \ -} +} while (0) -#define SIMPLEQ_REMOVE_HEAD(head, elm, field) { \ +#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \ if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ (head)->sqh_last = &(head)->sqh_first; \ -} +} while (0) /* * Tail queue definitions. @@ -185,15 +189,24 @@ struct { \ struct type **tqe_prev; /* address of previous next element */ \ } + +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_END(head) NULL +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + /* * Tail queue functions. */ -#define TAILQ_INIT(head) { \ +#define TAILQ_INIT(head) do { \ (head)->tqh_first = NULL; \ (head)->tqh_last = &(head)->tqh_first; \ -} +} while (0) -#define TAILQ_INSERT_HEAD(head, elm, field) { \ +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ (head)->tqh_first->field.tqe_prev = \ &(elm)->field.tqe_next; \ @@ -201,16 +214,16 @@ struct { \ (head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_first = (elm); \ (elm)->field.tqe_prev = &(head)->tqh_first; \ -} +} while (0) -#define TAILQ_INSERT_TAIL(head, elm, field) { \ +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.tqe_next = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &(elm)->field.tqe_next; \ -} +} while (0) -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \ +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ (elm)->field.tqe_next->field.tqe_prev = \ &(elm)->field.tqe_next; \ @@ -218,23 +231,23 @@ struct { \ (head)->tqh_last = &(elm)->field.tqe_next; \ (listelm)->field.tqe_next = (elm); \ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} +} while (0) -#define TAILQ_INSERT_BEFORE(listelm, elm, field) { \ +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_next = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} +} while (0) -#define TAILQ_REMOVE(head, elm, field) { \ +#define TAILQ_REMOVE(head, elm, field) do { \ if (((elm)->field.tqe_next) != NULL) \ (elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_prev; \ else \ (head)->tqh_last = (elm)->field.tqe_prev; \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} +} while (0) /* * Circular queue definitions. @@ -251,15 +264,21 @@ struct { \ struct type *cqe_prev; /* previous element */ \ } +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_END(head) ((void *)(head)) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) + /* * Circular queue functions. */ -#define CIRCLEQ_INIT(head) { \ +#define CIRCLEQ_INIT(head) do { \ (head)->cqh_first = (void *)(head); \ (head)->cqh_last = (void *)(head); \ -} +} while (0) -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \ +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm)->field.cqe_next; \ (elm)->field.cqe_prev = (listelm); \ if ((listelm)->field.cqe_next == (void *)(head)) \ @@ -267,9 +286,9 @@ struct { \ else \ (listelm)->field.cqe_next->field.cqe_prev = (elm); \ (listelm)->field.cqe_next = (elm); \ -} +} while (0) -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \ +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm); \ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ if ((listelm)->field.cqe_prev == (void *)(head)) \ @@ -277,9 +296,9 @@ struct { \ else \ (listelm)->field.cqe_prev->field.cqe_next = (elm); \ (listelm)->field.cqe_prev = (elm); \ -} +} while (0) -#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \ +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ (elm)->field.cqe_next = (head)->cqh_first; \ (elm)->field.cqe_prev = (void *)(head); \ if ((head)->cqh_last == (void *)(head)) \ @@ -287,9 +306,9 @@ struct { \ else \ (head)->cqh_first->field.cqe_prev = (elm); \ (head)->cqh_first = (elm); \ -} +} while (0) -#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \ +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.cqe_next = (void *)(head); \ (elm)->field.cqe_prev = (head)->cqh_last; \ if ((head)->cqh_first == (void *)(head)) \ @@ -297,9 +316,9 @@ struct { \ else \ (head)->cqh_last->field.cqe_next = (elm); \ (head)->cqh_last = (elm); \ -} +} while (0) -#define CIRCLEQ_REMOVE(head, elm, field) { \ +#define CIRCLEQ_REMOVE(head, elm, field) do { \ if ((elm)->field.cqe_next == (void *)(head)) \ (head)->cqh_last = (elm)->field.cqe_prev; \ else \ @@ -310,5 +329,5 @@ struct { \ else \ (elm)->field.cqe_prev->field.cqe_next = \ (elm)->field.cqe_next; \ -} +} while (0) #endif /* !_SYS_QUEUE_H_ */ |