summaryrefslogtreecommitdiff
path: root/sys/lib/libkern
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-04-01 20:40:00 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-04-01 20:40:00 +0000
commit810f5285cd821bed9114d9d5c2b24eb521965dfb (patch)
tree277c41ca4c53c7f945d699e3cfb65e778e05414f /sys/lib/libkern
parent7859146b9a9d558cf4f3341b9a31e62894396128 (diff)
It turns out that the so-called fast ffs(3) routines were wrong, as soon as
more than one bit is set, as the ff1 instruction counts from the highest order. However, gcc/m88k with optimization enabled would use a correct, short sequence based upon ff1 and tweaks, to achieve the intended result, hence i did not catch this flaw initially. So revert to the C implementation - it is correct, still decently fast, and will only be used when compiling at -O0.
Diffstat (limited to 'sys/lib/libkern')
-rw-r--r--sys/lib/libkern/arch/m88k/Makefile.inc4
-rw-r--r--sys/lib/libkern/arch/m88k/ffs.S16
2 files changed, 2 insertions, 18 deletions
diff --git a/sys/lib/libkern/arch/m88k/Makefile.inc b/sys/lib/libkern/arch/m88k/Makefile.inc
index 953cb7d5684..d34437d10d7 100644
--- a/sys/lib/libkern/arch/m88k/Makefile.inc
+++ b/sys/lib/libkern/arch/m88k/Makefile.inc
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile.inc,v 1.7 2004/01/21 14:28:36 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.8 2004/04/01 20:39:59 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.S
+ strncpy.c scanc.c skpc.c strncasecmp.c ffs.c
diff --git a/sys/lib/libkern/arch/m88k/ffs.S b/sys/lib/libkern/arch/m88k/ffs.S
deleted file mode 100644
index aca0ca50381..00000000000
--- a/sys/lib/libkern/arch/m88k/ffs.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* $OpenBSD: ffs.S,v 1.2 2004/01/22 20:39:06 deraadt 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