On 08/16/2013 01:46 PM, Richard Henderson wrote:
> On 08/16/2013 08:37 AM, Alex Williamson wrote:
>> On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote:
>>> On 08/16/2013 05:50 AM, Alex Williamson wrote:
>>>> +    /* Size must be a power of 2 */
>>>> +    if (l & (l - 1)) {
>>>> +        while (l & (access_size_max - 1)) {
>>>> +            access_size_max >>= 1;
>>>> +        }
>>>> +    }
>>>> +
>>>
>>> Why the loop at all?  x & -x extracts the lsb of x.
>>
>> l = 5, we want 4, not 1.  Thanks,
> 
> It still doesn't require a loop.
> 
>   l = 1 << (31 - clz32(l));

or even pow2floor() declared in qemu-common.h and implemented in
cutils.c.  No need to reinvent what we already have.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to