summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/amd64/string
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2004-01-28 01:44:44 +0000
committermickey <mickey@openbsd.org>2004-01-28 01:44:44 +0000
commit118f6189edb47d41d3a0badafe95d9585c0d1c57 (patch)
treec3faff936ba5ff911d7de4701203333f4e180b66 /lib/libc/arch/amd64/string
parentan amd64 arch support. (diff)
downloadwireguard-openbsd-118f6189edb47d41d3a0badafe95d9585c0d1c57.tar.xz
wireguard-openbsd-118f6189edb47d41d3a0badafe95d9585c0d1c57.zip
things for amd64; from art@
Diffstat (limited to 'lib/libc/arch/amd64/string')
-rw-r--r--lib/libc/arch/amd64/string/Makefile.inc6
-rw-r--r--lib/libc/arch/amd64/string/ffs.S18
-rw-r--r--lib/libc/arch/amd64/string/strlen.S18
3 files changed, 42 insertions, 0 deletions
diff --git a/lib/libc/arch/amd64/string/Makefile.inc b/lib/libc/arch/amd64/string/Makefile.inc
new file mode 100644
index 00000000000..002194e1d8c
--- /dev/null
+++ b/lib/libc/arch/amd64/string/Makefile.inc
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile.inc,v 1.1 2004/01/28 01:44:45 mickey Exp $
+
+SRCS+= bcmp.c ffs.S index.c memchr.c memcmp.c bcopy.c bzero.c \
+ rindex.c strcat.c strcmp.c strcpy.c strcspn.c strlen.S \
+ strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
+ strspn.c strstr.c swab.c memset.c strlcpy.c strlcat.c
diff --git a/lib/libc/arch/amd64/string/ffs.S b/lib/libc/arch/amd64/string/ffs.S
new file mode 100644
index 00000000000..2666bc49e9d
--- /dev/null
+++ b/lib/libc/arch/amd64/string/ffs.S
@@ -0,0 +1,18 @@
+/* $OpenBSD: ffs.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
+ */
+
+#include <machine/asm.h>
+
+ENTRY(ffs)
+ bsfl %edi,%eax
+ jz L1 /* ZF is set if all bits are 0 */
+ incl %eax /* bits numbered from 1, not 0 */
+ ret
+
+ _ALIGN_TEXT
+L1: xorl %eax,%eax /* clear result */
+ ret
diff --git a/lib/libc/arch/amd64/string/strlen.S b/lib/libc/arch/amd64/string/strlen.S
new file mode 100644
index 00000000000..3afccb8f1ac
--- /dev/null
+++ b/lib/libc/arch/amd64/string/strlen.S
@@ -0,0 +1,18 @@
+/* $OpenBSD: strlen.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
+ */
+
+#include <machine/asm.h>
+
+ENTRY(strlen)
+ cld /* set search forward */
+ xorl %eax,%eax /* set search for null terminator */
+ movq $-1,%rcx /* set search for lots of characters */
+ repne /* search! */
+ scasb
+ notq %rcx /* get length by taking complement */
+ leaq -1(%rcx),%rax /* and subtracting one */
+ ret