/* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion * on use of volatile and __*_bit() (set/clear/change): * *_bit() want use of volatile. * __*_bit() are "relaxed" and don't use spinlock or volatile.
*/
/** * __ffs - find first bit in word. returns 0 to "BITS_PER_LONG-1". * @word: The word to search * * __ffs() return is undefined if no bit is set. * * 32-bit fast __ffs by LaMont Jones "lamont At hp com". * 64-bit enhancement by Grant Grundler "grundler At parisc-linux org". * (with help from willy/jejb to get the semantics right) * * This algorithm avoids branches by making use of nullification. * One side effect of "extr" instructions is it sets PSW[N] bit. * How PSW[N] (nullify next insn) gets set is determined by the * "condition" field (eg "<>" or "TR" below) in the extr* insn. * Only the 1st and one of either the 2cd or 3rd insn will get executed. * Each set of 3 insn will get executed in 2 cycles on PA8x00 vs 16 or so * cycles for each mispredicted branch.
*/
/* * ffs: find first bit set. returns 1 to BITS_PER_LONG or 0 (if none 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).
*/ static __inline__ int ffs(int x)
{ return x ? (__ffs((unsignedlong)x) + 1) : 0;
}
/* * fls: find last (most significant) bit set. * fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
*/
static __inline__ int fls(unsignedint x)
{ int ret; if (!x) return 0;