diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/compiler.h | 15 |
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) |