From 11363da8f5a6e1cc5e09463609b4b06d8302582a Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 25 Sep 2006 23:32:07 -0700 Subject: [PATCH] --- yaml --- r: 35646 b: refs/heads/master c: 92fc707208bb2e601c24b5ab65db37bcb361b658 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/asm-frv/bitops.h | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 195cec01e73c..499ec34f3f73 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: af8c65b57aaa4ae321af34dbfc5ca7f5625263fe +refs/heads/master: 92fc707208bb2e601c24b5ab65db37bcb361b658 diff --git a/trunk/include/asm-frv/bitops.h b/trunk/include/asm-frv/bitops.h index 980ae1b0cd28..97fb746f76c7 100644 --- a/trunk/include/asm-frv/bitops.h +++ b/trunk/include/asm-frv/bitops.h @@ -161,16 +161,29 @@ static inline int __test_bit(int nr, const volatile void * addr) #include #include -/* - * fls: find last bit set. +/** + * fls - find last bit set + * @x: the word to search + * + * This is defined the same way as ffs: + * - return 32..1 to indicate bit 31..0 most significant bit set + * - return 0 to indicate no bits set */ #define fls(x) \ ({ \ int bit; \ \ - asm("scan %1,gr0,%0" : "=r"(bit) : "r"(x)); \ + asm(" subcc %1,gr0,gr0,icc0 \n" \ + " ckne icc0,cc4 \n" \ + " cscan.p %1,gr0,%0 ,cc4,#1 \n" \ + " csub %0,%0,%0 ,cc4,#0 \n" \ + " csub %2,%0,%0 ,cc4,#1 \n" \ + : "=&r"(bit) \ + : "r"(x), "r"(32) \ + : "icc0", "cc4" \ + ); \ \ - bit ? 33 - bit : bit; \ + bit; \ }) #include