|
From: | Orit Wasserman |
Subject: | Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling functions |
Date: | Wed, 04 Jul 2012 10:04:59 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |