Page MenuHomeFreeBSD

D50131.id154838.diff
No OneTemporary

D50131.id154838.diff

diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile
--- a/share/man/man3/Makefile
+++ b/share/man/man3/Makefile
@@ -258,6 +258,7 @@
queue.3 STAILQ_REMOVE.3 \
queue.3 STAILQ_REMOVE_AFTER.3 \
queue.3 STAILQ_REMOVE_HEAD.3 \
+ queue.3 STAILQ_REVERSE.3 \
queue.3 STAILQ_SWAP.3 \
queue.3 TAILQ_CLASS_ENTRY.3 \
queue.3 TAILQ_CLASS_HEAD.3 \
diff --git a/share/man/man3/queue.3 b/share/man/man3/queue.3
--- a/share/man/man3/queue.3
+++ b/share/man/man3/queue.3
@@ -73,6 +73,7 @@
.Nm STAILQ_REMOVE ,
.Nm STAILQ_REMOVE_AFTER ,
.Nm STAILQ_REMOVE_HEAD ,
+.Nm STAILQ_REVERSE ,
.Nm STAILQ_SPLIT_AFTER ,
.Nm STAILQ_SWAP ,
.Nm LIST_CLASS_ENTRY ,
@@ -177,6 +178,7 @@
.Fn STAILQ_REMOVE "STAILQ_HEAD *head" "TYPE *elm" "TYPE" "STAILQ_ENTRY NAME"
.Fn STAILQ_REMOVE_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME"
.Fn STAILQ_REMOVE_HEAD "STAILQ_HEAD *head" "STAILQ_ENTRY NAME"
+.Fn STAILQ_REVERSE "STAILQ_HEAD *head" "TYPE" "STAILQ_ENTRY NAME"
.Fn STAILQ_SPLIT_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_HEAD *rest" "STAILQ_ENTRY NAME"
.Fn STAILQ_SWAP "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" "TYPE"
.\"
@@ -791,6 +793,10 @@
high-usage code paths or to operate on long tail queues.
.Pp
The macro
+.Nm STAILQ_REVERSE
+reverses the queue in place.
+.Pp
+The macro
.Nm STAILQ_SPLIT_AFTER
splits the tail queue referenced by
.Fa head ,
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -564,6 +564,21 @@
(head2)->stqh_last = &STAILQ_FIRST(head2); \
} while (0)
+#define STAILQ_REVERSE(head, type, field) do { \
+ if (STAILQ_EMPTY(head)) \
+ break; \
+ QUEUE_TYPEOF(type) *_Var, *_Varp, *_Varn; \
+ for (_Var = STAILQ_FIRST(head), _Varp = NULL; \
+ _Var != NULL;) { \
+ _Varn = STAILQ_NEXT(_Var, field); \
+ STAILQ_NEXT(_Var, field) = _Varp; \
+ _Varp = _Var; \
+ _Var = _Varn; \
+ } \
+ (head)->stqh_last = &STAILQ_NEXT(STAILQ_FIRST(head), field); \
+ (head)->stqh_first = _Varp; \
+} while (0)
+
#define STAILQ_END(head) NULL

File Metadata

Mime Type
text/plain
Expires
Tue, Jun 23, 5:54 PM (9 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34255320
Default Alt Text
D50131.id154838.diff (2 KB)

Event Timeline