Skip to content

Commit

Permalink
xtensa: define __fls
Browse files Browse the repository at this point in the history
Like fls, but can't be handed 0 and returns the bit number.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Rusty Russell committed Jan 3, 2009
1 parent 5c134da commit 5ece5c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/asm-xtensa/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ static inline int fls (unsigned int x)
return 32 - __cntlz(x);
}

/**
* __fls - find last (most-significant) set bit in a long word
* @word: the word to search
*
* Undefined if no set bit exists, so code should check against 0 first.
*/
static inline unsigned long __fls(unsigned long word)
{
return 31 - __cntlz(word);
}
#else

/* Use the generic implementation if we don't have the nsa/nsau instructions. */
Expand All @@ -90,6 +100,7 @@ static inline int fls (unsigned int x)
# include <asm-generic/bitops/__ffs.h>
# include <asm-generic/bitops/ffz.h>
# include <asm-generic/bitops/fls.h>
# include <asm-generic/bitops/__fls.h>

#endif

Expand Down

0 comments on commit 5ece5c5

Please sign in to comment.