• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *    Stack-less Just-In-Time compiler
3  *
4  *    Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without modification, are
7  * permitted provided that the following conditions are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright notice, this list of
10  *      conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright notice, this list
13  *      of conditions and the following disclaimer in the documentation and/or other materials
14  *      provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _SLJIT_CONFIG_INTERNAL_H_
28 #define _SLJIT_CONFIG_INTERNAL_H_
29 
30 /*
31    SLJIT defines the following architecture dependent types and macros:
32 
33    Types:
34      sljit_sb, sljit_ub : signed and unsigned 8 bit byte
35      sljit_sh, sljit_uh : signed and unsigned 16 bit half-word (short) type
36      sljit_si, sljit_ui : signed and unsigned 32 bit integer type
37      sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
38      sljit_p : unsgined pointer value (usually the same as sljit_uw, but
39                some 64 bit ABIs may use 32 bit pointers)
40      sljit_s : single precision floating point value
41      sljit_d : double precision floating point value
42 
43    Macros for feature detection (boolean):
44      SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
45      SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
46      SLJIT_LITTLE_ENDIAN : little endian architecture
47      SLJIT_BIG_ENDIAN : big endian architecture
48      SLJIT_UNALIGNED : allows unaligned memory accesses for non-fpu operations (only!)
49      SLJIT_INDIRECT_CALL : see SLJIT_FUNC_OFFSET() for more information
50 
51    Constants:
52      SLJIT_NUMBER_OF_REGISTERS : number of available registers
53      SLJIT_NUMBER_OF_SCRATCH_REGISTERS : number of available scratch registers
54      SLJIT_NUMBER_OF_SAVED_REGISTERS : number of available saved registers
55      SLJIT_NUMBER_OF_FLOAT_REGISTERS : number of available floating point registers
56      SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS : number of available floating point scratch registers
57      SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS : number of available floating point saved registers
58      SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
59      SLJIT_DOUBLE_SHIFT : the shift required to apply when accessing
60                           a double precision floating point array by index
61      SLJIT_SINGLE_SHIFT : the shift required to apply when accessing
62                           a single precision floating point array by index
63      SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
64 
65    Other macros:
66      SLJIT_CALL : C calling convention define for both calling JIT form C and C callbacks for JIT
67      SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
68 */
69 
70 #if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
71 	|| (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
72 	|| (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
73 	|| (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
74 	|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
75 	|| (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
76 	|| (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
77 	|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
78 	|| (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
79 	|| (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
80 	|| (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
81 	|| (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
82 	|| (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
83 	|| (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
84 #error "An architecture must be selected"
85 #endif
86 
87 /* Sanity check. */
88 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
89 	+ (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
90 	+ (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
91 	+ (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
92 	+ (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
93 	+ (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
94 	+ (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
95 	+ (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
96 	+ (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
97 	+ (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
98 	+ (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
99 	+ (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
100 	+ (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
101 	+ (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
102 #error "Multiple architectures are selected"
103 #endif
104 
105 /* Auto select option (requires compiler support) */
106 #if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
107 
108 #ifndef _WIN32
109 
110 #if defined(__i386__) || defined(__i386)
111 #define SLJIT_CONFIG_X86_32 1
112 #elif defined(__x86_64__)
113 #define SLJIT_CONFIG_X86_64 1
114 #elif defined(__arm__) || defined(__ARM__)
115 #ifdef __thumb2__
116 #define SLJIT_CONFIG_ARM_THUMB2 1
117 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
118 #define SLJIT_CONFIG_ARM_V7 1
119 #else
120 #define SLJIT_CONFIG_ARM_V5 1
121 #endif
122 #elif defined (__aarch64__)
123 #define SLJIT_CONFIG_ARM_64 1
124 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
125 #define SLJIT_CONFIG_PPC_64 1
126 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
127 #define SLJIT_CONFIG_PPC_32 1
128 #elif defined(__mips__) && !defined(_LP64)
129 #define SLJIT_CONFIG_MIPS_32 1
130 #elif defined(__mips64)
131 #define SLJIT_CONFIG_MIPS_64 1
132 #elif defined(__sparc__) || defined(__sparc)
133 #define SLJIT_CONFIG_SPARC_32 1
134 #elif defined(__tilegx__)
135 #define SLJIT_CONFIG_TILEGX 1
136 #else
137 /* Unsupported architecture */
138 #define SLJIT_CONFIG_UNSUPPORTED 1
139 #endif
140 
141 #else /* !_WIN32 */
142 
143 #if defined(_M_X64) || defined(__x86_64__)
144 #define SLJIT_CONFIG_X86_64 1
145 #elif defined(_ARM_)
146 #define SLJIT_CONFIG_ARM_V5 1
147 #else
148 #define SLJIT_CONFIG_X86_32 1
149 #endif
150 
151 #endif /* !WIN32 */
152 #endif /* SLJIT_CONFIG_AUTO */
153 
154 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
155 #undef SLJIT_EXECUTABLE_ALLOCATOR
156 #endif
157 
158 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
159 	|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
160 #define SLJIT_CONFIG_ARM_32 1
161 #endif
162 
163 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
164 #define SLJIT_CONFIG_X86 1
165 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
166 #define SLJIT_CONFIG_ARM 1
167 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
168 #define SLJIT_CONFIG_PPC 1
169 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
170 #define SLJIT_CONFIG_MIPS 1
171 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) || (defined SLJIT_CONFIG_SPARC_64 && SLJIT_CONFIG_SPARC_64)
172 #define SLJIT_CONFIG_SPARC 1
173 #endif
174 
175 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
176 #define SLJIT_NUMBER_OF_REGISTERS 10
177 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
178 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
179 #ifndef _WIN64
180 #define SLJIT_NUMBER_OF_REGISTERS 12
181 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
182 #else
183 #define SLJIT_NUMBER_OF_REGISTERS 12
184 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
185 #endif /* _WIN64 */
186 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
187 #define SLJIT_NUMBER_OF_REGISTERS 11
188 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
189 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
190 #define SLJIT_NUMBER_OF_REGISTERS 11
191 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
192 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
193 #define SLJIT_NUMBER_OF_REGISTERS 23
194 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
195 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
196 #define SLJIT_NUMBER_OF_REGISTERS 22
197 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
198 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
199 #define SLJIT_NUMBER_OF_REGISTERS 17
200 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
201 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
202 #define SLJIT_NUMBER_OF_REGISTERS 18
203 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
204 #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
205 #define SLJIT_NUMBER_OF_REGISTERS 0
206 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
207 #endif
208 
209 #define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
210 	(SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
211 
212 #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
213 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
214 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
215 #else
216 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
217 #endif
218 
219 #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
220 	(SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
221 
222 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
223 
224 /* These libraries are needed for the macros below. */
225 #include <stdlib.h>
226 #include <string.h>
227 
228 #endif /* STD_MACROS_DEFINED */
229 
230 /* General macros:
231    Note: SLJIT is designed to be independent from them as possible.
232 
233    In release mode (SLJIT_DEBUG is not defined) only the following macros are needed:
234 */
235 
236 #ifndef SLJIT_MALLOC
237 #define SLJIT_MALLOC(size) malloc(size)
238 #endif
239 
240 #ifndef SLJIT_FREE
241 #define SLJIT_FREE(ptr) free(ptr)
242 #endif
243 
244 #ifndef SLJIT_MEMMOVE
245 #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
246 #endif
247 
248 #ifndef SLJIT_ZEROMEM
249 #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
250 #endif
251 
252 #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
253 
254 #if defined(__GNUC__) && (__GNUC__ >= 3)
255 #define SLJIT_LIKELY(x)		__builtin_expect((x), 1)
256 #define SLJIT_UNLIKELY(x)	__builtin_expect((x), 0)
257 #else
258 #define SLJIT_LIKELY(x)		(x)
259 #define SLJIT_UNLIKELY(x)	(x)
260 #endif
261 
262 #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
263 
264 #ifndef SLJIT_INLINE
265 /* Inline functions. Some old compilers do not support them. */
266 #if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
267 #define SLJIT_INLINE
268 #else
269 #define SLJIT_INLINE __inline
270 #endif
271 #endif /* !SLJIT_INLINE */
272 
273 #ifndef SLJIT_CONST
274 /* Const variables. */
275 #define SLJIT_CONST const
276 #endif
277 
278 #ifndef SLJIT_UNUSED_ARG
279 /* Unused arguments. */
280 #define SLJIT_UNUSED_ARG(arg) (void)arg
281 #endif
282 
283 #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
284 /* Static ABI functions. For all-in-one programs. */
285 
286 #if defined(__GNUC__)
287 /* Disable unused warnings in gcc. */
288 #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
289 #else
290 #define SLJIT_API_FUNC_ATTRIBUTE static
291 #endif
292 
293 #else
294 #define SLJIT_API_FUNC_ATTRIBUTE
295 #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
296 
297 #ifndef SLJIT_CACHE_FLUSH
298 
299 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
300 
301 /* Not required to implement on archs with unified caches. */
302 #define SLJIT_CACHE_FLUSH(from, to)
303 
304 #elif defined __APPLE__
305 
306 /* Supported by all macs since Mac OS 10.5.
307    However, it does not work on non-jailbroken iOS devices,
308    although the compilation is successful. */
309 
310 #define SLJIT_CACHE_FLUSH(from, to) \
311 	sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
312 
313 #elif defined __ANDROID__
314 
315 /* Android lacks __clear_cache; instead, cacheflush should be used. */
316 
317 #define SLJIT_CACHE_FLUSH(from, to) \
318     cacheflush((long)(from), (long)(to), 0)
319 
320 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
321 
322 /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
323 #define SLJIT_CACHE_FLUSH(from, to) \
324 	ppc_cache_flush((from), (to))
325 
326 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
327 
328 /* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
329 #define SLJIT_CACHE_FLUSH(from, to) \
330 	sparc_cache_flush((from), (to))
331 
332 #else
333 
334 /* Calls __ARM_NR_cacheflush on ARM-Linux. */
335 #define SLJIT_CACHE_FLUSH(from, to) \
336 	__clear_cache((char*)(from), (char*)(to))
337 
338 #endif
339 
340 #endif /* !SLJIT_CACHE_FLUSH */
341 
342 /* 8 bit byte type. */
343 typedef unsigned char sljit_ub;
344 typedef signed char sljit_sb;
345 
346 /* 16 bit half-word type. */
347 typedef unsigned short int sljit_uh;
348 typedef signed short int sljit_sh;
349 
350 /* 32 bit integer type. */
351 typedef unsigned int sljit_ui;
352 typedef signed int sljit_si;
353 
354 /* Machine word type. Can encapsulate a pointer.
355      32 bit for 32 bit machines.
356      64 bit for 64 bit machines. */
357 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
358 /* Just to have something. */
359 #define SLJIT_WORD_SHIFT 0
360 typedef unsigned long int sljit_uw;
361 typedef long int sljit_sw;
362 #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
363 	&& !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
364 	&& !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
365 	&& !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
366 	&& !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
367 #define SLJIT_32BIT_ARCHITECTURE 1
368 #define SLJIT_WORD_SHIFT 2
369 typedef unsigned int sljit_uw;
370 typedef int sljit_sw;
371 #else
372 #define SLJIT_64BIT_ARCHITECTURE 1
373 #define SLJIT_WORD_SHIFT 3
374 #ifdef _WIN32
375 typedef unsigned __int64 sljit_uw;
376 typedef __int64 sljit_sw;
377 #else
378 typedef unsigned long int sljit_uw;
379 typedef long int sljit_sw;
380 #endif
381 #endif
382 
383 typedef sljit_uw sljit_p;
384 
385 /* Floating point types. */
386 typedef float sljit_s;
387 typedef double sljit_d;
388 
389 /* Shift for pointer sized data. */
390 #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
391 
392 /* Shift for double precision sized data. */
393 #define SLJIT_DOUBLE_SHIFT 3
394 #define SLJIT_SINGLE_SHIFT 2
395 
396 #ifndef SLJIT_W
397 
398 /* Defining long constants. */
399 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
400 #define SLJIT_W(w)	(w##ll)
401 #else
402 #define SLJIT_W(w)	(w)
403 #endif
404 
405 #endif /* !SLJIT_W */
406 
407 #ifndef SLJIT_CALL
408 
409 /* ABI (Application Binary Interface) types. */
410 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
411 
412 #if defined(__GNUC__) && !defined(__APPLE__)
413 
414 #define SLJIT_CALL __attribute__ ((fastcall))
415 #define SLJIT_X86_32_FASTCALL 1
416 
417 #elif defined(_MSC_VER)
418 
419 #define SLJIT_CALL __fastcall
420 #define SLJIT_X86_32_FASTCALL 1
421 
422 #elif defined(__BORLANDC__)
423 
424 #define SLJIT_CALL __msfastcall
425 #define SLJIT_X86_32_FASTCALL 1
426 
427 #else /* Unknown compiler. */
428 
429 /* The cdecl attribute is the default. */
430 #define SLJIT_CALL
431 
432 #endif
433 
434 #else /* Non x86-32 architectures. */
435 
436 #define SLJIT_CALL
437 
438 #endif /* SLJIT_CONFIG_X86_32 */
439 
440 #endif /* !SLJIT_CALL */
441 
442 #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
443 
444 /* These macros are useful for the applications. */
445 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
446 	|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
447 
448 #ifdef __LITTLE_ENDIAN__
449 #define SLJIT_LITTLE_ENDIAN 1
450 #else
451 #define SLJIT_BIG_ENDIAN 1
452 #endif
453 
454 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
455 	|| (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
456 
457 #ifdef __MIPSEL__
458 #define SLJIT_LITTLE_ENDIAN 1
459 #else
460 #define SLJIT_BIG_ENDIAN 1
461 #endif
462 
463 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
464 
465 #define SLJIT_BIG_ENDIAN 1
466 
467 #else
468 #define SLJIT_LITTLE_ENDIAN 1
469 #endif
470 
471 #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
472 
473 /* Sanity check. */
474 #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
475 #error "Exactly one endianness must be selected"
476 #endif
477 
478 #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
479 #error "Exactly one endianness must be selected"
480 #endif
481 
482 #ifndef SLJIT_INDIRECT_CALL
483 #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
484 	|| ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
485 /* It seems certain ppc compilers use an indirect addressing for functions
486    which makes things complicated. */
487 #define SLJIT_INDIRECT_CALL 1
488 #endif
489 #endif /* SLJIT_INDIRECT_CALL */
490 
491 #ifndef SLJIT_RETURN_ADDRESS_OFFSET
492 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
493 #define SLJIT_RETURN_ADDRESS_OFFSET 8
494 #else
495 #define SLJIT_RETURN_ADDRESS_OFFSET 0
496 #endif
497 #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
498 
499 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
500 /* Auto detect SSE2 support using CPUID.
501    On 64 bit x86 cpus, sse2 must be present. */
502 #define SLJIT_DETECT_SSE2 1
503 #endif
504 
505 #ifndef SLJIT_UNALIGNED
506 
507 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
508 	|| (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
509 	|| (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
510 	|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
511 	|| (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
512 	|| (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
513 	|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
514 #define SLJIT_UNALIGNED 1
515 #endif
516 
517 #endif /* !SLJIT_UNALIGNED */
518 
519 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
520 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
521 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
522 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
523 #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
524 #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
525 #endif
526 
527 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
528 #include <stdio.h>
529 #endif
530 
531 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
532 
533 #if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
534 
535 /* SLJIT_HALT_PROCESS must halt the process. */
536 #ifndef SLJIT_HALT_PROCESS
537 #include <stdlib.h>
538 
539 #define SLJIT_HALT_PROCESS() \
540 	abort();
541 #endif /* !SLJIT_HALT_PROCESS */
542 
543 #include <stdio.h>
544 
545 #endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
546 
547 /* Feel free to redefine these two macros. */
548 #ifndef SLJIT_ASSERT
549 
550 #define SLJIT_ASSERT(x) \
551 	do { \
552 		if (SLJIT_UNLIKELY(!(x))) { \
553 			printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
554 			SLJIT_HALT_PROCESS(); \
555 		} \
556 	} while (0)
557 
558 #endif /* !SLJIT_ASSERT */
559 
560 #ifndef SLJIT_ASSERT_STOP
561 
562 #define SLJIT_ASSERT_STOP() \
563 	do { \
564 		printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
565 		SLJIT_HALT_PROCESS(); \
566 	} while (0)
567 
568 #endif /* !SLJIT_ASSERT_STOP */
569 
570 #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
571 
572 /* Forcing empty, but valid statements. */
573 #undef SLJIT_ASSERT
574 #undef SLJIT_ASSERT_STOP
575 
576 #define SLJIT_ASSERT(x) \
577 	do { } while (0)
578 #define SLJIT_ASSERT_STOP() \
579 	do { } while (0)
580 
581 #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
582 
583 #ifndef SLJIT_COMPILE_ASSERT
584 
585 /* Should be improved eventually. */
586 #define SLJIT_COMPILE_ASSERT(x, description) \
587 	SLJIT_ASSERT(x)
588 
589 #endif /* !SLJIT_COMPILE_ASSERT */
590 
591 #endif
592