Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/unwind/src/config.h
12346 views
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 libunwind project.
10
//
11
//===----------------------------------------------------------------------===//
12
13
14
#ifndef LIBUNWIND_CONFIG_H
15
#define LIBUNWIND_CONFIG_H
16
17
#include <assert.h>
18
#include <stdio.h>
19
#include <stdint.h>
20
#include <stdlib.h>
21
22
// Platform specific configuration defines.
23
#ifdef __APPLE__
24
#if defined(FOR_DYLD)
25
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
26
#else
27
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
28
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
29
#endif
30
#elif defined(_WIN32)
31
#ifdef __SEH__
32
#define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
33
#else
34
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
35
#endif
36
#else
37
#if defined(__ARM_DWARF_EH__) || !defined(__arm__)
38
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
39
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
40
#endif
41
#endif
42
43
#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
44
#define _LIBUNWIND_EXPORT
45
#define _LIBUNWIND_HIDDEN
46
#else
47
#if !defined(__ELF__) && !defined(__MACH__)
48
#define _LIBUNWIND_EXPORT __declspec(dllexport)
49
#define _LIBUNWIND_HIDDEN
50
#else
51
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
52
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
53
#endif
54
#endif
55
56
#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
57
#define _LIBUNWIND_BUILD_SJLJ_APIS
58
#endif
59
60
#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
61
#define _LIBUNWIND_SUPPORT_FRAME_APIS
62
#endif
63
64
#if defined(__i386__) || defined(__x86_64__) || \
65
defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
66
(!defined(__APPLE__) && defined(__arm__)) || \
67
(defined(__arm64__) || defined(__aarch64__)) || \
68
defined(__mips__)
69
#if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
70
#define _LIBUNWIND_BUILD_ZERO_COST_APIS
71
#endif
72
#endif
73
74
#if defined(__powerpc64__) && defined(_ARCH_PWR8)
75
#define PPC64_HAS_VMX
76
#endif
77
78
#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
79
#define _LIBUNWIND_ABORT(msg) \
80
do { \
81
abort(); \
82
} while (0)
83
#else
84
#define _LIBUNWIND_ABORT(msg) \
85
do { \
86
fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__, \
87
__LINE__, msg); \
88
fflush(stderr); \
89
abort(); \
90
} while (0)
91
#endif
92
93
#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
94
#define _LIBUNWIND_LOG0(msg)
95
#define _LIBUNWIND_LOG(msg, ...)
96
#else
97
#define _LIBUNWIND_LOG0(msg) \
98
fprintf(stderr, "libunwind: " msg "\n")
99
#define _LIBUNWIND_LOG(msg, ...) \
100
fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
101
#endif
102
103
#if defined(NDEBUG)
104
#define _LIBUNWIND_LOG_IF_FALSE(x) x
105
#else
106
#define _LIBUNWIND_LOG_IF_FALSE(x) \
107
do { \
108
bool _ret = x; \
109
if (!_ret) \
110
_LIBUNWIND_LOG("" #x " failed in %s", __FUNCTION__); \
111
} while (0)
112
#endif
113
114
// Macros that define away in non-Debug builds
115
#ifdef NDEBUG
116
#define _LIBUNWIND_DEBUG_LOG(msg, ...)
117
#define _LIBUNWIND_TRACE_API(msg, ...)
118
#define _LIBUNWIND_TRACING_UNWINDING (0)
119
#define _LIBUNWIND_TRACING_DWARF (0)
120
#define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
121
#define _LIBUNWIND_TRACE_DWARF(...)
122
#else
123
#ifdef __cplusplus
124
extern "C" {
125
#endif
126
extern bool logAPIs();
127
extern bool logUnwinding();
128
extern bool logDWARF();
129
#ifdef __cplusplus
130
}
131
#endif
132
#define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__)
133
#define _LIBUNWIND_TRACE_API(msg, ...) \
134
do { \
135
if (logAPIs()) \
136
_LIBUNWIND_LOG(msg, __VA_ARGS__); \
137
} while (0)
138
#define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
139
#define _LIBUNWIND_TRACING_DWARF logDWARF()
140
#define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \
141
do { \
142
if (logUnwinding()) \
143
_LIBUNWIND_LOG(msg, __VA_ARGS__); \
144
} while (0)
145
#define _LIBUNWIND_TRACE_DWARF(...) \
146
do { \
147
if (logDWARF()) \
148
fprintf(stderr, __VA_ARGS__); \
149
} while (0)
150
#endif
151
152
#ifdef __cplusplus
153
// Used to fit UnwindCursor and Registers_xxx types against unw_context_t /
154
// unw_cursor_t sized memory blocks.
155
#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
156
# define COMP_OP ==
157
#else
158
# define COMP_OP <=
159
#endif
160
template <typename _Type, typename _Mem>
161
struct check_fit {
162
template <typename T>
163
struct blk_count {
164
static const size_t count =
165
(sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
166
};
167
static const bool does_fit =
168
(blk_count<_Type>::count COMP_OP blk_count<_Mem>::count);
169
};
170
#undef COMP_OP
171
#endif // __cplusplus
172
173
#endif // LIBUNWIND_CONFIG_H
174
175