lkml.org 
[lkml]   [2006]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/7] FRV: Fix fls() to handle bit 31 being set correctly [try #3]
    Date
    From: David Howells <dhowells@redhat.com>

    Fix FRV fls() to handle bit 31 being set correctly (it should return 32 not 0).

    Signed-Off-By: David Howells <dhowells@redhat.com>
    ---

    include/asm-frv/bitops.h | 21 +++++++++++++++++----
    1 files changed, 17 insertions(+), 4 deletions(-)

    diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
    index 980ae1b..97fb746 100644
    --- a/include/asm-frv/bitops.h
    +++ b/include/asm-frv/bitops.h
    @@ -161,16 +161,29 @@ #include <asm-generic/bitops/ffs.h>
    #include <asm-generic/bitops/__ffs.h>
    #include <asm-generic/bitops/find.h>

    -/*
    - * 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 <asm-generic/bitops/fls64.h>
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-09-13 20:39    [W:3.030 / U:0.896 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site