On 07/03/2012 10:49 PM, Eric Blake wrote: > 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. > I will fix it
- [Qemu-devel] [PATCH v14 06/13] Add save_block_hdr function Orit Wasserman
- [Qemu-devel] [PATCH v14 05/13] Add uleb encoding/decoding f... Orit Wasserman
- [Qemu-devel] [PATCH v14 08/13] Change ram_save_block to ret... Orit Wasserman
- [Qemu-devel] [PATCH v14 11/13] Add XBZRLE to ram_save_block... Orit Wasserman
- [Qemu-devel] [PATCH v14 09/13] Add migration_end function Orit Wasserman
- [Qemu-devel] [PATCH v14 04/13] Add cache handling functions Orit Wasserman
- Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling ... Blue Swirl
- Re: [Qemu-devel] [PATCH v14 04/13] Add cache handl... Eric Blake
- Re: [Qemu-devel] [PATCH v14 04/13] Add cache h... Orit Wasserman
- Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling ... Eric Blake
- [Qemu-devel] [PATCH v14 02/13] Add migration capabilities Orit Wasserman
- [Qemu-devel] [PATCH v14 13/13] Add XBZRLE statistics Orit Wasserman
- [Qemu-devel] [PATCH v14 01/13] Add MigrationParams structur... Orit Wasserman
- [Qemu-devel] [PATCH v14 12/13] Add set_cachesize command Orit Wasserman
- [Qemu-devel] [PATCH v14 10/13] Add xbzrle_encode_buffer and... Orit Wasserman