Mailing List Archive

cvs commit: apache-2.0/src/include bsd_queue.h
fanf 00/09/07 03:03:45

Modified: src/include bsd_queue.h
Log:
Add my concatenation macros. These have been submitted to FreeBSD. See
http://www.FreeBSD.org/cgi/query-pr.cgi?pr=20024

Revision Changes Path
1.2 +37 -7 apache-2.0/src/include/bsd_queue.h

Index: bsd_queue.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/bsd_queue.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- bsd_queue.h 2000/09/07 10:01:25 1.1
+++ bsd_queue.h 2000/09/07 10:03:44 1.2
@@ -76,7 +76,8 @@
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
+ * the list. A tail queue may be traversed in either direction. Tail
+ * queues may be concatenated.
*
* A circle queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
@@ -84,7 +85,7 @@
* traverse the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the list.
* A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
+ * complex end of list detection. Circle queues may be concatenated.
*
* For details on the use of these macros, see the queue(3) manual page.
*
@@ -107,6 +108,7 @@
* _INSERT_TAIL - - + + +
* _REMOVE_HEAD + - + - -
* _REMOVE + + + + +
+ * _CONCAT - - - + +
*
*/

@@ -224,7 +226,7 @@
} while (0)

#define STAILQ_LAST(head, type, field) \
- (STAILQ_EMPTY(head) ? \
+ (STAILQ_EMPTY((head)) ? \
NULL : \
strbase(type, (head)->stqh_last, field))

@@ -232,7 +234,7 @@

#define STAILQ_REMOVE(head, elm, type, field) do { \
if (STAILQ_FIRST((head)) == (elm)) { \
- STAILQ_REMOVE_HEAD(head, field); \
+ STAILQ_REMOVE_HEAD((head), field); \
} \
else { \
struct type *curelm = STAILQ_FIRST((head)); \
@@ -411,6 +413,15 @@
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
} while (0)

+#define TAILQ_CONCAT(head1, head2, field) do { \
+ if (!TAILQ_EMPTY(head2)) { \
+ *(head1)->tqh_last = (head2)->tqh_first; \
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+ (head1)->tqh_last = (head2)->tqh_last; \
+ TAILQ_INIT(head2); \
+ } \
+} while (0)
+
/*
* Circular queue declarations.
*/
@@ -491,11 +502,11 @@
CIRCLEQ_LAST((head)) = (elm); \
} while (0)

-#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)

-#define CIRCLEQ_NEXT(elm,field) ((elm)->field.cqe_next)
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)

-#define CIRCLEQ_PREV(elm,field) ((elm)->field.cqe_prev)
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)

#define CIRCLEQ_REMOVE(head, elm, field) do { \
if (CIRCLEQ_NEXT((elm), field) == (void *)(head)) \
@@ -508,6 +519,25 @@
else \
CIRCLEQ_NEXT(CIRCLEQ_PREV((elm), field), field) = \
CIRCLEQ_NEXT((elm), field); \
+} while (0)
+
+#define CIRCLEQ_CONCAT(head1, head2, field) do { \
+ if (!CIRCLEQ_EMPTY((head2))) { \
+ if (!CIRCLEQ_EMPTY((head1))) { \
+ CIRCLEQ_NEXT(CIRCLEQ_LAST((head1)), field) = \
+ CIRCLEQ_FIRST((head2)); \
+ CIRCLEQ_PREV(CIRCLEQ_FIRST((head2)), field = \
+ CIRCLEQ_LAST((head1)); \
+ } else { \
+ CIRCLEQ_FIRST((head1)) = CIRCLEQ_FIRST((head2));\
+ CIRCLEQ_PREV(CIRCLEQ_FIRST((head1)), field) = \
+ (void *)(head1); \
+ } \
+ CIRCLEQ_LAST((head1)) = CIRCLEQ_LAST((head2)) \
+ CIRCLEQ_NEXT(CIRCLEQ_LAST((head1)), field) = \
+ (void *)(head1); \
+ CIRCLEQ_INIT((head2)); \
+ } \
} while (0)

#ifdef _KERNEL