qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 01/13] compiler.h: replace QEMU_GNUC_PREREQ macro


From: marcandre . lureau
Subject: [PATCH v2 01/13] compiler.h: replace QEMU_GNUC_PREREQ macro
Date: Thu, 26 Nov 2020 15:29:03 +0400

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Replace it with glib G_GNUC_CHECK_VERSION.

Available since 2.42, the macro received a small correction in
2.55.1 (glib d44afbadda8a "macros: make G_GNUC_CHECK_VERSION()
portable" which was apparently harmless).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qemu/atomic.h      |  2 +-
 include/qemu/compiler.h    | 15 +++------------
 scripts/cocci-macro-file.h |  1 -
 accel/tcg/cpu-exec.c       |  2 +-
 4 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index c1d211a351..c409257c11 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -248,7 +248,7 @@
  * 4.3 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36793).
  */
 #if defined(__i386__) || defined(__x86_64__)
-#if !QEMU_GNUC_PREREQ(4, 4)
+#if !G_GNUC_CHECK_VERSION(4, 4)
 #if defined __x86_64__
 #define smp_mb()    ({ asm volatile("mfence" ::: "memory"); (void)0; })
 #else
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index c76281f354..cf044bab4a 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -7,21 +7,12 @@
 #ifndef COMPILER_H
 #define COMPILER_H
 
+#include "glib-compat.h"
+
 #if defined __clang_analyzer__ || defined __COVERITY__
 #define QEMU_STATIC_ANALYSIS 1
 #endif
 
-/*----------------------------------------------------------------------------
-| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
-| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
-*----------------------------------------------------------------------------*/
-#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
-
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
@@ -104,7 +95,7 @@
                                    sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
 
 #if defined __GNUC__
-# if !QEMU_GNUC_PREREQ(4, 4)
+# if !G_GNUC_CHECK_VERSION(4, 4)
    /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
 #  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
 # else
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index c6bbc05ba3..20eea6b708 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -19,7 +19,6 @@
  */
 
 /* From qemu/compiler.h */
-#define QEMU_GNUC_PREREQ(maj, min) 1
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define QEMU_SENTINEL __attribute__((sentinel))
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 58aea605d8..21a46d2e85 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -724,7 +724,7 @@ int cpu_exec(CPUState *cpu)
 
     /* prepare setjmp context for exception handling */
     if (sigsetjmp(cpu->jmp_env, 0) != 0) {
-#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
+#if defined(__clang__) || !G_GNUC_CHECK_VERSION(4, 6)
         /* Some compilers wrongly smash all local variables after
          * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
          * Reload essential local variables here for those compilers.
-- 
2.29.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]