Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KopCx-0007VY-OY for qemu-devel@nongnu.org; Sat, 11 Oct 2008 20:53:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KopCx-0007V0-AV for qemu-devel@nongnu.org; Sat, 11 Oct 2008 20:53:19 -0400 Received: from [199.232.76.173] (port=52989 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KopCx-0007Uv-0d for qemu-devel@nongnu.org; Sat, 11 Oct 2008 20:53:19 -0400 Received: from savannah.gnu.org ([199.232.41.3]:35781 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KopCw-0003Ku-LQ for qemu-devel@nongnu.org; Sat, 11 Oct 2008 20:53:18 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KopCw-0001X8-3z for qemu-devel@nongnu.org; Sun, 12 Oct 2008 00:53:18 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KopCv-0001X3-Qp for qemu-devel@nongnu.org; Sun, 12 Oct 2008 00:53:18 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sun, 12 Oct 2008 00:53:17 +0000 Subject: [Qemu-devel] [5465] hw/apic.c: use __builtin funtions instead of assembly code Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5465 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5465 Author: aurel32 Date: 2008-10-12 00:53:17 +0000 (Sun, 12 Oct 2008) Log Message: ----------- hw/apic.c: use __builtin funtions instead of assembly code Suggested by malc. Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/apic.c Modified: trunk/hw/apic.c =================================================================== --- trunk/hw/apic.c 2008-10-12 00:53:08 UTC (rev 5464) +++ trunk/hw/apic.c 2008-10-12 00:53:17 UTC (rev 5465) @@ -104,15 +104,14 @@ static void apic_set_irq(APICState *s, int vector_num, int trigger_mode); static void apic_update_irq(APICState *s); -/* Find first bit starting from msb. Return 0 if value = 0 */ +/* Find first bit starting from msb */ static int fls_bit(uint32_t value) { +#if defined(__GNUC__) + return 31 - __builtin_clz(value); +#else unsigned int ret = 0; -#if defined(HOST_I386) || defined(HOST_X86_64) - __asm__ __volatile__ ("bsr %1, %0\n" : "+r" (ret) : "rm" (value)); - return ret; -#else if (value > 0xffff) value >>= 16, ret = 16; if (value > 0xff) @@ -125,15 +124,14 @@ #endif } -/* Find first bit starting from lsb. Return 0 if value = 0 */ +/* Find first bit starting from lsb */ static int ffs_bit(uint32_t value) { +#if defined(__GNUC__) + return __builtin_ffs(value) - 1; +#else unsigned int ret = 0; -#if defined(HOST_I386) || defined(HOST_X86_64) - __asm__ __volatile__ ("bsf %1, %0\n" : "+r" (ret) : "rm" (value)); - return ret; -#else if (!value) return 0; if (!(value & 0xffff))