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