Browse code

update for C++17 compliance, update to latest 2sf, add WINE cross-compile makefiles

Adam Higerd authored on 2021/02/11 15:36:17
Showing 1 changed files
... ...
@@ -10,7 +10,7 @@
10 10
 #ifdef ASMJIT_CONFIG_FILE
11 11
 # include ASMJIT_CONFIG_FILE
12 12
 #else
13
-# include "./config.h"
13
+# include "./Config.h"
14 14
 #endif // ASMJIT_CONFIG_FILE
15 15
 
16 16
 // Turn off deprecation warnings when compiling AsmJit.
... ...
@@ -264,7 +264,7 @@
264 264
 namespace asmjit { static inline int disabledTrace(...) { return 0; } }
265 265
 # ifdef ASMJIT_TRACE
266 266
 #  define ASMJIT_TSEC(_Section_) _Section_
267
-#  define ASMJIT_TLOG ::printf(__VA_ARGS__)
267
+#  define ASMJIT_TLOG ::fprintf(stderr, __VA_ARGS__)
268 268
 # else
269 269
 #  define ASMJIT_TSEC(_Section_) do {} while(0)
270 270
 #  define ASMJIT_TLOG 0 && ::asmjit::disabledTrace
Browse code

Some recent fixes from asmjit.

Naram Qashat authored on 2014/09/22 11:11:14
Showing 1 changed files
... ...
@@ -236,7 +236,7 @@
236 236
 
237 237
 //! Cross-platform solution to get offset of `_Field_` in `_Struct_`.
238 238
 #define ASMJIT_OFFSET_OF(_Struct_, _Field_) \
239
-  (reinterpret_cast<size_t>(reinterpret_cast<const uint8_t*>(&reinterpret_cast<const _Struct_*>(0x1)->_Field_)) - 1)
239
+  (reinterpret_cast<intptr_t>(reinterpret_cast<const uint8_t*>(&reinterpret_cast<const _Struct_*>(0x1)->_Field_)) - 1)
240 240
 
241 241
 // ============================================================================
242 242
 // [asmjit::build - ASMJIT_ARRAY_SIZE]
Browse code

* Fixes for gcc and clang (while they can compile the code, the DLLs made aren't functional, but oh well).

* [2SF] Used more up-to-date asmjit, despite the ugly looking code.

Naram Qashat authored on 2014/09/17 19:51:45
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,371 @@
1
+// [AsmJit]
2
+// Complete x86/x64 JIT and Remote Assembler for C++.
3
+//
4
+// [License]
5
+// Zlib - See LICENSE.md file in the package.
6
+
7
+#pragma once
8
+
9
+// [Include]
10
+#ifdef ASMJIT_CONFIG_FILE
11
+# include ASMJIT_CONFIG_FILE
12
+#else
13
+# include "./config.h"
14
+#endif // ASMJIT_CONFIG_FILE
15
+
16
+// Turn off deprecation warnings when compiling AsmJit.
17
+#if defined(ASMJIT_EXPORTS) && defined(_MSC_VER)
18
+# ifndef _CRT_SECURE_NO_DEPRECATE
19
+#  define _CRT_SECURE_NO_DEPRECATE
20
+# endif // !_CRT_SECURE_NO_DEPRECATE
21
+# ifndef _CRT_SECURE_NO_WARNINGS
22
+#  define _CRT_SECURE_NO_WARNINGS
23
+# endif // !_CRT_SECURE_NO_WARNINGS
24
+#endif // ASMJIT_EXPORTS
25
+
26
+// [Dependencies - C]
27
+#include <cstdio>
28
+#include <cstdlib>
29
+#include <cstring>
30
+
31
+// [Dependencies - C++]
32
+#include <new>
33
+
34
+// ============================================================================
35
+// [asmjit::build - Sanity]
36
+// ============================================================================
37
+
38
+#if defined(ASMJIT_DISABLE_NAMES) && !defined(ASMJIT_DISABLE_LOGGER)
39
+# error "ASMJIT_DISABLE_NAMES requires ASMJIT_DISABLE_LOGGER to be defined."
40
+#endif // ASMJIT_DISABLE_NAMES && !ASMJIT_DISABLE_LOGGER
41
+
42
+// ============================================================================
43
+// [asmjit::build - OS]
44
+// ============================================================================
45
+
46
+#if defined(_WINDOWS) || defined(__WINDOWS__) || defined(_WIN32) || defined(_WIN64)
47
+# define ASMJIT_OS_WINDOWS
48
+#elif defined(__linux) || defined(__linux__)
49
+# define ASMJIT_OS_POSIX
50
+# define ASMJIT_OS_LINUX
51
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
52
+# define ASMJIT_OS_POSIX
53
+# define ASMJIT_OS_BSD
54
+#elif defined(__APPLE__)
55
+# define ASMJIT_OS_POSIX
56
+# define ASMJIT_OS_MAC
57
+#else
58
+# warning "AsmJit - Unable to detect host operating system, using ASMJIT_OS_POSIX"
59
+# define ASMJIT_OS_POSIX
60
+#endif
61
+
62
+// ============================================================================
63
+// [asmjit::build - Arch]
64
+// ============================================================================
65
+
66
+#if defined(_M_X64    ) || \
67
+    defined(_M_AMD64  ) || \
68
+    defined(_WIN64    ) || \
69
+    defined(__amd64__ ) || \
70
+    defined(__LP64    ) || \
71
+    defined(__x86_64__)
72
+# define ASMJIT_HOST_X64
73
+# define ASMJIT_HOST_LE
74
+# define ASMJIT_HOST_UNALIGNED_16
75
+# define ASMJIT_HOST_UNALIGNED_32
76
+# define ASMJIT_HOST_UNALIGNED_64
77
+#elif \
78
+    defined(_M_IX86  ) || \
79
+    defined(__INTEL__) || \
80
+    defined(__i386__ )
81
+# define ASMJIT_HOST_X86
82
+# define ASMJIT_HOST_LE
83
+# define ASMJIT_HOST_UNALIGNED_16
84
+# define ASMJIT_HOST_UNALIGNED_32
85
+# define ASMJIT_HOST_UNALIGNED_64
86
+#elif \
87
+    defined(_ARM               ) || \
88
+    defined(_M_ARM_FP          ) || \
89
+    defined(__ARM_NEON__       ) || \
90
+    defined(__arm              ) || \
91
+    defined(__arm__            ) || \
92
+    defined(__TARGET_ARCH_ARM  ) || \
93
+    defined(__TARGET_ARCH_THUMB) || \
94
+    defined(__thumb__          )
95
+# define ASMJIT_HOST_ARM
96
+# define ASMJIT_HOST_LE
97
+#else
98
+# warning "AsmJit - Unable to detect host architecture"
99
+#endif
100
+
101
+// ============================================================================
102
+// [asmjit::build - Build]
103
+// ============================================================================
104
+
105
+// Build host architecture if no architecture is selected.
106
+#if !defined(ASMJIT_BUILD_HOST) && \
107
+    !defined(ASMJIT_BUILD_X86) && \
108
+    !defined(ASMJIT_BUILD_X64)
109
+# define ASMJIT_BUILD_HOST
110
+#endif
111
+
112
+// Autodetect host architecture if enabled.
113
+#ifdef ASMJIT_BUILD_HOST
114
+# if defined(ASMJIT_HOST_X86) && !defined(ASMJIT_BUILD_X86)
115
+#  define ASMJIT_BUILD_X86
116
+# endif // ASMJIT_HOST_X86 && !ASMJIT_BUILD_X86
117
+# if defined(ASMJIT_HOST_X64) && !defined(ASMJIT_BUILD_X64)
118
+#  define ASMJIT_BUILD_X64
119
+# endif // ASMJIT_HOST_X64 && !ASMJIT_BUILD_X64
120
+#endif // ASMJIT_BUILD_HOST
121
+
122
+// ============================================================================
123
+// [asmjit::build - Decorators]
124
+// ============================================================================
125
+
126
+#if defined(ASMJIT_EMBED) && !defined(ASMJIT_STATIC)
127
+# define ASMJIT_STATIC
128
+#endif // ASMJIT_EMBED && !ASMJIT_STATIC
129
+
130
+#ifdef ASMJIT_STATIC
131
+# define ASMJIT_API
132
+#elif defined(ASMJIT_OS_WINDOWS)
133
+# if (defined(__GNUC__) || defined(__clang__)) && !defined(__MINGW32__)
134
+#  ifdef ASMJIT_EXPORTS
135
+#   define ASMJIT_API __attribute__((dllexport))
136
+#  else
137
+#   define ASMJIT_API __attribute__((dllimport))
138
+#  endif // ASMJIT_EXPORTS
139
+# else
140
+#  ifdef ASMJIT_EXPORTS
141
+#   define ASMJIT_API __declspec(dllexport)
142
+#  else
143
+#   define ASMJIT_API __declspec(dllimport)
144
+#  endif
145
+# endif
146
+#elif defined(__GNUC__) && __GNUC__ >= 4
147
+# define ASMJIT_API __attribute__((visibility("default")))
148
+#endif
149
+
150
+#ifndef ASMJIT_API
151
+# define ASMJIT_API
152
+#endif // ASMJIT_API
153
+
154
+// This is basically a workaround. When using MSVC and marking class as DLL
155
+// export everything is exported, which is unwanted since there are many
156
+// inlines which mimic instructions. MSVC automatically exports typeinfo and
157
+// vtable if at least one symbol of that class is exported. However, GCC has
158
+// some strange behavior that even if one or more symbol is exported it doesn't
159
+// export `typeinfo` unless the class itself is marked as "visibility(default)".
160
+#if !defined(ASMJIT_OS_WINDOWS) && (defined(__GNUC__) || defined (__clang__))
161
+# define ASMJIT_VCLASS ASMJIT_API
162
+#else
163
+# define ASMJIT_VCLASS
164
+#endif
165
+
166
+#ifndef ASMJIT_VAR
167
+# define ASMJIT_VAR extern ASMJIT_API
168
+#endif // !ASMJIT_VAR
169
+
170
+#ifdef _MSC_VER
171
+# define ASMJIT_INLINE __forceinline
172
+#elif defined(__clang__)
173
+# define ASMJIT_INLINE inline __attribute__((always_inline)) __attribute__((visibility("hidden")))
174
+#elif defined(__GNUC__)
175
+# define ASMJIT_INLINE inline __attribute__((always_inline))
176
+#else
177
+# define ASMJIT_INLINE inline
178
+#endif
179
+
180
+#ifdef ASMJIT_HOST_X86
181
+# if defined(__GNUC__) || defined(__clang__)
182
+#  define ASMJIT_REGPARM_1 __attribute__((regparm(1)))
183
+#  define ASMJIT_REGPARM_2 __attribute__((regparm(2)))
184
+#  define ASMJIT_REGPARM_3 __attribute__((regparm(3)))
185
+#  define ASMJIT_FASTCALL  __attribute__((fastcall))
186
+#  define ASMJIT_STDCALL   __attribute__((stdcall))
187
+#  define ASMJIT_CDECL     __attribute__((cdecl))
188
+# else
189
+#  define ASMJIT_FASTCALL  __fastcall
190
+#  define ASMJIT_STDCALL   __stdcall
191
+#  define ASMJIT_CDECL     __cdecl
192
+# endif
193
+#else
194
+# define ASMJIT_FASTCALL
195
+# define ASMJIT_STDCALL
196
+# define ASMJIT_CDECL
197
+#endif // ASMJIT_HOST_X86
198
+
199
+// ============================================================================
200
+// [asmjit::build - Enum]
201
+// ============================================================================
202
+
203
+#ifdef _MSC_VER
204
+# define ASMJIT_ENUM(_Name_) enum _Name_ : uint32_t
205
+#else
206
+# define ASMJIT_ENUM(_Name_) enum _Name_
207
+#endif
208
+
209
+// ============================================================================
210
+// [asmjit::build - Memory Management]
211
+// ============================================================================
212
+
213
+#if !defined(ASMJIT_ALLOC) && !defined(ASMJIT_REALLOC) && !defined(ASMJIT_FREE)
214
+# define ASMJIT_ALLOC(_Size_) ::malloc(_Size_)
215
+# define ASMJIT_REALLOC(_Ptr_, _Size_) ::realloc(_Ptr_, _Size_)
216
+# define ASMJIT_FREE(_Ptr_) ::free(_Ptr_)
217
+#else
218
+# if !defined(ASMJIT_ALLOC) || !defined(ASMJIT_REALLOC) || !defined(ASMJIT_FREE)
219
+#  error "AsmJit - You must redefine ASMJIT_ALLOC, ASMJIT_REALLOC and ASMJIT_FREE."
220
+# endif
221
+#endif // !ASMJIT_ALLOC && !ASMJIT_REALLOC && !ASMJIT_FREE
222
+
223
+// ============================================================================
224
+// [asmjit::build - _ASMJIT_HOST_INDEX]
225
+// ============================================================================
226
+
227
+#ifdef ASMJIT_HOST_LE
228
+# define _ASMJIT_HOST_INDEX(_Total_, _Index_) (_Index_)
229
+#else
230
+# define _ASMJIT_HOST_INDEX(_Total_, _Index_) ((_Total_) - 1 - (_Index_))
231
+#endif
232
+
233
+// ============================================================================
234
+// [asmjit::build - BLEND_OFFSET_OF]
235
+// ============================================================================
236
+
237
+//! Cross-platform solution to get offset of `_Field_` in `_Struct_`.
238
+#define ASMJIT_OFFSET_OF(_Struct_, _Field_) \
239
+  (reinterpret_cast<size_t>(reinterpret_cast<const uint8_t*>(&reinterpret_cast<const _Struct_*>(0x1)->_Field_)) - 1)
240
+
241
+// ============================================================================
242
+// [asmjit::build - ASMJIT_ARRAY_SIZE]
243
+// ============================================================================
244
+
245
+#define ASMJIT_ARRAY_SIZE(_Array_) \
246
+  (sizeof(_Array_) / sizeof(*_Array_))
247
+
248
+// ============================================================================
249
+// [asmjit::build - ASMJIT_DEBUG / ASMJIT_TRACE]
250
+// ============================================================================
251
+
252
+// If ASMJIT_DEBUG and ASMJIT_RELEASE is not defined ASMJIT_DEBUG will be
253
+// detected using the compiler specific macros. This enables to set the build
254
+// type using IDE.
255
+#if !defined(ASMJIT_DEBUG) && !defined(ASMJIT_RELEASE)
256
+# ifdef _DEBUG
257
+#  define ASMJIT_DEBUG
258
+# endif // _DEBUG
259
+#endif // !ASMJIT_DEBUG && !ASMJIT_RELEASE
260
+
261
+// ASMJIT_TRACE is only used by sources and private headers. It's safe to make
262
+// it unavailable outside of AsmJit.
263
+#ifdef ASMJIT_EXPORTS
264
+namespace asmjit { static inline int disabledTrace(...) { return 0; } }
265
+# ifdef ASMJIT_TRACE
266
+#  define ASMJIT_TSEC(_Section_) _Section_
267
+#  define ASMJIT_TLOG ::printf(__VA_ARGS__)
268
+# else
269
+#  define ASMJIT_TSEC(_Section_) do {} while(0)
270
+#  define ASMJIT_TLOG 0 && ::asmjit::disabledTrace
271
+# endif // ASMJIT_TRACE
272
+#endif // ASMJIT_EXPORTS
273
+
274
+// ============================================================================
275
+// [asmjit::build - ASMJIT_UNUSED]
276
+// ============================================================================
277
+
278
+#ifndef ASMJIT_UNUSED
279
+# define ASMJIT_UNUSED(_Var_) ((void)_Var_)
280
+#endif // ASMJIT_UNUSED
281
+
282
+// ============================================================================
283
+// [asmjit::build - ASMJIT_NOP]
284
+// ============================================================================
285
+
286
+#ifndef ASMJIT_NOP
287
+# define ASMJIT_NOP() ((void)0)
288
+#endif // ASMJIT_NOP
289
+
290
+// ============================================================================
291
+// [asmjit::build - ASMJIT_NO_COPY]
292
+// ============================================================================
293
+
294
+#define ASMJIT_NO_COPY(_Type_) \
295
+private: \
296
+  ASMJIT_INLINE _Type_(const _Type_& other); \
297
+  ASMJIT_INLINE _Type_& operator=(const _Type_& other); \
298
+public:
299
+
300
+// ============================================================================
301
+// [asmjit::build - StdInt]
302
+// ============================================================================
303
+
304
+#ifdef __MINGW32__
305
+# include <sys/types.h>
306
+#endif // __MINGW32__
307
+
308
+#if defined(_MSC_VER) && _MSC_VER < 1600
309
+# ifndef ASMJIT_SUPRESS_STD_TYPES
310
+#  if _MSC_VER < 1300
311
+typedef signed char int8_t;
312
+typedef signed short int16_t;
313
+typedef signed int int32_t;
314
+typedef signed __int64 int64_t;
315
+typedef unsigned char uint8_t;
316
+typedef unsigned short uint16_t;
317
+typedef unsigned int uint32_t;
318
+typedef unsigned __int64 uint64_t;
319
+#  else
320
+typedef signed __int8 int8_t;
321
+typedef signed __int16 int16_t;
322
+typedef signed __int32 int32_t;
323
+typedef signed __int64 int64_t;
324
+typedef unsigned __int8 uint8_t;
325
+typedef unsigned __int16 uint16_t;
326
+typedef unsigned __int32 uint32_t;
327
+typedef unsigned __int64 uint64_t;
328
+#  endif // _MSC_VER
329
+# endif // ASMJIT_SUPRESS_STD_TYPES
330
+#else
331
+# include <cstdint>
332
+# include <climits>
333
+#endif
334
+
335
+#ifdef _MSC_VER
336
+# define ASMJIT_INT64_C(_Num_) _Num_##i64
337
+# define ASMJIT_UINT64_C(_Num_) _Num_##ui64
338
+#else
339
+# define ASMJIT_INT64_C(_Num_) _Num_##LL
340
+# define ASMJIT_UINT64_C(_Num_) _Num_##ULL
341
+#endif
342
+
343
+// ============================================================================
344
+// [asmjit::build - Windows]
345
+// ============================================================================
346
+
347
+#if defined(ASMJIT_OS_WINDOWS) && !defined(ASMJIT_SUPRESS_WINDOWS_H)
348
+
349
+# ifndef WIN32_LEAN_AND_MEAN
350
+#  define WIN32_LEAN_AND_MEAN
351
+#  define ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN
352
+# endif // !WIN32_LEAN_AND_MEAN
353
+
354
+# ifndef NOMINMAX
355
+#  define NOMINMAX
356
+#  define ASMJIT_UNDEF_NOMINMAX
357
+# endif // !NOMINMAX
358
+
359
+# include <windows.h>
360
+
361
+# ifdef ASMJIT_UNDEF_NOMINMAX
362
+#  undef NOMINMAX
363
+#  undef ASMJIT_UNDEF_NOMINMAX
364
+# endif
365
+
366
+# ifdef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN
367
+#  undef WIN32_LEAN_AND_MEAN
368
+#  undef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN
369
+# endif
370
+
371
+#endif // ASMJIT_OS_WINDOWS  && !ASMJIT_SUPRESS_WINDOWS_H