Module Name:    src
Committed By:   matt
Date:           Thu Apr 22 17:50:31 UTC 2010

Modified Files:
        src/common/lib/libc/arch/mips/string [matt-nb5-mips64]: ffs.S

Log Message:
Fix mips32/mips64 versions of ffs.


To generate a diff of this commit:
cvs rdiff -u -r1.1.40.2 -r1.1.40.3 src/common/lib/libc/arch/mips/string/ffs.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/mips/string/ffs.S
diff -u src/common/lib/libc/arch/mips/string/ffs.S:1.1.40.2 src/common/lib/libc/arch/mips/string/ffs.S:1.1.40.3
--- src/common/lib/libc/arch/mips/string/ffs.S:1.1.40.2	Wed Apr 21 05:17:12 2010
+++ src/common/lib/libc/arch/mips/string/ffs.S	Thu Apr 22 17:50:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.S,v 1.1.40.2 2010/04/21 05:17:12 matt Exp $	*/
+/*	$NetBSD: ffs.S,v 1.1.40.3 2010/04/22 17:50:30 matt Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,7 +30,7 @@
 
 #include <mips/asm.h>
 
-RCSID("$NetBSD: ffs.S,v 1.1.40.2 2010/04/21 05:17:12 matt Exp $")
+RCSID("$NetBSD: ffs.S,v 1.1.40.3 2010/04/22 17:50:30 matt Exp $")
 
 /* bit = ffs(value) */
 
@@ -45,9 +45,11 @@
 	.set	mips32
 	li	v1, 32
 #if __mips == 64
-	sll	v0, a0, 0
+	sll	a0, a0, 0
 #endif
-	clz	v0, v0
+	negu	a1, a0
+	and	a0, a1
+	clz	v0, a0
 	j	ra
 	 subu	v0, v1, v0
 	.set	pop
@@ -55,6 +57,8 @@
 #if defined(_LP64) && __mips == 64
 LEAF(ffsl)
 	li	v1, 64
+	negu	a1, a0
+	and	a0, a1
 	dclz	v0, a0
 	j	ra
 	 subu	v0, v1, v0

Reply via email to