hw/apic.c: use functions from host-utils.h
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5469 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
a013cc6593
commit
bb7e729397
38
hw/apic.c
38
hw/apic.c
@ -20,7 +20,7 @@
|
|||||||
#include "hw.h"
|
#include "hw.h"
|
||||||
#include "pc.h"
|
#include "pc.h"
|
||||||
#include "qemu-timer.h"
|
#include "qemu-timer.h"
|
||||||
#include "osdep.h"
|
#include "host-utils.h"
|
||||||
|
|
||||||
//#define DEBUG_APIC
|
//#define DEBUG_APIC
|
||||||
//#define DEBUG_IOAPIC
|
//#define DEBUG_IOAPIC
|
||||||
@ -108,45 +108,13 @@ static void apic_update_irq(APICState *s);
|
|||||||
/* Find first bit starting from msb */
|
/* Find first bit starting from msb */
|
||||||
static int fls_bit(uint32_t value)
|
static int fls_bit(uint32_t value)
|
||||||
{
|
{
|
||||||
#if QEMU_GNUC_PREREQ(3, 4)
|
return 31 - clz32(value);
|
||||||
return 31 - __builtin_clz(value);
|
|
||||||
#else
|
|
||||||
unsigned int ret = 0;
|
|
||||||
|
|
||||||
if (value > 0xffff)
|
|
||||||
value >>= 16, ret = 16;
|
|
||||||
if (value > 0xff)
|
|
||||||
value >>= 8, ret += 8;
|
|
||||||
if (value > 0xf)
|
|
||||||
value >>= 4, ret += 4;
|
|
||||||
if (value > 0x3)
|
|
||||||
value >>= 2, ret += 2;
|
|
||||||
return ret + (value >> 1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find first bit starting from lsb */
|
/* Find first bit starting from lsb */
|
||||||
static int ffs_bit(uint32_t value)
|
static int ffs_bit(uint32_t value)
|
||||||
{
|
{
|
||||||
#if QEMU_GNUC_PREREQ(3, 4)
|
return ctz32(value);
|
||||||
return __builtin_ffs(value) - 1;
|
|
||||||
#else
|
|
||||||
unsigned int ret = 0;
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
return 0;
|
|
||||||
if (!(value & 0xffff))
|
|
||||||
value >>= 16, ret = 16;
|
|
||||||
if (!(value & 0xff))
|
|
||||||
value >>= 8, ret += 8;
|
|
||||||
if (!(value & 0xf))
|
|
||||||
value >>= 4, ret += 4;
|
|
||||||
if (!(value & 0x3))
|
|
||||||
value >>= 2, ret += 2;
|
|
||||||
if (!(value & 0x1))
|
|
||||||
ret++;
|
|
||||||
return ret;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_bit(uint32_t *tab, int index)
|
static inline void set_bit(uint32_t *tab, int index)
|
||||||
|
Loading…
Reference in New Issue
Block a user