Skip to content

Commit bad5b1e

Browse files
author
aurel32
committed
Define macro QEMU_GNUC_PREREQ and use it
Signed-off-by: Aurelien Jarno <[email protected]> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5467 c046a42c-6fe2-441c-8c8c-71466251a162
1 parent 5b7ada4 commit bad5b1e

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

host-utils.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);
5151

5252
static always_inline int clz32(uint32_t val)
5353
{
54-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
54+
#if QEMU_GNUC_PREREQ(3, 4)
5555
if (val)
5656
return __builtin_clz(val);
5757
else
@@ -93,7 +93,7 @@ static always_inline int clo32(uint32_t val)
9393

9494
static always_inline int clz64(uint64_t val)
9595
{
96-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
96+
#if QEMU_GNUC_PREREQ(3, 4)
9797
if (val)
9898
return __builtin_clzll(val);
9999
else
@@ -118,7 +118,7 @@ static always_inline int clo64(uint64_t val)
118118

119119
static always_inline int ctz32 (uint32_t val)
120120
{
121-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
121+
#if QEMU_GNUC_PREREQ(3, 4)
122122
if (val)
123123
return __builtin_ctz(val);
124124
else
@@ -162,7 +162,7 @@ static always_inline int cto32 (uint32_t val)
162162

163163
static always_inline int ctz64 (uint64_t val)
164164
{
165-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
165+
#if QEMU_GNUC_PREREQ(3, 4)
166166
if (val)
167167
return __builtin_ctz(val);
168168
else
@@ -206,7 +206,7 @@ static always_inline int ctpop16 (uint16_t val)
206206

207207
static always_inline int ctpop32 (uint32_t val)
208208
{
209-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
209+
#if QEMU_GNUC_PREREQ(3, 4)
210210
return __builtin_popcount(val);
211211
#else
212212
val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
@@ -221,7 +221,7 @@ static always_inline int ctpop32 (uint32_t val)
221221

222222
static always_inline int ctpop64 (uint64_t val)
223223
{
224-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224+
#if QEMU_GNUC_PREREQ(3, 4)
225225
return __builtin_popcountll(val);
226226
#else
227227
val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);

hw/apic.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "hw.h"
2121
#include "pc.h"
2222
#include "qemu-timer.h"
23+
#include "osdep.h"
2324

2425
//#define DEBUG_APIC
2526
//#define DEBUG_IOAPIC
@@ -107,7 +108,7 @@ static void apic_update_irq(APICState *s);
107108
/* Find first bit starting from msb */
108109
static int fls_bit(uint32_t value)
109110
{
110-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
111+
#if QEMU_GNUC_PREREQ(3, 4)
111112
return 31 - __builtin_clz(value);
112113
#else
113114
unsigned int ret = 0;
@@ -127,7 +128,7 @@ static int fls_bit(uint32_t value)
127128
/* Find first bit starting from lsb */
128129
static int ffs_bit(uint32_t value)
129130
{
130-
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
131+
#if QEMU_GNUC_PREREQ(3, 4)
131132
return __builtin_ffs(value) - 1;
132133
#else
133134
unsigned int ret = 0;

osdep.h

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262

6363
#define qemu_printf printf
6464

65+
#if defined (__GNUC__) && defined (__GNUC_MINOR_)
66+
# define QEMU_GNUC_PREREQ(maj, min) \
67+
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
68+
#else
69+
# define QEMU_GNUC_PREREQ(maj, min) 0
70+
#endif
71+
6572
void *qemu_memalign(size_t alignment, size_t size);
6673
void *qemu_vmalloc(size_t size);
6774
void qemu_vfree(void *ptr);

0 commit comments

Comments
 (0)