lib/libc/aarch64/string: add strlcat SIMD implementation

This patch requires D46243 as it depends on strlcpy being labeled
__strlcpy.

It's a direct copy from the amd64 string functions using memchr and
strlcpy to implement strlcat.

Tested by:	fuz (exprun)
Reviewed by:	fuz, emaste
Sponsored by:	Google LLC (GSoC 2024)
PR:		281175
Differential Revision: https://reviews.freebsd.org/D46272
This commit is contained in:
Getz Mikalsen 2024-08-26 23:10:16 +02:00 committed by Robert Clausecker
parent 3dc5429158
commit bea89d038a
3 changed files with 31 additions and 1 deletions

View file

@ -29,7 +29,8 @@ MDSRCS+= \
strlcpy.S \
strncmp.S \
memccpy.S \
strncat.c
strncat.c \
strlcat.c
#
# Add the above functions. Generate an asm file that includes the needed

View file

@ -0,0 +1,4 @@
.weak memchr
.set memchr, __memchr_aarch64
#include "aarch64/memchr.S"

View file

@ -0,0 +1,25 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2023 Robert Clausecker
*/
#include <sys/cdefs.h>
#include <string.h>
void *__memchr_aarch64(const void *, int, size_t);
size_t __strlcpy(char *restrict, const char *restrict, size_t);
size_t
strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
{
char *loc = __memchr_aarch64(dst, '\0', dstsize);
if (loc != NULL) {
size_t dstlen = (size_t)(loc - dst);
return (dstlen + __strlcpy(loc, src, dstsize - dstlen));
} else
return (dstsize + strlen(src));
}