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

This patch requires D46170 as it depends on strlcpy being labeled
__memccpy.

It's a direct copy from the amd64 string functions.

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

View file

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

View file

@ -0,0 +1,29 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2023 Robert Clausecker
*/
#include <sys/cdefs.h>
#include <string.h>
void *__memccpy(void *restrict, const void *restrict, int, size_t);
char *
strncat(char *dest, const char *src, size_t n)
{
size_t len;
char *endptr;
len = strlen(dest);
endptr = __memccpy(dest + len, src, '\0', n);
/* avoid an extra branch */
if (endptr == NULL)
endptr = dest + len + n + 1;
endptr[-1] = '\0';
return (dest);
}