add another QUEUEDEBUG check: in TAILQ_REMOVE(), if the element we're

removing has no next element, verify that the queue head agrees that
the current element is the last one.  (this is how I found the recent
ppc pmap bugs).
This commit is contained in:
chs 2002-10-22 04:50:38 +00:00
parent 4017fd1809
commit f17273fd1e

View File

@ -1,4 +1,4 @@
/* $NetBSD: queue.h,v 1.31 2002/06/01 23:51:05 lukem Exp $ */ /* $NetBSD: queue.h,v 1.32 2002/10/22 04:50:38 chs Exp $ */
/* /*
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -343,6 +343,11 @@ struct { \
panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
if (*(elm)->field.tqe_prev != (elm)) \ if (*(elm)->field.tqe_prev != (elm)) \
panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__); panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__);
#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \
if ((elm)->field.tqe_next == NULL && \
(head)->tqh_last != &(elm)->field.tqe_next) \
panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \
(head), (elm), __FILE__, __LINE__);
#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ #define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \
(elm)->field.tqe_next = (void *)1L; \ (elm)->field.tqe_next = (void *)1L; \
(elm)->field.tqe_prev = (void *)1L; (elm)->field.tqe_prev = (void *)1L;
@ -350,6 +355,7 @@ struct { \
#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) #define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)
#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) #define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)
#define QUEUEDEBUG_TAILQ_OP(elm, field) #define QUEUEDEBUG_TAILQ_OP(elm, field)
#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field)
#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) #define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field)
#endif #endif
@ -397,6 +403,7 @@ struct { \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define TAILQ_REMOVE(head, elm, field) do { \ #define TAILQ_REMOVE(head, elm, field) do { \
QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \
QUEUEDEBUG_TAILQ_OP((elm), field) \ QUEUEDEBUG_TAILQ_OP((elm), field) \
if (((elm)->field.tqe_next) != NULL) \ if (((elm)->field.tqe_next) != NULL) \
(elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_next->field.tqe_prev = \