summaryrefslogtreecommitdiffstats
path: root/sys/lib/libkern/arch
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2004-04-01 20:39:55 +0000
committermiod <miod@openbsd.org>2004-04-01 20:39:55 +0000
commitd84580875301d99e4ccd8f1d9f79a515bdec1167 (patch)
tree998cb9b1ed71dba764dcc29855b69b3809d7b4d2 /sys/lib/libkern/arch
parentaudio/x-vorbis, ok henning@ (diff)
downloadwireguard-openbsd-d84580875301d99e4ccd8f1d9f79a515bdec1167.tar.xz
wireguard-openbsd-d84580875301d99e4ccd8f1d9f79a515bdec1167.zip
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/arch')
-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