diff -ur linux-/include/asm-i386/bitops.h linux/include/asm-i386/bitops.h --- linux-/include/asm-i386/bitops.h Thu Nov 22 20:46:18 2001 +++ linux/include/asm-i386/bitops.h Tue Mar 5 21:08:15 2002 @@ -316,6 +316,8 @@ return (offset + set + res); } +#include + /** * ffz - find first zero in word. * @word: The word to search @@ -447,13 +447,19 @@ */ static __inline__ int ffs(int x) { - int r; - - __asm__("bsfl %1,%0\n\t" - "jnz 1f\n\t" - "movl $-1,%0\n" - "1:" : "=r" (r) : "rm" (x)); - return r+1; + /* The generic_ffs function is used to avoid the asm when the + argument is a constant. */ + if (__builtin_constant_p (x)) { + return generic_ffs (x); + } else { + int r; + + __asm__("bsfl %1,%0\n\t" + "jnz 1f\n\t" + "movl $-1,%0\n" + "1:" : "=r" (r) : "rm" (x)); + return r+1; + } } /**