[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] bitops: unify bitops_ffsl with the one in host-
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] bitops: unify bitops_ffsl with the one in host-utils.h |
Date: |
Wed, 30 Jan 2013 21:58:23 +0000 |
On 30 January 2013 21:51, Eric Blake <address@hidden> 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