Commit bad5b1ec8e5d2b68be2c0fd33db2094942e6b685

Authored by aurel32
1 parent 5b7ada46

Define macro QEMU_GNUC_PREREQ and use it

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5467 c046a42c-6fe2-441c-8c8c-71466251a162
host-utils.h
@@ -51,7 +51,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); @@ -51,7 +51,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);
51 51
52 static always_inline int clz32(uint32_t val) 52 static always_inline int clz32(uint32_t val)
53 { 53 {
54 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 54 +#if QEMU_GNUC_PREREQ(3, 4)
55 if (val) 55 if (val)
56 return __builtin_clz(val); 56 return __builtin_clz(val);
57 else 57 else
@@ -93,7 +93,7 @@ static always_inline int clo32(uint32_t val) @@ -93,7 +93,7 @@ static always_inline int clo32(uint32_t val)
93 93
94 static always_inline int clz64(uint64_t val) 94 static always_inline int clz64(uint64_t val)
95 { 95 {
96 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 96 +#if QEMU_GNUC_PREREQ(3, 4)
97 if (val) 97 if (val)
98 return __builtin_clzll(val); 98 return __builtin_clzll(val);
99 else 99 else
@@ -118,7 +118,7 @@ static always_inline int clo64(uint64_t val) @@ -118,7 +118,7 @@ static always_inline int clo64(uint64_t val)
118 118
119 static always_inline int ctz32 (uint32_t val) 119 static always_inline int ctz32 (uint32_t val)
120 { 120 {
121 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 121 +#if QEMU_GNUC_PREREQ(3, 4)
122 if (val) 122 if (val)
123 return __builtin_ctz(val); 123 return __builtin_ctz(val);
124 else 124 else
@@ -162,7 +162,7 @@ static always_inline int cto32 (uint32_t val) @@ -162,7 +162,7 @@ static always_inline int cto32 (uint32_t val)
162 162
163 static always_inline int ctz64 (uint64_t val) 163 static always_inline int ctz64 (uint64_t val)
164 { 164 {
165 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 165 +#if QEMU_GNUC_PREREQ(3, 4)
166 if (val) 166 if (val)
167 return __builtin_ctz(val); 167 return __builtin_ctz(val);
168 else 168 else
@@ -206,7 +206,7 @@ static always_inline int ctpop16 (uint16_t val) @@ -206,7 +206,7 @@ static always_inline int ctpop16 (uint16_t val)
206 206
207 static always_inline int ctpop32 (uint32_t val) 207 static always_inline int ctpop32 (uint32_t val)
208 { 208 {
209 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 209 +#if QEMU_GNUC_PREREQ(3, 4)
210 return __builtin_popcount(val); 210 return __builtin_popcount(val);
211 #else 211 #else
212 val = (val & 0x55555555) + ((val >> 1) & 0x55555555); 212 val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
@@ -221,7 +221,7 @@ static always_inline int ctpop32 (uint32_t val) @@ -221,7 +221,7 @@ static always_inline int ctpop32 (uint32_t val)
221 221
222 static always_inline int ctpop64 (uint64_t val) 222 static always_inline int ctpop64 (uint64_t val)
223 { 223 {
224 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 224 +#if QEMU_GNUC_PREREQ(3, 4)
225 return __builtin_popcountll(val); 225 return __builtin_popcountll(val);
226 #else 226 #else
227 val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); 227 val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
hw/apic.c
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 #include "hw.h" 20 #include "hw.h"
21 #include "pc.h" 21 #include "pc.h"
22 #include "qemu-timer.h" 22 #include "qemu-timer.h"
  23 +#include "osdep.h"
23 24
24 //#define DEBUG_APIC 25 //#define DEBUG_APIC
25 //#define DEBUG_IOAPIC 26 //#define DEBUG_IOAPIC
@@ -107,7 +108,7 @@ static void apic_update_irq(APICState *s); @@ -107,7 +108,7 @@ static void apic_update_irq(APICState *s);
107 /* Find first bit starting from msb */ 108 /* Find first bit starting from msb */
108 static int fls_bit(uint32_t value) 109 static int fls_bit(uint32_t value)
109 { 110 {
110 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 111 +#if QEMU_GNUC_PREREQ(3, 4)
111 return 31 - __builtin_clz(value); 112 return 31 - __builtin_clz(value);
112 #else 113 #else
113 unsigned int ret = 0; 114 unsigned int ret = 0;
@@ -127,7 +128,7 @@ static int fls_bit(uint32_t value) @@ -127,7 +128,7 @@ static int fls_bit(uint32_t value)
127 /* Find first bit starting from lsb */ 128 /* Find first bit starting from lsb */
128 static int ffs_bit(uint32_t value) 129 static int ffs_bit(uint32_t value)
129 { 130 {
130 -#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 131 +#if QEMU_GNUC_PREREQ(3, 4)
131 return __builtin_ffs(value) - 1; 132 return __builtin_ffs(value) - 1;
132 #else 133 #else
133 unsigned int ret = 0; 134 unsigned int ret = 0;
@@ -62,6 +62,13 @@ @@ -62,6 +62,13 @@
62 62
63 #define qemu_printf printf 63 #define qemu_printf printf
64 64
  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 +
65 void *qemu_memalign(size_t alignment, size_t size); 72 void *qemu_memalign(size_t alignment, size_t size);
66 void *qemu_vmalloc(size_t size); 73 void *qemu_vmalloc(size_t size);
67 void qemu_vfree(void *ptr); 74 void qemu_vfree(void *ptr);