From 5fdba512ea50675f172def79a1732e58d3baf048 Mon Sep 17 00:00:00 2001 From: hsu Date: Thu, 3 Aug 2000 16:36:40 +0000 Subject: 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 --- sys/sys/queue.h | 9 +++++++-- 1 file 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 + /* * 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) -- cgit v1.1