OLD | NEW |
(Empty) | |
| 1 //===----------------------------- config.h -------------------------------===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 // Source Licenses. See LICENSE.TXT for details. |
| 7 // |
| 8 // |
| 9 // Defines macros used within libuwind project. |
| 10 // |
| 11 //===----------------------------------------------------------------------===// |
| 12 |
| 13 |
| 14 #ifndef LIBUNWIND_CONFIG_H |
| 15 #define LIBUNWIND_CONFIG_H |
| 16 |
| 17 #include <assert.h> |
| 18 |
| 19 // Define static_assert() unless already defined by compiler. |
| 20 #ifndef __has_feature |
| 21 #define __has_feature(__x) 0 |
| 22 #endif |
| 23 #if !(__has_feature(cxx_static_assert)) |
| 24 #define static_assert(__b, __m) \ |
| 25 extern int compile_time_assert_failed[ ( __b ) ? 1 : -1 ] \ |
| 26 __attribute__( ( unused ) ); |
| 27 #endif |
| 28 |
| 29 // Platform specific configuration defines. |
| 30 #if __APPLE__ |
| 31 #include <Availability.h> |
| 32 #ifdef __cplusplus |
| 33 extern "C" { |
| 34 #endif |
| 35 void __assert_rtn(const char *, const char *, int, const char *) |
| 36 __attribute__((noreturn)); |
| 37 #ifdef __cplusplus |
| 38 } |
| 39 #endif |
| 40 |
| 41 #define _LIBUNWIND_BUILD_ZERO_COST_APIS (__i386__ || __x86_64__ || __arm64__) |
| 42 #define _LIBUNWIND_BUILD_SJLJ_APIS (__arm__) |
| 43 #define _LIBUNWIND_SUPPORT_FRAME_APIS (__i386__ || __x86_64__) |
| 44 #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) |
| 45 #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) |
| 46 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__
) |
| 47 #define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg) |
| 48 |
| 49 #if FOR_DYLD |
| 50 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 |
| 51 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 |
| 52 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 |
| 53 #else |
| 54 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 |
| 55 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 |
| 56 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 |
| 57 #endif |
| 58 |
| 59 #else |
| 60 // #define _LIBUNWIND_BUILD_ZERO_COST_APIS |
| 61 // #define _LIBUNWIND_BUILD_SJLJ_APIS |
| 62 // #define _LIBUNWIND_SUPPORT_FRAME_APIS |
| 63 // #define _LIBUNWIND_EXPORT |
| 64 // #define _LIBUNWIND_HIDDEN |
| 65 // #define _LIBUNWIND_LOG() |
| 66 // #define _LIBUNWIND_ABORT() |
| 67 // #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND |
| 68 // #define _LIBUNWIND_SUPPORT_DWARF_UNWIND |
| 69 // #define _LIBUNWIND_SUPPORT_DWARF_INDEX |
| 70 #endif |
| 71 |
| 72 |
| 73 // Macros that define away in non-Debug builds |
| 74 #ifdef NDEBUG |
| 75 #define _LIBUNWIND_DEBUG_LOG(msg, ...) |
| 76 #define _LIBUNWIND_TRACE_API(msg, ...) |
| 77 #define _LIBUNWIND_TRACING_UNWINDING 0 |
| 78 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) |
| 79 #define _LIBUNWIND_LOG_NON_ZERO(x) x |
| 80 #else |
| 81 #ifdef __cplusplus |
| 82 extern "C" { |
| 83 #endif |
| 84 extern bool logAPIs(); |
| 85 extern bool logUnwinding(); |
| 86 #ifdef __cplusplus |
| 87 } |
| 88 #endif |
| 89 #define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__) |
| 90 #define _LIBUNWIND_LOG_NON_ZERO(x) \ |
| 91 do { \ |
| 92 int _err = x; \ |
| 93 if ( _err != 0 ) \ |
| 94 _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \ |
| 95 } while (0) |
| 96 #define _LIBUNWIND_TRACE_API(msg, ...) \ |
| 97 do { \ |
| 98 if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
| 99 } while(0) |
| 100 #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \ |
| 101 do { \ |
| 102 if ( logUnwinding() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
| 103 } while(0) |
| 104 #define _LIBUNWIND_TRACING_UNWINDING logUnwinding() |
| 105 #endif |
| 106 |
| 107 |
| 108 #endif // LIBUNWIND_CONFIG_H |
OLD | NEW |