diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-04-01 20:40:00 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-04-01 20:40:00 +0000 |
commit | 810f5285cd821bed9114d9d5c2b24eb521965dfb (patch) | |
tree | 277c41ca4c53c7f945d699e3cfb65e778e05414f | |
parent | 7859146b9a9d558cf4f3341b9a31e62894396128 (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.
-rw-r--r-- | lib/libc/arch/m88k/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/m88k/string/ffs.S | 16 | ||||
-rw-r--r-- | sys/lib/libkern/arch/m88k/Makefile.inc | 4 | ||||
-rw-r--r-- | sys/lib/libkern/arch/m88k/ffs.S | 16 |
4 files changed, 4 insertions, 36 deletions
diff --git a/lib/libc/arch/m88k/string/Makefile.inc b/lib/libc/arch/m88k/string/Makefile.inc index 7b2bddad6c5..918aa9c2789 100644 --- a/lib/libc/arch/m88k/string/Makefile.inc +++ b/lib/libc/arch/m88k/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.4 2004/01/26 20:05:29 miod Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2004/04/01 20:39:55 miod Exp $ # $NetBSD: Makefile.inc,v 1.1 1995/03/20 14:45:45 mycroft Exp $ -SRCS+= bcmp.c bcopy.c bzero.c ffs.S index.c memchr.c memcmp.c memset.c \ +SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memchr.c memcmp.c memset.c \ rindex.c strcat.c strcmp.c strcpy.c strcspn.c strlcpy.c strlen.c \ strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \ strspn.c strstr.c swab.c diff --git a/lib/libc/arch/m88k/string/ffs.S b/lib/libc/arch/m88k/string/ffs.S deleted file mode 100644 index b851d315749..00000000000 --- a/lib/libc/arch/m88k/string/ffs.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $OpenBSD: ffs.S,v 1.1 2004/01/26 20:05:29 miod Exp $ */ - -/* - * Written by Miodrag Vallat, 2004 - Public Domain - */ - -#include "DEFS.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 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 |