From nobody Mon Dec 25 14:26:04 2023 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 4SzKvc3dwSz54nJ9; Mon, 25 Dec 2023 14:26:04 +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 4SzKvc283Nz3NF4; Mon, 25 Dec 2023 14:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703514364; 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=tgy1vWvJyfeTJNcyS7M3ZMcgHnWNcG1wBtan1hmrSDs=; b=ZHWUwtFDGzsJUwEVCNSrsQ5IoQZomf3cU9EP85XWBD35zK4NF+Lexogtmn9DV9hlnEgjx7 QBYq04hUPbeG07JuFfOqQHyNZz6V+nygy2TGI1bkG/+TAG8qFCracx+A7QThpouZgqD+VH weJdnUNYr08+e5+80nJT8E4aKhGNC/qSVPCjPS006zS7oB4q3PYVYxegHMwUMzxqHlcy44 r6Kt0AWNg9zKUmIpyRWR1Tzk+fyKuPwewhPMih30Zo7VQ+VYUL8wEWRGJEB3cpLCNSkZ6L TnZrK5dwMHD7/7XiTbXkeju6+nStfOth44PnRhN6Sp72/fFbYw0qybNFNWRy+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703514364; a=rsa-sha256; cv=none; b=maGCDeGubDeEPKpRE03tHeUe6eXXrqNJ82tl+nUfDpy0NnXFSzOzl18twXjP5Ixc+WtVbz oqd1OS7WYnsiTSADg3n5RJeCybLvHfbe6WktWIP/QBwRymgGoS42uAAgqplPx4D6R7/ek/ hQ9AdNLE3g4BAITy8/YU9wjFWem9mKh8b6mdN3BtSnxKMh1tQenWYtZZnCcq1qofD6Kv4p 2s9JVm9fQJ2Bd0+WMhZm7rJamrpnvGncn5bAkL2nkpqlulcsiH7FGnGvADUJGOGBbp/MTw gtbidMxSgLAFCR+6Dsd+PXXypPIW34vUpEOzO86H+7OgPEAaYJk7Mc+3ovGffg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703514364; 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=tgy1vWvJyfeTJNcyS7M3ZMcgHnWNcG1wBtan1hmrSDs=; b=eIYc5QWp4uLhDz99gT9LkTEfIfuEZy1d4GxVtG2ugXOBmyo0x73t77JHbH6I7kac57O/Ot jJbqzWAz9NjATzdGLJNQUMCA4ISRkrMzovHiz3bun0VxTKRhY7m3El0UoHFBhRQsx+TaM3 78MmjXIHDr6Adg6pOB8VqkX9nwD1W7zRVJyu5+rD2zFNo0gQFtSMnJRaud3CPkzShVziCD jkGciBChcGJ30c5Z8yK2QLtCZmaLvYbd8Pmj8+FWK+NG9CHVcLPMMsvLaE7ZaCMCV6vqqm gwx/aAxgedY51+17ejMuQeOr5HW1wCxrorpP6z1uZTwI2p7GTUBaBONVmbuNtQ== 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 4SzKvc1GCrz4t; Mon, 25 Dec 2023 14:26:04 +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 3BPEQ4WC023943; Mon, 25 Dec 2023 14:26:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BPEQ4bM023940; Mon, 25 Dec 2023 14:26:04 GMT (envelope-from git) Date: Mon, 25 Dec 2023 14:26:04 GMT Message-Id: <202312251426.3BPEQ4bM023940@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Clausecker Subject: git: e0d4f419ac41 - main - 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/main X-Git-Reftype: branch X-Git-Commit: e0d4f419ac41aa91b862f3ceadc32a86abf08572 Auto-Submitted: auto-generated The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=e0d4f419ac41aa91b862f3ceadc32a86abf08572 commit e0d4f419ac41aa91b862f3ceadc32a86abf08572 Author: Robert Clausecker AuthorDate: 2023-12-05 14:03:28 +0000 Commit: Robert Clausecker CommitDate: 2023-12-25 13:59:50 +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 --- 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 fd976c7676b7..91603fe6dbac 100644 --- a/lib/libc/string/bstring.3 +++ b/lib/libc/string/bstring.3 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 4, 1993 +.Dd December 5, 2023 .Dt BSTRING 3 .Os .Sh NAME @@ -56,7 +56,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 * @@ -78,6 +83,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 ce8d5f65ac93..3bdae24354c1 100644 --- a/lib/libc/string/memccpy.3 +++ b/lib/libc/string/memccpy.3 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 9, 1993 +.Dd December 5, 2023 .Dt MEMCCPY 3 .Os .Sh NAME @@ -36,7 +36,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 @@ -59,13 +64,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 174824ba2393..d6a446503eb6 100644 --- a/lib/libc/string/memccpy.c +++ b/lib/libc/string/memccpy.c @@ -32,7 +32,7 @@ #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) {