[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] Use ffs in favor of ffsll
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v2] Use ffs in favor of ffsll |
Date: |
Wed, 01 Jul 2009 22:55:02 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
Jan Kiszka wrote:
> Blue Swirl wrote:
>> On 7/1/09, Jan Kiszka <address@hidden> 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 <address@hidden>
---
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;
}
}
- [Qemu-devel] [PATCH] Use ffs in favor of ffsll, Jan Kiszka, 2009/07/01
- [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll, Blue Swirl, 2009/07/01
- [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH v2] Use ffs in favor of ffsll,
Jan Kiszka <=
- Re: [Qemu-devel] [PATCH v2] Use ffs in favor of ffsll, Nathan Froyd, 2009/07/01
- [Qemu-devel] Re: [PATCH v2] Use ffs in favor of ffsll, Jan Kiszka, 2009/07/01
- Re: [Qemu-devel] [PATCH v2] Use ffs in favor of ffsll, Stuart Brady, 2009/07/01
- [Qemu-devel] [PATCH] Use ctz64 in favor of ffsll, Jan Kiszka, 2009/07/02
- [Qemu-devel] [PATCH v2] Use ctz64 in favor of ffsll, Jan Kiszka, 2009/07/02
- Re: [Qemu-devel] [PATCH v2] Use ctz64 in favor of ffsll, Paul Brook, 2009/07/03
- Re: [Qemu-devel] [PATCH v2] Use ctz64 in favor of ffsll, Jan Kiszka, 2009/07/04
Re: [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll, Christoph Egger, 2009/07/02