Copied STAILQ_HEAD_INITIALIZER and LIST_HEAD_INITIALIZER from NetBSD, and

added STAILQ_REMOVE_HEAD_QUEUE to emulate NetBSD's SIMPLEQ_REMOVE_HEAD (that
removes not only the first element but a queue of elements).
This commit is contained in:
Nick Hibma 1999-01-06 20:03:11 +00:00
parent d718b44f52
commit f6b387c28e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42359

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
* $Id: queue.h,v 1.21 1998/05/12 03:55:25 gibbs Exp $
* $Id: queue.h,v 1.22 1998/06/24 20:51:09 phk Exp $
*/
#ifndef _SYS_QUEUE_H_
@ -133,7 +133,7 @@ struct { \
(head)->slh_first = NULL; \
}
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
(elm)->field.sle_next = (slistelm)->field.sle_next; \
(slistelm)->field.sle_next = (elm); \
} while (0)
@ -171,6 +171,9 @@ struct name { \
struct type **stqh_last;/* addr of last next element */ \
}
#define STAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).stqh_first }
#define STAILQ_ENTRY(type) \
struct { \
struct type *stqe_next; /* next element */ \
@ -215,6 +218,12 @@ struct { \
(head)->stqh_last = &(head)->stqh_first; \
} while (0)
#define STAILQ_REMOVE_HEAD_QUEUE(head, elm, field) do { \
if (((head)->stqh_first = (elm)->field.stqe_next) == NULL) \
(head)->stqh_last = &(head)->stqh_first; \
} while (0)
#define STAILQ_REMOVE(head, elm, type, field) do { \
if ((head)->stqh_first == (elm)) { \
STAILQ_REMOVE_HEAD(head, field); \
@ -237,6 +246,9 @@ struct name { \
struct type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
#define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \