From patchwork Sun Oct 25 09:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40863 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 CB0793887004; Sun, 25 Oct 2020 09:37:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB0793887004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603618644; bh=z/M70yZJhqYIUP8P4knVSoIbgEPd1mftgBf9Tc7ZVfE=; 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=Xr6YnTJkXY4dZb2KvR6+lpX0c+AMq7k7CmD3MgQzfjPpqvjGNkiQuuXzj4KDMGzKv GZSVpoYE/tBUKq9+PlrcRkpogyAOPctyZzzM252PZE/IzmfUMM0zuGm8HZbJ/0A7x3 kYsXp9PyJiAeywLfLDRZJKtv+3ZSFHiIxfBEb/Rc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by sourceware.org (Postfix) with ESMTPS id 2D7F9388187D for ; Sun, 25 Oct 2020 09:37:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2D7F9388187D Received: by mail-wm1-x343.google.com with SMTP id l15so9084018wmi.3 for ; Sun, 25 Oct 2020 02:37:22 -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=z/M70yZJhqYIUP8P4knVSoIbgEPd1mftgBf9Tc7ZVfE=; b=hHmdS8QMSR20sJFjwgW1sJkaSEvJfzlvorG4y0b0o++YUoElRbcwY4f8YEWorWZ8yU KGGVTq5vXNbdUS4W9e2TwcJThLAyYamWHeaD/a0LS75zA+QuJ7LPBBha8rCZHkf4cV55 RcljvZbXTMqP8VrTrbV8iGu7OgdFxUXUq/2kMW9A4aYElJt/mTVQxr+2mNRI0bGjtiq4 855jj4M1wJhnxBVWUSyX8Ig7oedLNhhuzr9ku+8QxcM8wOgQl8LmSm1ZwrVvECIRBiWB gD/Iacofm8Y/jGIuItjOjJdfnBo/53vcP3ZIoftyQYJsVsA/anu7ZCLOp8kqH5HaG6qP QUFQ== X-Gm-Message-State: AOAM531PlNM+U4rmk2h04GHT3pgTpU+VklCNhYV2aRd0SqCMpcYgx3J7 UNmg2aJ+W39XA/C7um4PQ7Q= X-Google-Smtp-Source: ABdhPJydBeUheDg0iXm3iV2S3SdEBu6muTtnJu8sBWeoitm2VXAt61ZV7wwSUGZ3bL23ZFFyZxtcmQ== X-Received: by 2002:a1c:2581:: with SMTP id l123mr10723213wml.169.1603618641356; Sun, 25 Oct 2020 02:37:21 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id m8sm15776446wrw.17.2020.10.25.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 02:37:20 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH 08/10] tailq.3: Add remaining details to complete the page Date: Sun, 25 Oct 2020 10:36:50 +0100 Message-Id: <20201025093651.4616-9-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201025093651.4616-1-colomar.6.4.3@gmail.com> References: <20201025093651.4616-1-colomar.6.4.3@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 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" Signed-off-by: Alejandro Colomar --- man3/tailq.3 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/man3/tailq.3 b/man3/tailq.3 index e38cc7e86..cac4a9c3f 100644 --- a/man3/tailq.3 +++ b/man3/tailq.3 @@ -55,6 +55,7 @@ TAILQ_NEXT, TAILQ_PREV, TAILQ_REMOVE .\"TAILQ_SWAP +\- implementation of a doubly-linked tail queue .SH SYNOPSIS .nf .B #include sys/queue.h @@ -110,6 +111,7 @@ TAILQ_REMOVE .\" .PP .\" .BI "void TAILQ_SWAP(TAILQ_HEAD *" head1 ", TAILQ_HEAD *" head2 ", TYPE, TAILQ_ENTRY " NAME ");" .SH DESCRIPTION +These macros define and operate on doubly-linked tail queues. .PP In the macro definitions, .I TYPE @@ -336,11 +338,44 @@ from the tail queue. .\" and .\" .IR head2 . .SH RETURN VALUE +.BR TAILQ_EMPTY () +returns nonzero if the queue is empty, +and zero if the queue contains at least one entry. +.PP +.BR TAILQ_FIRST (), +.BR TAILQ_LAST (), +.BR TAILQ_NEXT (), +and +.BR TAILQ_PREV () +return a pointer to the first, last, next or previous +.I TYPE +structure, respectively. +.PP +.BR TAILQ_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. (TAILQ functions first appeared in 4.4BSD). .SH BUGS +The macros +.BR TAILQ_FOREACH () +and +.BR TAILQ_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 TAILQ_FOREACH_SAFE () +and +.BR TAILQ_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 @@ -398,3 +433,5 @@ main(void) } .EE .SH SEE ALSO +.BR insque (3), +.BR queue (3)