1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
// AsmJit - Complete JIT Assembler for C++ Language.
// Copyright (c) 2008-2010, Petr Kobalicek <kobalicek.petr@gmail.com>
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// [Guard]
#ifndef _ASMJIT_BUILD_H
#define _ASMJIT_BUILD_H
// [Include]
#include "Config.h"
// Here should be optional include files that's needed fo successfuly
// use macros defined here. Remember, AsmJit uses only AsmJit namespace
// and all macros are used within it.
#include <stdio.h>
#include <stdlib.h>
// ----------------------------------------------------------------------------
// [AsmJit - OS]
// ----------------------------------------------------------------------------
#if defined(WINDOWS) || defined(__WINDOWS__) || defined(_WIN32) || defined(_WIN64)
# define ASMJIT_WINDOWS
#elif defined(__linux__) || defined(__unix__) || \
defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__DragonFly__) || defined(__BSD__) || defined(__FREEBSD__) || \
defined(__APPLE__)
# define ASMJIT_POSIX
#else
# warning "AsmJit - Can't match operating system, using ASMJIT_POSIX"
# define ASMJIT_POSIX
#endif
// ----------------------------------------------------------------------------
// [AsmJit - Architecture]
// ----------------------------------------------------------------------------
// define it only if it's not defined. In some systems we can
// use -D command in compiler to bypass this autodetection.
#if !defined(ASMJIT_X86) && !defined(ASMJIT_X64)
# if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || \
defined(_M_X64) || defined(_WIN64)
# define ASMJIT_X64 // x86-64
# else
// _M_IX86, __INTEL__, __i386__
# define ASMJIT_X86
# endif
#endif
// ----------------------------------------------------------------------------
// [AsmJit - API]
// ----------------------------------------------------------------------------
// Hide AsmJit symbols that we don't want to export (AssemblerIntrinsics class for example).
#if !defined(ASMJIT_HIDDEN)
# if defined(__GNUC__) && __GNUC__ >= 4
# define ASMJIT_HIDDEN __attribute__((visibility("hidden")))
# endif // __GNUC__ && __GNUC__ >= 4
#endif // ASMJIT_HIDDEN
// Make AsmJit as shared library by default.
#if !defined(ASMJIT_API)
# if defined(ASMJIT_WINDOWS)
# if defined(__GNUC__)
# if defined(AsmJit_EXPORTS)
# define ASMJIT_API __attribute__((dllexport))
# else
# define ASMJIT_API __attribute__((dllimport))
# endif // AsmJit_EXPORTS
# else
# if defined(AsmJit_EXPORTS)
# define ASMJIT_API __declspec(dllexport)
# else
# define ASMJIT_API __declspec(dllimport)
# endif // AsmJit_EXPORTS
# endif // __GNUC__
# else
# if defined(__GNUC__)
# if __GNUC__ >= 4
# define ASMJIT_API __attribute__((visibility("default")))
# define ASMJIT_VAR extern ASMJIT_API
# endif // __GNUC__ >= 4
# endif // __GNUC__
# endif
#endif // ASMJIT_API
#if defined(ASMJIT_API)
# define ASMJIT_VAR extern ASMJIT_API
#else
# define ASMJIT_API
# define ASMJIT_VAR
#endif // ASMJIT_API
// If not detected, fallback to nothing.
#if !defined(ASMJIT_HIDDEN)
# define ASMJIT_HIDDEN
#endif // ASMJIT_HIDDEN
#if !defined(ASMJIT_NOTHROW)
#define ASMJIT_NOTHROW throw()
#endif // ASMJIT_NOTHROW
// [AsmJit - Memory Management]
#if !defined(ASMJIT_MALLOC)
# define ASMJIT_MALLOC ::malloc
#endif // ASMJIT_MALLOC
#if !defined(ASMJIT_REALLOC)
# define ASMJIT_REALLOC ::realloc
#endif // ASMJIT_REALLOC
#if !defined(ASMJIT_FREE)
# define ASMJIT_FREE ::free
#endif // ASMJIT_FREE
// ----------------------------------------------------------------------------
// [AsmJit - Calling Conventions]
// ----------------------------------------------------------------------------
#if defined(ASMJIT_X86)
# if defined(__GNUC__)
# define ASMJIT_REGPARM_1 __attribute__((regparm(1)))
# define ASMJIT_REGPARM_2 __attribute__((regparm(2)))
# define ASMJIT_REGPARM_3 __attribute__((regparm(3)))
# define ASMJIT_FASTCALL __attribute__((fastcall))
# define ASMJIT_STDCALL __attribute__((stdcall))
# define ASMJIT_CDECL __attribute__((cdecl))
# else
# define ASMJIT_FASTCALL __fastcall
# define ASMJIT_STDCALL __stdcall
# define ASMJIT_CDECL __cdecl
# endif
#else
# define ASMJIT_FASTCALL
# define ASMJIT_STDCALL
# define ASMJIT_CDECL
#endif // ASMJIT_X86
#if !defined(ASMJIT_UNUSED)
# define ASMJIT_UNUSED(var) ((void)var)
#endif // ASMJIT_UNUSED
#if !defined(ASMJIT_NOP)
# define ASMJIT_NOP() ((void)0)
#endif // ASMJIT_NOP
// [AsmJit - C++ Compiler Support]
#define ASMJIT_TYPE_TO_TYPE(type) type
#define ASMJIT_HAS_STANDARD_DEFINE_OPTIONS
#define ASMJIT_HAS_PARTIAL_TEMPLATE_SPECIALIZATION
// Support for VC6
#if defined(_MSC_VER) && (_MSC_VER < 1400)
#undef ASMJIT_TYPE_TO_TYPE
namespace AsmJit {
template<typename T>
struct _Type2Type { typedef T Type; };
}
#define ASMJIT_TYPE_TO_TYPE(T) _Type2Type<T>::Type
#undef ASMJIT_HAS_STANDARD_DEFINE_OPTIONS
#undef ASMJIT_HAS_PARTIAL_TEMPLATE_SPECIALIZATION
#endif
// ----------------------------------------------------------------------------
// [AsmJit - Types]
// ----------------------------------------------------------------------------
#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
// Use <stdint.h>
#include <stdint.h>
#else
// Use typedefs.
#if defined(_MSC_VER)
#if (_MSC_VER < 1300)
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif
#endif // _MSC_VER
#endif // STDINT.H
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
#if defined(ASMJIT_X86)
typedef int32_t sysint_t;
typedef uint32_t sysuint_t;
#else
typedef int64_t sysint_t;
typedef uint64_t sysuint_t;
#endif
#if defined(_MSC_VER)
# define ASMJIT_INT64_C(num) num##i64
# define ASMJIT_UINT64_C(num) num##ui64
#else
# define ASMJIT_INT64_C(num) num##LL
# define ASMJIT_UINT64_C(num) num##ULL
#endif
// ----------------------------------------------------------------------------
// [AsmJit - C++ Macros]
// ----------------------------------------------------------------------------
#define ASMJIT_ARRAY_SIZE(A) (sizeof(A) / sizeof(*A))
#define ASMJIT_DISABLE_COPY(__type__) \
private: \
inline __type__(const __type__& other); \
inline __type__& operator=(const __type__& other);
// ----------------------------------------------------------------------------
// [AsmJit - Debug]
// ----------------------------------------------------------------------------
// If ASMJIT_DEBUG and ASMJIT_NO_DEBUG is not defined then ASMJIT_DEBUG will be
// detected using the compiler specific macros. This enables to set the build
// type using IDE.
#if !defined(ASMJIT_DEBUG) && !defined(ASMJIT_NO_DEBUG)
#if defined(_DEBUG)
#define ASMJIT_DEBUG
#endif // _DEBUG
#endif // !ASMJIT_DEBUG && !ASMJIT_NO_DEBUG
// ----------------------------------------------------------------------------
// [AsmJit - Assert]
// ----------------------------------------------------------------------------
namespace AsmJit {
ASMJIT_API void assertionFailure(const char* file, int line, const char* exp);
} // AsmJit namespace
#if defined(ASMJIT_DEBUG)
# if !defined(ASMJIT_ASSERT)
# define ASMJIT_ASSERT(exp) do { if (!(exp)) ::AsmJit::assertionFailure(__FILE__, __LINE__, #exp); } while(0)
# endif
#else
# if !defined(ASMJIT_ASSERT)
# define ASMJIT_ASSERT(exp) ASMJIT_NOP()
# endif
#endif // DEBUG
// GCC warnings fix: I can't understand why GCC has no interface to push/pop
// specific warnings.
// #if defined(__GNUC__)
// # if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 402001
// # pragma GCC diagnostic ignored "-w"
// # endif
// #endif // __GNUC__
// ----------------------------------------------------------------------------
// [AsmJit - OS Support]
// ----------------------------------------------------------------------------
#if defined(ASMJIT_WINDOWS)
#include <Windows.h>
#endif // ASMJIT_WINDOWS
// [Guard]
#endif // _ASMJIT_BUILD_H
|