Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108960086
D42600.id130091.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D42600.id130091.diff
View Options
diff --git a/lib/libc/amd64/string/strcat.S b/lib/libc/amd64/string/strcat.S
--- a/lib/libc/amd64/string/strcat.S
+++ b/lib/libc/amd64/string/strcat.S
@@ -1,6 +1,14 @@
-/*
- * Written by J.T. Conklin <jtc@acorntoolworks.com>
- * Public domain.
+/*-
+ * Copyright (c) 2023, The FreeBSD Foundation
+ *
+ * SPDX-License-Expression: BSD-2-Clause
+ *
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * Adapted from NetBSD's common/lib/libc/arch/x86_64/string/strcat.S
+ * written by J.T. Conklin <jtc@acorntoolworks.com>
+ * that was originally dedicated to the public domain
*/
#include <machine/asm.h>
@@ -8,7 +16,14 @@
RCSID("$NetBSD: strcat.S,v 1.4 2004/07/26 18:51:21 drochner Exp $")
#endif
-ENTRY(strcat)
+#include "amd64_archlevel.h"
+
+ARCHFUNCS(strcat)
+ ARCHFUNC(strcat, scalar)
+ ARCHFUNC(strcat, baseline)
+ENDARCHFUNCS(strcat)
+
+ARCHENTRY(strcat, scalar)
movq %rdi,%rax
movabsq $0x0101010101010101,%r8
movabsq $0x8080808080808080,%r9
@@ -161,6 +176,28 @@
.Ldone:
ret
-END(strcat)
+ARCHEND(strcat, scalar)
+
+/*
+ * Call into strlen + strcpy if we have any SIMD at all.
+ * The scalar implementation above is better for the scalar
+ * case as it avoids the function call overhead, but pessimal
+ * if we could call SIMD routines instead.
+ */
+ARCHENTRY(strcat, baseline)
+ push %rbp
+ mov %rsp, %rbp
+ push %rsi
+ push %rbx
+ mov %rdi, %rbx # remember destination for later
+ call CNAME(strlen) # strlen(dest)
+ mov -8(%rbp), %rsi
+ lea (%rbx, %rax, 1), %rdi # dest + strlen(dest)
+ call CNAME(__stpcpy) # stpcpy(dest + strlen(dest), src)
+ mov %rbx, %rax # return dest
+ pop %rbx
+ leave
+ ret
+ARCHEND(strcat, baseline)
.section .note.GNU-stack,"",%progbits
diff --git a/share/man/man7/simd.7 b/share/man/man7/simd.7
--- a/share/man/man7/simd.7
+++ b/share/man/man7/simd.7
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE
.
-.Dd November 9, 2023
+.Dd November 14, 2023
.Dt SIMD 7
.Os
.Sh NAME
@@ -66,7 +66,7 @@
.It rindex Ta S Ta Ta S1 Ta S
.It stpcpy Ta Ta Ta S1
.It stpncpy Ta Ta Ta S1
-.It strcat Ta Ta Ta S Ta S
+.It strcat Ta Ta Ta S1 Ta S
.It strchr Ta S Ta Ta S1 Ta S
.It strchrnul Ta Ta Ta S1
.It strcmp Ta Ta S Ta S1 Ta S
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 31, 12:31 AM (8 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16349204
Default Alt Text
D42600.id130091.diff (2 KB)
Attached To
Mode
D42600: lib/libc/amd64/string/strcat.S: enable use of SIMD
Attached
Detach File
Event Timeline
Log In to Comment