svn commit: r221843 - in head: share/man/man3 sys/sys
Matthew D Fleming
mdf at FreeBSD.org
Fri May 13 15:49:23 UTC 2011
Author: mdf
Date: Fri May 13 15:49:23 2011
New Revision: 221843
URL: http://svn.freebsd.org/changeset/base/221843
Log:
Note that the _SWAP operation is supported for all list/queue types.
Also place STAILQ_REMOVE_HEAD in alphabetical order. Lastly, document
the _SWAP macros.
PR: kern/143033
MFC after: 1 week
Modified:
head/share/man/man3/Makefile
head/share/man/man3/queue.3
head/sys/sys/queue.h
Modified: head/share/man/man3/Makefile
==============================================================================
--- head/share/man/man3/Makefile Fri May 13 15:21:31 2011 (r221842)
+++ head/share/man/man3/Makefile Fri May 13 15:49:23 2011 (r221843)
@@ -53,6 +53,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \
queue.3 LIST_INSERT_HEAD.3 \
queue.3 LIST_NEXT.3 \
queue.3 LIST_REMOVE.3 \
+ queue.3 LIST_SWAP.3 \
queue.3 SLIST_EMPTY.3 \
queue.3 SLIST_ENTRY.3 \
queue.3 SLIST_FIRST.3 \
@@ -67,6 +68,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \
queue.3 SLIST_REMOVE.3 \
queue.3 SLIST_REMOVE_AFTER.3 \
queue.3 SLIST_REMOVE_HEAD.3 \
+ queue.3 SLIST_SWAP.3 \
queue.3 STAILQ_CONCAT.3 \
queue.3 STAILQ_EMPTY.3 \
queue.3 STAILQ_ENTRY.3 \
@@ -84,6 +86,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \
queue.3 STAILQ_REMOVE.3 \
queue.3 STAILQ_REMOVE_AFTER.3 \
queue.3 STAILQ_REMOVE_HEAD.3 \
+ queue.3 STAILQ_SWAP.3 \
queue.3 TAILQ_CONCAT.3 \
queue.3 TAILQ_EMPTY.3 \
queue.3 TAILQ_ENTRY.3 \
@@ -102,7 +105,8 @@ MLINKS+= queue.3 LIST_EMPTY.3 \
queue.3 TAILQ_LAST.3 \
queue.3 TAILQ_NEXT.3 \
queue.3 TAILQ_PREV.3 \
- queue.3 TAILQ_REMOVE.3
+ queue.3 TAILQ_REMOVE.3 \
+ queue.3 TAILQ_SWAP.3
MLINKS+= stdarg.3 va_arg.3 \
stdarg.3 va_copy.3 \
stdarg.3 va_end.3 \
Modified: head/share/man/man3/queue.3
==============================================================================
--- head/share/man/man3/queue.3 Fri May 13 15:21:31 2011 (r221842)
+++ head/share/man/man3/queue.3 Fri May 13 15:49:23 2011 (r221843)
@@ -32,7 +32,7 @@
.\" @(#)queue.3 8.2 (Berkeley) 1/24/94
.\" $FreeBSD$
.\"
-.Dd March 24, 2006
+.Dd May 13, 2011
.Dt QUEUE 3
.Os
.Sh NAME
@@ -50,6 +50,7 @@
.Nm SLIST_REMOVE_AFTER ,
.Nm SLIST_REMOVE_HEAD ,
.Nm SLIST_REMOVE ,
+.Nm SLIST_SWAP ,
.Nm STAILQ_CONCAT ,
.Nm STAILQ_EMPTY ,
.Nm STAILQ_ENTRY ,
@@ -67,6 +68,7 @@
.Nm STAILQ_REMOVE_AFTER ,
.Nm STAILQ_REMOVE_HEAD ,
.Nm STAILQ_REMOVE ,
+.Nm STAILQ_SWAP ,
.Nm LIST_EMPTY ,
.Nm LIST_ENTRY ,
.Nm LIST_FIRST ,
@@ -80,6 +82,7 @@
.Nm LIST_INSERT_HEAD ,
.Nm LIST_NEXT ,
.Nm LIST_REMOVE ,
+.Nm LIST_SWAP ,
.Nm TAILQ_CONCAT ,
.Nm TAILQ_EMPTY ,
.Nm TAILQ_ENTRY ,
@@ -98,7 +101,8 @@
.Nm TAILQ_LAST ,
.Nm TAILQ_NEXT ,
.Nm TAILQ_PREV ,
-.Nm TAILQ_REMOVE
+.Nm TAILQ_REMOVE ,
+.Nm TAILQ_SWAP
.Nd implementations of singly-linked lists, singly-linked tail queues,
lists and tail queues
.Sh SYNOPSIS
@@ -118,6 +122,7 @@ lists and tail queues
.Fn SLIST_REMOVE_AFTER "TYPE *elm" "SLIST_ENTRY NAME"
.Fn SLIST_REMOVE_HEAD "SLIST_HEAD *head" "SLIST_ENTRY NAME"
.Fn SLIST_REMOVE "SLIST_HEAD *head" "TYPE *elm" "TYPE" "SLIST_ENTRY NAME"
+.Fn SLIST_SWAP "SLIST_HEAD *head1" "SLIST_HEAD *head2" "SLIST_ENTRY NAME"
.\"
.Fn STAILQ_CONCAT "STAILQ_HEAD *head1" "STAILQ_HEAD *head2"
.Fn STAILQ_EMPTY "STAILQ_HEAD *head"
@@ -136,6 +141,7 @@ lists and tail queues
.Fn STAILQ_REMOVE_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME"
.Fn STAILQ_REMOVE_HEAD "STAILQ_HEAD *head" "STAILQ_ENTRY NAME"
.Fn STAILQ_REMOVE "STAILQ_HEAD *head" "TYPE *elm" "TYPE" "STAILQ_ENTRY NAME"
+.Fn STAILQ_SWAP "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" "STAILQ_ENTRY NAME"
.\"
.Fn LIST_EMPTY "LIST_HEAD *head"
.Fn LIST_ENTRY "TYPE"
@@ -150,6 +156,7 @@ lists and tail queues
.Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME"
.Fn LIST_NEXT "TYPE *elm" "LIST_ENTRY NAME"
.Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME"
+.Fn LIST_SWAP "LIST_HEAD *head1" "LIST_HEAD *head2" "TYPE" "LIST_ENTRY NAME"
.\"
.Fn TAILQ_CONCAT "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TAILQ_ENTRY NAME"
.Fn TAILQ_EMPTY "TAILQ_HEAD *head"
@@ -170,6 +177,7 @@ lists and tail queues
.Fn TAILQ_NEXT "TYPE *elm" "TAILQ_ENTRY NAME"
.Fn TAILQ_PREV "TYPE *elm" "HEADNAME" "TAILQ_ENTRY NAME"
.Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
+.Fn TAILQ_SWAP "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TYPE" "TAILQ_ENTRY NAME"
.\"
.Sh DESCRIPTION
These macros define and operate on four types of data structures:
@@ -184,6 +192,8 @@ Insertion of a new entry after any eleme
O(1) removal of an entry from the head of the list.
.It
Forward traversal through the list.
+.It
+Swawpping the contents of two lists.
.El
.Pp
Singly-linked lists are the simplest of the four data structures
@@ -402,6 +412,13 @@ The macro
removes the element
.Fa elm
from the list.
+.Pp
+The macro
+.Nm SLIST_SWAP
+swaps the contents of
+.Fa head1
+and
+.Fa head2 .
.Sh SINGLY-LINKED LIST EXAMPLE
.Bd -literal
SLIST_HEAD(slisthead, entry) head =
@@ -584,6 +601,13 @@ The macro
removes the element
.Fa elm
from the tail queue.
+.Pp
+The macro
+.Nm STAILQ_SWAP
+swaps the contents of
+.Fa head1
+and
+.Fa head2 .
.Sh SINGLY-LINKED TAIL QUEUE EXAMPLE
.Bd -literal
STAILQ_HEAD(stailhead, entry) head =
@@ -743,6 +767,13 @@ The macro
removes the element
.Fa elm
from the list.
+.Pp
+The macro
+.Nm LIST_SWAP
+swaps the contents of
+.Fa head1
+and
+.Fa head2 .
.Sh LIST EXAMPLE
.Bd -literal
LIST_HEAD(listhead, entry) head =
@@ -942,6 +973,13 @@ The macro
removes the element
.Fa elm
from the tail queue.
+.Pp
+The macro
+.Nm TAILQ_SWAP
+swaps the contents of
+.Fa head1
+and
+.Fa head2 .
.Sh TAIL QUEUE EXAMPLE
.Bd -literal
TAILQ_HEAD(tailhead, entry) head =
Modified: head/sys/sys/queue.h
==============================================================================
--- head/sys/sys/queue.h Fri May 13 15:21:31 2011 (r221842)
+++ head/sys/sys/queue.h Fri May 13 15:49:23 2011 (r221843)
@@ -99,6 +99,7 @@
* _REMOVE_AFTER + - + -
* _REMOVE_HEAD + - + -
* _REMOVE + + + +
+ * _SWAP + + + +
*
*/
#ifdef QUEUE_MACRO_DEBUG
@@ -307,18 +308,18 @@ struct { \
TRASHIT(*oldnext); \
} while (0)
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if ((STAILQ_FIRST((head)) = \
- STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
if ((STAILQ_NEXT(elm, field) = \
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0)
+#define STAILQ_REMOVE_HEAD(head, field) do { \
+ if ((STAILQ_FIRST((head)) = \
+ STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
+ (head)->stqh_last = &STAILQ_FIRST((head)); \
+} while (0)
+
#define STAILQ_SWAP(head1, head2, type) do { \
struct type *swap_first = STAILQ_FIRST(head1); \
struct type **swap_last = (head1)->stqh_last; \
More information about the svn-src-all
mailing list