From patchwork Fri Oct 23 14:57:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40836 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E790398B415; Fri, 23 Oct 2020 14:58:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E790398B415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603465123; bh=5VzGfuCRBYUPOGammsGiC1iF//89ugYSH/Et8T9RNHg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=us2mvdRvxWMh9szZEMlj0Zh7tNhS5MvPInFy0uby/XSazx36KIEbVPlcxCvRC+YvN QouNWOPFY8yhXTuDVv71VahjGbx/vfSV8Dx7qPO2wNhvn7FZHnh4MTZCAd7v1+mB5I FVcpWMXRsP6h2XgyXn93lqGD+fLkzLjwelc9BLMY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id 3A5AF398B41C for ; Fri, 23 Oct 2020 14:58:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A5AF398B41C Received: by mail-wr1-x441.google.com with SMTP id h7so2235461wre.4 for ; Fri, 23 Oct 2020 07:58:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5VzGfuCRBYUPOGammsGiC1iF//89ugYSH/Et8T9RNHg=; b=gJYpbpRjoqpj39xgQNWdiOZ9L6YSe7Msg9HJ+AT1JAiIRzuy+fdKfFIi1zuEjo37u7 ZQKigqvgpZp4bLeRrVkISREO2vcYwvdUlTCGu8DBKFqhk1mj+I318KfEuhkthTn0Vy4c JPMCAuJ+Mc5Pi0eYMf892H/C9iFc1HDwYXWKohOM6aVWf+13h15gIfJ1dYiaSTgZLPbv WNKOe+JLkZ9o5RFMsSbwAkH3ZR21UPiH3FhSOgbsnVwvLTUA69ORMDA1N38b8Dhh5Syx YUVS7QOJFm2W1tqzFTxglM5LADiT2OcjgReSDJOudsywV9xMHB2UMYOw9e627hmDIUnx WoUQ== X-Gm-Message-State: AOAM532rG1o9NeoEU68KYgfG/m/evEHzJLw9pqq2ECxtfDmKK6ROA59y /hsjkl0ZJzoYL1bVgVGSE64= X-Google-Smtp-Source: ABdhPJzV9nwRrkHha8OjG1tcYRzsaO4g+lv8ucucgLMttOk9vmui+qGiFxzDX9+cOkF/3R30UAmTJw== X-Received: by 2002:adf:c3c6:: with SMTP id d6mr3108171wrg.206.1603465119281; Fri, 23 Oct 2020 07:58:39 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id m8sm3755268wrw.17.2020.10.23.07.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 07:58:38 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH 08/11] circleq.3: ffix: Use man markup Date: Fri, 23 Oct 2020 16:57:34 +0200 Message-Id: <20201023145736.102750-9-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201023145736.102750-1-colomar.6.4.3@gmail.com> References: <20201023145736.102750-1-colomar.6.4.3@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, UPPERCASE_50_75 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , linux-man@vger.kernel.org, libc-alpha@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Signed-off-by: Alejandro Colomar --- 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 +.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 #include #include @@ -283,5 +312,5 @@ main(void) exit(EXIT_SUCCESS); } -.Ed +.EE .SH SEE ALSO