Be more GCC-friendly with attributes

Being clang the default compiler, we were always giving precedence to
the __has_attribute check. Unfortunately clang generally doesn't support
the new attributes (alloc_size was briefly supported and then reverted)
so we were always doing both checks. Give the precedence to GCC as that is
the working case now.

Do the same for  __has_builtin() for consistency.
This commit is contained in:
Pedro F. Giffuni 2015-08-28 14:06:28 +00:00
parent 160c44fe95
commit ddd54889b7

View File

@ -237,12 +237,12 @@
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#endif
#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
#if __GNUC_PREREQ__(4, 3) || __has_attribute(alloc_size)
#define __alloc_size(x) __attribute__((__alloc_size__(x)))
#else
#define __alloc_size(x)
#endif
#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
#if __GNUC_PREREQ__(4, 9) || __has_attribute(alloc_align)
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
#else
#define __alloc_align(x)
@ -382,7 +382,7 @@
#define __returns_twice
#endif
#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
#define __unreachable() __builtin_unreachable()
#else
#define __unreachable() ((void)0)
@ -535,7 +535,7 @@
* well enough to use them in limited cases.
*/
#if defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
#if __GNUC_PREREQ__(4, 3) || __has_attribute(artificial)
#define __gnu_inline __attribute__((__gnu_inline__, __artificial__))
#else
#define __gnu_inline __attribute__((__gnu_inline__))