]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
lib/libc/amd64/string: add strlcpy scalar, baseline implementation
authorRobert Clausecker <fuz@FreeBSD.org>
Sun, 12 Nov 2023 22:47:06 +0000 (17:47 -0500)
committerRobert Clausecker <fuz@FreeBSD.org>
Mon, 25 Dec 2023 13:56:05 +0000 (14:56 +0100)
commit74d6cfad54d676299ee5e4695139461876dfd757
tree3e78bf059a86811cd624ed68f1d5882381e63782
parentf7098b8659923873a7c60b64cb68182e470786f9
lib/libc/amd64/string: add strlcpy scalar, baseline implementation

Somewhat similar to stpncpy, but different in that we need to compute
the full source length even if the buffer is shorter than the source.

strlcat is implemented as a simple wrapper around strlcpy.  The scalar
implementation of strlcpy just calls into strlen() and memcpy() to do
the job.

Perf-wise we're very close to stpncpy.  The code is slightly slower as
it needs to carry on with finding the source string length even if the
buffer ends before the string.

Sponsored by: The FreeBSD Foundation
Tested by: developers@, exp-run
Approved by: mjg
MFC after: 1 month
MFC to: stable/14
PR: 275785
Differential Revision: https://reviews.freebsd.org/D42863
lib/libc/amd64/string/Makefile.inc
lib/libc/amd64/string/strlcpy.S [new file with mode: 0644]