On the PowerPC there is an instruction called 'cntlzw' - count leading
zeros word which does the above.
something like the following, but take it with a grain of salt since
I've never done any PowerPC programming before and I don't have a
machine to test this on.
extern __inline__ int ffs(int x)
{
int result;
asm ("cntlzw %0,%1" : "=r" (result) : "r" (x));
return 32 - result; /* IBM backwards ordering of bits */
}
astor
-- Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway http://www.guardian.no/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu