Annotation of embedaddon/pcre/sljit/sljitConfigInternal.h, revision 1.1.1.5

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>