bitops.h patch
Hi Grant,
Thanks first for the help of previous patches :-)
And here is the final one for bitops.h suggested by Lamont for
2.6:
diff -Naur linux-2.6.0-test2.orig/include/asm-parisc/bitops.h linux-2.6.0-test2-b/include/asm-parisc/bitops.h
--- linux-2.6.0-test2.orig/include/asm-parisc/bitops.h 2003-08-05 19:24:18.000000000
+0200
+++ linux-2.6.0-test2-b/include/asm-parisc/bitops.h 2003-08-06 10:02:00.000000000
+0200
@@ -223,16 +223,31 @@
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
+ *
+ * This is a fast ffs version written by "LaMont Jones <[email protected]>"
*/
-static __inline__ unsigned long __ffs(unsigned long word)
-{
- unsigned long result = 0;
- while (!(word & 1UL)) {
- result++;
- word >>= 1;
- }
- return result;
+static __inline__ int __ffs(int x)
+{
+ int ret;
+ __asm__(" ldi 32,%1\n"
+ " extru,<> %0,31,16,%%r0\n"
+ " extru,TR %0,15,16,%0\n"
+ " addi -16,%1,%1\n"
+ " extru,<> %0,31,8,%%r0\n"
+ " extru,TR %0,23,8,%0\n"
+ " addi -8,%1,%1\n"
+ " extru,<> %0,31,4,%%r0\n"
+ " extru,TR %0,27,4,%0\n"
+ " addi -4,%1,%1\n"
+ " extru,<> %0,31,2,%%r0\n"
+ " extru,TR %0,29,2,%0\n"
+ " addi -2,%1,%1\n"
+ " extru,= %0,31,1,%%r0\n"
+ " addi -1,%1,%1\n"
+ : "=r" (x), "=r" (ret)
+ : "0" (x), "1" (ret));
+ return ret;
}
/*
================================================================================
If some interrest could you ci for me (I have no ci access)
Thanks in advance,
Joel
------------------------------------------------------
Soldes Tiscali ADSL : 27,50 euros/mois jusque fin 2003. On s'habitue vite à payer son ADSL moins cher!
Plus d'info? Cliquez ici... http://reg.tiscali.be/default.asp?lg=fr
include/asm-parisc/bitops.h +23 -8
@@ -223,16 +223,31 @@* @word: The word to search * * Undefined if no bit exists, so code should check against 0 first. +* +* This is a fast ffs version written by "LaMont Jones <[email protected]>" */ -static __inline__unsigned long __ffs (unsigned long word) -{ -unsigned long result =0 ; -while (!(word &1UL )) { - result++; - word >>=1 ; - } -return result; +static __inline__int __ffs (int x) +{ +int ret; + __asm__(" ldi 32,%1\n" +" extru,<> %0,31,16,%%r0\n" +" extru,TR %0,15,16,%0\n" +" addi -16,%1,%1\n" +" extru,<> %0,31,8,%%r0\n" +" extru,TR %0,23,8,%0\n" +" addi -8,%1,%1\n" +" extru,<> %0,31,4,%%r0\n" +" extru,TR %0,27,4,%0\n" +" addi -4,%1,%1\n" +" extru,<> %0,31,2,%%r0\n" +" extru,TR %0,29,2,%0\n" +" addi -2,%1,%1\n" +" extru,= %0,31,1,%%r0\n" +" addi -1,%1,%1\n" + :"=r" (x),"=r" (ret) + :"0" (x),"1" (ret)); +return ret; }/*
include/asm-parisc/bitops.h +38 -2
@@ -208,13 +208,49 @@#ifdef __KERNEL__ +/** +* __ffs - find first bit in word. +* @word: The word to search +* +* Undefined if no bit exists, so code should check against 0 first. +* +* This is a fast ffs version written by "LaMont Jones <[email protected]>" +*/ + +static __inline__int __ffs (int x) +{ +int ret; + __asm__(" ldi 32,%1\n" +" extru,<> %0,31,16,%%r0\n" +" extru,TR %0,15,16,%0\n" +" addi -16,%1,%1\n" +" extru,<> %0,31,8,%%r0\n" +" extru,TR %0,23,8,%0\n" +" addi -8,%1,%1\n" +" extru,<> %0,31,4,%%r0\n" +" extru,TR %0,27,4,%0\n" +" addi -4,%1,%1\n" +" extru,<> %0,31,2,%%r0\n" +" extru,TR %0,29,2,%0\n" +" addi -2,%1,%1\n" +" extru,= %0,31,1,%%r0\n" +" addi -1,%1,%1\n" + :"=r" (x),"=r" (ret) + :"0" (x),"1" (ret)); +return ret; +} +/* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). */ - -#define ffs (x) generic_ffs(x) +static __inline__int ffs (int x) +{ +if (!x) +return 0 ; +return __ffs ((unsigned long )x); +}/* * hweightN: returns the hamming weight (i.e. the number