diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 12:07:16 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 12:07:16 +0000 |
commit | 511b3d71f57a59e6f28c6baf2f5ee72d246ff3c0 (patch) | |
tree | a2beb7e268e19b6af1e2c83cb8bd37f063513d7e | |
parent | cfb2a4d8ca097da1efaea57fde773395fc48d4f9 (diff) |
the linked list argument
-rw-r--r-- | sys/sys/queue.h | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 4cd83dff2b4..962009c90d4 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -1,5 +1,5 @@ -/* $OpenBSD: queue.h,v 1.3 1996/04/21 22:31:56 deraadt Exp $ */ -/* $NetBSD: queue.h,v 1.10 1996/04/09 20:55:34 cgd Exp $ */ +/* $OpenBSD: queue.h,v 1.4 1996/05/22 12:07:15 deraadt Exp $ */ +/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ /* * Copyright (c) 1991, 1993 @@ -50,6 +50,13 @@ * or after an existing element or at the head of the list. A list * may only be traversed in the forward direction. * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so only elements can only be removed from the + * head of 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 simple queue may only be traversed in the forward direection. + * * A tail 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 * linked so that an arbitrary element can be removed without a need to @@ -119,6 +126,51 @@ struct { \ } /* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} + +#define SIMPLEQ_REMOVE_HEAD(head, elm, field) { \ + if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} + +/* * Tail queue definitions. */ #define TAILQ_HEAD(name, type) \ |