aboutsummaryrefslogtreecommitdiff
path: root/macros.h
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2021-01-15 20:39:45 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2021-01-16 19:56:33 +0000
commit22f25a9e4feddbc093ae01cd53bdda3c2c3a82e9 (patch)
tree4d0c9bce90d0f0d04c22e9f88b52f910695cfaf6 /macros.h
parentMerge branch 'decset-1047-and-1048' (diff)
Print stack trace on assert() failure or when calling fatal_error()
Note: this uses the __sanitizer_print_stack_trace() function from the AddressSanitizer runtime, so it only works when AddressSanitizer is in use.
Diffstat (limited to 'macros.h')
-rw-r--r--macros.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/macros.h b/macros.h
index 1fd82b77..206c18d3 100644
--- a/macros.h
+++ b/macros.h
@@ -27,6 +27,21 @@
#define HAS_BUILTIN(x) 0
#endif
+#ifdef __has_feature
+ #define HAS_FEATURE(x) __has_feature(x)
+#else
+ #define HAS_FEATURE(x) 0
+#endif
+
+// __has_extension() is a Clang macro used to determine if a feature is
+// available even if not standardized in the current "-std" mode.
+#ifdef __has_extension
+ #define HAS_EXTENSION(x) __has_extension(x)
+#else
+ // Clang versions prior to 3.0 only supported __has_feature()
+ #define HAS_EXTENSION(x) HAS_FEATURE(x)
+#endif
+
#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(unused) || defined(__TINYC__)
#define UNUSED __attribute__((__unused__))
#else
@@ -139,11 +154,11 @@
#define XSTRDUP XMALLOC NONNULL_ARGS
#if __STDC_VERSION__ >= 201112L
- #define NORETURN _Noreturn
+ #define noreturn _Noreturn
#elif GNUC_AT_LEAST(3, 0)
- #define NORETURN __attribute__((__noreturn__))
+ #define noreturn __attribute__((__noreturn__))
#else
- #define NORETURN
+ #define noreturn
#endif
#if CLANG_AT_LEAST(3, 6)