Re: [2.6.6-BK] x86_64 has buggy ffs() implementation

From: H. Peter Anvin
Date: Wed May 12 2004 - 17:32:02 EST


Gabriel Paubert wrote:

Either I'm asleep or you are emulating bsrl, not bsfl. It
should rather be:

if ( y & 0x00000001) return 1;
if ( y & 0x00000002) return 2;
if ( y & 0x00000004) return 3;
...
if ( y & 0x80000000) return 32;
return 0;

No need for the else clauses either because of the return.
But maybe even __builtin_ffs(y) would work in this case.


If __builtin_ffs() works *AND HAS THE RIGHT SEMANTICS* it's probably the best thing to use.

Otherwise, yes, generic_ffs() can clearly be used inside the __builtin_constant_p() clause.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/