1 //===----------------------------- config.h -------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
9 // Defines macros used within libuwind project.
11 //===----------------------------------------------------------------------===//
14 #ifndef LIBUNWIND_CONFIG_H
15 #define LIBUNWIND_CONFIG_H
21 // Define static_assert() unless already defined by compiler.
23 #define __has_feature(__x) 0
25 #if !(__has_feature(cxx_static_assert)) && !defined(static_assert)
26 #define static_assert(__b, __m) \
27 extern int compile_time_assert_failed[ ( __b ) ? 1 : -1 ] \
28 __attribute__( ( unused ) );
31 // Platform specific configuration defines.
34 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
35 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0
36 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
38 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
39 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
40 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
43 #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
44 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
45 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
46 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
48 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
49 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0
50 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
54 // FIXME: these macros are not correct for COFF targets
55 #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
56 #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
58 #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
59 #define _LIBUNWIND_BUILD_SJLJ_APIS 1
61 #define _LIBUNWIND_BUILD_SJLJ_APIS 0
64 #if defined(__i386__) || defined(__x86_64__)
65 #define _LIBUNWIND_SUPPORT_FRAME_APIS 1
67 #define _LIBUNWIND_SUPPORT_FRAME_APIS 0
70 #if defined(__i386__) || defined(__x86_64__) || \
71 (!defined(__APPLE__) && defined(__arm__)) || \
72 (defined(__arm64__) || defined(__aarch64__)) || \
73 (defined(__APPLE__) && defined(__mips__)) || \
75 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 1
77 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
80 #define _LIBUNWIND_ABORT(msg) \
82 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__, \
87 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
89 // Macros that define away in non-Debug builds
91 #define _LIBUNWIND_DEBUG_LOG(msg, ...)
92 #define _LIBUNWIND_TRACE_API(msg, ...)
93 #define _LIBUNWIND_TRACING_UNWINDING 0
94 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
95 #define _LIBUNWIND_LOG_NON_ZERO(x) x
100 extern bool logAPIs();
101 extern bool logUnwinding();
105 #define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__)
106 #define _LIBUNWIND_LOG_NON_ZERO(x) \
110 _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
112 #define _LIBUNWIND_TRACE_API(msg, ...) \
114 if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
116 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \
118 if ( logUnwinding() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
120 #define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
124 // Used to fit UnwindCursor and Registers_xxx types against unw_context_t /
125 // unw_cursor_t sized memory blocks.
126 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
131 template <typename _Type, typename _Mem>
133 template <typename T>
135 static const size_t count =
136 (sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
138 static const bool does_fit =
139 (blk_count<_Type>::count COMP_OP blk_count<_Mem>::count);
142 #endif // __cplusplus
144 #endif // LIBUNWIND_CONFIG_H