/[pcre]/code/trunk/sljit/sljitConfigInternal.h
ViewVC logotype

Contents of /code/trunk/sljit/sljitConfigInternal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1491 - (show annotations)
Mon Jul 7 07:11:16 2014 UTC (5 years, 2 months ago) by zherczeg
File MIME type: text/plain
File size: 19453 byte(s)
Major JIT compiler update.
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_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
159 #define SLJIT_CONFIG_X86 1
160 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
161 || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
162 #define SLJIT_CONFIG_ARM 1
163 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
164 #define SLJIT_CONFIG_PPC 1
165 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
166 #define SLJIT_CONFIG_MIPS 1
167 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) || (defined SLJIT_CONFIG_SPARC_64 && SLJIT_CONFIG_SPARC_64)
168 #define SLJIT_CONFIG_SPARC 1
169 #endif
170
171 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
172 #define SLJIT_NUMBER_OF_REGISTERS 10
173 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
174 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
175 #ifndef _WIN64
176 #define SLJIT_NUMBER_OF_REGISTERS 12
177 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
178 #else
179 #define SLJIT_NUMBER_OF_REGISTERS 12
180 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
181 #endif /* _WIN64 */
182 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
183 #define SLJIT_NUMBER_OF_REGISTERS 11
184 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
185 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
186 #define SLJIT_NUMBER_OF_REGISTERS 11
187 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
188 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
189 #define SLJIT_NUMBER_OF_REGISTERS 23
190 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
191 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
192 #define SLJIT_NUMBER_OF_REGISTERS 22
193 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
194 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
195 #define SLJIT_NUMBER_OF_REGISTERS 17
196 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
197 #elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
198 #define SLJIT_NUMBER_OF_REGISTERS 18
199 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
200 #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
201 #define SLJIT_NUMBER_OF_REGISTERS 0
202 #define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
203 #endif
204
205 #define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
206 (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
207
208 #define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
209 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
210 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
211 #else
212 #define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
213 #endif
214
215 #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
216 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
217
218 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
219
220 /* These libraries are needed for the macros below. */
221 #include <stdlib.h>
222 #include <string.h>
223
224 #endif /* STD_MACROS_DEFINED */
225
226 /* General macros:
227 Note: SLJIT is designed to be independent from them as possible.
228
229 In release mode (SLJIT_DEBUG is not defined) only the following macros are needed:
230 */
231
232 #ifndef SLJIT_MALLOC
233 #define SLJIT_MALLOC(size) malloc(size)
234 #endif
235
236 #ifndef SLJIT_FREE
237 #define SLJIT_FREE(ptr) free(ptr)
238 #endif
239
240 #ifndef SLJIT_MEMMOVE
241 #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
242 #endif
243
244 #ifndef SLJIT_ZEROMEM
245 #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
246 #endif
247
248 #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
249
250 #if defined(__GNUC__) && (__GNUC__ >= 3)
251 #define SLJIT_LIKELY(x) __builtin_expect((x), 1)
252 #define SLJIT_UNLIKELY(x) __builtin_expect((x), 0)
253 #else
254 #define SLJIT_LIKELY(x) (x)
255 #define SLJIT_UNLIKELY(x) (x)
256 #endif
257
258 #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
259
260 #ifndef SLJIT_INLINE
261 /* Inline functions. Some old compilers do not support them. */
262 #if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
263 #define SLJIT_INLINE
264 #else
265 #define SLJIT_INLINE __inline
266 #endif
267 #endif /* !SLJIT_INLINE */
268
269 #ifndef SLJIT_CONST
270 /* Const variables. */
271 #define SLJIT_CONST const
272 #endif
273
274 #ifndef SLJIT_UNUSED_ARG
275 /* Unused arguments. */
276 #define SLJIT_UNUSED_ARG(arg) (void)arg
277 #endif
278
279 #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
280 /* Static ABI functions. For all-in-one programs. */
281
282 #if defined(__GNUC__)
283 /* Disable unused warnings in gcc. */
284 #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
285 #else
286 #define SLJIT_API_FUNC_ATTRIBUTE static
287 #endif
288
289 #else
290 #define SLJIT_API_FUNC_ATTRIBUTE
291 #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
292
293 #ifndef SLJIT_CACHE_FLUSH
294
295 #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
296
297 /* Not required to implement on archs with unified caches. */
298 #define SLJIT_CACHE_FLUSH(from, to)
299
300 #elif defined __APPLE__
301
302 /* Supported by all macs since Mac OS 10.5.
303 However, it does not work on non-jailbroken iOS devices,
304 although the compilation is successful. */
305
306 #define SLJIT_CACHE_FLUSH(from, to) \
307 sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
308
309 #elif defined __ANDROID__
310
311 /* Android lacks __clear_cache; instead, cacheflush should be used. */
312
313 #define SLJIT_CACHE_FLUSH(from, to) \
314 cacheflush((long)(from), (long)(to), 0)
315
316 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
317
318 /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
319 #define SLJIT_CACHE_FLUSH(from, to) \
320 ppc_cache_flush((from), (to))
321
322 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
323
324 /* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
325 #define SLJIT_CACHE_FLUSH(from, to) \
326 sparc_cache_flush((from), (to))
327
328 #else
329
330 /* Calls __ARM_NR_cacheflush on ARM-Linux. */
331 #define SLJIT_CACHE_FLUSH(from, to) \
332 __clear_cache((char*)(from), (char*)(to))
333
334 #endif
335
336 #endif /* !SLJIT_CACHE_FLUSH */
337
338 /* 8 bit byte type. */
339 typedef unsigned char sljit_ub;
340 typedef signed char sljit_sb;
341
342 /* 16 bit half-word type. */
343 typedef unsigned short int sljit_uh;
344 typedef signed short int sljit_sh;
345
346 /* 32 bit integer type. */
347 typedef unsigned int sljit_ui;
348 typedef signed int sljit_si;
349
350 /* Machine word type. Can encapsulate a pointer.
351 32 bit for 32 bit machines.
352 64 bit for 64 bit machines. */
353 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
354 /* Just to have something. */
355 #define SLJIT_WORD_SHIFT 0
356 typedef unsigned long int sljit_uw;
357 typedef long int sljit_sw;
358 #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
359 && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
360 && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
361 && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
362 && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
363 #define SLJIT_32BIT_ARCHITECTURE 1
364 #define SLJIT_WORD_SHIFT 2
365 typedef unsigned int sljit_uw;
366 typedef int sljit_sw;
367 #else
368 #define SLJIT_64BIT_ARCHITECTURE 1
369 #define SLJIT_WORD_SHIFT 3
370 #ifdef _WIN32
371 typedef unsigned __int64 sljit_uw;
372 typedef __int64 sljit_sw;
373 #else
374 typedef unsigned long int sljit_uw;
375 typedef long int sljit_sw;
376 #endif
377 #endif
378
379 typedef sljit_uw sljit_p;
380
381 /* Floating point types. */
382 typedef float sljit_s;
383 typedef double sljit_d;
384
385 /* Shift for pointer sized data. */
386 #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
387
388 /* Shift for double precision sized data. */
389 #define SLJIT_DOUBLE_SHIFT 3
390 #define SLJIT_SINGLE_SHIFT 2
391
392 #ifndef SLJIT_W
393
394 /* Defining long constants. */
395 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
396 #define SLJIT_W(w) (w##ll)
397 #else
398 #define SLJIT_W(w) (w)
399 #endif
400
401 #endif /* !SLJIT_W */
402
403 #ifndef SLJIT_CALL
404
405 /* ABI (Application Binary Interface) types. */
406 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
407
408 #if defined(__GNUC__) && !defined(__APPLE__)
409
410 #define SLJIT_CALL __attribute__ ((fastcall))
411 #define SLJIT_X86_32_FASTCALL 1
412
413 #elif defined(_MSC_VER)
414
415 #define SLJIT_CALL __fastcall
416 #define SLJIT_X86_32_FASTCALL 1
417
418 #elif defined(__BORLANDC__)
419
420 #define SLJIT_CALL __msfastcall
421 #define SLJIT_X86_32_FASTCALL 1
422
423 #else /* Unknown compiler. */
424
425 /* The cdecl attribute is the default. */
426 #define SLJIT_CALL
427
428 #endif
429
430 #else /* Non x86-32 architectures. */
431
432 #define SLJIT_CALL
433
434 #endif /* SLJIT_CONFIG_X86_32 */
435
436 #endif /* !SLJIT_CALL */
437
438 #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
439
440 /* These macros are useful for the applications. */
441 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
442 || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
443
444 #ifdef __LITTLE_ENDIAN__
445 #define SLJIT_LITTLE_ENDIAN 1
446 #else
447 #define SLJIT_BIG_ENDIAN 1
448 #endif
449
450 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
451 || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
452
453 #ifdef __MIPSEL__
454 #define SLJIT_LITTLE_ENDIAN 1
455 #else
456 #define SLJIT_BIG_ENDIAN 1
457 #endif
458
459 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
460
461 #define SLJIT_BIG_ENDIAN 1
462
463 #else
464 #define SLJIT_LITTLE_ENDIAN 1
465 #endif
466
467 #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
468
469 /* Sanity check. */
470 #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
471 #error "Exactly one endianness must be selected"
472 #endif
473
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 #ifndef SLJIT_INDIRECT_CALL
479 #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
480 || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
481 /* It seems certain ppc compilers use an indirect addressing for functions
482 which makes things complicated. */
483 #define SLJIT_INDIRECT_CALL 1
484 #endif
485 #endif /* SLJIT_INDIRECT_CALL */
486
487 #ifndef SLJIT_RETURN_ADDRESS_OFFSET
488 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
489 #define SLJIT_RETURN_ADDRESS_OFFSET 8
490 #else
491 #define SLJIT_RETURN_ADDRESS_OFFSET 0
492 #endif
493 #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
494
495 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
496 /* Auto detect SSE2 support using CPUID.
497 On 64 bit x86 cpus, sse2 must be present. */
498 #define SLJIT_DETECT_SSE2 1
499 #endif
500
501 #ifndef SLJIT_UNALIGNED
502
503 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
504 || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
505 || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
506 || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
507 || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
508 || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
509 || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
510 #define SLJIT_UNALIGNED 1
511 #endif
512
513 #endif /* !SLJIT_UNALIGNED */
514
515 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
516 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
517 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
518 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
519 #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
520 #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
521 #endif
522
523 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
524 #include <stdio.h>
525 #endif
526
527 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
528
529 #if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
530
531 /* SLJIT_HALT_PROCESS must halt the process. */
532 #ifndef SLJIT_HALT_PROCESS
533 #include <stdlib.h>
534
535 #define SLJIT_HALT_PROCESS() \
536 abort();
537 #endif /* !SLJIT_HALT_PROCESS */
538
539 #include <stdio.h>
540
541 #endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
542
543 /* Feel free to redefine these two macros. */
544 #ifndef SLJIT_ASSERT
545
546 #define SLJIT_ASSERT(x) \
547 do { \
548 if (SLJIT_UNLIKELY(!(x))) { \
549 printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
550 SLJIT_HALT_PROCESS(); \
551 } \
552 } while (0)
553
554 #endif /* !SLJIT_ASSERT */
555
556 #ifndef SLJIT_ASSERT_STOP
557
558 #define SLJIT_ASSERT_STOP() \
559 do { \
560 printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
561 SLJIT_HALT_PROCESS(); \
562 } while (0)
563
564 #endif /* !SLJIT_ASSERT_STOP */
565
566 #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
567
568 /* Forcing empty, but valid statements. */
569 #undef SLJIT_ASSERT
570 #undef SLJIT_ASSERT_STOP
571
572 #define SLJIT_ASSERT(x) \
573 do { } while (0)
574 #define SLJIT_ASSERT_STOP() \
575 do { } while (0)
576
577 #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
578
579 #ifndef SLJIT_COMPILE_ASSERT
580
581 /* Should be improved eventually. */
582 #define SLJIT_COMPILE_ASSERT(x, description) \
583 SLJIT_ASSERT(x)
584
585 #endif /* !SLJIT_COMPILE_ASSERT */
586
587 #endif

  ViewVC Help
Powered by ViewVC 1.1.5