diff options
Diffstat (limited to 'contrib/llvm/projects/libunwind/src/config.h')
-rw-r--r-- | contrib/llvm/projects/libunwind/src/config.h | 107 |
1 files changed, 61 insertions, 46 deletions
diff --git a/contrib/llvm/projects/libunwind/src/config.h b/contrib/llvm/projects/libunwind/src/config.h index 7ebd57f..74c63f0 100644 --- a/contrib/llvm/projects/libunwind/src/config.h +++ b/contrib/llvm/projects/libunwind/src/config.h @@ -16,6 +16,7 @@ #include <assert.h> #include <stdio.h> +#include <stdlib.h> // Define static_assert() unless already defined by compiler. #ifndef __has_feature @@ -29,28 +30,6 @@ // Platform specific configuration defines. #ifdef __APPLE__ - #include <Availability.h> - #ifdef __cplusplus - extern "C" { - #endif - void __assert_rtn(const char *, const char *, int, const char *) - __attribute__((noreturn)); - #ifdef __cplusplus - } - #endif - - #define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \ - defined(__x86_64__) || \ - defined(__arm64__) || \ - defined(__mips__)) - #define _LIBUNWIND_BUILD_SJLJ_APIS defined(__arm__) - #define _LIBUNWIND_SUPPORT_FRAME_APIS (defined(__i386__) || \ - defined(__x86_64__)) - #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) - #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) - #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__) - #define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg) - #if defined(FOR_DYLD) #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 @@ -60,36 +39,52 @@ #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 #endif - #else - #include <stdlib.h> + #if defined(__ARM_DWARF_EH__) || !defined(__arm__) + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 + #define _LIBUNWIND_SUPPORT_DWARF_INDEX 1 + #else + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #endif +#endif + +// FIXME: these macros are not correct for COFF targets +#define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) +#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) - static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) __attribute__ ((noreturn)); - static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) { - fprintf(stderr, "libunwind: %s %s:%d - %s\n", func, file, line, msg); - assert(false); - abort(); - } +#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__) +#define _LIBUNWIND_BUILD_SJLJ_APIS 1 +#else +#define _LIBUNWIND_BUILD_SJLJ_APIS 0 +#endif - #define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \ - defined(__x86_64__) || \ - defined(__arm__) || \ - defined(__aarch64__) || \ - defined(__riscv__)) - #define _LIBUNWIND_BUILD_SJLJ_APIS 0 - #define _LIBUNWIND_SUPPORT_FRAME_APIS (defined(__i386__) || \ - defined(__x86_64__)) - #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) - #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) - #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__) - #define _LIBUNWIND_ABORT(msg) assert_rtn(__func__, __FILE__, __LINE__, msg) +#if defined(__i386__) || defined(__x86_64__) +#define _LIBUNWIND_SUPPORT_FRAME_APIS 1 +#else +#define _LIBUNWIND_SUPPORT_FRAME_APIS 0 +#endif - #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 - #define _LIBUNWIND_SUPPORT_DWARF_UNWIND !defined(__arm__) || \ - defined(__ARM_DWARF_EH__) - #define _LIBUNWIND_SUPPORT_DWARF_INDEX _LIBUNWIND_SUPPORT_DWARF_UNWIND +#if defined(__i386__) || defined(__x86_64__) || \ + (!defined(__APPLE__) && defined(__arm__)) || \ + (defined(__arm64__) || defined(__aarch64__)) || \ + (defined(__APPLE__) && defined(__mips__)) || \ + defined(__riscv__) +#define _LIBUNWIND_BUILD_ZERO_COST_APIS 1 +#else +#define _LIBUNWIND_BUILD_ZERO_COST_APIS 0 #endif +#define _LIBUNWIND_ABORT(msg) \ + do { \ + fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__, \ + __LINE__, msg); \ + fflush(stderr); \ + abort(); \ + } while (0) +#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__) // Macros that define away in non-Debug builds #ifdef NDEBUG @@ -125,5 +120,25 @@ #define _LIBUNWIND_TRACING_UNWINDING logUnwinding() #endif +#ifdef __cplusplus +// Used to fit UnwindCursor and Registers_xxx types against unw_context_t / +// unw_cursor_t sized memory blocks. +#if defined(_LIBUNWIND_IS_NATIVE_ONLY) +# define COMP_OP == +#else +# define COMP_OP < +#endif +template <typename _Type, typename _Mem> +struct check_fit { + template <typename T> + struct blk_count { + static const size_t count = + (sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t); + }; + static const bool does_fit = + (blk_count<_Type>::count COMP_OP blk_count<_Mem>::count); +}; +#undef COMP_OP +#endif // __cplusplus #endif // LIBUNWIND_CONFIG_H |