linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] circleq.3: Fork from queue.3
@ 2020-10-23 14:57 Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 01/11] circleq.3: New page that will hold the (circleq) content of queue.3 Alejandro Colomar
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Hi Michael,

It's going much faster than I thought :-)

There's a detail I wasn't sure about:

There are BSDs that don't have CIRCLEQ macros,
or at least it isn't documented there (FreeBSD comes to my mind).
So I'm not sure CIRCLEQ originated at the same time as the others (4.4BSD).
Maybe you know better.
That affects patches 07/10 and 08/10.

Please, apply these patches after "queue.3: Sort alphabetically".

Cheers,

Alex

Alejandro Colomar (11):
  circleq.3: New page that will hold the (circleq) content of queue.3
  circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3
  circleq.3, queue.3: SYNOPSIS: Move code from queue.3 to circleq.3
  circleq.3, queue.3: DESCRIPTION: Move circleq specific code from
    queue.3 to circleq.3
  circleq.3, queue.3: EXAMPLES: Move circleq example program from
    queue.3 to circleq.3
  queue.3: ffix
  circleq.3: Copy and adapt code from queue.3
  circleq.3: ffix: Use man markup
  circleq.3: Add remaining details to complete the page
  CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3,
    CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3,
    CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link
    to the new circleq(3) page instead of queue(3)
  queue.3: SEE ALSO: Add circleq(3)

 man3/CIRCLEQ_ENTRY.3         |   2 +-
 man3/CIRCLEQ_HEAD.3          |   2 +-
 man3/CIRCLEQ_INIT.3          |   2 +-
 man3/CIRCLEQ_INSERT_AFTER.3  |   2 +-
 man3/CIRCLEQ_INSERT_BEFORE.3 |   2 +-
 man3/CIRCLEQ_INSERT_HEAD.3   |   2 +-
 man3/CIRCLEQ_INSERT_TAIL.3   |   2 +-
 man3/CIRCLEQ_REMOVE.3        |   2 +-
 man3/circleq.3               | 354 +++++++++++++++++++++++++++++++++++
 man3/queue.3                 | 234 +----------------------
 10 files changed, 365 insertions(+), 239 deletions(-)
 create mode 100644 man3/circleq.3

-- 
2.28.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/11] circleq.3: New page that will hold the (circleq) content of queue.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 02/11] circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3 Alejandro Colomar
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 man3/circleq.3

diff --git a/man3/circleq.3 b/man3/circleq.3
new file mode 100644
index 000000000..39920948a
--- /dev/null
+++ b/man3/circleq.3
@@ -0,0 +1,40 @@
+.\" Copyright (c) 1993
+.\"    The Regents of the University of California.  All rights reserved.
+.\" and Copyright (c) 2020 by Alejandro Colomar <colomar.6.4.3@gmail.com>
+.\"
+.\" %%%LICENSE_START(BSD_3_CLAUSE_UCB)
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\" %%%LICENSE_END
+.\"
+.\"
+.TH CIRCLEQ 3 2020-10-21 "GNU" "Linux Programmer's Manual"
+.SH NAME
+.SH SYNOPSIS
+.SH DESCRIPTION
+.SH RETURN VALUE
+.SH CONFORMING TO
+.SH BUGS
+.SH EXAMPLES
+.SH SEE ALSO
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/11] circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 01/11] circleq.3: New page that will hold the (circleq) content of queue.3 Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 03/11] circleq.3, queue.3: SYNOPSIS: Move code from queue.3 " Alejandro Colomar
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 18 ++++++++++++++++++
 man3/queue.3   | 18 ------------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index 39920948a..bb024d697 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -31,6 +31,24 @@
 .\"
 .TH CIRCLEQ 3 2020-10-21 "GNU" "Linux Programmer's Manual"
 .SH NAME
+.Nm CIRCLEQ_EMPTY ,
+.Nm CIRCLEQ_ENTRY ,
+.Nm CIRCLEQ_FIRST ,
+.Nm CIRCLEQ_FOREACH ,
+.Nm CIRCLEQ_FOREACH_REVERSE ,
+.Nm CIRCLEQ_HEAD ,
+.Nm CIRCLEQ_HEAD_INITIALIZER ,
+.Nm CIRCLEQ_INIT ,
+.Nm CIRCLEQ_INSERT_AFTER ,
+.Nm CIRCLEQ_INSERT_BEFORE ,
+.Nm CIRCLEQ_INSERT_HEAD ,
+.Nm CIRCLEQ_INSERT_TAIL ,
+.Nm CIRCLEQ_LAST ,
+.Nm CIRCLEQ_LOOP_NEXT ,
+.Nm CIRCLEQ_LOOP_PREV ,
+.Nm CIRCLEQ_NEXT ,
+.Nm CIRCLEQ_PREV ,
+.Nm CIRCLEQ_REMOVE
 .SH SYNOPSIS
 .SH DESCRIPTION
 .SH RETURN VALUE
diff --git a/man3/queue.3 b/man3/queue.3
index 36432718d..1b68275d5 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -78,24 +78,6 @@
 .Nm TAILQ_PREV ,
 .Nm TAILQ_REMOVE ,
 .\" .Nm TAILQ_SWAP ,
-.Nm CIRCLEQ_EMPTY ,
-.Nm CIRCLEQ_ENTRY ,
-.Nm CIRCLEQ_FIRST ,
-.Nm CIRCLEQ_FOREACH ,
-.Nm CIRCLEQ_FOREACH_REVERSE ,
-.Nm CIRCLEQ_HEAD ,
-.Nm CIRCLEQ_HEAD_INITIALIZER ,
-.Nm CIRCLEQ_INIT ,
-.Nm CIRCLEQ_INSERT_AFTER ,
-.Nm CIRCLEQ_INSERT_BEFORE ,
-.Nm CIRCLEQ_INSERT_HEAD ,
-.Nm CIRCLEQ_INSERT_TAIL ,
-.Nm CIRCLEQ_LAST ,
-.Nm CIRCLEQ_LOOP_NEXT ,
-.Nm CIRCLEQ_LOOP_PREV ,
-.Nm CIRCLEQ_NEXT ,
-.Nm CIRCLEQ_PREV ,
-.Nm CIRCLEQ_REMOVE
 .Nd implementations of singly-linked lists, singly-linked tail queues,
 lists, tail queues, and circular queues
 .Sh SYNOPSIS
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/11] circleq.3, queue.3: SYNOPSIS: Move code from queue.3 to circleq.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 01/11] circleq.3: New page that will hold the (circleq) content of queue.3 Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 02/11] circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3 Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 04/11] circleq.3, queue.3: DESCRIPTION: Move circleq specific " Alejandro Colomar
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 18 ++++++++++++++++++
 man3/queue.3   | 18 ------------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index bb024d697..df547fca7 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -50,6 +50,24 @@
 .Nm CIRCLEQ_PREV ,
 .Nm CIRCLEQ_REMOVE
 .SH SYNOPSIS
+.Fn CIRCLEQ_EMPTY "CIRCLEQ_HEAD *head"
+.Fn CIRCLEQ_ENTRY "TYPE"
+.Fn CIRCLEQ_FIRST "CIRCLEQ_HEAD *head"
+.Fn CIRCLEQ_FOREACH "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_FOREACH_REVERSE "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_HEAD "HEADNAME" "TYPE"
+.Fn CIRCLEQ_HEAD_INITIALIZER "CIRCLEQ_HEAD head"
+.Fn CIRCLEQ_INIT "CIRCLEQ_HEAD *head"
+.Fn CIRCLEQ_INSERT_AFTER "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_INSERT_BEFORE "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_INSERT_HEAD "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_INSERT_TAIL "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_LAST "CIRCLEQ_HEAD *head"
+.Fn CIRCLEQ_LOOP_NEXT "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_LOOP_PREV "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_NEXT "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_PREV "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .SH DESCRIPTION
 .SH RETURN VALUE
 .SH CONFORMING TO
diff --git a/man3/queue.3 b/man3/queue.3
index 1b68275d5..247bfb874 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -128,24 +128,6 @@ lists, tail queues, and circular queues
 .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"
-.Fn CIRCLEQ_EMPTY "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_ENTRY "TYPE"
-.Fn CIRCLEQ_FIRST "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_FOREACH "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_FOREACH_REVERSE "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_HEAD "HEADNAME" "TYPE"
-.Fn CIRCLEQ_HEAD_INITIALIZER "CIRCLEQ_HEAD head"
-.Fn CIRCLEQ_INIT "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_INSERT_AFTER "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_BEFORE "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_HEAD "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_TAIL "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_LAST "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_LOOP_NEXT "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_LOOP_PREV "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_NEXT "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_PREV "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .\"
 .Sh DESCRIPTION
 These macros define and operate on five types of data structures:
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/11] circleq.3, queue.3: DESCRIPTION: Move circleq specific code from queue.3 to circleq.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (2 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 03/11] circleq.3, queue.3: SYNOPSIS: Move code from queue.3 " Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 05/11] circleq.3, queue.3: EXAMPLES: Move circleq example program " Alejandro Colomar
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 137 +++++++++++++++++++++++++++++++++++++++++++++++++
 man3/queue.3   | 137 -------------------------------------------------
 2 files changed, 137 insertions(+), 137 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index df547fca7..a28a82919 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -69,6 +69,143 @@
 .Fn CIRCLEQ_PREV "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .SH DESCRIPTION
+.Ss Circular queues
+A circular queue is headed by a structure defined by the
+.Nm CIRCLEQ_HEAD
+macro.
+This structure contains a pair of pointers,
+one to the first element in the circular queue and the other to
+the last element in the circular queue.
+The elements are doubly linked so that an arbitrary element can be
+removed without traversing the circular queue.
+New elements can be added to the circular queue after an existing element,
+before an existing element, at the head of the circular queue,
+or at the end of the circular queue.
+A
+.Fa CIRCLEQ_HEAD
+structure is declared as follows:
+.Bd -literal -offset indent
+CIRCLEQ_HEAD(HEADNAME, TYPE) head;
+.Ed
+.Pp
+where
+.Li HEADNAME
+is the name of the structure to be defined, and
+.Li TYPE
+is the type of the elements to be linked into the circular queue.
+A pointer to the head of the circular queue can later be declared as:
+.Bd -literal -offset indent
+struct HEADNAME *headp;
+.Ed
+.Pp
+(The names
+.Li head
+and
+.Li headp
+are user selectable.)
+.Pp
+The macro
+.Nm CIRCLEQ_HEAD_INITIALIZER
+evaluates to an initializer for the circular queue
+.Fa head .
+.Pp
+The macro
+.Nm CIRCLEQ_EMPTY
+evaluates to true if there are no items on the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_ENTRY
+declares a structure that connects the elements in
+the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_FIRST
+returns the first item on the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_FOREACH
+traverses the circular queue referenced by
+.Fa head
+in the forward direction, assigning each element in turn to
+.Fa var .
+.Fa var
+is set to
+.Fa &head
+if the loop completes normally, or if there were no elements.
+.Pp
+The macro
+.Nm CIRCLEQ_FOREACH_REVERSE
+traverses the circular queue referenced by
+.Fa head
+in the reverse direction, assigning each element in turn to
+.Fa var .
+.Pp
+The macro
+.Nm CIRCLEQ_INIT
+initializes the circular queue referenced by
+.Fa head .
+.Pp
+The macro
+.Nm CIRCLEQ_INSERT_HEAD
+inserts the new element
+.Fa elm
+at the head of the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_INSERT_TAIL
+inserts the new element
+.Fa elm
+at the end of the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_INSERT_AFTER
+inserts the new element
+.Fa elm
+after the element
+.Fa listelm .
+.Pp
+The macro
+.Nm CIRCLEQ_INSERT_BEFORE
+inserts the new element
+.Fa elm
+before the element
+.Fa listelm .
+.Pp
+The macro
+.Nm CIRCLEQ_LAST
+returns the last item on the circular queue.
+.Pp
+The macro
+.Nm CIRCLEQ_NEXT
+returns the next item on the circular queue, or
+.Fa &head
+if this item is the last one.
+.Pp
+The macro
+.Nm CIRCLEQ_PREV
+returns the previous item on the circular queue, or
+.Fa &head
+if this item is the first one.
+.Pp
+The macro
+.Nm CIRCLEQ_LOOP_NEXT
+returns the next item on the circular queue.
+If
+.Fa elm
+is the last element on the circular queue, the first element is returned.
+.Pp
+The macro
+.Nm CIRCLEQ_LOOP_PREV
+returns the previous item on the circular queue.
+If
+.Fa elm
+is the first element on the circular queue, the last element is returned.
+.Pp
+The macro
+.Nm CIRCLEQ_REMOVE
+removes the element
+.Fa elm
+from the circular queue.
 .SH RETURN VALUE
 .SH CONFORMING TO
 .SH BUGS
diff --git a/man3/queue.3 b/man3/queue.3
index 247bfb874..794790881 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -673,143 +673,6 @@ from the tail queue.
 .\" .Fa head2 .
 .Pp
 See the EXAMPLES section below for an example program using a tail queue.
-.Ss Circular queues
-A circular queue is headed by a structure defined by the
-.Nm CIRCLEQ_HEAD
-macro.
-This structure contains a pair of pointers,
-one to the first element in the circular queue and the other to
-the last element in the circular queue.
-The elements are doubly linked so that an arbitrary element can be
-removed without traversing the circular queue.
-New elements can be added to the circular queue after an existing element,
-before an existing element, at the head of the circular queue,
-or at the end of the circular queue.
-A
-.Fa CIRCLEQ_HEAD
-structure is declared as follows:
-.Bd -literal -offset indent
-CIRCLEQ_HEAD(HEADNAME, TYPE) head;
-.Ed
-.Pp
-where
-.Li HEADNAME
-is the name of the structure to be defined, and
-.Li TYPE
-is the type of the elements to be linked into the circular queue.
-A pointer to the head of the circular queue can later be declared as:
-.Bd -literal -offset indent
-struct HEADNAME *headp;
-.Ed
-.Pp
-(The names
-.Li head
-and
-.Li headp
-are user selectable.)
-.Pp
-The macro
-.Nm CIRCLEQ_HEAD_INITIALIZER
-evaluates to an initializer for the circular queue
-.Fa head .
-.Pp
-The macro
-.Nm CIRCLEQ_EMPTY
-evaluates to true if there are no items on the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_ENTRY
-declares a structure that connects the elements in
-the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_FIRST
-returns the first item on the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_FOREACH
-traverses the circular queue referenced by
-.Fa head
-in the forward direction, assigning each element in turn to
-.Fa var .
-.Fa var
-is set to
-.Fa &head
-if the loop completes normally, or if there were no elements.
-.Pp
-The macro
-.Nm CIRCLEQ_FOREACH_REVERSE
-traverses the circular queue referenced by
-.Fa head
-in the reverse direction, assigning each element in turn to
-.Fa var .
-.Pp
-The macro
-.Nm CIRCLEQ_INIT
-initializes the circular queue referenced by
-.Fa head .
-.Pp
-The macro
-.Nm CIRCLEQ_INSERT_HEAD
-inserts the new element
-.Fa elm
-at the head of the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_INSERT_TAIL
-inserts the new element
-.Fa elm
-at the end of the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_INSERT_AFTER
-inserts the new element
-.Fa elm
-after the element
-.Fa listelm .
-.Pp
-The macro
-.Nm CIRCLEQ_INSERT_BEFORE
-inserts the new element
-.Fa elm
-before the element
-.Fa listelm .
-.Pp
-The macro
-.Nm CIRCLEQ_LAST
-returns the last item on the circular queue.
-.Pp
-The macro
-.Nm CIRCLEQ_NEXT
-returns the next item on the circular queue, or
-.Fa &head
-if this item is the last one.
-.Pp
-The macro
-.Nm CIRCLEQ_PREV
-returns the previous item on the circular queue, or
-.Fa &head
-if this item is the first one.
-.Pp
-The macro
-.Nm CIRCLEQ_LOOP_NEXT
-returns the next item on the circular queue.
-If
-.Fa elm
-is the last element on the circular queue, the first element is returned.
-.Pp
-The macro
-.Nm CIRCLEQ_LOOP_PREV
-returns the previous item on the circular queue.
-If
-.Fa elm
-is the first element on the circular queue, the last element is returned.
-.Pp
-The macro
-.Nm CIRCLEQ_REMOVE
-removes the element
-.Fa elm
-from the circular queue.
 .Sh EXAMPLES
 .Ss Singly-linked tail queue example
 .Bd -literal
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/11] circleq.3, queue.3: EXAMPLES: Move circleq example program from queue.3 to circleq.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (3 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 04/11] circleq.3, queue.3: DESCRIPTION: Move circleq specific " Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 06/11] queue.3: ffix Alejandro Colomar
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 man3/queue.3   | 56 --------------------------------------------------
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index a28a82919..2d683b441 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -210,4 +210,60 @@ from the circular queue.
 .SH CONFORMING TO
 .SH BUGS
 .SH EXAMPLES
+.Ss Circular queue example
+.Bd -literal
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/queue.h>
+
+struct entry {
+    int data;
+    CIRCLEQ_ENTRY(entry) entries;           /* Queue. */
+};
+
+CIRCLEQ_HEAD(circlehead, entry);
+
+int
+main(void)
+{
+    struct entry    *n1, *n2, *n3, *np;
+    struct circlehead head;                 /* Queue head. */
+    int     i;
+
+    CIRCLEQ_INIT(&head);                    /* Initialize the queue. */
+
+    n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
+    CIRCLEQ_INSERT_HEAD(&head, n1, entries);
+
+    n1 = malloc(sizeof(struct entry));      /* Insert at the tail. */
+    CIRCLEQ_INSERT_TAIL(&head, n1, entries);
+
+    n2 = malloc(sizeof(struct entry));      /* Insert after. */
+    CIRCLEQ_INSERT_AFTER(&head, n1, n2, entries);
+
+    n3 = malloc(sizeof(struct entry));      /* Insert before. */
+    CIRCLEQ_INSERT_BEFORE(&head, n2, n3, entries);
+
+    CIRCLEQ_REMOVE(&head, n2, entries);     /* Deletion. */
+    free(n2);
+                                            /* Forward traversal. */
+    i = 0;
+    CIRCLEQ_FOREACH(np, &head, entries)
+        np->data = i++;
+                                            /* Reverse traversal. */
+    CIRCLEQ_FOREACH_REVERSE(np, &head, entries)
+        printf("%i\en", np->data);
+                                            /* Queue deletion. */
+    n1 = CIRCLEQ_FIRST(&head);
+    while (n1 != (void *)&head) {
+        n2 = CIRCLEQ_NEXT(n1, entries);
+        free(n1);
+        n1 = n2;
+    }
+    CIRCLEQ_INIT(&head);
+
+    exit(EXIT_SUCCESS);
+}
+.Ed
 .SH SEE ALSO
diff --git a/man3/queue.3 b/man3/queue.3
index 794790881..26e304b2f 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -791,62 +791,6 @@ main(void)
     exit(EXIT_SUCCESS);
 }
 .Ed
-.Ss Circular queue example
-.Bd -literal
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/queue.h>
-
-struct entry {
-    int data;
-    CIRCLEQ_ENTRY(entry) entries;           /* Queue. */
-};
-
-CIRCLEQ_HEAD(circlehead, entry);
-
-int
-main(void)
-{
-    struct entry    *n1, *n2, *n3, *np;
-    struct circlehead head;                 /* Queue head. */
-    int     i;
-
-    CIRCLEQ_INIT(&head);                    /* Initialize the queue. */
-
-    n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
-    CIRCLEQ_INSERT_HEAD(&head, n1, entries);
-
-    n1 = malloc(sizeof(struct entry));      /* Insert at the tail. */
-    CIRCLEQ_INSERT_TAIL(&head, n1, entries);
-
-    n2 = malloc(sizeof(struct entry));      /* Insert after. */
-    CIRCLEQ_INSERT_AFTER(&head, n1, n2, entries);
-
-    n3 = malloc(sizeof(struct entry));      /* Insert before. */
-    CIRCLEQ_INSERT_BEFORE(&head, n2, n3, entries);
-
-    CIRCLEQ_REMOVE(&head, n2, entries);     /* Deletion. */
-    free(n2);
-                                            /* Forward traversal. */
-    i = 0;
-    CIRCLEQ_FOREACH(np, &head, entries)
-        np->data = i++;
-                                            /* Reverse traversal. */
-    CIRCLEQ_FOREACH_REVERSE(np, &head, entries)
-        printf("%i\en", np->data);
-                                            /* Queue deletion. */
-    n1 = CIRCLEQ_FIRST(&head);
-    while (n1 != (void *)&head) {
-        n2 = CIRCLEQ_NEXT(n1, entries);
-        free(n1);
-        n1 = n2;
-    }
-    CIRCLEQ_INIT(&head);
-
-    exit(EXIT_SUCCESS);
-}
-.Ed
 .Sh CONFORMING TO
 Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
 Present on the BSDs.
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/11] queue.3: ffix
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (4 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 05/11] circleq.3, queue.3: EXAMPLES: Move circleq example program " Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 07/11] circleq.3: Copy and adapt code from queue.3 Alejandro Colomar
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/queue.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man3/queue.3 b/man3/queue.3
index 26e304b2f..79cdca318 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -76,8 +76,8 @@
 .Nm TAILQ_LAST ,
 .Nm TAILQ_NEXT ,
 .Nm TAILQ_PREV ,
-.Nm TAILQ_REMOVE ,
-.\" .Nm TAILQ_SWAP ,
+.Nm TAILQ_REMOVE
+.\" .Nm TAILQ_SWAP
 .Nd implementations of singly-linked lists, singly-linked tail queues,
 lists, tail queues, and circular queues
 .Sh SYNOPSIS
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/11] circleq.3: Copy and adapt code from queue.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (5 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 06/11] queue.3: ffix Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 08/11] circleq.3: ffix: Use man markup Alejandro Colomar
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index 2d683b441..491e1ec91 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -50,6 +50,8 @@
 .Nm CIRCLEQ_PREV ,
 .Nm CIRCLEQ_REMOVE
 .SH SYNOPSIS
+.In sys/queue.h
+.\"
 .Fn CIRCLEQ_EMPTY "CIRCLEQ_HEAD *head"
 .Fn CIRCLEQ_ENTRY "TYPE"
 .Fn CIRCLEQ_FIRST "CIRCLEQ_HEAD *head"
@@ -69,6 +71,18 @@
 .Fn CIRCLEQ_PREV "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
 .SH DESCRIPTION
+In the macro definitions,
+.Fa TYPE
+is the name of a user-defined structure,
+that must contain a field of type
+.Li CIRCLEQ_ENTRY ,
+named
+.Fa NAME .
+The argument
+.Fa HEADNAME
+is the name of a user-defined structure that must be declared
+using the macro
+.Li CIRCLEQ_HEAD .
 .Ss Circular queues
 A circular queue is headed by a structure defined by the
 .Nm CIRCLEQ_HEAD
@@ -208,6 +222,10 @@ removes the element
 from the circular queue.
 .SH RETURN VALUE
 .SH CONFORMING TO
+Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
+Present on the BSDs
+(CIRCLEQ macros first appeared in
+.Bx 4.4 ).
 .SH BUGS
 .SH EXAMPLES
 .Ss Circular queue example
@@ -227,9 +245,9 @@ CIRCLEQ_HEAD(circlehead, entry);
 int
 main(void)
 {
-    struct entry    *n1, *n2, *n3, *np;
+    struct entry *n1, *n2, *n3, *np;
     struct circlehead head;                 /* Queue head. */
-    int     i;
+    int i;
 
     CIRCLEQ_INIT(&head);                    /* Initialize the queue. */
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/11] circleq.3: ffix: Use man markup
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (6 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 07/11] circleq.3: Copy and adapt code from queue.3 Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 09/11] circleq.3: Add remaining details to complete the page Alejandro Colomar
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 257 +++++++++++++++++++++++++++----------------------
 1 file changed, 143 insertions(+), 114 deletions(-)

diff --git a/man3/circleq.3 b/man3/circleq.3
index 491e1ec91..f24df2e15 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -31,61 +31,86 @@
 .\"
 .TH CIRCLEQ 3 2020-10-21 "GNU" "Linux Programmer's Manual"
 .SH NAME
-.Nm CIRCLEQ_EMPTY ,
-.Nm CIRCLEQ_ENTRY ,
-.Nm CIRCLEQ_FIRST ,
-.Nm CIRCLEQ_FOREACH ,
-.Nm CIRCLEQ_FOREACH_REVERSE ,
-.Nm CIRCLEQ_HEAD ,
-.Nm CIRCLEQ_HEAD_INITIALIZER ,
-.Nm CIRCLEQ_INIT ,
-.Nm CIRCLEQ_INSERT_AFTER ,
-.Nm CIRCLEQ_INSERT_BEFORE ,
-.Nm CIRCLEQ_INSERT_HEAD ,
-.Nm CIRCLEQ_INSERT_TAIL ,
-.Nm CIRCLEQ_LAST ,
-.Nm CIRCLEQ_LOOP_NEXT ,
-.Nm CIRCLEQ_LOOP_PREV ,
-.Nm CIRCLEQ_NEXT ,
-.Nm CIRCLEQ_PREV ,
-.Nm CIRCLEQ_REMOVE
+CIRCLEQ_EMPTY,
+CIRCLEQ_ENTRY,
+CIRCLEQ_FIRST,
+CIRCLEQ_FOREACH,
+CIRCLEQ_FOREACH_REVERSE,
+CIRCLEQ_HEAD,
+CIRCLEQ_HEAD_INITIALIZER,
+CIRCLEQ_INIT,
+CIRCLEQ_INSERT_AFTER,
+CIRCLEQ_INSERT_BEFORE,
+CIRCLEQ_INSERT_HEAD,
+CIRCLEQ_INSERT_TAIL,
+CIRCLEQ_LAST,
+CIRCLEQ_LOOP_NEXT,
+CIRCLEQ_LOOP_PREV,
+CIRCLEQ_NEXT,
+CIRCLEQ_PREV,
+CIRCLEQ_REMOVE
 .SH SYNOPSIS
-.In sys/queue.h
-.\"
-.Fn CIRCLEQ_EMPTY "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_ENTRY "TYPE"
-.Fn CIRCLEQ_FIRST "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_FOREACH "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_FOREACH_REVERSE "TYPE *var" "CIRCLEQ_HEAD *head" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_HEAD "HEADNAME" "TYPE"
-.Fn CIRCLEQ_HEAD_INITIALIZER "CIRCLEQ_HEAD head"
-.Fn CIRCLEQ_INIT "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_INSERT_AFTER "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_BEFORE "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_HEAD "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_INSERT_TAIL "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_LAST "CIRCLEQ_HEAD *head"
-.Fn CIRCLEQ_LOOP_NEXT "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_LOOP_PREV "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_NEXT "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_PREV "TYPE *elm" "CIRCLEQ_ENTRY NAME"
-.Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
+.nf
+.B #include <sys/queue.h>
+.PP
+.BI "int CIRCLEQ_EMPTY(CIRCLEQ_HEAD *" head ");"
+.PP
+.B CIRCLEQ_ENTRY(TYPE);
+.PP
+.BI "CIRCLEQ_ENTRY *CIRCLEQ_FIRST(CIRCLEQ_HEAD *" head ");"
+.PP
+.BI "CIRCLEQ_FOREACH(TYPE *" var ", CIRCLEQ_HEAD *" head ", CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "CIRCLEQ_FOREACH_REVERSE(TYPE *" var ", CIRCLEQ_HEAD *" head ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.B CIRCLEQ_HEAD(HEADNAME, TYPE);
+.PP
+.BI "CIRCLEQ_HEAD CIRCLEQ_HEAD_INITIALIZER(CIRCLEQ_HEAD " head ");"
+.PP
+.BI "void CIRCLEQ_INIT(CIRCLEQ_HEAD *" head ");"
+.PP
+.BI "void CIRCLEQ_INSERT_AFTER(CIRCLEQ_HEAD *" head ", TYPE *" listelm ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "void CIRCLEQ_INSERT_BEFORE(CIRCLEQ_HEAD *" head ", TYPE *" listelm ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "void CIRCLEQ_INSERT_HEAD(CIRCLEQ_HEAD *" head ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "void CIRCLEQ_INSERT_TAIL(CIRCLEQ_HEAD *" head ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "CIRCLEQ_ENTRY *CIRCLEQ_LAST(CIRCLEQ_HEAD *" head ");"
+.PP
+.BI "void CIRCLEQ_LOOP_NEXT(CIRCLEQ_HEAD *" head ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "void CIRCLEQ_LOOP_PREV(CIRCLEQ_HEAD *" head ", TYPE *" elm ","
+.BI "                CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "CIRCLEQ_ENTRY *CIRCLEQ_NEXT(TYPE *" elm ", CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "CIRCLEQ_ENTRY *CIRCLEQ_PREV(TYPE *" elm ", CIRCLEQ_ENTRY " NAME ");"
+.PP
+.BI "void CIRCLEQ_REMOVE(CIRCLEQ_HEAD *" head ", TYPE *" elm ", CIRCLEQ_ENTRY " NAME ");"
 .SH DESCRIPTION
 In the macro definitions,
-.Fa TYPE
+.I TYPE
 is the name of a user-defined structure,
 that must contain a field of type
-.Li CIRCLEQ_ENTRY ,
+.IR CIRCLEQ_ENTRY ,
 named
-.Fa NAME .
+.IR NAME .
 The argument
-.Fa HEADNAME
+.I HEADNAME
 is the name of a user-defined structure that must be declared
 using the macro
-.Li CIRCLEQ_HEAD .
-.Ss Circular queues
+.BR CIRCLEQ_HEAD ().
+.PP
 A circular queue is headed by a structure defined by the
-.Nm CIRCLEQ_HEAD
+.BR CIRCLEQ_HEAD ()
 macro.
 This structure contains a pair of pointers,
 one to the first element in the circular queue and the other to
@@ -96,140 +121,144 @@ New elements can be added to the circular queue after an existing element,
 before an existing element, at the head of the circular queue,
 or at the end of the circular queue.
 A
-.Fa CIRCLEQ_HEAD
+.I CIRCLEQ_HEAD
 structure is declared as follows:
-.Bd -literal -offset indent
+.PP
+.in +4
+.EX
 CIRCLEQ_HEAD(HEADNAME, TYPE) head;
-.Ed
-.Pp
+.EE
+.in
+.PP
 where
-.Li HEADNAME
+.I HEADNAME
 is the name of the structure to be defined, and
-.Li TYPE
+.I TYPE
 is the type of the elements to be linked into the circular queue.
 A pointer to the head of the circular queue can later be declared as:
-.Bd -literal -offset indent
+.PP
+.in +4
+.EX
 struct HEADNAME *headp;
-.Ed
-.Pp
+.EE
+.in
+.PP
 (The names
-.Li head
+.I head
 and
-.Li headp
+.I headp
 are user selectable.)
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_HEAD_INITIALIZER
+.BR CIRCLEQ_HEAD_INITIALIZER ()
 evaluates to an initializer for the circular queue
-.Fa head .
-.Pp
+.IR head .
+.PP
 The macro
-.Nm CIRCLEQ_EMPTY
+.BR CIRCLEQ_EMPTY ()
 evaluates to true if there are no items on the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_ENTRY
+.BR CIRCLEQ_ENTRY ()
 declares a structure that connects the elements in
 the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_FIRST
+.BR CIRCLEQ_FIRST ()
 returns the first item on the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_FOREACH
+.BR CIRCLEQ_FOREACH ()
 traverses the circular queue referenced by
-.Fa head
+.I head
 in the forward direction, assigning each element in turn to
-.Fa var .
-.Fa var
+.IR var .
+.I var
 is set to
-.Fa &head
+.I &head
 if the loop completes normally, or if there were no elements.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_FOREACH_REVERSE
+.BR CIRCLEQ_FOREACH_REVERSE ()
 traverses the circular queue referenced by
-.Fa head
+.I head
 in the reverse direction, assigning each element in turn to
-.Fa var .
-.Pp
+.IR var .
+.PP
 The macro
-.Nm CIRCLEQ_INIT
+.BR CIRCLEQ_INIT ()
 initializes the circular queue referenced by
-.Fa head .
-.Pp
+.IR head .
+.PP
 The macro
-.Nm CIRCLEQ_INSERT_HEAD
+.BR CIRCLEQ_INSERT_HEAD ()
 inserts the new element
-.Fa elm
+.I elm
 at the head of the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_INSERT_TAIL
+.BR CIRCLEQ_INSERT_TAIL ()
 inserts the new element
-.Fa elm
+.I elm
 at the end of the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_INSERT_AFTER
+.BR CIRCLEQ_INSERT_AFTER ()
 inserts the new element
-.Fa elm
+.I elm
 after the element
-.Fa listelm .
-.Pp
+.IR listelm .
+.PP
 The macro
-.Nm CIRCLEQ_INSERT_BEFORE
+.BR CIRCLEQ_INSERT_BEFORE ()
 inserts the new element
-.Fa elm
+.I elm
 before the element
-.Fa listelm .
-.Pp
+.IR listelm .
+.PP
 The macro
-.Nm CIRCLEQ_LAST
+.BR CIRCLEQ_LAST ()
 returns the last item on the circular queue.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_NEXT
+.BR CIRCLEQ_NEXT ()
 returns the next item on the circular queue, or
-.Fa &head
+.I &head
 if this item is the last one.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_PREV
+.BR CIRCLEQ_PREV ()
 returns the previous item on the circular queue, or
-.Fa &head
+.I &head
 if this item is the first one.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_LOOP_NEXT
+.BR CIRCLEQ_LOOP_NEXT ()
 returns the next item on the circular queue.
 If
-.Fa elm
+.I elm
 is the last element on the circular queue, the first element is returned.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_LOOP_PREV
+.BR CIRCLEQ_LOOP_PREV ()
 returns the previous item on the circular queue.
 If
-.Fa elm
+.I elm
 is the first element on the circular queue, the last element is returned.
-.Pp
+.PP
 The macro
-.Nm CIRCLEQ_REMOVE
+.BR CIRCLEQ_REMOVE ()
 removes the element
-.Fa elm
+.I elm
 from the circular queue.
 .SH RETURN VALUE
 .SH CONFORMING TO
 Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
 Present on the BSDs
-(CIRCLEQ macros first appeared in
-.Bx 4.4 ).
+(CIRCLEQ macros first appeared in 4.4BSD).
 .SH BUGS
 .SH EXAMPLES
-.Ss Circular queue example
-.Bd -literal
+.EX
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -283,5 +312,5 @@ main(void)
 
     exit(EXIT_SUCCESS);
 }
-.Ed
+.EE
 .SH SEE ALSO
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/11] circleq.3: Add remaining details to complete the page
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (7 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 08/11] circleq.3: ffix: Use man markup Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 10/11] CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3, CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3, CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link to the new circleq(3) page instead of queue(3) Alejandro Colomar
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/circleq.3 | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/man3/circleq.3 b/man3/circleq.3
index f24df2e15..33215be77 100644
--- a/man3/circleq.3
+++ b/man3/circleq.3
@@ -49,6 +49,7 @@ CIRCLEQ_LOOP_PREV,
 CIRCLEQ_NEXT,
 CIRCLEQ_PREV,
 CIRCLEQ_REMOVE
+\- implementation of a double-linked circular queue
 .SH SYNOPSIS
 .nf
 .B #include <sys/queue.h>
@@ -96,6 +97,8 @@ CIRCLEQ_REMOVE
 .PP
 .BI "void CIRCLEQ_REMOVE(CIRCLEQ_HEAD *" head ", TYPE *" elm ", CIRCLEQ_ENTRY " NAME ");"
 .SH DESCRIPTION
+These macros define and operate on doubly-linked circular queues.
+.PP
 In the macro definitions,
 .I TYPE
 is the name of a user-defined structure,
@@ -252,11 +255,44 @@ removes the element
 .I elm
 from the circular queue.
 .SH RETURN VALUE
+.BR CIRCLEQ_EMPTY ()
+returns nonzero if the queue is empty,
+and zero if the queue contains at least one entry.
+.PP
+.BR CIRCLEQ_FIRST (),
+.BR CIRCLEQ_LAST (),
+.BR CIRCLEQ_NEXT (),
+and
+.BR CIRCLEQ_PREV ()
+return a pointer to the first, last, next or previous
+.I CIRCLEQ_ENTRY
+structure, respectively.
+.PP
+.BR CIRCLEQ_HEAD_INITIALIZER ()
+returns an initializer that can be assigned to the queue
+.IR head .
 .SH CONFORMING TO
 Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
 Present on the BSDs
 (CIRCLEQ macros first appeared in 4.4BSD).
 .SH BUGS
+The macros
+.BR CIRCLEQ_FOREACH ()
+and
+.BR CIRCLEQ_FOREACH_REVERSE ()
+don't allow
+.I var
+to be removed or freed within the loop,
+as it would interfere with the traversal.
+The macros
+.BR CIRCLEQ_FOREACH_SAFE ()
+and
+.BR CIRCLEQ_FOREACH_REVERSE_SAFE (),
+which are present on the BSDs but are not present in glibc,
+fix this limitation by allowing
+.I var
+to safely be removed from the list and freed from within the loop
+without interfering with the traversal.
 .SH EXAMPLES
 .EX
 #include <stddef.h>
@@ -314,3 +350,5 @@ main(void)
 }
 .EE
 .SH SEE ALSO
+.BR insque (3),
+.BR queue (3)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/11] CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3, CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3, CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link to the new circleq(3) page instead of queue(3)
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (8 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 09/11] circleq.3: Add remaining details to complete the page Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 14:57 ` [PATCH 11/11] queue.3: SEE ALSO: Add circleq(3) Alejandro Colomar
  2020-10-23 16:19 ` [PATCH 00/11] circleq.3: Fork from queue.3 Michael Kerrisk (man-pages)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/CIRCLEQ_ENTRY.3         | 2 +-
 man3/CIRCLEQ_HEAD.3          | 2 +-
 man3/CIRCLEQ_INIT.3          | 2 +-
 man3/CIRCLEQ_INSERT_AFTER.3  | 2 +-
 man3/CIRCLEQ_INSERT_BEFORE.3 | 2 +-
 man3/CIRCLEQ_INSERT_HEAD.3   | 2 +-
 man3/CIRCLEQ_INSERT_TAIL.3   | 2 +-
 man3/CIRCLEQ_REMOVE.3        | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/man3/CIRCLEQ_ENTRY.3 b/man3/CIRCLEQ_ENTRY.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_ENTRY.3
+++ b/man3/CIRCLEQ_ENTRY.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_HEAD.3 b/man3/CIRCLEQ_HEAD.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_HEAD.3
+++ b/man3/CIRCLEQ_HEAD.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_INIT.3 b/man3/CIRCLEQ_INIT.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_INIT.3
+++ b/man3/CIRCLEQ_INIT.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_INSERT_AFTER.3 b/man3/CIRCLEQ_INSERT_AFTER.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_INSERT_AFTER.3
+++ b/man3/CIRCLEQ_INSERT_AFTER.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_INSERT_BEFORE.3 b/man3/CIRCLEQ_INSERT_BEFORE.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_INSERT_BEFORE.3
+++ b/man3/CIRCLEQ_INSERT_BEFORE.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_INSERT_HEAD.3 b/man3/CIRCLEQ_INSERT_HEAD.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_INSERT_HEAD.3
+++ b/man3/CIRCLEQ_INSERT_HEAD.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_INSERT_TAIL.3 b/man3/CIRCLEQ_INSERT_TAIL.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_INSERT_TAIL.3
+++ b/man3/CIRCLEQ_INSERT_TAIL.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
diff --git a/man3/CIRCLEQ_REMOVE.3 b/man3/CIRCLEQ_REMOVE.3
index c2956c9fc..ed0fc9a3b 100644
--- a/man3/CIRCLEQ_REMOVE.3
+++ b/man3/CIRCLEQ_REMOVE.3
@@ -1 +1 @@
-.so man3/queue.3
+.so man3/circleq.3
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 11/11] queue.3: SEE ALSO: Add circleq(3)
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (9 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 10/11] CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3, CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3, CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link to the new circleq(3) page instead of queue(3) Alejandro Colomar
@ 2020-10-23 14:57 ` Alejandro Colomar
  2020-10-23 16:19 ` [PATCH 00/11] circleq.3: Fork from queue.3 Michael Kerrisk (man-pages)
  11 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2020-10-23 14:57 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/queue.3 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/man3/queue.3 b/man3/queue.3
index 79cdca318..0c57f8ef6 100644
--- a/man3/queue.3
+++ b/man3/queue.3
@@ -798,6 +798,7 @@ Present on the BSDs.
 functions first appeared in
 .Bx 4.4 .
 .Sh SEE ALSO
+.Xr circleq 3
 .Xr insque 3
 .Xr list 3
 .Xr slist 3
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 00/11] circleq.3: Fork from queue.3
  2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
                   ` (10 preceding siblings ...)
  2020-10-23 14:57 ` [PATCH 11/11] queue.3: SEE ALSO: Add circleq(3) Alejandro Colomar
@ 2020-10-23 16:19 ` Michael Kerrisk (man-pages)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-10-23 16:19 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: mtk.manpages, linux-man, libc-alpha

Hello Alex,

On 10/23/20 4:57 PM, Alejandro Colomar wrote:
> Hi Michael,
> 
> It's going much faster than I thought :-)
> 
> There's a detail I wasn't sure about:
> 
> There are BSDs that don't have CIRCLEQ macros,
> or at least it isn't documented there (FreeBSD comes to my mind).
> So I'm not sure CIRCLEQ originated at the same time as the others (4.4BSD).
> Maybe you know better.
> That affects patches 07/10 and 08/10.

I don't know, I'm sorry.  But, i think we don't need to worry about it too much.

> Please, apply these patches after "queue.3: Sort alphabetically".

Done. I've applied this whole series. Thanks!

Cheers,

Michael

> Alejandro Colomar (11):
>   circleq.3: New page that will hold the (circleq) content of queue.3
>   circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3
>   circleq.3, queue.3: SYNOPSIS: Move code from queue.3 to circleq.3
>   circleq.3, queue.3: DESCRIPTION: Move circleq specific code from
>     queue.3 to circleq.3
>   circleq.3, queue.3: EXAMPLES: Move circleq example program from
>     queue.3 to circleq.3
>   queue.3: ffix
>   circleq.3: Copy and adapt code from queue.3
>   circleq.3: ffix: Use man markup
>   circleq.3: Add remaining details to complete the page
>   CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3,
>     CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3,
>     CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link
>     to the new circleq(3) page instead of queue(3)
>   queue.3: SEE ALSO: Add circleq(3)
> 
>  man3/CIRCLEQ_ENTRY.3         |   2 +-
>  man3/CIRCLEQ_HEAD.3          |   2 +-
>  man3/CIRCLEQ_INIT.3          |   2 +-
>  man3/CIRCLEQ_INSERT_AFTER.3  |   2 +-
>  man3/CIRCLEQ_INSERT_BEFORE.3 |   2 +-
>  man3/CIRCLEQ_INSERT_HEAD.3   |   2 +-
>  man3/CIRCLEQ_INSERT_TAIL.3   |   2 +-
>  man3/CIRCLEQ_REMOVE.3        |   2 +-
>  man3/circleq.3               | 354 +++++++++++++++++++++++++++++++++++
>  man3/queue.3                 | 234 +----------------------
>  10 files changed, 365 insertions(+), 239 deletions(-)
>  create mode 100644 man3/circleq.3
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-10-23 16:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23 14:57 [PATCH 00/11] circleq.3: Fork from queue.3 Alejandro Colomar
2020-10-23 14:57 ` [PATCH 01/11] circleq.3: New page that will hold the (circleq) content of queue.3 Alejandro Colomar
2020-10-23 14:57 ` [PATCH 02/11] circleq.3, queue.3: NAME: Move code from queue-3 to circleq.3 Alejandro Colomar
2020-10-23 14:57 ` [PATCH 03/11] circleq.3, queue.3: SYNOPSIS: Move code from queue.3 " Alejandro Colomar
2020-10-23 14:57 ` [PATCH 04/11] circleq.3, queue.3: DESCRIPTION: Move circleq specific " Alejandro Colomar
2020-10-23 14:57 ` [PATCH 05/11] circleq.3, queue.3: EXAMPLES: Move circleq example program " Alejandro Colomar
2020-10-23 14:57 ` [PATCH 06/11] queue.3: ffix Alejandro Colomar
2020-10-23 14:57 ` [PATCH 07/11] circleq.3: Copy and adapt code from queue.3 Alejandro Colomar
2020-10-23 14:57 ` [PATCH 08/11] circleq.3: ffix: Use man markup Alejandro Colomar
2020-10-23 14:57 ` [PATCH 09/11] circleq.3: Add remaining details to complete the page Alejandro Colomar
2020-10-23 14:57 ` [PATCH 10/11] CIRCLEQ_ENTRY.3, CIRCLEQ_HEAD.3, CIRCLEQ_INIT.3, CIRCLEQ_INSERT_AFTER.3, CIRCLEQ_INSERT_BEFORE.3, CIRCLEQ_INSERT_HEAD.3, CIRCLEQ_INSERT_TAIL.3, CIRCLEQ_REMOVE.3: Link to the new circleq(3) page instead of queue(3) Alejandro Colomar
2020-10-23 14:57 ` [PATCH 11/11] queue.3: SEE ALSO: Add circleq(3) Alejandro Colomar
2020-10-23 16:19 ` [PATCH 00/11] circleq.3: Fork from queue.3 Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).