aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.h
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2016-07-05 18:00:23 +0000
committerEd Maste <emaste@FreeBSD.org>2016-07-05 18:00:23 +0000
commite2fc5d984d0bcb0eba77ce5030f053dfc0eae2a2 (patch)
treeb21dcab8cdbe07ded020ad2c036bd62d4b8d88ce /src/config.h
parentca83053650e2c15214b17a869aae5d544c9a59da (diff)
downloadsrc-vendor/llvm-libunwind/libunwind-r272680.tar.gz
src-vendor/llvm-libunwind/libunwind-r272680.zip
Import LLVM libunwind snapshot revision 272680vendor/llvm-libunwind/libunwind-r272680
Significant upstream revisions: 260595: [AArch64] Fix libunwind build when using GNU assembler 270692: Introduce a native-only unwinder build. 270972: Disable cross-unwinding by default. 271004: [libunwind] Improve unwinder stack usage - II 272680: [libunwind] Improve unwinder stack usage - III Obtained from: https://llvm.org/svn/llvm-project/libunwind/trunk/
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h105
1 files changed, 60 insertions, 45 deletions
diff --git a/src/config.h b/src/config.h
index ecc0a6b4465d..a50222f7c90d 100644
--- a/src/config.h
+++ b/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,35 +39,51 @@
#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__))
- #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__))
+#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
@@ -124,5 +119,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