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