From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmJe5-0000gS-Tt for qemu-devel@nongnu.org; Wed, 04 Jul 2012 03:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmJe3-0003hu-Gp for qemu-devel@nongnu.org; Wed, 04 Jul 2012 03:05:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmJe3-0003dS-2j for qemu-devel@nongnu.org; Wed, 04 Jul 2012 03:05:03 -0400 Message-ID: <4FF3EB1B.4020105@redhat.com> Date: Wed, 04 Jul 2012 10:04:59 +0300 From: Orit Wasserman MIME-Version: 1.0 References: <1341323574-23206-1-git-send-email-owasserm@redhat.com> <1341323574-23206-5-git-send-email-owasserm@redhat.com> <4FF34CB8.8070008@redhat.com> In-Reply-To: <4FF34CB8.8070008@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v14 04/13] Add cache handling functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, Blue Swirl , Petter Svard , Benoit Hudzia , avi@redhat.com, Aidan Shribman , pbonzini@redhat.com, chegu_vinod@hp.com 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