aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-09-26 17:48:50 +0200
committerThomas Huth <thuth@redhat.com>2018-10-17 08:36:28 +0200
commit97ff87c0ed020c2a4b931146e142d67abe852e22 (patch)
treeaa5c5de9ce476031ff56e27213f2cde13e769c09 /include
parent957e8b34920a1404a1318b2e1ffa0726d40e0a9b (diff)
qemu/compiler: Wrap __attribute__((flatten)) in a macro
Older versions of Clang (before 3.5) and GCC (before 4.1) do not support the "__attribute__((flatten))" yet. We don't care about such old versions of GCC anymore, but since Clang 3.4 is still used in EPEL for RHEL7 / CentOS 7, we should not use this attribute directly but with a wrapper macro instead. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/compiler.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index bf47e7bee4..66f8c241dc 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -131,6 +131,21 @@
#define HAS_ASSUME_ALIGNED
#endif
+#ifndef __has_attribute
+#define __has_attribute(x) 0 /* compatibility with older GCC */
+#endif
+
+/*
+ * GCC doesn't provide __has_attribute() until GCC 5, but we know all the GCC
+ * versions we support have the "flatten" attribute. Clang may not have the
+ * "flatten" attribute but always has __has_attribute() to check for it.
+ */
+#if __has_attribute(flatten) || !defined(__clang__)
+# define QEMU_FLATTEN __attribute__((flatten))
+#else
+# define QEMU_FLATTEN
+#endif
+
/* Implement C11 _Generic via GCC builtins. Example:
*
* QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)