git: 3dc5429158cf - main - lib/libc/aarch64/string: add strncat SIMD implementation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 10 Jan 2025 15:03:57 UTC
The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=3dc5429158cf221374cdbd0bbb728962bff4fb76 commit 3dc5429158cf221374cdbd0bbb728962bff4fb76 Author: Getz Mikalsen <getz@FreeBSD.org> AuthorDate: 2024-08-26 18:15:34 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2025-01-10 15:02:40 +0000 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 --- lib/libc/aarch64/string/Makefile.inc | 3 ++- lib/libc/aarch64/string/strncat.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc index 78145a17ab85..876ef4257b4c 100644 --- a/lib/libc/aarch64/string/Makefile.inc +++ b/lib/libc/aarch64/string/Makefile.inc @@ -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 diff --git a/lib/libc/aarch64/string/strncat.c b/lib/libc/aarch64/string/strncat.c new file mode 100644 index 000000000000..33b278ac5e04 --- /dev/null +++ b/lib/libc/aarch64/string/strncat.c @@ -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); +}