Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys add the _END() macros for OpenBSD compatibility
details: https://anonhg.NetBSD.org/src/rev/07fdc2cbb45f
branches: trunk
changeset: 786001:07fdc2cbb45f
user: christos <christos%NetBSD.org@localhost>
date: Wed Apr 10 22:22:16 2013 +0000
description:
add the _END() macros for OpenBSD compatibility
diffstat:
sys/sys/queue.h | 46 +++++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 21 deletions(-)
diffs (141 lines):
diff -r a224fe4dcf56 -r 07fdc2cbb45f sys/sys/queue.h
--- a/sys/sys/queue.h Wed Apr 10 22:21:53 2013 +0000
+++ b/sys/sys/queue.h Wed Apr 10 22:22:16 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: queue.h,v 1.53 2011/11/19 22:51:31 tls Exp $ */
+/* $NetBSD: queue.h,v 1.54 2013/04/10 22:22:16 christos Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -124,12 +124,13 @@
#endif
#define LIST_INIT(head) do { \
- (head)->lh_first = NULL; \
+ (head)->lh_first = LIST_END(head); \
} while (/*CONSTCOND*/0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
QUEUEDEBUG_LIST_OP((listelm), field) \
- if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != \
+ LIST_END(head)) \
(listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \
@@ -146,7 +147,7 @@
#define LIST_INSERT_HEAD(head, elm, field) do { \
QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head))\
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \
@@ -173,7 +174,8 @@
/*
* List access methods.
*/
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
+#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head))
+#define LIST_END(head) NULL
#define LIST_FIRST(head) ((head)->lh_first)
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
@@ -446,7 +448,7 @@
#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
+ { TAILQ_END(head), &(head).tqh_first }
#define _TAILQ_ENTRY(type, qual) \
struct { \
@@ -490,13 +492,13 @@
#endif
#define TAILQ_INIT(head) do { \
- (head)->tqh_first = NULL; \
+ (head)->tqh_first = TAILQ_END(head); \
(head)->tqh_last = &(head)->tqh_first; \
} while (/*CONSTCOND*/0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head))\
(head)->tqh_first->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
@@ -507,7 +509,7 @@
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \
- (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_next = TAILQ_END(head); \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &(elm)->field.tqe_next; \
@@ -515,7 +517,8 @@
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
QUEUEDEBUG_TAILQ_OP((listelm), field) \
- if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != \
+ TAILQ_END(head)) \
(elm)->field.tqe_next->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
@@ -535,7 +538,7 @@
#define TAILQ_REMOVE(head, elm, field) do { \
QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \
QUEUEDEBUG_TAILQ_OP((elm), field) \
- if (((elm)->field.tqe_next) != NULL) \
+ if (((elm)->field.tqe_next) != TAILQ_END(head)) \
(elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \
else \
@@ -546,23 +549,23 @@
#define TAILQ_FOREACH(var, head, field) \
for ((var) = ((head)->tqh_first); \
- (var); \
- (var) = ((var)->field.tqe_next))
+ (var) != TAILQ_END(head); \
+ (var) = ((var)->field.tqe_next))
#define TAILQ_FOREACH_SAFE(var, head, field, next) \
for ((var) = ((head)->tqh_first); \
- (var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \
- (var) = (next))
+ (var) != TAILQ_END(head) && \
+ ((next) = TAILQ_NEXT(var, field), 1); (var) = (next))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
- (var); \
- (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));\
+ (var) != TAILQ_END(head); \
+ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \
for ((var) = TAILQ_LAST((head), headname); \
- (var) && ((prev) = TAILQ_PREV((var), headname, field), 1);\
- (var) = (prev))
+ (var) != TAILQ_END(head) && \
+ ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev))
#define TAILQ_CONCAT(head1, head2, field) do { \
if (!TAILQ_EMPTY(head2)) { \
@@ -576,8 +579,9 @@
/*
* Tail queue access methods.
*/
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+#define TAILQ_EMPTY(head) ((head)->tqh_first == TAILQ_END(head))
#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_END(head) (NULL)
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_LAST(head, headname) \
Home |
Main Index |
Thread Index |
Old Index