git: 79287d783c72 - main - lib/libc/aarch64/string: strcat enable use of SIMD

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Fri, 10 Jan 2025 15:03:52 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/src/commit/?id=79287d783c72f95eb47c26dbfdfca279086e16a9

commit 79287d783c72f95eb47c26dbfdfca279086e16a9
Author:     Getz Mikalsen <getz@FreeBSD.org>
AuthorDate: 2024-08-26 18:14:15 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2025-01-10 15:02:40 +0000

    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(-)

diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc
index 996a2fd45bc0..0b2974947389 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 000000000000..c70875be1c1a
--- /dev/null
+++ b/lib/libc/aarch64/string/strcat.c
@@ -0,0 +1,20 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <string.h>
+
+#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);
+}