HomeFreeBSD

lib/libc/amd64/string: add strlcpy scalar, baseline implementation

Description

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

(cherry picked from commit 74d6cfad54d676299ee5e4695139461876dfd757)

Details

Provenance
fuzAuthored on Nov 12 2023, 10:47 PM
Differential Revision
D42863: lib/libc/amd64/string: add strlcpy scalar/baseline implementation
Parents
rGf5d63ae20d65: lib/libc/tests/string: add unit test for strlcpy
Branches
Unknown
Tags
Unknown