From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm96L-0003Hr-Py for qemu-devel@nongnu.org; Tue, 03 Jul 2012 15:49:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sm96H-0007LS-2h for qemu-devel@nongnu.org; Tue, 03 Jul 2012 15:49:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm96G-0007L4-Q1 for qemu-devel@nongnu.org; Tue, 03 Jul 2012 15:49:29 -0400 Message-ID: <4FF34CB8.8070008@redhat.com> Date: Tue, 03 Jul 2012 13:49:12 -0600 From: Eric Blake MIME-Version: 1.0 References: <1341323574-23206-1-git-send-email-owasserm@redhat.com> <1341323574-23206-5-git-send-email-owasserm@redhat.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigDCC3F9D2165C1AB6B2D3D59C" 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: Blue Swirl Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, Petter Svard , stefanha@gmail.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, Orit Wasserman , Benoit Hudzia , avi@redhat.com, Aidan Shribman , pbonzini@redhat.com, chegu_vinod@hp.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDCC3F9D2165C1AB6B2D3D59C Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 &=3D ~(1 << (ffs(value) - 1)); >=20 > ffs() only uses 'int', not int64_t. ffsl() is not universally availabl= e. >=20 >> + } >> + 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 =3D 0x8000000000000000ULL >> clz64(value); } return value; } since clz64() is already part of qemu sources. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigDCC3F9D2165C1AB6B2D3D59C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP80y5AAoJEKeha0olJ0NqLHkH/jCFv2vyoqy8wdS5valMCxP6 Pu4rWtDNmCMqpbNGHW/sETem8qv3KOOAmD+g8nIIquGYyXiTuWlteMhJoDApg2Oh lmK1PIfArxA+Ldg3qN+dkOL7y00KaZJwdXm6/8bXxTsaO0gJfNjZ3E6MFf8I6D/a Y8Ca0I1VqMUy+Lf2A2jkFSS47fZlDQpS/07ZM/CRByILo533+qWq5hEQh9SqtFIt 1ZzaHTG3B8auzSaIEuYJFVVBhtgrv81uvNcmhtZJ8u2foE5eLhTJR6ctALLyoIbQ bLT+taD4BHMbtLICLeYTy9lG8gq2Pefydzl82+E03BTl3Sttlkm6lhBpBhPeEOk= =wP84 -----END PGP SIGNATURE----- --------------enigDCC3F9D2165C1AB6B2D3D59C--