From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MMHpN-00088e-55 for qemu-devel@nongnu.org; Thu, 02 Jul 2009 04:39:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MMHpH-00084p-N3 for qemu-devel@nongnu.org; Thu, 02 Jul 2009 04:39:32 -0400 Received: from [199.232.76.173] (port=43855 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMHpH-00084h-Es for qemu-devel@nongnu.org; Thu, 02 Jul 2009 04:39:27 -0400 Received: from outbound-dub.frontbridge.com ([213.199.154.16]:61804 helo=IE1EHSOBE002.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1MMHpH-0003ol-1F for qemu-devel@nongnu.org; Thu, 02 Jul 2009 04:39:27 -0400 From: Christoph Egger Subject: Re: [Qemu-devel] Re: [PATCH] Use ffs in favor of ffsll Date: Thu, 2 Jul 2009 10:39:08 +0200 References: <4A4BC57E.504@web.de> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200907021039.09082.Christoph.Egger@amd.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Anthony Liguori , Jan Kiszka On Wednesday 01 July 2009 22:27:51 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. 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