1 | // [AsmJit] |
2 | // Machine Code Generation for C++. |
3 | // |
4 | // [License] |
5 | // Zlib - See LICENSE.md file in the package. |
6 | |
7 | // AsmJit Static Builds and Embedding |
8 | // ---------------------------------- |
9 | // |
10 | // These definitions can be used to enable static library build. Embed is used |
11 | // when AsmJit's source code is embedded directly in another project, implies |
12 | // static build as well. |
13 | // |
14 | // #define ASMJIT_EMBED // Asmjit is embedded (implies ASMJIT_BUILD_STATIC). |
15 | // #define ASMJIT_STATIC // Enable static-library build. |
16 | |
17 | // AsmJit Build Mode |
18 | // ----------------- |
19 | // |
20 | // These definitions control the build mode and tracing support. The build mode |
21 | // should be auto-detected at compile time, but it's possible to override it in |
22 | // case that the auto-detection fails. |
23 | // |
24 | // Tracing is a feature that is never compiled by default and it's only used to |
25 | // debug AsmJit itself. |
26 | // |
27 | // #define ASMJIT_BUILD_DEBUG // Always use debug-mode (ASMJIT_ASSERT enabled). |
28 | // #define ASMJIT_BUILD_RELEASE // Always use release-mode (ASMJIT_ASSERT disabled). |
29 | |
30 | // AsmJit Build Backends |
31 | // --------------------- |
32 | // |
33 | // These definitions control which backends to compile. If none of these is |
34 | // defined AsmJit will use host architecture by default (for JIT code generation). |
35 | // |
36 | // #define ASMJIT_BUILD_X86 // Enable X86 targets (X86 and X86_64). |
37 | // #define ASMJIT_BUILD_ARM // Enable ARM targets (ARM and AArch64). |
38 | // #define ASMJIT_BUILD_HOST // Enable targets based on target arch (default). |
39 | |
40 | // AsmJit Build Options |
41 | // -------------------- |
42 | // |
43 | // Flags can be defined to disable standard features. These are handy especially |
44 | // when building AsmJit statically and some features are not needed or unwanted |
45 | // (like BaseCompiler). |
46 | // |
47 | // AsmJit features are enabled by default. |
48 | // #define ASMJIT_DISABLE_BUILDER // Disable Builder (completely). |
49 | // #define ASMJIT_DISABLE_COMPILER // Disable Compiler (completely). |
50 | // #define ASMJIT_DISABLE_JIT // Disable JIT memory manager and JitRuntime. |
51 | // #define ASMJIT_DISABLE_LOGGING // Disable logging and formatting (completely). |
52 | // #define ASMJIT_DISABLE_TEXT // Disable everything that contains text |
53 | // // representation (instructions, errors, ...). |
54 | // #define ASMJIT_DISABLE_INST_API // Disable API related to instruction database |
55 | // // (validation, cpu features, rw-info, etc). |
56 | |
57 | #ifndef _ASMJIT_CORE_BUILD_H |
58 | #define _ASMJIT_CORE_BUILD_H |
59 | |
60 | // ============================================================================ |
61 | // [asmjit::Version] |
62 | // ============================================================================ |
63 | |
64 | #define ASMJIT_LIBRARY_VERSION 0x010200 /* 1.2.0 */ |
65 | |
66 | // ============================================================================ |
67 | // [asmjit::Dependencies] |
68 | // ============================================================================ |
69 | |
70 | // We really want std-types as globals. |
71 | #include <stdarg.h> |
72 | #include <stddef.h> |
73 | #include <stdint.h> |
74 | #include <stdio.h> |
75 | #include <stdlib.h> |
76 | #include <string.h> |
77 | |
78 | #include <new> |
79 | #include <limits> |
80 | #include <type_traits> |
81 | #include <utility> |
82 | |
83 | #if defined(_WIN32) |
84 | #ifndef WIN32_LEAN_AND_MEAN |
85 | #define WIN32_LEAN_AND_MEAN |
86 | #define ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN |
87 | #endif |
88 | #ifndef NOMINMAX |
89 | #define NOMINMAX |
90 | #define ASMJIT_UNDEF_NOMINMAX |
91 | #endif |
92 | #include <windows.h> |
93 | #ifdef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN |
94 | #undef WIN32_LEAN_AND_MEAN |
95 | #undef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN |
96 | #endif |
97 | #ifdef ASMJIT_UNDEF_NOMINMAX |
98 | #undef NOMINMAX |
99 | #undef ASMJIT_UNDEF_NOMINMAX |
100 | #endif |
101 | #else |
102 | #include <pthread.h> |
103 | #endif |
104 | |
105 | // ============================================================================ |
106 | // [asmjit::Build - Globals - Deprecated] |
107 | // ============================================================================ |
108 | |
109 | // DEPRECATED: Will be removed in the future. |
110 | #if defined(ASMJIT_BUILD_EMBED) || defined(ASMJIT_BUILD_STATIC) |
111 | #if defined(ASMJIT_BUILD_EMBED) |
112 | #pragma message("'ASMJIT_BUILD_EMBED' is deprecated, use 'ASMJIT_STATIC'") |
113 | #endif |
114 | #if defined(ASMJIT_BUILD_STATIC) |
115 | #pragma message("'ASMJIT_BUILD_STATIC' is deprecated, use 'ASMJIT_STATIC'") |
116 | #endif |
117 | |
118 | #if !defined(ASMJIT_STATIC) |
119 | #define ASMJIT_STATIC |
120 | #endif |
121 | #endif |
122 | |
123 | // ============================================================================ |
124 | // [asmjit::Build - Globals - Build Mode] |
125 | // ============================================================================ |
126 | |
127 | // Detect ASMJIT_BUILD_DEBUG and ASMJIT_BUILD_RELEASE if not defined. |
128 | #if !defined(ASMJIT_BUILD_DEBUG) && !defined(ASMJIT_BUILD_RELEASE) |
129 | #if !defined(NDEBUG) |
130 | #define ASMJIT_BUILD_DEBUG |
131 | #else |
132 | #define ASMJIT_BUILD_RELEASE |
133 | #endif |
134 | #endif |
135 | |
136 | // Prevent compile-time errors caused by misconfiguration. |
137 | #if defined(ASMJIT_DISABLE_TEXT) && !defined(ASMJIT_DISABLE_LOGGING) |
138 | #error "[asmjit] ASMJIT_DISABLE_TEXT requires ASMJIT_DISABLE_LOGGING to be defined." |
139 | #endif |
140 | |
141 | // ============================================================================ |
142 | // [asmjit::Build - Globals - Target Architecture] |
143 | // ============================================================================ |
144 | |
145 | #if defined(_M_X64) || defined(__x86_64__) |
146 | #define ASMJIT_ARCH_X86 64 |
147 | #elif defined(_M_IX86) || defined(__X86__) || defined(__i386__) |
148 | #define ASMJIT_ARCH_X86 32 |
149 | #else |
150 | #define ASMJIT_ARCH_X86 0 |
151 | #endif |
152 | |
153 | #if defined(__arm64__) || defined(__aarch64__) |
154 | # define ASMJIT_ARCH_ARM 64 |
155 | #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__) || defined(__thumb2__) |
156 | #define ASMJIT_ARCH_ARM 32 |
157 | #else |
158 | #define ASMJIT_ARCH_ARM 0 |
159 | #endif |
160 | |
161 | #if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) |
162 | #define ASMJIT_ARCH_MIPS 64 |
163 | #elif defined(_MIPS_ARCH_MIPS32) || defined(_M_MRX000) || defined(__mips__) |
164 | #define ASMJIT_ARCH_MIPS 32 |
165 | #else |
166 | #define ASMJIT_ARCH_MIPS 0 |
167 | #endif |
168 | |
169 | #define ASMJIT_ARCH_BITS (ASMJIT_ARCH_X86 | ASMJIT_ARCH_ARM | ASMJIT_ARCH_MIPS) |
170 | #if ASMJIT_ARCH_BITS == 0 |
171 | #undef ASMJIT_ARCH_BITS |
172 | #if defined (__LP64__) || defined(_LP64) |
173 | #define ASMJIT_ARCH_BITS 64 |
174 | #else |
175 | #define ASMJIT_ARCH_BITS 32 |
176 | #endif |
177 | #endif |
178 | |
179 | #if (defined(__ARMEB__)) || \ |
180 | (defined(__MIPSEB__)) || \ |
181 | (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) |
182 | #define ASMJIT_ARCH_LE 0 |
183 | #define ASMJIT_ARCH_BE 1 |
184 | #else |
185 | #define ASMJIT_ARCH_LE 1 |
186 | #define ASMJIT_ARCH_BE 0 |
187 | #endif |
188 | |
189 | // Build host architecture if no architecture is selected. |
190 | #if !defined(ASMJIT_BUILD_HOST) && \ |
191 | !defined(ASMJIT_BUILD_X86) && \ |
192 | !defined(ASMJIT_BUILD_ARM) |
193 | #define ASMJIT_BUILD_HOST |
194 | #endif |
195 | |
196 | // Detect host architecture if building only for host. |
197 | #if ASMJIT_ARCH_X86 && defined(ASMJIT_BUILD_HOST) && !defined(ASMJIT_BUILD_X86) |
198 | #define ASMJIT_BUILD_X86 |
199 | #endif |
200 | |
201 | #if ASMJIT_ARCH_ARM && defined(ASMJIT_BUILD_HOST) && !defined(ASMJIT_BUILD_ARM) |
202 | #define ASMJIT_BUILD_ARM |
203 | #endif |
204 | |
205 | // ============================================================================ |
206 | // [asmjit::Build - Globals - C++ Compiler and Features Detection] |
207 | // ============================================================================ |
208 | |
209 | #define ASMJIT_CXX_CLANG 0 |
210 | #define ASMJIT_CXX_GNU 0 |
211 | #define ASMJIT_CXX_INTEL 0 |
212 | #define ASMJIT_CXX_MSC 0 |
213 | #define ASMJIT_CXX_MAKE_VER(MAJOR, MINOR, PATCH) ((MAJOR) * 10000000 + (MINOR) * 100000 + (PATCH)) |
214 | |
215 | // Intel Compiler [pretends to be GNU or MSC, so it must be checked first]: |
216 | // - https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler |
217 | // - https://software.intel.com/en-us/articles/c14-features-supported-by-intel-c-compiler |
218 | // - https://software.intel.com/en-us/articles/c17-features-supported-by-intel-c-compiler |
219 | #if defined(__INTEL_COMPILER) |
220 | |
221 | #undef ASMJIT_CXX_INTEL |
222 | #define ASMJIT_CXX_INTEL ASMJIT_CXX_MAKE_VER(__INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10, __INTEL_COMPILER % 10) |
223 | |
224 | // MSC Compiler: |
225 | // - https://msdn.microsoft.com/en-us/library/hh567368.aspx |
226 | // |
227 | // Version List: |
228 | // - 16.00.0 == VS2010 |
229 | // - 17.00.0 == VS2012 |
230 | // - 18.00.0 == VS2013 |
231 | // - 19.00.0 == VS2015 |
232 | // - 19.10.0 == VS2017 |
233 | #elif defined(_MSC_VER) && defined(_MSC_FULL_VER) |
234 | |
235 | #undef ASMJIT_CXX_MSC |
236 | #if _MSC_VER == _MSC_FULL_VER / 10000 |
237 | #define ASMJIT_CXX_MSC ASMJIT_CXX_MAKE_VER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000) |
238 | #else |
239 | #define ASMJIT_CXX_MSC ASMJIT_CXX_MAKE_VER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000) |
240 | #endif |
241 | |
242 | // SEVERE: VS2015 handles constexpr's incorrectly in case a struct contains a |
243 | // union. There is no workaround known other than rewriting the whole |
244 | // code. VS2017 has a similar bug, but it can be workarounded. |
245 | #if ASMJIT_CXX_MSC < ASMJIT_CXX_MAKE_VER(19, 10, 0) |
246 | #error "[asmjit] At least VS2017 is required due to a severe bug in VS2015's constexpr implementation" |
247 | #endif |
248 | |
249 | // Clang Compiler [Pretends to be GNU, so it must be checked before]: |
250 | // - https://clang.llvm.org/cxx_status.html |
251 | #elif defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) |
252 | |
253 | #undef ASMJIT_CXX_CLANG |
254 | #define ASMJIT_CXX_CLANG ASMJIT_CXX_MAKE_VER(__clang_major__, __clang_minor__, __clang_patchlevel__) |
255 | |
256 | // GNU Compiler: |
257 | // - https://gcc.gnu.org/projects/cxx-status.html |
258 | #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) |
259 | |
260 | #undef ASMJIT_CXX_GNU |
261 | #define ASMJIT_CXX_GNU ASMJIT_CXX_MAKE_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) |
262 | |
263 | #endif |
264 | |
265 | // Compiler features detection macros. |
266 | #if ASMJIT_CXX_CLANG && defined(__has_builtin) |
267 | #define ASMJIT_CXX_HAS_BUILTIN(NAME, CHECK) (__has_builtin(NAME)) |
268 | #else |
269 | #define ASMJIT_CXX_HAS_BUILTIN(NAME, CHECK) (!(!(CHECK))) |
270 | #endif |
271 | |
272 | #if ASMJIT_CXX_CLANG && defined(__has_extension) |
273 | #define ASMJIT_CXX_HAS_FEATURE(NAME, CHECK) (__has_extension(NAME)) |
274 | #elif ASMJIT_CXX_CLANG && defined(__has_feature) |
275 | #define ASMJIT_CXX_HAS_FEATURE(NAME, CHECK) (__has_feature(NAME)) |
276 | #else |
277 | #define ASMJIT_CXX_HAS_FEATURE(NAME, CHECK) (!(!(CHECK))) |
278 | #endif |
279 | |
280 | #if ASMJIT_CXX_CLANG && defined(__has_attribute) |
281 | #define ASMJIT_CXX_HAS_ATTRIBUTE(NAME, CHECK) (__has_attribute(NAME)) |
282 | #else |
283 | #define ASMJIT_CXX_HAS_ATTRIBUTE(NAME, CHECK) (!(!(CHECK))) |
284 | #endif |
285 | |
286 | #if ASMJIT_CXX_CLANG && defined(__has_cpp_attribute) |
287 | #define ASMJIT_CXX_HAS_CPP_ATTRIBUTE(NAME, CHECK) (__has_cpp_attribute(NAME)) |
288 | #else |
289 | #define ASMJIT_CXX_HAS_CPP_ATTRIBUTE(NAME, CHECK) (!(!(CHECK))) |
290 | #endif |
291 | |
292 | // Compiler features by vendor. |
293 | #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) |
294 | #define ASMJIT_CXX_HAS_NATIVE_WCHAR_T 0 |
295 | #else |
296 | #define ASMJIT_CXX_HAS_NATIVE_WCHAR_T 1 |
297 | #endif |
298 | |
299 | #if ASMJIT_CXX_HAS_FEATURE(cxx_unicode_literals, ( \ |
300 | (ASMJIT_CXX_INTEL >= ASMJIT_CXX_MAKE_VER(14, 0, 0)) || \ |
301 | (ASMJIT_CXX_MSC >= ASMJIT_CXX_MAKE_VER(19, 0, 0)) || \ |
302 | (ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(4 , 5, 0) && __cplusplus >= 201103L) )) |
303 | #define ASMJIT_CXX_HAS_UNICODE_LITERALS 1 |
304 | #else |
305 | #define ASMJIT_CXX_HAS_UNICODE_LITERALS 0 |
306 | #endif |
307 | |
308 | // ============================================================================ |
309 | // [asmjit::Build - Globals - API Decorators & Language Extensions] |
310 | // ============================================================================ |
311 | |
312 | // API (Export / Import). |
313 | #if !defined(ASMJIT_STATIC) |
314 | #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) |
315 | #if defined(ASMJIT_EXPORTS) |
316 | #define ASMJIT_API __declspec(dllexport) |
317 | #else |
318 | #define ASMJIT_API __declspec(dllimport) |
319 | #endif |
320 | #elif defined(_WIN32) && defined(__GNUC__) |
321 | #if defined(ASMJIT_EXPORTS) |
322 | #define ASMJIT_API __attribute__((__dllexport__)) |
323 | #else |
324 | #define ASMJIT_API __attribute__((__dllimport__)) |
325 | #endif |
326 | #elif defined(__GNUC__) |
327 | #define ASMJIT_API __attribute__((__visibility__("default"))) |
328 | #endif |
329 | #endif |
330 | |
331 | #if !defined(ASMJIT_API) |
332 | #define ASMJIT_API |
333 | #endif |
334 | |
335 | #if !defined(ASMJIT_VARAPI) |
336 | #define ASMJIT_VARAPI extern ASMJIT_API |
337 | #endif |
338 | |
339 | // This is basically a workaround. When using MSVC and marking class as DLL |
340 | // export everything gets exported, which is unwanted in most projects. MSVC |
341 | // automatically exports typeinfo and vtable if at least one symbol of the |
342 | // class is exported. However, GCC has some strange behavior that even if |
343 | // one or more symbol is exported it doesn't export typeinfo unless the |
344 | // class itself is decorated with "visibility(default)" (i.e. ASMJIT_API). |
345 | #if !defined(_WIN32) && defined(__GNUC__) |
346 | #define ASMJIT_VIRTAPI ASMJIT_API |
347 | #else |
348 | #define ASMJIT_VIRTAPI |
349 | #endif |
350 | |
351 | // Function attributes. |
352 | #if !defined(ASMJIT_BUILD_DEBUG) && defined(__GNUC__) |
353 | #define ASMJIT_INLINE inline __attribute__((__always_inline__)) |
354 | #elif !defined(ASMJIT_BUILD_DEBUG) && defined(_MSC_VER) |
355 | #define ASMJIT_INLINE __forceinline |
356 | #else |
357 | #define ASMJIT_INLINE inline |
358 | #endif |
359 | |
360 | #if defined(__GNUC__) |
361 | #define ASMJIT_NOINLINE __attribute__((__noinline__)) |
362 | #define ASMJIT_NORETURN __attribute__((__noreturn__)) |
363 | #elif defined(_MSC_VER) |
364 | #define ASMJIT_NOINLINE __declspec(noinline) |
365 | #define ASMJIT_NORETURN __declspec(noreturn) |
366 | #else |
367 | #define ASMJIT_NOINLINE |
368 | #define ASMJIT_NORETURN |
369 | #endif |
370 | |
371 | // Calling conventions. |
372 | #if ASMJIT_ARCH_X86 == 32 && defined(__GNUC__) |
373 | #define ASMJIT_CDECL __attribute__((__cdecl__)) |
374 | #define ASMJIT_STDCALL __attribute__((__stdcall__)) |
375 | #define ASMJIT_FASTCALL __attribute__((__fastcall__)) |
376 | #define ASMJIT_REGPARM(N) __attribute__((__regparm__(N))) |
377 | #elif ASMJIT_ARCH_X86 == 32 && defined(_MSC_VER) |
378 | #define ASMJIT_CDECL __cdecl |
379 | #define ASMJIT_STDCALL __stdcall |
380 | #define ASMJIT_FASTCALL __fastcall |
381 | #define ASMJIT_REGPARM(N) |
382 | #else |
383 | #define ASMJIT_CDECL |
384 | #define ASMJIT_STDCALL |
385 | #define ASMJIT_FASTCALL |
386 | #define ASMJIT_REGPARM(N) |
387 | #endif |
388 | |
389 | // Type alignment (not allowed by C++11 'alignas' keyword). |
390 | #if defined(__GNUC__) |
391 | #define ASMJIT_ALIGN_TYPE(TYPE, N) __attribute__((__aligned__(N))) TYPE |
392 | #elif defined(_MSC_VER) |
393 | #define ASMJIT_ALIGN_TYPE(TYPE, N) __declspec(align(N)) TYPE |
394 | #else |
395 | #define ASMJIT_ALIGN_TYPE(TYPE, N) TYPE |
396 | #endif |
397 | |
398 | // Annotations. |
399 | #if defined(__GNUC__) |
400 | #define ASMJIT_LIKELY(...) __builtin_expect(!!(__VA_ARGS__), 1) |
401 | #define ASMJIT_UNLIKELY(...) __builtin_expect(!!(__VA_ARGS__), 0) |
402 | #else |
403 | #define ASMJIT_LIKELY(...) (__VA_ARGS__) |
404 | #define ASMJIT_UNLIKELY(...) (__VA_ARGS__) |
405 | #endif |
406 | |
407 | #if defined(__clang__) && __cplusplus >= 201103L |
408 | #define ASMJIT_FALLTHROUGH [[clang::fallthrough]] |
409 | #elif ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(7, 0, 0) |
410 | #define ASMJIT_FALLTHROUGH __attribute__((__fallthrough__)) |
411 | #else |
412 | #define ASMJIT_FALLTHROUGH ((void)0) /* fallthrough */ |
413 | #endif |
414 | |
415 | #define ASMJIT_UNUSED(X) (void)(X) |
416 | |
417 | // Utilities. |
418 | #define ASMJIT_OFFSET_OF(STRUCT, MEMBER) ((int)(intptr_t)((const char*)&((const STRUCT*)0x100)->MEMBER) - 0x100) |
419 | #define ASMJIT_ARRAY_SIZE(X) uint32_t(sizeof(X) / sizeof(X[0])) |
420 | |
421 | #if ASMJIT_CXX_HAS_ATTRIBUTE(attribute_deprecated_with_message, ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(4, 5, 0)) |
422 | #define ASMJIT_DEPRECATED(DECL, MESSAGE) DECL __attribute__((__deprecated__(MESSAGE))) |
423 | #elif ASMJIT_MSC |
424 | #define ASMJIT_DEPRECATED(DECL, MESSAGE) __declspec(deprecated(MESSAGE)) DECL |
425 | #else |
426 | #define ASMJIT_DEPRECATED(DECL, MESSAGE) DECL |
427 | #endif |
428 | |
429 | #if ASMJIT_CXX_HAS_ATTRIBUTE(no_sanitize, 0) |
430 | #define ASMJIT_ATTRIBUTE_NO_SANITIZE_UNDEF __attribute__((__no_sanitize__("undefined"))) |
431 | #elif ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(4, 9, 0) |
432 | #define ASMJIT_ATTRIBUTE_NO_SANITIZE_UNDEF __attribute__((__no_sanitize_undefined__)) |
433 | #else |
434 | #define ASMJIT_ATTRIBUTE_NO_SANITIZE_UNDEF |
435 | #endif |
436 | |
437 | // ============================================================================ |
438 | // [asmjit::Build - Globals - Begin-Namespace / End-Namespace] |
439 | // ============================================================================ |
440 | |
441 | #if defined(__clang__) |
442 | #define ASMJIT_BEGIN_NAMESPACE \ |
443 | namespace asmjit { \ |
444 | _Pragma("clang diagnostic push") \ |
445 | _Pragma("clang diagnostic ignored \"-Wconstant-logical-operand\"") \ |
446 | _Pragma("clang diagnostic ignored \"-Wunnamed-type-template-args\"") |
447 | #define ASMJIT_END_NAMESPACE \ |
448 | _Pragma("clang diagnostic pop") \ |
449 | } |
450 | #elif ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(4, 0, 0) && \ |
451 | ASMJIT_CXX_GNU < ASMJIT_CXX_MAKE_VER(5, 0, 0) |
452 | #define ASMJIT_BEGIN_NAMESPACE \ |
453 | namespace asmjit { \ |
454 | _Pragma("GCC diagnostic push") \ |
455 | _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") |
456 | #define ASMJIT_END_NAMESPACE \ |
457 | _Pragma("GCC diagnostic pop") \ |
458 | } |
459 | #elif ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(8, 0, 0) |
460 | #define ASMJIT_BEGIN_NAMESPACE \ |
461 | namespace asmjit { \ |
462 | _Pragma("GCC diagnostic push") \ |
463 | _Pragma("GCC diagnostic ignored \"-Wclass-memaccess\"") |
464 | #define ASMJIT_END_NAMESPACE \ |
465 | _Pragma("GCC diagnostic pop") \ |
466 | } |
467 | #elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) |
468 | #define ASMJIT_BEGIN_NAMESPACE \ |
469 | namespace asmjit { \ |
470 | __pragma(warning(push)) \ |
471 | __pragma(warning(disable: 4127)) /* conditional expression is constant*/\ |
472 | __pragma(warning(disable: 4201)) /* nameless struct/union */ |
473 | #define ASMJIT_END_NAMESPACE \ |
474 | __pragma(warning(pop)) \ |
475 | } |
476 | #endif |
477 | |
478 | #if !defined(ASMJIT_BEGIN_NAMESPACE) && !defined(ASMJIT_END_NAMESPACE) |
479 | #define ASMJIT_BEGIN_NAMESPACE namespace asmjit { |
480 | #define ASMJIT_END_NAMESPACE } |
481 | #endif |
482 | |
483 | #define ASMJIT_BEGIN_SUB_NAMESPACE(NAMESPACE) \ |
484 | ASMJIT_BEGIN_NAMESPACE \ |
485 | namespace NAMESPACE { |
486 | |
487 | #define ASMJIT_END_SUB_NAMESPACE \ |
488 | } \ |
489 | ASMJIT_END_NAMESPACE |
490 | |
491 | // ============================================================================ |
492 | // [asmjit::Build - Globals - Utilities] |
493 | // ============================================================================ |
494 | |
495 | #define ASMJIT_NONCOPYABLE(...) \ |
496 | private: \ |
497 | __VA_ARGS__(const __VA_ARGS__& other) = delete; \ |
498 | __VA_ARGS__& operator=(const __VA_ARGS__& other) = delete; \ |
499 | public: |
500 | |
501 | #define ASMJIT_NONCONSTRUCTIBLE(...) \ |
502 | private: \ |
503 | __VA_ARGS__() = delete; \ |
504 | __VA_ARGS__(const __VA_ARGS__& other) = delete; \ |
505 | __VA_ARGS__& operator=(const __VA_ARGS__& other) = delete; \ |
506 | public: |
507 | |
508 | // ============================================================================ |
509 | // [asmjit::Build - Globals - Build-Only] |
510 | // ============================================================================ |
511 | |
512 | // Internal macros that are only used when building AsmJit itself. |
513 | #ifdef ASMJIT_EXPORTS |
514 | #if !defined(ASMJIT_BUILD_DEBUG) && ASMJIT_CXX_HAS_ATTRIBUTE(__optimize__, ASMJIT_CXX_GNU >= ASMJIT_CXX_MAKE_VER(4, 4, 0)) |
515 | #define ASMJIT_FAVOR_SIZE __attribute__((__optimize__("Os"))) |
516 | #define ASMJIT_FAVOR_SPEED __attribute__((__optimize__("O3"))) |
517 | #else |
518 | #define ASMJIT_FAVOR_SIZE |
519 | #define ASMJIT_FAVOR_SPEED |
520 | #endif |
521 | |
522 | // Only turn-off these warnings when building asmjit itself. |
523 | #ifdef _MSC_VER |
524 | #ifndef _CRT_SECURE_NO_DEPRECATE |
525 | #define _CRT_SECURE_NO_DEPRECATE |
526 | #endif |
527 | #ifndef _CRT_SECURE_NO_WARNINGS |
528 | #define _CRT_SECURE_NO_WARNINGS |
529 | #endif |
530 | #endif |
531 | #endif |
532 | |
533 | // ============================================================================ |
534 | // [asmjit::Build - Globals - Cleanup] |
535 | // ============================================================================ |
536 | |
537 | // Undefine everything that is not used by AsmJit outside of `build.h` and that |
538 | // is considered private. |
539 | #undef ASMJIT_CXX_CLANG |
540 | #undef ASMJIT_CXX_GNU |
541 | #undef ASMJIT_CXX_INTEL |
542 | #undef ASMJIT_CXX_MSC |
543 | #undef ASMJIT_CXX_MAKE_VER |
544 | |
545 | // ============================================================================ |
546 | // [asmjit::Build - Globals - Unit Testing Boilerplate] |
547 | // ============================================================================ |
548 | |
549 | // IDE: Make sure '#ifdef'ed unit tests are properly highlighted. |
550 | #if defined(__INTELLISENSE__) && !defined(ASMJIT_TEST) |
551 | #define ASMJIT_TEST |
552 | #endif |
553 | |
554 | // IDE: Make sure '#ifdef'ed unit tests are not disabled by IDE. |
555 | #if defined(ASMJIT_TEST) |
556 | #include "../../../test/broken.h" |
557 | #endif |
558 | |
559 | #endif // _ASMJIT_CORE_BUILD_H |
560 | |