summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2002-04-17 13:43:31 +0000
committertmm <tmm@FreeBSD.org>2002-04-17 13:43:31 +0000
commitc62faa9e3496b76a85ea9fa61b97daabc90fcbf9 (patch)
tree63ab2601b6469c21d039d7da29e4eee41350ff00
parentef239236f8ceb6f7b60b88adb5e1f2eb8845f514 (diff)
downloadFreeBSD-src-c62faa9e3496b76a85ea9fa61b97daabc90fcbf9.zip
FreeBSD-src-c62faa9e3496b76a85ea9fa61b97daabc90fcbf9.tar.gz
Add macros for concatenating tailqs and stailqs.
PR: 20024 Submitted by: Tony Finch <dot@dotat.at> (TAILQ_CONCAT)
-rw-r--r--sys/sys/queue.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 3d86d0c..a7b2d89 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -97,6 +97,7 @@
* _INSERT_BEFORE - + - +
* _INSERT_AFTER + + + +
* _INSERT_TAIL - - + +
+ * _CONCAT - - + +
* _REMOVE_HEAD + - + -
* _REMOVE + + + +
*
@@ -183,6 +184,14 @@ struct { \
/*
* Singly-linked Tail queue functions.
*/
+#define STAILQ_CONCAT(head1, head2) do { \
+ if (!STAILQ_EMPTY((head2))) { \
+ *(head1)->stqh_last = (head2)->stqh_first; \
+ (head1)->stqh_last = (head2)->stqh_last; \
+ STAILQ_INIT((head2)); \
+ } \
+} while (0)
+
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
#define STAILQ_FIRST(head) ((head)->stqh_first)
@@ -334,6 +343,15 @@ struct { \
/*
* Tail queue functions.
*/
+#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)
+
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define TAILQ_FIRST(head) ((head)->tqh_first)
OpenPOWER on IntegriCloud