[parisc-linux] bitops.h patch
Joel Soete
jsoe0708@tiscali.be
Wed, 6 Aug 2003 10:23:59 +0200
--========/3F2E54A800000406/mail.tiscali.be
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
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 <lamont@hp.com>"
*/
-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
--========/3F2E54A800000406/mail.tiscali.be
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Bitops-2.6.patch"
ZGlmZiAtTmF1ciBsaW51eC0yLjYuMC10ZXN0Mi5vcmlnL2luY2x1ZGUvYXNtLXBhcmlzYy9iaXRv
cHMuaCBsaW51eC0yLjYuMC10ZXN0Mi1iL2luY2x1ZGUvYXNtLXBhcmlzYy9iaXRvcHMuaAotLS0g
bGludXgtMi42LjAtdGVzdDIub3JpZy9pbmNsdWRlL2FzbS1wYXJpc2MvYml0b3BzLmgJMjAwMy0w
OC0wNSAxOToyNDoxOC4wMDAwMDAwMDAgKzAyMDAKKysrIGxpbnV4LTIuNi4wLXRlc3QyLWIvaW5j
bHVkZS9hc20tcGFyaXNjL2JpdG9wcy5oCTIwMDMtMDgtMDYgMTA6MDI6MDAuMDAwMDAwMDAwICsw
MjAwCkBAIC0yMjMsMTYgKzIyMywzMSBAQAogICogQHdvcmQ6IFRoZSB3b3JkIHRvIHNlYXJjaAog
ICoKICAqIFVuZGVmaW5lZCBpZiBubyBiaXQgZXhpc3RzLCBzbyBjb2RlIHNob3VsZCBjaGVjayBh
Z2FpbnN0IDAgZmlyc3QuCisgKgorICogVGhpcyBpcyBhIGZhc3QgZmZzIHZlcnNpb24gd3JpdHRl
biBieSAiTGFNb250IEpvbmVzIDxsYW1vbnRAaHAuY29tPiIKICAqLwotc3RhdGljIF9faW5saW5l
X18gdW5zaWduZWQgbG9uZyBfX2Zmcyh1bnNpZ25lZCBsb25nIHdvcmQpCi17Ci0JdW5zaWduZWQg
bG9uZyByZXN1bHQgPSAwOwogCi0Jd2hpbGUgKCEod29yZCAmIDFVTCkpIHsKLQkJcmVzdWx0Kys7
Ci0JCXdvcmQgPj49IDE7Ci0JfQotCXJldHVybiByZXN1bHQ7CitzdGF0aWMgX19pbmxpbmVfXyBp
bnQgX19mZnMoaW50IHgpCit7CisJaW50IHJldDsKKwlfX2FzbV9fKCIgbGRpICAgIDMyLCUxXG4i
CisJCSIgZXh0cnUsPD4gICUwLDMxLDE2LCUlcjBcbiIKKwkJIiBleHRydSxUUiAgJTAsMTUsMTYs
JTBcbiIKKwkJIiBhZGRpICAgIC0xNiwlMSwlMVxuIgorCQkiIGV4dHJ1LDw+ICAlMCwzMSw4LCUl
cjBcbiIKKwkJIiBleHRydSxUUiAgJTAsMjMsOCwlMFxuIgorCQkiIGFkZGkgICAgLTgsJTEsJTFc
biIKKwkJIiBleHRydSw8PiAgJTAsMzEsNCwlJXIwXG4iCisJCSIgZXh0cnUsVFIgICUwLDI3LDQs
JTBcbiIKKwkJIiBhZGRpICAgIC00LCUxLCUxXG4iCisJCSIgZXh0cnUsPD4gICUwLDMxLDIsJSVy
MFxuIgorCQkiIGV4dHJ1LFRSICAlMCwyOSwyLCUwXG4iCisJCSIgYWRkaSAgICAtMiwlMSwlMVxu
IgorCQkiIGV4dHJ1LD0gICUwLDMxLDEsJSVyMFxuIgorCQkiIGFkZGkgICAgLTEsJTEsJTFcbiIK
KwkJOiAiPXIiICh4KSwgIj1yIiAocmV0KQorCQk6ICIwIiAoeCksICIxIiAocmV0KSk7CisJcmV0
dXJuIHJldDsKIH0KIAogLyoK
--========/3F2E54A800000406/mail.tiscali.be
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Bitops-2.4.patch"
ZGlmZiAtTmF1ciBsaW51eC0yLjQuMjEtcGE5Lm9yaWcvaW5jbHVkZS9hc20tcGFyaXNjL2JpdG9w
cy5oIGxpbnV4LTIuNC4yMS1wYTktYi9pbmNsdWRlL2FzbS1wYXJpc2MvYml0b3BzLmgKLS0tIGxp
bnV4LTIuNC4yMS1wYTkub3JpZy9pbmNsdWRlL2FzbS1wYXJpc2MvYml0b3BzLmgJMjAwMy0wOC0w
NSAxOToxNzozNy4wMDAwMDAwMDAgKzAyMDAKKysrIGxpbnV4LTIuNC4yMS1wYTktYi9pbmNsdWRl
L2FzbS1wYXJp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