aboutsummaryrefslogtreecommitdiff
path: root/X11/Xfuncproto.h.in
diff options
context:
space:
mode:
Diffstat (limited to 'X11/Xfuncproto.h.in')
-rw-r--r--X11/Xfuncproto.h.in31
1 files changed, 22 insertions, 9 deletions
diff --git a/X11/Xfuncproto.h.in b/X11/Xfuncproto.h.in
index dac92291e..e9e5e7141 100644
--- a/X11/Xfuncproto.h.in
+++ b/X11/Xfuncproto.h.in
@@ -75,15 +75,21 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif /* _XFUNCPROTOBEGIN */
+/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
+#ifndef __has_attribute
+# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+
/* Added in X11R6.9, so available in any version of modular xproto */
-#if defined(__GNUC__) && (__GNUC__ >= 4)
+#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))
# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
#else
# define _X_SENTINEL(x)
#endif /* GNUC >= 4 */
/* Added in X11R6.9, so available in any version of modular xproto */
-#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \
+ && !defined(__CYGWIN__) && !defined(__MINGW32__)
# define _X_EXPORT __attribute__((visibility("default")))
# define _X_HIDDEN __attribute__((visibility("hidden")))
# define _X_INTERNAL __attribute__((visibility("internal")))
@@ -109,29 +115,34 @@ in this Software without prior written authorization from The Open Group.
/* Bulk branch prediction hints via marking error path functions as "cold" */
/* requires xproto >= 7.0.25 */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
+#if __has_attribute(__cold__) || \
+ (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */
# define _X_COLD __attribute__((__cold__))
#else
# define _X_COLD /* nothing */
#endif
/* Added in X11R6.9, so available in any version of modular xproto */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)
+#if __has_attribute(deprecated) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))
# define _X_DEPRECATED __attribute__((deprecated))
#else /* not gcc >= 3.1 */
# define _X_DEPRECATED
#endif
/* requires xproto >= 7.0.17 */
-#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if __has_attribute(noreturn) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define _X_NORETURN __attribute((noreturn))
#else
# define _X_NORETURN
#endif /* GNUC */
/* Added in X11R6.9, so available in any version of modular xproto */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+#if __has_attribute(__format__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
#else /* not gcc >= 2.3 */
# define _X_ATTRIBUTE_PRINTF(x,y)
@@ -140,14 +151,16 @@ in this Software without prior written authorization from The Open Group.
/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable
argument macros, must be only used inside #ifdef _X_NONNULL guards, as
many legacy X clients are compiled in C89 mode still. */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+#if __has_attribute(nonnull) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
#define _X_NONNULL(args...) __attribute__((nonnull(args)))
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
#define _X_NONNULL(...) /* */
#endif
/* requires xproto >= 7.0.22 */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
+#if __has_attribute(__unused__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
#define _X_UNUSED __attribute__((__unused__))
#else
#define _X_UNUSED /* */