Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MMGLs-0002kb-Kk for qemu-devel@nongnu.org; Thu, 02 Jul 2009 03:05:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MMGLo-0002h5-6Y for qemu-devel@nongnu.org; Thu, 02 Jul 2009 03:05:00 -0400 Received: from [199.232.76.173] (port=33076 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMGLo-0002h2-3M for qemu-devel@nongnu.org; Thu, 02 Jul 2009 03:04:56 -0400 Received: from mx20.gnu.org ([199.232.41.8]:45907) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MMGLn-0008LZ-Db for qemu-devel@nongnu.org; Thu, 02 Jul 2009 03:04:55 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MMGLl-00062z-PI for qemu-devel@nongnu.org; Thu, 02 Jul 2009 03:04:54 -0400 Message-ID: <4A4C5C0E.2050502@web.de> Date: Thu, 02 Jul 2009 09:04:46 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4A4BC57E.504@web.de> <4A4BC87A.6050005@web.de> <4A4BCD26.2060102@web.de> <20090701205802.GA11286@codesourcery.com> <20090701230216.GA14043@miranda.arrow> In-Reply-To: <20090701230216.GA14043@miranda.arrow> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig573A790A5BF71C50C9B5B9FA" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] Use ctz64 in favor of ffsll List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stuart Brady Cc: Anthony Liguori , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig573A790A5BF71C50C9B5B9FA Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Stuart Brady wrote: > On Wed, Jul 01, 2009 at 01:58:02PM -0700, Nathan Froyd wrote: >> On Wed, Jul 01, 2009 at 10:55:02PM +0200, Jan Kiszka wrote: >>> - for (i =3D 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { >>> - bit =3D ffsll(env->interrupt_bitmap[i]); >>> + for (i =3D 0; i < sizeof(env->interrupt_bitmap) / sizeof(int); i= ++) { >>> + /* Note: This assumes little endian host, which is true in K= VM mode. >>> + In TCG mode it must be zero anyway. */ >>> + bit =3D ffs(((int *)env->interrupt_bitmap)[i]); >> ISTR that some PPC hosts support KVM... >=20 > FWIW, I notice we currently have a qemu_fls() defined in cutils.c, whic= h=20 > uses the clz32() defined in host-utils.h. >=20 > qemu_ffsll() could be implemented fairly easily in terms of ctz64(), > although note that ffsll(n) =3D=3D (ctz64(n) + 1) % 65. ctz64 - that's what I wanted! (No need to introduce qemu_ffsll, at least not for this use case.) Jan ---------> Not all host platforms support ffsll. Signed-off-by: Jan Kiszka --- target-i386/machine.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target-i386/machine.c b/target-i386/machine.c index 259302c..e4099ca 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -148,9 +148,9 @@ void cpu_save(QEMUFile *f, void *opaque) to find it and save its number instead (-1 for none). */ pending_irq =3D -1; for (i =3D 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { - bit =3D ffsll(env->interrupt_bitmap[i]); - if (bit) { - pending_irq =3D i * 64 + bit - 1; + if (env->interrupt_bitmap[i]) { + bit =3D ctz64(env->interrupt_bitmap[i]); + pending_irq =3D i * 64 + bit; break; } } --------------enig573A790A5BF71C50C9B5B9FA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpMXBIACgkQniDOoMHTA+nQAgCdG2o70pyHwuKsDR/csy1RbuHN 3CgAn3oKZEOGg+Wl5c3RVsbNfzOGN/9D =cVms -----END PGP SIGNATURE----- --------------enig573A790A5BF71C50C9B5B9FA--