wineport: Use a lookup table to make our slow ffs() a bit faster.

Dan Kegel dank at
Fri Mar 11 07:51:27 CST 2011

Do you actually have a system that doesn't have HAVE_FFS set?

On my machine,

int main(int argc, char **argv)
   return ffs(argc);

compiles to

       pushl   %ebp
       movl    %esp, %ebp
       movl    $-1, %edx
       bsfl    8(%ebp), %eax
       cmove   %edx, %eax
       addl    $1, %eax
       popl    %ebp

which is probably pretty fast.

Large lookup tables can dirty the L1 cache and slow other things down.

See also

More information about the wine-devel mailing list