aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/queue.h
diff options
context:
space:
mode:
authorThomas Moestl <tmm@FreeBSD.org>2002-04-17 13:43:31 +0000
committerThomas Moestl <tmm@FreeBSD.org>2002-04-17 13:43:31 +0000
commit421a9d041e809730f635932c0574e50c2bfeacc2 (patch)
tree63ab2601b6469c21d039d7da29e4eee41350ff00 /sys/sys/queue.h
parent41196280aca35b06bb55ebb4bb855b401959fd85 (diff)
downloadsrc-421a9d041e809730f635932c0574e50c2bfeacc2.tar.gz
src-421a9d041e809730f635932c0574e50c2bfeacc2.zip
Add macros for concatenating tailqs and stailqs.
PR: 20024 Submitted by: Tony Finch <dot@dotat.at> (TAILQ_CONCAT)
Notes
Notes: svn path=/head/; revision=94938
Diffstat (limited to 'sys/sys/queue.h')
-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 3d86d0c22f5a..a7b2d896ef40 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)