From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A13775235 for ; Sun, 12 Nov 2023 09:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K7U32jJf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DA06C433C8; Sun, 12 Nov 2023 09:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699780685; bh=4OZ5pjlZcOR5C1mMy/ZMLW5UGIj/eQsxRwe+fNCiBwQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K7U32jJf3Ol59lo24w9UxsPoZbVkqZLuCB2kHDLSXt6uTUhFGY+FlipEmmKNzVgO2 vviuui4yAkODSHm7yeaupebbs3/ThSjJMsDJO7TvGhaDvK9Rc1qoPCY0vW8sKz51Gx A1p3ad6EOaKsCInNWcvPxn9qEZmsPgvuoBTgZgnynDLJFh0I8iohptXlW0Hc8gR6oI qlUyaHxf7gg9SrNwU8uS5tojo1ueumRMaEyNAypLKOGh+yqT4DxWi7G/52/sNXNMvj hRWQz+IsAYqUlHIoO+fnkIWhswcGThq2q53pki2e3EkeyW1SfqvJQ26YWvv0AaJzPt 8nHrUD7i1IL+Q== Date: Sun, 12 Nov 2023 10:18:00 +0100 From: Alejandro Colomar To: linux-man@vger.kernel.org Cc: Alejandro Colomar , libc-alpha@sourceware.org, 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 1/2] string_copying.7: BUGS: *cat(3) functions aren't always bad Message-ID: <20231112091748.6906-3-alx@kernel.org> References: Precedence: bulk X-Mailing-List: linux-man@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="DfMLUrktnfbmmkbw" Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.42.0 --DfMLUrktnfbmmkbw Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Sun, 12 Nov 2023 10:18:00 +0100 From: Alejandro Colomar To: linux-man@vger.kernel.org Cc: Alejandro Colomar , libc-alpha@sourceware.org, 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 1/2] string_copying.7: BUGS: *cat(3) functions aren't always bad 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) ---------------------------------------/ --=20 2.42.0 --DfMLUrktnfbmmkbw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmVQmEgACgkQnowa+77/ 2zJN6g/9FN3se87VRWESy6dfZGg/AgsFLmgLT/Dnd2P1OJj46zhQy7tE8lldC7Tm EaZzOo9ZUVMMmvNLJyUlBoD9IoijnvzG7mC5plHkF8uA2/xmtqcU3qUcI3hV7DPL RYD8itDJRm27oBrcmSYhdxb6h2i5NBuGLGtqiGlVWAkmaoFDUu3d+0581LAQrXkc nrd35nzxk6U9q24wYFXcYeJgCbtjojUjONo6OXqAV62b3tK2C/SxXjXru+C4wj3J i06Ip3i8VN+vEYmati5LroUACEcpvQaU7bWDP3ncoTHo5i/UThaSwihmBr6VYoTw U7egtAh1US76SMI06Eo2oE5erffjcifPOBzTq+LSHCzgIYXyAK6Tg1zsMWhigNpu fJEFUZn3T3GxmAthtTl8Xbmb5mn1JZwWwzjgMMg6Ka3R8wUZNDOKabR94XJaOQod Iz2bp20dOATElMsRzSd6AqFvtuz+g8lRsyHTL+eNhKrQlL0owiYKSoAIgqzAiWse nOlJTCmYp4BiK3d3Hz4MwgAB4YntVItlzAdYYzwckle1sQo6MxNEkX+iyLvZBB3s qx4Ub9WXOLjiT8+r4hqu89WMFoXdw9agW0uSIo8acLYNfah2b7teOuOH73b2zha9 303JRIbmS4SE+7Ss1hrnF+5KbsrfNmw9u5j0QFH4g/oo2OG2Y+s= =dooF -----END PGP SIGNATURE----- --DfMLUrktnfbmmkbw--