Commit bad5b1ec8e5d2b68be2c0fd33db2094942e6b685
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
Showing
3 changed files
with
16 additions
and
8 deletions
host-utils.h
| ... | ... | @@ -51,7 +51,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); |
| 51 | 51 | |
| 52 | 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 | 55 | if (val) |
| 56 | 56 | return __builtin_clz(val); |
| 57 | 57 | else |
| ... | ... | @@ -93,7 +93,7 @@ static always_inline int clo32(uint32_t val) |
| 93 | 93 | |
| 94 | 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 | 97 | if (val) |
| 98 | 98 | return __builtin_clzll(val); |
| 99 | 99 | else |
| ... | ... | @@ -118,7 +118,7 @@ static always_inline int clo64(uint64_t val) |
| 118 | 118 | |
| 119 | 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 | 122 | if (val) |
| 123 | 123 | return __builtin_ctz(val); |
| 124 | 124 | else |
| ... | ... | @@ -162,7 +162,7 @@ static always_inline int cto32 (uint32_t val) |
| 162 | 162 | |
| 163 | 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 | 166 | if (val) |
| 167 | 167 | return __builtin_ctz(val); |
| 168 | 168 | else |
| ... | ... | @@ -206,7 +206,7 @@ static always_inline int ctpop16 (uint16_t val) |
| 206 | 206 | |
| 207 | 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 | 210 | return __builtin_popcount(val); |
| 211 | 211 | #else |
| 212 | 212 | val = (val & 0x55555555) + ((val >> 1) & 0x55555555); |
| ... | ... | @@ -221,7 +221,7 @@ static always_inline int ctpop32 (uint32_t val) |
| 221 | 221 | |
| 222 | 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 | 225 | return __builtin_popcountll(val); |
| 226 | 226 | #else |
| 227 | 227 | val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); | ... | ... |
hw/apic.c
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | #include "hw.h" |
| 21 | 21 | #include "pc.h" |
| 22 | 22 | #include "qemu-timer.h" |
| 23 | +#include "osdep.h" | |
| 23 | 24 | |
| 24 | 25 | //#define DEBUG_APIC |
| 25 | 26 | //#define DEBUG_IOAPIC |
| ... | ... | @@ -107,7 +108,7 @@ static void apic_update_irq(APICState *s); |
| 107 | 108 | /* Find first bit starting from msb */ |
| 108 | 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 | 112 | return 31 - __builtin_clz(value); |
| 112 | 113 | #else |
| 113 | 114 | unsigned int ret = 0; |
| ... | ... | @@ -127,7 +128,7 @@ static int fls_bit(uint32_t value) |
| 127 | 128 | /* Find first bit starting from lsb */ |
| 128 | 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 | 132 | return __builtin_ffs(value) - 1; |
| 132 | 133 | #else |
| 133 | 134 | unsigned int ret = 0; | ... | ... |
osdep.h
| ... | ... | @@ -62,6 +62,13 @@ |
| 62 | 62 | |
| 63 | 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 | 72 | void *qemu_memalign(size_t alignment, size_t size); |
| 66 | 73 | void *qemu_vmalloc(size_t size); |
| 67 | 74 | void qemu_vfree(void *ptr); | ... | ... |