summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/aarch64/string/Makefile.inc4
-rw-r--r--lib/libc/arch/aarch64/string/ffs.S18
-rw-r--r--lib/libc/arch/powerpc/string/Makefile.inc4
-rw-r--r--lib/libc/arch/powerpc/string/ffs.S16
-rw-r--r--lib/libc/arch/powerpc64/string/Makefile.inc4
-rw-r--r--lib/libc/arch/powerpc64/string/ffs.S15
6 files changed, 55 insertions, 6 deletions
diff --git a/lib/libc/arch/aarch64/string/Makefile.inc b/lib/libc/arch/aarch64/string/Makefile.inc
index a44e1d0265e..2a65a8da0dd 100644
--- a/lib/libc/arch/aarch64/string/Makefile.inc
+++ b/lib/libc/arch/aarch64/string/Makefile.inc
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile.inc,v 1.1 2017/01/11 18:09:24 patrick Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2020/06/26 20:16:21 naddy Exp $
SRCS+= bcopy.c memcpy.c memmove.c \
strchr.c strrchr.c \
- bcmp.c bzero.c ffs.c memchr.c memcmp.c memset.c \
+ bcmp.c bzero.c ffs.S memchr.c memcmp.c memset.c \
strcmp.c strncmp.c \
strcat.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \
strncat.c strncpy.c strpbrk.c strsep.c \
diff --git a/lib/libc/arch/aarch64/string/ffs.S b/lib/libc/arch/aarch64/string/ffs.S
new file mode 100644
index 00000000000..94995c70110
--- /dev/null
+++ b/lib/libc/arch/aarch64/string/ffs.S
@@ -0,0 +1,18 @@
+/* $OpenBSD: ffs.S,v 1.1 2020/06/26 20:16:21 naddy Exp $ */
+/*
+ * Written by Christian Weisgerber <naddy@openbsd.org>.
+ * Public domain.
+ */
+
+#include "DEFS.h"
+
+ENTRY(ffs)
+ RETGUARD_SETUP(ffs, x15)
+ rbit w1, w0
+ clz w1, w1
+ cmp w0, wzr
+ csinc w0, wzr, w1, eq
+ RETGUARD_CHECK(ffs, x15)
+ ret
+END(ffs)
+.protected
diff --git a/lib/libc/arch/powerpc/string/Makefile.inc b/lib/libc/arch/powerpc/string/Makefile.inc
index 4a97429a2c3..065455f8679 100644
--- a/lib/libc/arch/powerpc/string/Makefile.inc
+++ b/lib/libc/arch/powerpc/string/Makefile.inc
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile.inc,v 1.6 2015/05/15 22:29:37 millert Exp $
+# $OpenBSD: Makefile.inc,v 1.7 2020/06/26 20:16:21 naddy Exp $
SRCS+= memcpy.c memmove.S \
strchr.c strrchr.c \
- bcmp.c bzero.c ffs.c memchr.c memcmp.c memset.c strcat.c \
+ bcmp.c bzero.c ffs.S memchr.c memcmp.c memset.c strcat.c \
strcmp.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \
strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
strspn.c strstr.c swab.c
diff --git a/lib/libc/arch/powerpc/string/ffs.S b/lib/libc/arch/powerpc/string/ffs.S
new file mode 100644
index 00000000000..d7091526d41
--- /dev/null
+++ b/lib/libc/arch/powerpc/string/ffs.S
@@ -0,0 +1,16 @@
+/* $OpenBSD: ffs.S,v 1.1 2020/06/26 20:16:21 naddy Exp $ */
+/*
+ * Written by Christian Weisgerber <naddy@openbsd.org>.
+ * Public domain.
+ */
+
+#include "SYS.h"
+
+ENTRY(ffs)
+ neg %r4, %r3
+ and %r3, %r3, %r4
+ cntlzw %r3, %r3
+ subfic %r3, %r3, 32
+ blr
+END(ffs)
+.protected
diff --git a/lib/libc/arch/powerpc64/string/Makefile.inc b/lib/libc/arch/powerpc64/string/Makefile.inc
index da0411aa36e..ba6e9dde0e5 100644
--- a/lib/libc/arch/powerpc64/string/Makefile.inc
+++ b/lib/libc/arch/powerpc64/string/Makefile.inc
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile.inc,v 1.1 2020/06/25 02:34:22 drahn Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2020/06/26 20:16:21 naddy Exp $
SRCS+= memcpy.c memmove.S \
strchr.c strrchr.c \
- bcmp.c bzero.c ffs.c memchr.c memcmp.c memset.c strcat.c \
+ bcmp.c bzero.c ffs.S memchr.c memcmp.c memset.c strcat.c \
strcmp.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \
strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
strspn.c strstr.c swab.c
diff --git a/lib/libc/arch/powerpc64/string/ffs.S b/lib/libc/arch/powerpc64/string/ffs.S
new file mode 100644
index 00000000000..8e656698ec9
--- /dev/null
+++ b/lib/libc/arch/powerpc64/string/ffs.S
@@ -0,0 +1,15 @@
+/* $OpenBSD: ffs.S,v 1.1 2020/06/26 20:16:21 naddy Exp $ */
+/*
+ * Written by Christian Weisgerber <naddy@openbsd.org>.
+ * Public domain.
+ */
+
+#include "DEFS.h"
+
+ENTRY(ffs)
+ neg %r4, %r3
+ and %r3, %r3, %r4
+ cntlzw %r3, %r3
+ subfic %r3, %r3, 32
+ blr
+END_BUILTIN(ffs)