From 22f25a9e4feddbc093ae01cd53bdda3c2c3a82e9 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Fri, 15 Jan 2021 20:39:45 +0000 Subject: 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. --- macros.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'macros.h') 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) -- cgit v1.3