diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-10-12 00:53:17 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-10-12 00:53:17 +0000 |
commit | e95f5491bc4172f76d98f79de40a36098152937c (patch) | |
tree | 507362983a693ab4b65fe4dae1233976946691ff /hw | |
parent | 7d01998021e38363d53bc93f198023a05d8a52bf (diff) |
hw/apic.c: use __builtin funtions instead of assembly code
Suggested by malc.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5465 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/apic.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -104,15 +104,14 @@ static void apic_init_ipi(APICState *s); 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 @@ static int fls_bit(uint32_t value) #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)) |