qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll


From: Christoph Egger
Subject: Re: [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll
Date: Thu, 2 Jul 2009 10:39:08 +0200
User-agent: KMail/1.9.7

On Wednesday 01 July 2009 22:27:51 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.

A qemu_ffsll() implementation can be something like this:

int qemu_ffsll(long long mask)
{
      int bit;

      bit = ffs((int)mask);
      if (bit == 0) {
           mask >>= 32;
           bit = ffs((int)mask);
           if (bit) bit += 32;
      }
       return bit;
}

Christoph



-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632





reply via email to

[Prev in Thread] Current Thread [Next in Thread]