From 79287d783c72f95eb47c26dbfdfca279086e16a9 Mon Sep 17 00:00:00 2001 From: Getz Mikalsen Date: Mon, 26 Aug 2024 20:14:15 +0200 Subject: [PATCH] lib/libc/aarch64/string: strcat enable use of SIMD Call into SIMD strlen and stpcpy for an optimized strcat. Port of D42600 for amd64. Tested by: fuz (exprun) Reviewed by: fuz, emaste Sponsored by: Google LLC (GSoC 2024) PR: 281175 Differential Revision: https://reviews.freebsd.org/D46417 --- lib/libc/aarch64/string/Makefile.inc | 3 ++- lib/libc/aarch64/string/strcat.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 lib/libc/aarch64/string/strcat.c diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc index 996a2fd45bc..0b297494738 100644 --- a/lib/libc/aarch64/string/Makefile.inc +++ b/lib/libc/aarch64/string/Makefile.inc @@ -25,7 +25,8 @@ MDSRCS+= \ strspn.S \ strcspn.S \ strpbrk.c \ - strsep.c + strsep.c \ + strcat.c # # Add the above functions. Generate an asm file that includes the needed diff --git a/lib/libc/aarch64/string/strcat.c b/lib/libc/aarch64/string/strcat.c new file mode 100644 index 00000000000..c70875be1c1 --- /dev/null +++ b/lib/libc/aarch64/string/strcat.c @@ -0,0 +1,20 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Getz Mikalsen +*/ + +#include + +#undef strcat /* _FORTIFY_SOURCE */ + +char * +strcat(char * __restrict s, const char * __restrict append) +{ + char *save = s; + + /* call into SIMD optimized functions */ + stpcpy(s + strlen(s), append); + + return(save); +}