HomeFreeBSD

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

Description

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

Based on the strlcpy code from D42863, this patch adds a SIMD-enhanced
implementation of memccpy for amd64. A scalar implementation calling
into memchr and memcpy to do the job is provided, too.

Please note that this code does not behave exactly the same as the C
implementation of memccpy for overlapping inputs. However, overlapping
inputs are not allowed for this function by ISO/IEC 9899:1999 and neither
has the C implementation any code to deal with the possibility. It just
proceeds byte-by-byte, which may or may not do the expected thing for
some overlaps. We do not document whether overlapping inputs are
supported in memccpy(3).

Tested by: developers@, exp-run
Approved by: mjg
MFC after: 1 month
MFC to: stable/14
PR: 275785
Differential Revision: https://reviews.freebsd.org/D42902

(cherry picked from commit fc0e38a7a67a6d43095efb00cf19ee5f95dcf710)

Details

Provenance
fuzAuthored on Dec 2 2023, 12:28 PM
Differential Revision
D42902: lib/libc/amd64/string: add memccpy, strncat scalar, baseline implementations
Parents
rGde2d155d2cac: lib/libc/tests/string: add unit tests for memccpy()
Branches
Unknown
Tags
Unknown