Skip to content

Commit

Permalink
Define macro QEMU_GNUC_PREREQ and use it
Browse files Browse the repository at this point in the history
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5467 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
aurel32 committed Oct 12, 2008
1 parent 5b7ada4 commit bad5b1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 6 additions & 6 deletions host-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);

static always_inline int clz32(uint32_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
return __builtin_clz(val);
else
Expand Down Expand Up @@ -93,7 +93,7 @@ static always_inline int clo32(uint32_t val)

static always_inline int clz64(uint64_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
return __builtin_clzll(val);
else
Expand All @@ -118,7 +118,7 @@ static always_inline int clo64(uint64_t val)

static always_inline int ctz32 (uint32_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
return __builtin_ctz(val);
else
Expand Down Expand Up @@ -162,7 +162,7 @@ static always_inline int cto32 (uint32_t val)

static always_inline int ctz64 (uint64_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
return __builtin_ctz(val);
else
Expand Down Expand Up @@ -206,7 +206,7 @@ static always_inline int ctpop16 (uint16_t val)

static always_inline int ctpop32 (uint32_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcount(val);
#else
val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
Expand All @@ -221,7 +221,7 @@ static always_inline int ctpop32 (uint32_t val)

static always_inline int ctpop64 (uint64_t val)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcountll(val);
#else
val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
Expand Down
5 changes: 3 additions & 2 deletions hw/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "hw.h"
#include "pc.h"
#include "qemu-timer.h"
#include "osdep.h"

//#define DEBUG_APIC
//#define DEBUG_IOAPIC
Expand Down Expand Up @@ -107,7 +108,7 @@ static void apic_update_irq(APICState *s);
/* Find first bit starting from msb */
static int fls_bit(uint32_t value)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
return 31 - __builtin_clz(value);
#else
unsigned int ret = 0;
Expand All @@ -127,7 +128,7 @@ static int fls_bit(uint32_t value)
/* Find first bit starting from lsb */
static int ffs_bit(uint32_t value)
{
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_ffs(value) - 1;
#else
unsigned int ret = 0;
Expand Down
7 changes: 7 additions & 0 deletions osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@

#define qemu_printf printf

#if defined (__GNUC__) && defined (__GNUC_MINOR_)
# define QEMU_GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define QEMU_GNUC_PREREQ(maj, min) 0
#endif

void *qemu_memalign(size_t alignment, size_t size);
void *qemu_vmalloc(size_t size);
void qemu_vfree(void *ptr);
Expand Down

0 comments on commit bad5b1e

Please sign in to comment.