From patchwork Mon Jul 29 11:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 1965959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DFYMbwGx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXbz54LqGz1yf4 for ; Mon, 29 Jul 2024 21:41:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE9663858D37 for ; Mon, 29 Jul 2024 11:41:03 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id EBC603858D37 for ; Mon, 29 Jul 2024 11:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBC603858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EBC603858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722253249; cv=none; b=jdZJFFOyf45j1SJAgQGvY8l/iq2jHhkpo0BfvLI42thy5AxylP9D7iNqwBQLMGoFaiZnVPtftUdRuaztoABvVw0WwMyTLsZjvjLVl8ufFc8bG98nw7v9sNPOvDQjh6t9Cenv6qich2OB/D8fjODYIlyzk4IrvYMJkfz4Qy80GgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722253249; c=relaxed/simple; bh=gRrIb8fOmswxKa44vX014yWWugAdSlkkh/UBUrAiI1U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qPkMDDPYgzNdYUE6YUCZUAZOBuEqfSkD1k8MIEJ2gCCATY8+kNcUG0OpBimYpy/GpU41fEzzAylqFF3I+NtjIb+AHSU6JAVrkVZQOBFF/G4RiU4O+bmHCKo4Wc3fccn2fN2E3nxfwVDQ9w6HO9Ds85rFDgVKE0C68JSqR0YrHSg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722253247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WD30e+R7o6Q/bQ9Mtc+18w1UqMpqpuQ13NeC0x0wVQU=; b=DFYMbwGx8xSzNPXs9ChwIVRrPdarEXZI8R83xq0mwAJlvcezru6MM/aD7cgcxthVj5CWZW J/eeQ7fC0jaGLN2ZwCiWZsN1fcmquRZvb5U4fxPj7q2U5TzXuULD1Xc5EEn814T53TCnsj 1l/hdxDQFZ6X41JmITOYRhr6W4gyaDM= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-f0x1ylDMMNu2DPpaxNOZxw-1; Mon, 29 Jul 2024 07:40:46 -0400 X-MC-Unique: f0x1ylDMMNu2DPpaxNOZxw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8ED181955D48 for ; Mon, 29 Jul 2024 11:40:45 +0000 (UTC) Received: from x1carbon9g.redhat.com (unknown [10.45.224.228]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96A96195605F; Mon, 29 Jul 2024 11:40:43 +0000 (UTC) From: Arjun Shankar To: libc-alpha@sourceware.org Cc: Arjun Shankar Subject: [PATCH] manual/stdio: Clarify putc and putwc Date: Mon, 29 Jul 2024 13:40:34 +0200 Message-ID: <20240729114034.50894-1-arjun@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org The manual entry for `putc' described what "most systems" do instead of describing the glibc implementation and its guarantees. This commit fixes that by warning that putc may be implemented as a macro that double-evaluates `stream'. Even though the current `putc' implementation does not double-evaluate `stream', offering this obscure guarantee as an extension to what POSIX allows does not seem very useful. The entry for `putwc' is also edited to bring it in line with `putc'. --- manual/stdio.texi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/manual/stdio.texi b/manual/stdio.texi index f5e289d58a..c3066114d2 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -903,21 +903,23 @@ This function is a GNU extension. @deftypefun int putc (int @var{c}, FILE *@var{stream}) @standards{ISO, stdio.h} @safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}} -This is just like @code{fputc}, except that most systems implement it as +This is just like @code{fputc}, except that it may be implemented as a macro, making it faster. One consequence is that it may evaluate the @var{stream} argument more than once, which is an exception to the -general rule for macros. @code{putc} is usually the best function to -use for writing a single character. +general rule for macros. Therefore, @var{stream} should never be an +expression with side-effects. @code{putc} is usually the best function +to use for writing a single character. @end deftypefun @deftypefun wint_t putwc (wchar_t @var{wc}, FILE *@var{stream}) @standards{ISO, wchar.h} @safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}} -This is just like @code{fputwc}, except that it can be implement as +This is just like @code{fputwc}, except that it may be implemented as a macro, making it faster. One consequence is that it may evaluate the @var{stream} argument more than once, which is an exception to the -general rule for macros. @code{putwc} is usually the best function to -use for writing a single wide character. +general rule for macros. Therefore, @var{stream} should never be an +expression with side-effects. @code{putwc} is usually the best function +to use for writing a single wide character. @end deftypefun @deftypefun int putc_unlocked (int @var{c}, FILE *@var{stream})