summaryrefslogtreecommitdiff
path: root/sys/lib/libkern/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-01-21 14:28:37 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-01-21 14:28:37 +0000
commite0ef38ea9d2b1ba6f8a109cf0b41d51ba36abe33 (patch)
treecfbc5052e05b64ee10b4e27ae95dfc6e2a898222 /sys/lib/libkern/arch
parentf807dd695246f05c1b579f844a9a8df3b7db37e6 (diff)
A faster ffs() routine based upon the ff1 assembly instruction.
Diffstat (limited to 'sys/lib/libkern/arch')
-rw-r--r--sys/lib/libkern/arch/m88k/Makefile.inc5
-rw-r--r--sys/lib/libkern/arch/m88k/ffs.S16
2 files changed, 18 insertions, 3 deletions
diff --git a/sys/lib/libkern/arch/m88k/Makefile.inc b/sys/lib/libkern/arch/m88k/Makefile.inc
index 981b6ce386d..953cb7d5684 100644
--- a/sys/lib/libkern/arch/m88k/Makefile.inc
+++ b/sys/lib/libkern/arch/m88k/Makefile.inc
@@ -1,7 +1,6 @@
-# $OpenBSD: Makefile.inc,v 1.6 2003/06/01 17:00:30 deraadt Exp $
-# $NetBSD: Makefile.inc,v 1.2 1996/04/13 01:17:58 cgd Exp $
+# $OpenBSD: Makefile.inc,v 1.7 2004/01/21 14:28:36 miod Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
memchr.c memcmp.c memset.c bcmp.c random.c \
strcmp.c strlcat.c strlcpy.c strlen.c strncmp.c \
- strncpy.c scanc.c skpc.c strncasecmp.c ffs.c
+ strncpy.c scanc.c skpc.c strncasecmp.c ffs.S
diff --git a/sys/lib/libkern/arch/m88k/ffs.S b/sys/lib/libkern/arch/m88k/ffs.S
new file mode 100644
index 00000000000..fedb6481cb2
--- /dev/null
+++ b/sys/lib/libkern/arch/m88k/ffs.S
@@ -0,0 +1,16 @@
+/* $OpenBSD: ffs.S,v 1.1 2004/01/21 14:28:36 miod Exp $ */
+
+/*
+ * Written by Miodrag Vallat, 2004 - Public Domain
+ */
+
+#include <machine/asm.h>
+
+ENTRY(ffs)
+ bcnd eq0, r2, 1f ! ff1(0) = 32, treat differently
+ ff1 r3, r2
+ jmp.n r1
+ add r2, r3, 1 ! ff1 returns 0-31, need to increment
+1:
+ jmp.n r1
+ or r2, r0, r0