Here's what is there now.
static inline unsigned long log2(unsigned long x)
{
unsigned long r = 0;
__asm__(
"bsrl %1, %0\n\t"
"jnz 1f\n\t"
"movl $-1, %0\n\t"
"1:\n\t"
: "=r" (r) : "g" (x));
return r;
}
Unless there are objections I'd like to put this in C code because:
- I'm getting assembly errors
- It's non-portable code
- I don't think we need the potential performance boost that much.
Comments?
ron
- Re: bitops.h Ronald G Minnich
- Re: bitops.h Ronald G Minnich
