From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MM6ph-0002Pm-19 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 16:55:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MM6pc-0002Oc-MN for qemu-devel@nongnu.org; Wed, 01 Jul 2009 16:55:08 -0400 Received: from [199.232.76.173] (port=39602 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MM6pc-0002OT-Ee for qemu-devel@nongnu.org; Wed, 01 Jul 2009 16:55:04 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:34235) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MM6pb-0008Hn-SW for qemu-devel@nongnu.org; Wed, 01 Jul 2009 16:55:04 -0400 Message-ID: <4A4BCD26.2060102@web.de> Date: Wed, 01 Jul 2009 22:55:02 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4A4BC57E.504@web.de> <4A4BC87A.6050005@web.de> In-Reply-To: <4A4BC87A.6050005@web.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH v2] Use ffs in favor of ffsll List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Anthony Liguori , qemu-devel Jan Kiszka wrote: > Blue Swirl wrote: >> On 7/1/09, Jan Kiszka wrote: >>> Not all host platforms support the ll variant. This is not a critical >>> path, so go the easy way. >>> - for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { >>> - bit = ffsll(env->interrupt_bitmap[i]); >>> + for (i = 0; i < sizeof(env->interrupt_bitmap) / sizeof(int); i++) { >>> + bit = ffs(((int *)env->interrupt_bitmap)[i]); >>> if (bit) { >>> - pending_irq = i * 64 + bit - 1; >>> + pending_irq = i * 8 * sizeof(int) + bit - 1; >> I think this will not work on a big endian host. > > Right, may theoretically bite us once we are able to migrate between kvm > and tcg. Will send a better version nevertheless. > I decided that a comment should suffice. ----- Not all host platforms support the ll variant. This is not a critical path, so go the easy way. Signed-off-by: Jan Kiszka --- target-i386/machine.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/target-i386/machine.c b/target-i386/machine.c index 259302c..1a56b3d 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -147,10 +147,12 @@ void cpu_save(QEMUFile *f, void *opaque) /* There can only be one pending IRQ set in the bitmap at a time, so try to find it and save its number instead (-1 for none). */ pending_irq = -1; - for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { - bit = ffsll(env->interrupt_bitmap[i]); + for (i = 0; i < sizeof(env->interrupt_bitmap) / sizeof(int); i++) { + /* Note: This assumes little endian host, which is true in KVM mode. + In TCG mode it must be zero anyway. */ + bit = ffs(((int *)env->interrupt_bitmap)[i]); if (bit) { - pending_irq = i * 64 + bit - 1; + pending_irq = i * 8 * sizeof(int) + bit - 1; break; } }