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 libunwind project.
11 //===----------------------------------------------------------------------===//
14 #ifndef LIBUNWIND_CONFIG_H
15 #define LIBUNWIND_CONFIG_H
22 // Define static_assert() unless already defined by compiler.
24 #define __has_feature(__x) 0
26 #if !(__has_feature(cxx_static_assert)) && !defined(static_assert)
27 #define static_assert(__b, __m) \
28 extern int compile_time_assert_failed[ ( __b ) ? 1 : -1 ] \
29 __attribute__( ( unused ) );
32 // Platform specific configuration defines.
35 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
37 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
38 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
42 #define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
44 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
47 #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
48 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
49 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
53 #if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
54 #define _LIBUNWIND_EXPORT
55 #define _LIBUNWIND_HIDDEN
57 #if !defined(__ELF__) && !defined(__MACH__)
58 #define _LIBUNWIND_EXPORT __declspec(dllexport)
59 #define _LIBUNWIND_HIDDEN
61 #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
62 #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
66 #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
67 #define _LIBUNWIND_BUILD_SJLJ_APIS
70 #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
71 #define _LIBUNWIND_SUPPORT_FRAME_APIS
74 #if defined(__i386__) || defined(__x86_64__) || \
75 defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
76 (!defined(__APPLE__) && defined(__arm__)) || \
77 (defined(__arm64__) || defined(__aarch64__)) || \
78 defined(__mips__) || \
80 #if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
81 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
85 #if defined(__powerpc64__) && defined(_ARCH_PWR8)
89 #if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
90 #define _LIBUNWIND_ABORT(msg) \
95 #define _LIBUNWIND_ABORT(msg) \
97 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__, \
104 #if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
105 #define _LIBUNWIND_LOG0(msg)
106 #define _LIBUNWIND_LOG(msg, ...)
108 #define _LIBUNWIND_LOG0(msg) \
109 fprintf(stderr, "libunwind: " msg "\n")
110 #define _LIBUNWIND_LOG(msg, ...) \
111 fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
115 #define _LIBUNWIND_LOG_IF_FALSE(x) x
117 #define _LIBUNWIND_LOG_IF_FALSE(x) \
121 _LIBUNWIND_LOG("" #x " failed in %s", __FUNCTION__); \
125 // Macros that define away in non-Debug builds
127 #define _LIBUNWIND_DEBUG_LOG(msg, ...)
128 #define _LIBUNWIND_TRACE_API(msg, ...)
129 #define _LIBUNWIND_TRACING_UNWINDING (0)
130 #define _LIBUNWIND_TRACING_DWARF (0)
131 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
132 #define _LIBUNWIND_TRACE_DWARF(...)
137 extern bool logAPIs();
138 extern bool logUnwinding();
139 extern bool logDWARF();
143 #define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__)
144 #define _LIBUNWIND_TRACE_API(msg, ...) \
147 _LIBUNWIND_LOG(msg, __VA_ARGS__); \
149 #define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
150 #define _LIBUNWIND_TRACING_DWARF logDWARF()
151 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \
153 if (logUnwinding()) \
154 _LIBUNWIND_LOG(msg, __VA_ARGS__); \
156 #define _LIBUNWIND_TRACE_DWARF(...) \
159 fprintf(stderr, __VA_ARGS__); \
164 // Used to fit UnwindCursor and Registers_xxx types against unw_context_t /
165 // unw_cursor_t sized memory blocks.
166 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
171 template <typename _Type, typename _Mem>
173 template <typename T>
175 static const size_t count =
176 (sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
178 static const bool does_fit =
179 (blk_count<_Type>::count COMP_OP blk_count<_Mem>::count);
182 #endif // __cplusplus
184 #endif // LIBUNWIND_CONFIG_H