chiark / gitweb /
tidy up conflict
[pcre3.git] / sljit / sljitConfigInternal.h
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 macros depending on the target architecture:
32
33    Feature detection (boolean) macros:
34    SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
35    SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
36    SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
37    SLJIT_DOUBLE_SHIFT : the shift required to apply when accessing a double array by index
38    SLJIT_LITTLE_ENDIAN : little endian architecture
39    SLJIT_BIG_ENDIAN : big endian architecture
40    SLJIT_UNALIGNED : allows unaligned memory accesses for non-fpu operations (only!)
41    SLJIT_INDIRECT_CALL : see SLJIT_FUNC_OFFSET() for more information
42    SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
43
44    Types and useful macros:
45    sljit_sb, sljit_ub : signed and unsigned 8 bit byte
46    sljit_sh, sljit_uh : signed and unsigned 16 bit half-word (short) type
47    sljit_si, sljit_ui : signed and unsigned 32 bit integer type
48    sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
49    sljit_p : unsgined pointer value (usually the same as sljit_uw, but
50              some 64 bit ABIs may use 32 bit pointers)
51    sljit_s : single precision floating point value
52    sljit_d : double precision floating point value
53    SLJIT_CALL : C calling convention define for both calling JIT form C and C callbacks for JIT
54    SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
55 */
56
57 #if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
58         || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
59         || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
60         || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
61         || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
62         || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
63         || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
64         || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
65         || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
66         || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
67         || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
68         || (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
69         || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
70         || (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
71 #error "An architecture must be selected"
72 #endif
73
74 /* Sanity check. */
75 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
76         + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
77         + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
78         + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
79         + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
80         + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
81         + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
82         + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
83         + (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
84         + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
85         + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
86         + (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
87         + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
88         + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
89 #error "Multiple architectures are selected"
90 #endif
91
92 /* Auto select option (requires compiler support) */
93 #if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
94
95 #ifndef _WIN32
96
97 #if defined(__i386__) || defined(__i386)
98 #define SLJIT_CONFIG_X86_32 1
99 #elif defined(__x86_64__)
100 # if defined(__ILP32__)
101 #  define SLJIT_CONFIG_UNSUPPORTED 1
102 # else
103 #  define SLJIT_CONFIG_X86_64 1
104 # endif
105 #elif defined(__arm__) || defined(__ARM__)
106 #ifdef __thumb2__
107 #define SLJIT_CONFIG_ARM_THUMB2 1
108 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
109 #define SLJIT_CONFIG_ARM_V7 1
110 #else
111 #define SLJIT_CONFIG_ARM_V5 1
112 #endif
113 #elif defined (__aarch64__)
114 #define SLJIT_CONFIG_ARM_64 1
115 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
116 #define SLJIT_CONFIG_PPC_64 1
117 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
118 # ifndef __NO_FPRS__
119 #  define SLJIT_CONFIG_PPC_32 1
120 # else
121 #  define SLJIT_CONFIG_UNSUPPORTED 1
122 # endif
123 #elif defined(__mips__) && !defined(_LP64)
124 #define SLJIT_CONFIG_MIPS_32 1
125 #elif defined(__mips64)
126 #define SLJIT_CONFIG_MIPS_64 1
127 #elif defined(__sparc__) || defined(__sparc)
128 # if defined(__arch64__)
129 #  define SLJIT_CONFIG_UNSUPPORTED 1
130 # else
131 #  define SLJIT_CONFIG_SPARC_32 1
132 # endif
133 #elif defined(__tilegx__)
134 #define SLJIT_CONFIG_TILEGX 1
135 #else
136 /* Unsupported architecture */
137 #define SLJIT_CONFIG_UNSUPPORTED 1
138 #endif
139
140 #else /* !_WIN32 */
141
142 #if defined(_M_X64) || defined(__x86_64__)
143 #define SLJIT_CONFIG_X86_64 1
144 #elif defined(_ARM_)
145 #define SLJIT_CONFIG_ARM_V5 1
146 #else
147 #define SLJIT_CONFIG_X86_32 1
148 #endif
149
150 #endif /* !WIN32 */
151 #endif /* SLJIT_CONFIG_AUTO */
152
153 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
154 #undef SLJIT_EXECUTABLE_ALLOCATOR
155 #endif
156
157 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
158
159 /* These libraries are needed for the macros below. */
160 #include <stdlib.h>
161 #include <string.h>
162
163 #endif /* STD_MACROS_DEFINED */
164
165 /* General macros:
166    Note: SLJIT is designed to be independent from them as possible.
167
168    In release mode (SLJIT_DEBUG is not defined) only the following macros are needed:
169 */
170
171 #ifndef SLJIT_MALLOC
172 #define SLJIT_MALLOC(size) malloc(size)
173 #endif
174
175 #ifndef SLJIT_FREE
176 #define SLJIT_FREE(ptr) free(ptr)
177 #endif
178
179 #ifndef SLJIT_MEMMOVE
180 #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
181 #endif
182
183 #ifndef SLJIT_ZEROMEM
184 #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
185 #endif
186
187 #if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
188
189 #if defined(__GNUC__) && (__GNUC__ >= 3)
190 #define SLJIT_LIKELY(x)         __builtin_expect((x), 1)
191 #define SLJIT_UNLIKELY(x)       __builtin_expect((x), 0)
192 #else
193 #define SLJIT_LIKELY(x)         (x)
194 #define SLJIT_UNLIKELY(x)       (x)
195 #endif
196
197 #endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
198
199 #ifndef SLJIT_INLINE
200 /* Inline functions. Some old compilers do not support them. */
201 #if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
202 #define SLJIT_INLINE
203 #else
204 #define SLJIT_INLINE __inline
205 #endif
206 #endif /* !SLJIT_INLINE */
207
208 #ifndef SLJIT_CONST
209 /* Const variables. */
210 #define SLJIT_CONST const
211 #endif
212
213 #ifndef SLJIT_UNUSED_ARG
214 /* Unused arguments. */
215 #define SLJIT_UNUSED_ARG(arg) (void)arg
216 #endif
217
218 #if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
219 /* Static ABI functions. For all-in-one programs. */
220
221 #if defined(__GNUC__)
222 /* Disable unused warnings in gcc. */
223 #define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
224 #else
225 #define SLJIT_API_FUNC_ATTRIBUTE static
226 #endif
227
228 #else
229 #define SLJIT_API_FUNC_ATTRIBUTE
230 #endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
231
232 #ifndef SLJIT_CACHE_FLUSH
233
234 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
235
236 /* Not required to implement on archs with unified caches. */
237 #define SLJIT_CACHE_FLUSH(from, to)
238
239 #elif defined __APPLE__
240
241 /* Supported by all macs since Mac OS 10.5.
242    However, it does not work on non-jailbroken iOS devices,
243    although the compilation is successful. */
244
245 #define SLJIT_CACHE_FLUSH(from, to) \
246         sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
247
248 #elif defined __ANDROID__
249
250 /* Android lacks __clear_cache; instead, cacheflush should be used. */
251
252 #define SLJIT_CACHE_FLUSH(from, to) \
253     cacheflush((long)(from), (long)(to), 0)
254
255 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
256
257 /* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
258 #define SLJIT_CACHE_FLUSH(from, to) \
259         ppc_cache_flush((from), (to))
260
261 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
262
263 /* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
264 #define SLJIT_CACHE_FLUSH(from, to) \
265         sparc_cache_flush((from), (to))
266
267 #else
268
269 /* Calls __ARM_NR_cacheflush on ARM-Linux. */
270 #define SLJIT_CACHE_FLUSH(from, to) \
271         __clear_cache((char*)(from), (char*)(to))
272
273 #endif
274
275 #endif /* !SLJIT_CACHE_FLUSH */
276
277 /* 8 bit byte type. */
278 typedef unsigned char sljit_ub;
279 typedef signed char sljit_sb;
280
281 /* 16 bit half-word type. */
282 typedef unsigned short int sljit_uh;
283 typedef signed short int sljit_sh;
284
285 /* 32 bit integer type. */
286 typedef unsigned int sljit_ui;
287 typedef signed int sljit_si;
288
289 /* Machine word type. Can encapsulate a pointer.
290      32 bit for 32 bit machines.
291      64 bit for 64 bit machines. */
292 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
293 /* Just to have something. */
294 #define SLJIT_WORD_SHIFT 0
295 typedef unsigned long int sljit_uw;
296 typedef long int sljit_sw;
297 #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
298         && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
299         && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
300         && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
301         && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
302 #define SLJIT_32BIT_ARCHITECTURE 1
303 #define SLJIT_WORD_SHIFT 2
304 typedef unsigned int sljit_uw;
305 typedef int sljit_sw;
306 #else
307 #define SLJIT_64BIT_ARCHITECTURE 1
308 #define SLJIT_WORD_SHIFT 3
309 #ifdef _WIN32
310 typedef unsigned __int64 sljit_uw;
311 typedef __int64 sljit_sw;
312 #else
313 typedef unsigned long int sljit_uw;
314 typedef long int sljit_sw;
315 #endif
316 #endif
317
318 typedef sljit_uw sljit_p;
319
320 /* Floating point types. */
321 typedef float sljit_s;
322 typedef double sljit_d;
323
324 /* Shift for pointer sized data. */
325 #define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
326
327 /* Shift for double precision sized data. */
328 #define SLJIT_DOUBLE_SHIFT 3
329
330 #ifndef SLJIT_W
331
332 /* Defining long constants. */
333 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
334 #define SLJIT_W(w)      (w##ll)
335 #else
336 #define SLJIT_W(w)      (w)
337 #endif
338
339 #endif /* !SLJIT_W */
340
341 #ifndef SLJIT_CALL
342
343 /* ABI (Application Binary Interface) types. */
344 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
345
346 #if defined(__GNUC__) && !defined(__APPLE__)
347
348 #define SLJIT_CALL __attribute__ ((fastcall))
349 #define SLJIT_X86_32_FASTCALL 1
350
351 #elif defined(_MSC_VER)
352
353 #define SLJIT_CALL __fastcall
354 #define SLJIT_X86_32_FASTCALL 1
355
356 #elif defined(__BORLANDC__)
357
358 #define SLJIT_CALL __msfastcall
359 #define SLJIT_X86_32_FASTCALL 1
360
361 #else /* Unknown compiler. */
362
363 /* The cdecl attribute is the default. */
364 #define SLJIT_CALL
365
366 #endif
367
368 #else /* Non x86-32 architectures. */
369
370 #define SLJIT_CALL
371
372 #endif /* SLJIT_CONFIG_X86_32 */
373
374 #endif /* !SLJIT_CALL */
375
376 #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
377
378 /* These macros are useful for the applications. */
379 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
380         || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
381
382 #ifdef __LITTLE_ENDIAN__
383 #define SLJIT_LITTLE_ENDIAN 1
384 #else
385 #define SLJIT_BIG_ENDIAN 1
386 #endif
387
388 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
389         || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
390
391 #ifdef __MIPSEL__
392 #define SLJIT_LITTLE_ENDIAN 1
393 #else
394 #define SLJIT_BIG_ENDIAN 1
395 #endif
396
397 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
398
399 #define SLJIT_BIG_ENDIAN 1
400
401 #else
402 #define SLJIT_LITTLE_ENDIAN 1
403 #endif
404
405 #endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
406
407 /* Sanity check. */
408 #if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
409 #error "Exactly one endianness must be selected"
410 #endif
411
412 #if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
413 #error "Exactly one endianness must be selected"
414 #endif
415
416 #ifndef SLJIT_INDIRECT_CALL
417 #if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
418         || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
419 /* It seems certain ppc compilers use an indirect addressing for functions
420    which makes things complicated. */
421 #define SLJIT_INDIRECT_CALL 1
422 #endif
423 #endif /* SLJIT_INDIRECT_CALL */
424
425 #ifndef SLJIT_RETURN_ADDRESS_OFFSET
426 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
427 #define SLJIT_RETURN_ADDRESS_OFFSET 8
428 #else
429 #define SLJIT_RETURN_ADDRESS_OFFSET 0
430 #endif
431 #endif /* SLJIT_RETURN_ADDRESS_OFFSET */
432
433 #ifndef SLJIT_SSE2
434
435 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
436 /* Turn on SSE2 support on x86. */
437 #define SLJIT_SSE2 1
438
439 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
440 /* Auto detect SSE2 support using CPUID.
441    On 64 bit x86 cpus, sse2 must be present. */
442 #define SLJIT_DETECT_SSE2 1
443 #endif
444
445 #endif /* (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) */
446
447 #endif /* !SLJIT_SSE2 */
448
449 #ifndef SLJIT_UNALIGNED
450
451 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
452         || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
453         || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
454         || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
455         || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
456         || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
457         || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
458 #define SLJIT_UNALIGNED 1
459 #endif
460
461 #endif /* !SLJIT_UNALIGNED */
462
463 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
464 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
465 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
466 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
467 #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
468 #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
469 #endif
470
471 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
472 #include <stdio.h>
473 #endif
474
475 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
476
477 #if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
478
479 /* SLJIT_HALT_PROCESS must halt the process. */
480 #ifndef SLJIT_HALT_PROCESS
481 #include <stdlib.h>
482
483 #define SLJIT_HALT_PROCESS() \
484         abort();
485 #endif /* !SLJIT_HALT_PROCESS */
486
487 #include <stdio.h>
488
489 #endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
490
491 /* Feel free to redefine these two macros. */
492 #ifndef SLJIT_ASSERT
493
494 #define SLJIT_ASSERT(x) \
495         do { \
496                 if (SLJIT_UNLIKELY(!(x))) { \
497                         printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
498                         SLJIT_HALT_PROCESS(); \
499                 } \
500         } while (0)
501
502 #endif /* !SLJIT_ASSERT */
503
504 #ifndef SLJIT_ASSERT_STOP
505
506 #define SLJIT_ASSERT_STOP() \
507         do { \
508                 printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
509                 SLJIT_HALT_PROCESS(); \
510         } while (0)
511
512 #endif /* !SLJIT_ASSERT_STOP */
513
514 #else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
515
516 /* Forcing empty, but valid statements. */
517 #undef SLJIT_ASSERT
518 #undef SLJIT_ASSERT_STOP
519
520 #define SLJIT_ASSERT(x) \
521         do { } while (0)
522 #define SLJIT_ASSERT_STOP() \
523         do { } while (0)
524
525 #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
526
527 #ifndef SLJIT_COMPILE_ASSERT
528
529 /* Should be improved eventually. */
530 #define SLJIT_COMPILE_ASSERT(x, description) \
531         SLJIT_ASSERT(x)
532
533 #endif /* !SLJIT_COMPILE_ASSERT */
534
535 #endif