summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhsu <hsu@FreeBSD.org>2000-08-03 16:36:40 +0000
committerhsu <hsu@FreeBSD.org>2000-08-03 16:36:40 +0000
commit5fdba512ea50675f172def79a1732e58d3baf048 (patch)
treedd319c0aba5d9b4c2eb278054d303a2b1cc05dc1
parentf36f8d5bae2c807884f6707c6d3b169c3e868e85 (diff)
downloadFreeBSD-src-5fdba512ea50675f172def79a1732e58d3baf048.zip
FreeBSD-src-5fdba512ea50675f172def79a1732e58d3baf048.tar.gz
Restore STAILQ_LAST() semantics to match that of TAILQ_LAST()
and CIRCLEQ_LAST(). Return the last element instead of a pointer to the next field of the last element. Reviewed by: dfr
-rw-r--r--sys/sys/queue.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 04a6ffe..6b5d320 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -37,6 +37,8 @@
#ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_
+#include <struct.h>
+
/*
* This file defines five types of data structures: singly-linked lists,
* singly-linked tail queues, lists, tail queues, and circular queues.
@@ -217,11 +219,14 @@ struct { \
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
STAILQ_NEXT((elm), field) = NULL; \
- STAILQ_LAST((head)) = (elm); \
+ *(head)->stqh_last = (elm); \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0)
-#define STAILQ_LAST(head) (*(head)->stqh_last)
+#define STAILQ_LAST(head, type, field) \
+ (((head)->stqh_last == &(head)->stqh_first) ? \
+ NULL : \
+ strbase(type, (head)->stqh_last, field))
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
OpenPOWER on IntegriCloud