mirror of
https://github.com/opnsense/src.git
synced 2026-06-17 12:41:39 -04:00
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:
parent
bad17991c0
commit
3dc5429158
2 changed files with 31 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
29
lib/libc/aarch64/string/strncat.c
Normal file
29
lib/libc/aarch64/string/strncat.c
Normal 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);
|
||||
}
|
||||
Loading…
Reference in a new issue