From patchwork Sun Nov 12 11:26:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 79637 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 560FE385841B for ; Sun, 12 Nov 2023 11:27:21 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by sourceware.org (Postfix) with ESMTPS id A4F8F3858D37 for ; Sun, 12 Nov 2023 11:26:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4F8F3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A4F8F3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=145.40.73.55 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699788415; cv=none; b=iKLZrbqzqQW5jW0Anydb6wh0vrv+Z1PMmK6m9al7ge+v5pVWu9OK5soqHieSurCfL4ZD/tyXOwRv5bJT73NIY/ykz5+++RbHz5UZRne8p2sNSDlOYZffXqO+JhAsUppaT95MiOcSYTrkQ+cd4wn7gy2AdwStV2iCz+lVh87ZtPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699788415; c=relaxed/simple; bh=NvsLuhuzUB/V8+oiw9HqjyEG6qGrqTx6Grd0CLznoAk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=cXeW9+u6+TStWPOD0/ISEEcn3E6kEGpaGy/mwoWsrWeK5ZKRQuFMmw7mZMehjaPPk7XX81eMdmpoVVn3k8nrHQ+lCaCmaFJ2TJAoTHclRSzEk5BWTQ6Qoohb2TYJQj6AnOQ2TfFyx/CUW/cHBpIrE6DT24BzLLqb7SiCzjrQROM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 49794CE0C70; Sun, 12 Nov 2023 11:26:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ED8EC433C8; Sun, 12 Nov 2023 11:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699788409; bh=NvsLuhuzUB/V8+oiw9HqjyEG6qGrqTx6Grd0CLznoAk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=akTIHwTZChgXg2/JaCZ5nQz6pmbRpta9hyYmD3IP3w7yVmZ+PSWKqKZ6dfRGci6uV 3QY5lEDDBUgW0uo3GZhXHrHirwkPrE/MKu29LFMP+p34MiW3LdublA5OTXTPdti81e doHZ3tkOJVAMdfCz8XSmVy83VbFO44HYb2ptmycWrzDb+46ZMKH7hQFcPmY7pnw71k FnBygAYU3vV5pr1tG3JGRf5yRu2ZcxpuzDY7PiM3XDybEBzHnJ8Tb7f8mGR/7N4U5D h8de410Tzlbq28z+xv/IKKod/AdG5NlW8O6oyx4aeyogBXlYP1tu3AfHTdKK0gjqi3 c2QsSWx1ls+NA== Date: Sun, 12 Nov 2023 12:26:44 +0100 From: Alejandro Colomar To: linux-man@vger.kernel.org Cc: Alejandro Colomar , libc-alpha@sourceware.org, Guillem Jover , Paul Eggert , Jonny Grant , DJ Delorie , Matthew House , Oskari Pirhonen , Thorsten Kukuk , Adhemerval Zanella Netto , Zack Weinberg , "G. Branden Robinson" , Carlos O'Donell , Xi Ruoyao , Stefan Puiu , Andreas Schwab Subject: [PATCH v2 1/3] string_copying.7: BUGS: *cat(3) functions aren't always bad Message-ID: <20231112112629.13827-3-alx@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.42.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+patchwork=sourceware.org@sourceware.org The compiler will sometimes optimize them to normal *cpy(3) functions, since the length of dst is usually known, if the previous *cpy(3) is visible to the compiler. And they provide for cleaner code. If you know that they'll get optimized, you could use them. Cc: Paul Eggert Cc: Jonny Grant Cc: DJ Delorie Cc: Matthew House Cc: Oskari Pirhonen Cc: Thorsten Kukuk Cc: Adhemerval Zanella Netto Cc: Zack Weinberg Cc: "G. Branden Robinson" Cc: Carlos O'Donell Cc: Xi Ruoyao Cc: Stefan Puiu Cc: Andreas Schwab Signed-off-by: Alejandro Colomar --- man7/string_copying.7 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/man7/string_copying.7 b/man7/string_copying.7 index 1637ebc91..0254fbba6 100644 --- a/man7/string_copying.7 +++ b/man7/string_copying.7 @@ -592,8 +592,14 @@ .SH BUGS All catenation functions share the same performance problem: .UR https://www.joelonsoftware.com/\:2001/12/11/\:back\-to\-basics/ Shlemiel the painter .UE . +As a mitigation, +compilers are able to transform some calls to catenation functions +into normal copy functions, +since +.I strlen(dst) +is usually a byproduct of the previous copy. .\" ----- EXAMPLES :: -------------------------------------------------/ .SH EXAMPLES The following are examples of correct use of each of these functions. .\" ----- EXAMPLES :: stpcpy(3) ---------------------------------------/