summaryrefslogtreecommitdiff
path: root/openbsd-compat/sys-queue.h
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/sys-queue.h')
-rw-r--r--openbsd-compat/sys-queue.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/openbsd-compat/sys-queue.h b/openbsd-compat/sys-queue.h
index 402343324..5cf0587bd 100644
--- a/openbsd-compat/sys-queue.h
+++ b/openbsd-compat/sys-queue.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: queue.h,v 1.25 2004/04/08 16:08:21 henning Exp $ */ 1/* $OpenBSD: queue.h,v 1.32 2007/04/30 18:42:34 pedro Exp $ */
2/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ 2/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
3 3
4/* 4/*
@@ -167,6 +167,12 @@
167 * For details on the use of these macros, see the queue(3) manual page. 167 * For details on the use of these macros, see the queue(3) manual page.
168 */ 168 */
169 169
170#if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC))
171#define _Q_INVALIDATE(a) (a) = ((void *)-1)
172#else
173#define _Q_INVALIDATE(a)
174#endif
175
170/* 176/*
171 * Singly-linked List definitions. 177 * Singly-linked List definitions.
172 */ 178 */
@@ -229,13 +235,14 @@ struct { \
229#define SLIST_REMOVE(head, elm, type, field) do { \ 235#define SLIST_REMOVE(head, elm, type, field) do { \
230 if ((head)->slh_first == (elm)) { \ 236 if ((head)->slh_first == (elm)) { \
231 SLIST_REMOVE_HEAD((head), field); \ 237 SLIST_REMOVE_HEAD((head), field); \
232 } \ 238 } else { \
233 else { \
234 struct type *curelm = (head)->slh_first; \ 239 struct type *curelm = (head)->slh_first; \
235 while( curelm->field.sle_next != (elm) ) \ 240 \
241 while (curelm->field.sle_next != (elm)) \
236 curelm = curelm->field.sle_next; \ 242 curelm = curelm->field.sle_next; \
237 curelm->field.sle_next = \ 243 curelm->field.sle_next = \
238 curelm->field.sle_next->field.sle_next; \ 244 curelm->field.sle_next->field.sle_next; \
245 _Q_INVALIDATE((elm)->field.sle_next); \
239 } \ 246 } \
240} while (0) 247} while (0)
241 248
@@ -303,6 +310,8 @@ struct { \
303 (elm)->field.le_next->field.le_prev = \ 310 (elm)->field.le_next->field.le_prev = \
304 (elm)->field.le_prev; \ 311 (elm)->field.le_prev; \
305 *(elm)->field.le_prev = (elm)->field.le_next; \ 312 *(elm)->field.le_prev = (elm)->field.le_next; \
313 _Q_INVALIDATE((elm)->field.le_prev); \
314 _Q_INVALIDATE((elm)->field.le_next); \
306} while (0) 315} while (0)
307 316
308#define LIST_REPLACE(elm, elm2, field) do { \ 317#define LIST_REPLACE(elm, elm2, field) do { \
@@ -311,6 +320,8 @@ struct { \
311 &(elm2)->field.le_next; \ 320 &(elm2)->field.le_next; \
312 (elm2)->field.le_prev = (elm)->field.le_prev; \ 321 (elm2)->field.le_prev = (elm)->field.le_prev; \
313 *(elm2)->field.le_prev = (elm2); \ 322 *(elm2)->field.le_prev = (elm2); \
323 _Q_INVALIDATE((elm)->field.le_prev); \
324 _Q_INVALIDATE((elm)->field.le_next); \
314} while (0) 325} while (0)
315 326
316/* 327/*
@@ -369,8 +380,8 @@ struct { \
369 (listelm)->field.sqe_next = (elm); \ 380 (listelm)->field.sqe_next = (elm); \
370} while (0) 381} while (0)
371 382
372#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \ 383#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
373 if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ 384 if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
374 (head)->sqh_last = &(head)->sqh_first; \ 385 (head)->sqh_last = &(head)->sqh_first; \
375} while (0) 386} while (0)
376 387
@@ -465,6 +476,8 @@ struct { \
465 else \ 476 else \
466 (head)->tqh_last = (elm)->field.tqe_prev; \ 477 (head)->tqh_last = (elm)->field.tqe_prev; \
467 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ 478 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
479 _Q_INVALIDATE((elm)->field.tqe_prev); \
480 _Q_INVALIDATE((elm)->field.tqe_next); \
468} while (0) 481} while (0)
469 482
470#define TAILQ_REPLACE(head, elm, elm2, field) do { \ 483#define TAILQ_REPLACE(head, elm, elm2, field) do { \
@@ -475,6 +488,8 @@ struct { \
475 (head)->tqh_last = &(elm2)->field.tqe_next; \ 488 (head)->tqh_last = &(elm2)->field.tqe_next; \
476 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ 489 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
477 *(elm2)->field.tqe_prev = (elm2); \ 490 *(elm2)->field.tqe_prev = (elm2); \
491 _Q_INVALIDATE((elm)->field.tqe_prev); \
492 _Q_INVALIDATE((elm)->field.tqe_next); \
478} while (0) 493} while (0)
479 494
480/* 495/*
@@ -575,6 +590,8 @@ struct { \
575 else \ 590 else \
576 (elm)->field.cqe_prev->field.cqe_next = \ 591 (elm)->field.cqe_prev->field.cqe_next = \
577 (elm)->field.cqe_next; \ 592 (elm)->field.cqe_next; \
593 _Q_INVALIDATE((elm)->field.cqe_prev); \
594 _Q_INVALIDATE((elm)->field.cqe_next); \
578} while (0) 595} while (0)
579 596
580#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \ 597#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
@@ -588,6 +605,8 @@ struct { \
588 (head).cqh_first = (elm2); \ 605 (head).cqh_first = (elm2); \
589 else \ 606 else \
590 (elm2)->field.cqe_prev->field.cqe_next = (elm2); \ 607 (elm2)->field.cqe_prev->field.cqe_next = (elm2); \
608 _Q_INVALIDATE((elm)->field.cqe_prev); \
609 _Q_INVALIDATE((elm)->field.cqe_next); \
591} while (0) 610} while (0)
592 611
593#endif /* !_FAKE_QUEUE_H_ */ 612#endif /* !_FAKE_QUEUE_H_ */