From patchwork Sat Oct 24 22:21:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40845 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 C5A9F385780E; Sat, 24 Oct 2020 22:21:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5A9F385780E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603578100; bh=ThpV9XXFhMVJ/oGRgJ0IntjEeDldw+Bwy1c49CeXspA=; 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=w5nCrJ5DwxjephjXlifZ5AxYFEq/ClnIiVf+1gbmjgJe5ppjphLEwGIy5zUYiuX0l eJ2gn7xxbKovAHabSd/vFWZndQEZ3Ay4ygVIFYPe6e6n5SUk5UXCaQj/Aw1uEJ08N/ A5gMGU4WTeN+V4tkd1CnfpD4yGV9q+TFyIJ7gVi8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 3D080386F81B for ; Sat, 24 Oct 2020 22:21:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3D080386F81B Received: by mail-wr1-x42d.google.com with SMTP id h7so7382186wre.4 for ; Sat, 24 Oct 2020 15:21:37 -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=ThpV9XXFhMVJ/oGRgJ0IntjEeDldw+Bwy1c49CeXspA=; b=ueGMvMhzUUjGIyljbdP7/kjjfNv7xP3d8MNWUJuLCmGM2NaYMZDtUYkzKcMTzT2nBw QJXxt7VBJBgkkiIiiJ4KaXi6//gejuXX8D+zwBlV0bXtye/24Dk6efTFfY6kSOZscQTe p5MXxILtERqnMw96FlPlp5Ls2w3MrVuP2OyvDn+DJMH7ROk6qJJnLbl//9y/T/0o25vN G6WdltGNymnbD6dcvDTvVaHiVJ6bQbP2JV5LePSeMu1mejZ9WU+CUqbmbafWurzddnQf EG2gqYKDmzwXCknMcQsq0TrWdMbZCN3mHOA9WQMay+7zElFBujG/NHevYXGeyxKqsYOT o0bw== X-Gm-Message-State: AOAM531Cyzn0Dxc9cQotNJKBvRIjiyibYYmqV6BwObY6u1oFPpQWquV4 cn3FfTRGddK8PXe0UM3gnXD+SBK2hEk= X-Google-Smtp-Source: ABdhPJxKLAGO0KbIPmd6dVgz+oLFFPSl01EnxvFQZI9ftWrd9gL3nG4O8yTlUFfpbUPee8LjmdNCxQ== X-Received: by 2002:a05:6000:1005:: with SMTP id a5mr10155919wrx.360.1603578096205; Sat, 24 Oct 2020 15:21:36 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id 133sm16427654wmb.2.2020.10.24.15.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Oct 2020 15:21:35 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH 4/8] queue.3, stailq.3: DESCRIPTION: Move stailq specific code from queue.3 to stailq.3 Date: Sun, 25 Oct 2020 00:21:12 +0200 Message-Id: <20201024222115.6362-5-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201024222115.6362-1-colomar.6.4.3@gmail.com> References: <20201024222115.6362-1-colomar.6.4.3@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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/queue.3 | 177 -------------------------------------------------- man3/stailq.3 | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 177 deletions(-) diff --git a/man3/queue.3 b/man3/queue.3 index 72ec892ad..ee15e60be 100644 --- a/man3/queue.3 +++ b/man3/queue.3 @@ -245,183 +245,6 @@ or .Li CIRCLEQ_HEAD . See the examples below for further explanation of how these macros are used. -.Ss Singly-linked tail queues -A singly-linked tail queue is headed by a structure defined by the -.Nm STAILQ_HEAD -macro. -This structure contains a pair of pointers, -one to the first element in the tail queue and the other to -the last element in the tail queue. -The elements are singly linked for minimum space and pointer -manipulation overhead at the expense of O(n) removal for arbitrary -elements. -New elements can be added to the tail queue after an existing element, -at the head of the tail queue, or at the end of the tail queue. -A -.Fa STAILQ_HEAD -structure is declared as follows: -.Bd -literal -offset indent -STAILQ_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 tail queue. -A pointer to the head of the tail 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 STAILQ_HEAD_INITIALIZER -evaluates to an initializer for the tail queue -.Fa head . -.Pp -The macro -.Nm STAILQ_CONCAT -concatenates the tail queue headed by -.Fa head2 -onto the end of the one headed by -.Fa head1 -removing all entries from the former. -.Pp -The macro -.Nm STAILQ_EMPTY -evaluates to true if there are no items on the tail queue. -.Pp -The macro -.Nm STAILQ_ENTRY -declares a structure that connects the elements in -the tail queue. -.Pp -The macro -.Nm STAILQ_FIRST -returns the first item on the tail queue or NULL if the tail queue -is empty. -.Pp -The macro -.Nm STAILQ_FOREACH -traverses the tail queue referenced by -.Fa head -in the forward direction, assigning each element -in turn to -.Fa var . -.\" .Pp -.\" The macro -.\" .Nm STAILQ_FOREACH_FROM -.\" behaves identically to -.\" .Nm STAILQ_FOREACH -.\" when -.\" .Fa var -.\" is NULL, else it treats -.\" .Fa var -.\" as a previously found STAILQ element and begins the loop at -.\" .Fa var -.\" instead of the first element in the STAILQ referenced by -.\" .Fa head . -.\" .Pp -.\" The macro -.\" .Nm STAILQ_FOREACH_SAFE -.\" traverses the tail queue referenced by -.\" .Fa head -.\" in the forward direction, assigning each element -.\" in turn to -.\" .Fa var . -.\" However, unlike -.\" .Fn STAILQ_FOREACH -.\" here it is permitted to both remove -.\" .Fa var -.\" as well as free it from within the loop safely without interfering with the -.\" traversal. -.\" .Pp -.\" The macro -.\" .Nm STAILQ_FOREACH_FROM_SAFE -.\" behaves identically to -.\" .Nm STAILQ_FOREACH_SAFE -.\" when -.\" .Fa var -.\" is NULL, else it treats -.\" .Fa var -.\" as a previously found STAILQ element and begins the loop at -.\" .Fa var -.\" instead of the first element in the STAILQ referenced by -.\" .Fa head . -.Pp -The macro -.Nm STAILQ_INIT -initializes the tail queue referenced by -.Fa head . -.Pp -The macro -.Nm STAILQ_INSERT_HEAD -inserts the new element -.Fa elm -at the head of the tail queue. -.Pp -The macro -.Nm STAILQ_INSERT_TAIL -inserts the new element -.Fa elm -at the end of the tail queue. -.Pp -The macro -.Nm STAILQ_INSERT_AFTER -inserts the new element -.Fa elm -after the element -.Fa listelm . -.\" .Pp -.\" The macro -.\" .Nm STAILQ_LAST -.\" returns the last item on the tail queue. -.\" If the tail queue is empty the return value is -.\" .Dv NULL . -.Pp -The macro -.Nm STAILQ_NEXT -returns the next item on the tail queue, or NULL this item is the last. -.\" .Pp -.\" The macro -.\" .Nm STAILQ_REMOVE_AFTER -.\" removes the element after -.\" .Fa elm -.\" from the tail queue. -.\" Unlike -.\" .Fa STAILQ_REMOVE , -.\" this macro does not traverse the entire tail queue. -.Pp -The macro -.Nm STAILQ_REMOVE_HEAD -removes the element at the head of the tail queue. -For optimum efficiency, -elements being removed from the head of the tail queue should -use this macro explicitly rather than the generic -.Fa STAILQ_REMOVE -macro. -.Pp -The macro -.Nm STAILQ_REMOVE -removes the element -.Fa elm -from the tail queue. -.\" .Pp -.\" The macro -.\" .Nm STAILQ_SWAP -.\" swaps the contents of -.\" .Fa head1 -.\" and -.\" .Fa head2 . -.Pp -See the EXAMPLES section below for an example program -using a singly-linked tail queue. .Ss Tail queues A tail queue is headed by a structure defined by the .Nm TAILQ_HEAD diff --git a/man3/stailq.3 b/man3/stailq.3 index 161b7c3f0..9b0322e68 100644 --- a/man3/stailq.3 +++ b/man3/stailq.3 @@ -74,6 +74,183 @@ .\" .Fn STAILQ_SWAP "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" "STAILQ_ENTRY NAME" .\" .SH DESCRIPTION +.Ss Singly-linked tail queues +A singly-linked tail queue is headed by a structure defined by the +.Nm STAILQ_HEAD +macro. +This structure contains a pair of pointers, +one to the first element in the tail queue and the other to +the last element in the tail queue. +The elements are singly linked for minimum space and pointer +manipulation overhead at the expense of O(n) removal for arbitrary +elements. +New elements can be added to the tail queue after an existing element, +at the head of the tail queue, or at the end of the tail queue. +A +.Fa STAILQ_HEAD +structure is declared as follows: +.Bd -literal -offset indent +STAILQ_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 tail queue. +A pointer to the head of the tail 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 STAILQ_HEAD_INITIALIZER +evaluates to an initializer for the tail queue +.Fa head . +.Pp +The macro +.Nm STAILQ_CONCAT +concatenates the tail queue headed by +.Fa head2 +onto the end of the one headed by +.Fa head1 +removing all entries from the former. +.Pp +The macro +.Nm STAILQ_EMPTY +evaluates to true if there are no items on the tail queue. +.Pp +The macro +.Nm STAILQ_ENTRY +declares a structure that connects the elements in +the tail queue. +.Pp +The macro +.Nm STAILQ_FIRST +returns the first item on the tail queue or NULL if the tail queue +is empty. +.Pp +The macro +.Nm STAILQ_FOREACH +traverses the tail queue referenced by +.Fa head +in the forward direction, assigning each element +in turn to +.Fa var . +.\" .Pp +.\" The macro +.\" .Nm STAILQ_FOREACH_FROM +.\" behaves identically to +.\" .Nm STAILQ_FOREACH +.\" when +.\" .Fa var +.\" is NULL, else it treats +.\" .Fa var +.\" as a previously found STAILQ element and begins the loop at +.\" .Fa var +.\" instead of the first element in the STAILQ referenced by +.\" .Fa head . +.\" .Pp +.\" The macro +.\" .Nm STAILQ_FOREACH_SAFE +.\" traverses the tail queue referenced by +.\" .Fa head +.\" in the forward direction, assigning each element +.\" in turn to +.\" .Fa var . +.\" However, unlike +.\" .Fn STAILQ_FOREACH +.\" here it is permitted to both remove +.\" .Fa var +.\" as well as free it from within the loop safely without interfering with the +.\" traversal. +.\" .Pp +.\" The macro +.\" .Nm STAILQ_FOREACH_FROM_SAFE +.\" behaves identically to +.\" .Nm STAILQ_FOREACH_SAFE +.\" when +.\" .Fa var +.\" is NULL, else it treats +.\" .Fa var +.\" as a previously found STAILQ element and begins the loop at +.\" .Fa var +.\" instead of the first element in the STAILQ referenced by +.\" .Fa head . +.Pp +The macro +.Nm STAILQ_INIT +initializes the tail queue referenced by +.Fa head . +.Pp +The macro +.Nm STAILQ_INSERT_HEAD +inserts the new element +.Fa elm +at the head of the tail queue. +.Pp +The macro +.Nm STAILQ_INSERT_TAIL +inserts the new element +.Fa elm +at the end of the tail queue. +.Pp +The macro +.Nm STAILQ_INSERT_AFTER +inserts the new element +.Fa elm +after the element +.Fa listelm . +.\" .Pp +.\" The macro +.\" .Nm STAILQ_LAST +.\" returns the last item on the tail queue. +.\" If the tail queue is empty the return value is +.\" .Dv NULL . +.Pp +The macro +.Nm STAILQ_NEXT +returns the next item on the tail queue, or NULL this item is the last. +.\" .Pp +.\" The macro +.\" .Nm STAILQ_REMOVE_AFTER +.\" removes the element after +.\" .Fa elm +.\" from the tail queue. +.\" Unlike +.\" .Fa STAILQ_REMOVE , +.\" this macro does not traverse the entire tail queue. +.Pp +The macro +.Nm STAILQ_REMOVE_HEAD +removes the element at the head of the tail queue. +For optimum efficiency, +elements being removed from the head of the tail queue should +use this macro explicitly rather than the generic +.Fa STAILQ_REMOVE +macro. +.Pp +The macro +.Nm STAILQ_REMOVE +removes the element +.Fa elm +from the tail queue. +.\" .Pp +.\" The macro +.\" .Nm STAILQ_SWAP +.\" swaps the contents of +.\" .Fa head1 +.\" and +.\" .Fa head2 . +.Pp +See the EXAMPLES section below for an example program +using a singly-linked tail queue. .SH RETURN VALUE .SH CONFORMING TO .SH BUGS