qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [5467] Define macro QEMU_GNUC_PREREQ and use it
@ 2008-10-12 16:15 Aurelien Jarno
  0 siblings, 0 replies; only message in thread
From: Aurelien Jarno @ 2008-10-12 16:15 UTC (permalink / raw)
  To: qemu-devel

Revision: 5467
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5467
Author:   aurel32
Date:     2008-10-12 16:15:04 +0000 (Sun, 12 Oct 2008)

Log Message:
-----------
Define macro QEMU_GNUC_PREREQ and use it

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

Modified Paths:
--------------
    trunk/host-utils.h
    trunk/hw/apic.c
    trunk/osdep.h

Modified: trunk/host-utils.h
===================================================================
--- trunk/host-utils.h	2008-10-12 11:44:36 UTC (rev 5466)
+++ trunk/host-utils.h	2008-10-12 16:15:04 UTC (rev 5467)
@@ -51,7 +51,7 @@
 
 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
@@ -93,7 +93,7 @@
 
 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
@@ -118,7 +118,7 @@
 
 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
@@ -162,7 +162,7 @@
 
 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
@@ -206,7 +206,7 @@
 
 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);
@@ -221,7 +221,7 @@
 
 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);

Modified: trunk/hw/apic.c
===================================================================
--- trunk/hw/apic.c	2008-10-12 11:44:36 UTC (rev 5466)
+++ trunk/hw/apic.c	2008-10-12 16:15:04 UTC (rev 5467)
@@ -20,6 +20,7 @@
 #include "hw.h"
 #include "pc.h"
 #include "qemu-timer.h"
+#include "osdep.h"
 
 //#define DEBUG_APIC
 //#define DEBUG_IOAPIC
@@ -107,7 +108,7 @@
 /* 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;
@@ -127,7 +128,7 @@
 /* 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;

Modified: trunk/osdep.h
===================================================================
--- trunk/osdep.h	2008-10-12 11:44:36 UTC (rev 5466)
+++ trunk/osdep.h	2008-10-12 16:15:04 UTC (rev 5467)
@@ -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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-12 16:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-12 16:15 [Qemu-devel] [5467] Define macro QEMU_GNUC_PREREQ and use it Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).