[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling functions
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling functions |
Date: |
Tue, 03 Jul 2012 13:49:12 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
On 07/03/2012 01:23 PM, Blue Swirl wrote:
>> +
>> +static inline int64_t round2pow2(int64_t value)
round up or down?
>> +{
>> + while (!is_power_of_2(value)) {
>> + value &= ~(1 << (ffs(value) - 1));
>
> ffs() only uses 'int', not int64_t. ffsl() is not universally available.
>
>> + }
>> + return value;
>> +}
Not to mention that iterating one bit at a time is inefficient. We
already gave you several more efficient solutions; my favorite being:
static inline int64_t pow2floor(int64_t value)
{
if (!is_power_of_2(value)) {
value = 0x8000000000000000ULL >> clz64(value);
}
return value;
}
since clz64() is already part of qemu sources.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v14 03/13] Add XBZRLE documentation, (continued)
- [Qemu-devel] [PATCH v14 07/13] Add debugging infrastructure, Orit Wasserman, 2012/07/03
- [Qemu-devel] [PATCH v14 06/13] Add save_block_hdr function, Orit Wasserman, 2012/07/03
- [Qemu-devel] [PATCH v14 01/13] Add MigrationParams structure, Orit Wasserman, 2012/07/03
- [Qemu-devel] [PATCH v14 08/13] Change ram_save_block to return -1 if there are no more changes, Orit Wasserman, 2012/07/03
- [Qemu-devel] [PATCH v14 04/13] Add cache handling functions, Orit Wasserman, 2012/07/03
- Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling functions, Eric Blake, 2012/07/03
- [Qemu-devel] [PATCH v14 10/13] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions, Orit Wasserman, 2012/07/03
- Re: [Qemu-devel] [PATCH v14 10/13] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions, Orit Wasserman, 2012/07/04
- Re: [Qemu-devel] [PATCH v14 10/13] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions, Eric Blake, 2012/07/04
[Qemu-devel] [PATCH v14 05/13] Add uleb encoding/decoding functions, Orit Wasserman, 2012/07/03