On 30 January 2013 21:51, Eric Blake <ebl...@redhat.com> wrote: > On 01/30/2013 01:41 PM, Peter Maydell wrote: >> This reimplementation appears to have an off by one error. >> For example, on an input of 4, the old algorithm returns 2 >> and this one returns 3. > > Ouch - you are right that the old implementation is indeed a ctz() > instead of an ffs() operation. That means we need to fix all callers of > bitops_ffsl() to either use ffsl semantics, or to add a bitops_ctzl() > that provides the old behavior.
Mmm, it's all a bit confusing. My suggestion to try to clean this up in the longer term (ie not necessarily for 1.4) is: * make sure our function names and semantics line up with the gcc builtin definitions (adjusting callers as needed) * put the bit operations all in bitops.h rather than split between there and host-utils.h -- PMM