diff options
Diffstat (limited to 'include/asm-i386/bitops.h')
-rw-r--r-- | include/asm-i386/bitops.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 4807aa1d2e3d..65679aca4b22 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h | |||
@@ -332,9 +332,9 @@ static inline unsigned long __ffs(unsigned long word) | |||
332 | * Returns the bit-number of the first set bit, not the number of the byte | 332 | * Returns the bit-number of the first set bit, not the number of the byte |
333 | * containing a bit. | 333 | * containing a bit. |
334 | */ | 334 | */ |
335 | static inline int find_first_bit(const unsigned long *addr, unsigned size) | 335 | static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) |
336 | { | 336 | { |
337 | int x = 0; | 337 | unsigned x = 0; |
338 | 338 | ||
339 | while (x < size) { | 339 | while (x < size) { |
340 | unsigned long val = *addr++; | 340 | unsigned long val = *addr++; |
@@ -367,11 +367,6 @@ static inline unsigned long ffz(unsigned long word) | |||
367 | return word; | 367 | return word; |
368 | } | 368 | } |
369 | 369 | ||
370 | /* | ||
371 | * fls: find last bit set. | ||
372 | */ | ||
373 | |||
374 | #define fls(x) generic_fls(x) | ||
375 | #define fls64(x) generic_fls64(x) | 370 | #define fls64(x) generic_fls64(x) |
376 | 371 | ||
377 | #ifdef __KERNEL__ | 372 | #ifdef __KERNEL__ |
@@ -415,6 +410,23 @@ static inline int ffs(int x) | |||
415 | } | 410 | } |
416 | 411 | ||
417 | /** | 412 | /** |
413 | * fls - find last bit set | ||
414 | * @x: the word to search | ||
415 | * | ||
416 | * This is defined the same way as ffs. | ||
417 | */ | ||
418 | static inline int fls(int x) | ||
419 | { | ||
420 | int r; | ||
421 | |||
422 | __asm__("bsrl %1,%0\n\t" | ||
423 | "jnz 1f\n\t" | ||
424 | "movl $-1,%0\n" | ||
425 | "1:" : "=r" (r) : "rm" (x)); | ||
426 | return r+1; | ||
427 | } | ||
428 | |||
429 | /** | ||
418 | * hweightN - returns the hamming weight of a N-bit word | 430 | * hweightN - returns the hamming weight of a N-bit word |
419 | * @x: the word to weigh | 431 | * @x: the word to weigh |
420 | * | 432 | * |