瀏覽代碼

compiler: introduce QEMU_ANNOTATE

Allow a more shorter syntax when defining wrapper macros for
__attribute__((annotate(...))).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini 2 年之前
父節點
當前提交
d79b9202e4
共有 2 個文件被更改,包括 9 次插入3 次删除
  1. 6 0
      include/qemu/compiler.h
  2. 3 3
      include/qemu/osdep.h

+ 6 - 0
include/qemu/compiler.h

@@ -197,4 +197,10 @@
 #define BUILTIN_SUBCLL_BROKEN
 #define BUILTIN_SUBCLL_BROKEN
 #endif
 #endif
 
 
+#if __has_attribute(annotate)
+#define QEMU_ANNOTATE(x) __attribute__((annotate(x)))
+#else
+#define QEMU_ANNOTATE(x)
+#endif
+
 #endif /* COMPILER_H */
 #endif /* COMPILER_H */

+ 3 - 3
include/qemu/osdep.h

@@ -185,7 +185,7 @@ extern "C" {
  *   }
  *   }
  */
  */
 #ifdef __clang__
 #ifdef __clang__
-#define coroutine_fn __attribute__((__annotate__("coroutine_fn")))
+#define coroutine_fn QEMU_ANNOTATE("coroutine_fn")
 #else
 #else
 #define coroutine_fn
 #define coroutine_fn
 #endif
 #endif
@@ -195,7 +195,7 @@ extern "C" {
  * but can handle running in non-coroutine context too.
  * but can handle running in non-coroutine context too.
  */
  */
 #ifdef __clang__
 #ifdef __clang__
-#define coroutine_mixed_fn __attribute__((__annotate__("coroutine_mixed_fn")))
+#define coroutine_mixed_fn QEMU_ANNOTATE("coroutine_mixed_fn")
 #else
 #else
 #define coroutine_mixed_fn
 #define coroutine_mixed_fn
 #endif
 #endif
@@ -224,7 +224,7 @@ extern "C" {
  *   }
  *   }
  */
  */
 #ifdef __clang__
 #ifdef __clang__
-#define no_coroutine_fn __attribute__((__annotate__("no_coroutine_fn")))
+#define no_coroutine_fn QEMU_ANNOTATE("no_coroutine_fn")
 #else
 #else
 #define no_coroutine_fn
 #define no_coroutine_fn
 #endif
 #endif