From nobody Wed Jan 24 19:44:57 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TKvYk4Q0bz58bwZ; Wed, 24 Jan 2024 19:44:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TKvYk14ylz466C; Wed, 24 Jan 2024 19:44:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/KNHCKWigf3ZQqUg7dOq2O730bQzuyuMN82qINC674M=; b=IuzoU2qOLq/4vFTfSkAIO5NoOrz5PpqXr36I783YqftiwOXY5rZDfU5qGltg8sdRZpzkhs dXEI25En9v7ocZBXzP7BMmiQjaT39tPxqnQFLF/F/LSg1Iv0xCvBsLI0msy0kXJTXT0mUw PWJnHsLNPdR2MnUw+5ms1pzew2Srl9OmsZJDmeaJKE55bw0t5Rnj8/X4XJcI7xJcoPrwEH HWawbfWCk5P+Gr3zx7zGGlNHVwBPGBSucfA2P+OywU+UEP5dd8johCHVTJuKsWO+AOVZlB +xgNeiUIf3mzBR5nZvcJPLEA4I4MCrac+zT+GGHbBuVDknesAR6GW+6Z4+qEhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/KNHCKWigf3ZQqUg7dOq2O730bQzuyuMN82qINC674M=; b=pETBZ7QH1AeDdjBohhKtPiUCl+reLPsh5DqiW9nilnnGZBUkcjBKYbiZ+6wNDUawDOBDbo H9lPfnGZx7Z5WDHWQfcBM6bnsx5eJ94rNI2aTYubuWSWVNke1x7+2td3WWw58luQlsREOR B0tNUKkIyuyvmppKy6xfIAzKWFQSMu1vQBpS7CP/9DJpfrKVLWO9/XQYP4nKyOSM4RsZ6q mO6XiMs1Ft/bPAqQiSSqiIVz2pq6iXMsDhcjCsILqvYDBZrsSa+5tLhEKbR2JjqgcYyGkT nd8L/qhvLVX7FJvhoLaj2zxiosshpbj85YlbJ7yDz/Tg2KGZhhXGwkdGjArs2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706125498; a=rsa-sha256; cv=none; b=DktKAtOdiFyYa0a0oBdop934IPBfzYDqMxxXZUlU5pU3jk+7iMAPxHwBPuqB88dgLcKRpP RX1lJMausEKeYc4jllKIR6ci/EKijtGZSzLqGnFTQ5d8jagTk7gNKRKAJCp9vJl6iDvIOh 9BPfvaWWDrrh6rzalySS1MuErM+grwi/in5bdnFZMLVyBCjHFVb9P4f9yNJqZZhPRzsHOS Ae/kPzl+3EVHuxvYcRHHGC9brW2bipQf1KTdb/lewU5/H6sXNErL/h2Pt7FJH4bp5pN157 S7Yga5ZORwQRm927TIP3r84HHNQdlPyTuLDpO6/9HzCjL5L6Aed1+1DaaaY7Ng== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TKvYk0BQFzS8x; Wed, 24 Jan 2024 19:44:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40OJivk8006025; Wed, 24 Jan 2024 19:44:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40OJivu6006022; Wed, 24 Jan 2024 19:44:57 GMT (envelope-from git) Date: Wed, 24 Jan 2024 19:44:57 GMT Message-Id: <202401241944.40OJivu6006022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Clausecker Subject: git: 667fa9c40483 - stable/14 - lib/libc/string: document restrict qualification of memccpy() arguments List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 667fa9c40483f2c844a7960780e9567be4e581d5 Auto-Submitted: auto-generated The branch stable/14 has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=667fa9c40483f2c844a7960780e9567be4e581d5 commit 667fa9c40483f2c844a7960780e9567be4e581d5 Author: Robert Clausecker AuthorDate: 2023-12-05 14:03:28 +0000 Commit: Robert Clausecker CommitDate: 2024-01-24 19:39:30 +0000 lib/libc/string: document restrict qualification of memccpy() arguments POSIX.1-2004 and the upcoming C23 agree that memccpy()'s arguments are restrict qualified and must not overlap. In 2002, restrict qualifiers were added to 's declaration of the function. Make things official and document that the arguments must not overlap. See also: 61b60edfd3fff20f884419f8097870c7045315c9 Approved by: kib MFC after: 1 month MFC to: stable/14 (cherry picked from commit e0d4f419ac41aa91b862f3ceadc32a86abf08572) --- lib/libc/string/bstring.3 | 10 ++++++++-- lib/libc/string/memccpy.3 | 33 ++++++++++++++++++++++++++++++--- lib/libc/string/memccpy.c | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lib/libc/string/bstring.3 b/lib/libc/string/bstring.3 index cb29a6db6b14..bb1a0505fafd 100644 --- a/lib/libc/string/bstring.3 +++ b/lib/libc/string/bstring.3 @@ -29,7 +29,7 @@ .\" .\" @(#)bstring.3 8.1 (Berkeley) 6/4/93 .\" -.Dd June 4, 1993 +.Dd December 5, 2023 .Dt BSTRING 3 .Os .Sh NAME @@ -58,7 +58,12 @@ .Ft int .Fn memcmp "const void *b1" "const void *b2" "size_t len" .Ft void * -.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Fo memccpy +.Fa "void * restrict dst" +.Fa "const void * restrict src" +.Fa "int c" +.Fa "size_t len" +.Fc .Ft void * .Fn memcpy "void *dst" "const void *src" "size_t len" .Ft void * @@ -80,6 +85,7 @@ See the specific manual pages for more information. .Xr memccpy 3 , .Xr memchr 3 , .Xr memcmp 3 , +.Xr memccpy 3 , .Xr memcpy 3 , .Xr memmove 3 , .Xr memset 3 diff --git a/lib/libc/string/memccpy.3 b/lib/libc/string/memccpy.3 index fb2409ada846..fe543d9172d3 100644 --- a/lib/libc/string/memccpy.3 +++ b/lib/libc/string/memccpy.3 @@ -27,7 +27,7 @@ .\" .\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93 .\" -.Dd June 9, 1993 +.Dd December 5, 2023 .Dt MEMCCPY 3 .Os .Sh NAME @@ -38,7 +38,12 @@ .Sh SYNOPSIS .In string.h .Ft void * -.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Fo memccpy +.Fa "void * restrict dst" +.Fa "const void * restrict src" +.Fa "int c" +.Fa "size_t len" +.Fc .Sh DESCRIPTION The .Fn memccpy @@ -61,13 +66,35 @@ is returned. Otherwise, .Fa len bytes are copied, and a NULL pointer is returned. +If +.Fa src +and +.Fa dst +overlap, behavior is undefined. .Sh SEE ALSO .Xr bcopy 3 , .Xr memcpy 3 , .Xr memmove 3 , .Xr strcpy 3 +.Sh STANDARDS +The +.Fn memccpy +function conforms to +.St -p1003.1-2004 +and +.\" St -isoC-2024 . +ISO/IEC 9899:2024 (\(lqISO\~C23\(rq). .Sh HISTORY The .Fn memccpy function first appeared in -.Bx 4.4 . +.Bx 4.4 +and was first specified in the +.\" St -svid1 . +System\~V Interface Definition, First Edition (\(lqSVID1\(rq). +The +.Ft restrict +keyword was added to the prototype in +.Fx 5.0.0 +in accordance with the updated specification of +.St -p1003.1-2004 . diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c index fd080d4293f4..5ef2dd6567ca 100644 --- a/lib/libc/string/memccpy.c +++ b/lib/libc/string/memccpy.c @@ -35,7 +35,7 @@ static char sccsid[] = "@(#)memccpy.c 8.1 (Berkeley) 6/4/93"; #include void * -memccpy(void *t, const void *f, int c, size_t n) +memccpy(void * restrict t, const void * restrict f, int c, size_t n) { if (n) {