From patchwork Tue Oct 20 21:31:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40792 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 04BDD3954430; Tue, 20 Oct 2020 21:32:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04BDD3954430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603229523; bh=zeE3eUJsgtOl8itXfGQx1CTaT1qQcCvBm/X582QC+1c=; 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=f9mqqm4JYTt2GEi8i645PB0zER/NzqR4EkSAcTNYg015mVAJJPvP7ZXOIogE+69ry 0IARR896yXmpnmxWmqF0coJMzQytpPIp7mI+0AyKwdt39GFZrvFt6BUjoyJ0sImcpa 4kOil0zCD6fR1yJbyyPxxnzHyURZXe83LI8T30Lw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by sourceware.org (Postfix) with ESMTPS id 0D083395188E for ; Tue, 20 Oct 2020 21:31:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0D083395188E Received: by mail-wr1-x442.google.com with SMTP id e17so4458709wru.12 for ; Tue, 20 Oct 2020 14:31:58 -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=zeE3eUJsgtOl8itXfGQx1CTaT1qQcCvBm/X582QC+1c=; b=tYmFhZ4Vr+iAYJj3hS/bAOF/Li5cio+zH6P8E4H+kg+SMvzJt+TQA/zrtL9OdjMj34 gKGUt9VxKaeZt0CRbni3ztcj8LHZApo3h/V7WWzJZC51Yu0fw6v02RNrs+OS4xI03aXc ctCwVtN9DXzDSAUsl3LHwL8xXiS60aqtnsHIxgcZ9wWsqGGAPOoA4rvkw3mF5uYNlzBl 2FUUWQFWpaGcEyVJVRbVg9u1bQdx5gSQUY92fRtN5Kh9ricKpQzQDGzj3j5Eo9rKs7EJ sN288bcvXP1eC+du8oYD4jbuHL/wdXbFeMpD8972JU0UrU50lDGUdeY2aySyuE/b6bWL LmNA== X-Gm-Message-State: AOAM531xR1XKkFWZJUWv1kdiC0XF72wS+SAGa9LieMG64pw22qdCrqPm p/4ZXZFMFBhwLgF+7PX0Fug= X-Google-Smtp-Source: ABdhPJyGefQGBkB5O+dJQkZJ1JFnfJkZ5fmgQFECYzaPUpgS2WbR4SfwoFhtpXErFBacUC0fzt56MA== X-Received: by 2002:adf:f643:: with SMTP id x3mr408224wrp.180.1603229517198; Tue, 20 Oct 2020 14:31:57 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id y4sm35387wrp.74.2020.10.20.14.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 14:31:56 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH v2 08/10] list.3: Add details Date: Tue, 20 Oct 2020 23:31:06 +0200 Message-Id: <20201020213107.83837-9-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020142146.61837-23-colomar.6.4.3@gmail.com> References: <20201020142146.61837-23-colomar.6.4.3@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 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 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" list.3: NAME: Add description list.3: DESCRIPTION: Add short description list.3: SEE ALSO: Add insque(3) and queue(3) list.3: BUGS: Note LIST_FOREACH() limitations list.3: RETURN VALUE: Add details about the return value of those macros that "return" a value Signed-off-by: Alejandro Colomar --- man3/list.3 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/man3/list.3 b/man3/list.3 index 0f9b20d26..8233c3b3e 100644 --- a/man3/list.3 +++ b/man3/list.3 @@ -48,6 +48,7 @@ LIST_NEXT, LIST_PREV, LIST_REMOVE .\"LIST_SWAP +\- implementation of a doubly-linked list .SH SYNOPSIS .nf .B #include @@ -87,6 +88,8 @@ LIST_REMOVE .\".BI "void LIST_SWAP(LIST_HEAD *" head1 ", LIST_HEAD *" head2 ", TYPE, LIST_ENTRY " NAME ");" .fi .SH DESCRIPTION +These macros define and operate on doubly-linked lists. +.PP In the macro definitions, .I TYPE is the name of a user defined structure, @@ -253,11 +256,39 @@ from the list. .\" and .\" .IR head2 . .SH RETURN VALUE +.BR LIST_EMPTY () +returns non-zero if the list is empty, +and zero if the list contains at least one entry. +.PP +.BR LIST_FIRST (), +and +.BR LIST_NEXT () +return a pointer to the first or next +.I LIST_ENTRY +structre, respectively. +.PP +.BR LIST_HEAD_INITIALIZER () +returns an initializer that can be assigned to the list +.IR head . .SH CONFORMING TO Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008. Present on the BSDs (LIST macros first appeared in 4.4BSD). .SH BUGS +The macro +.BR LIST_FOREACH () +doesn't allow +.I var +to be removed or freed within the loop, +as it would interfere with the traversal. +The macro +.BR LIST_FOREACH_SAFE (), +which is not present in glibc, +solves this bug by +allowing to both remove +.I var +as well as free it from within the loop safely +without interfering with the traversal. .SH EXAMPLES .EX #include @@ -312,3 +343,5 @@ main(void) } .EE .SH SEE ALSO +.BR insque (3), +.BR queue (3)