Home | History | Annotate | Line # | Download | only in sljit_src
      1 /*	$NetBSD: sljitConfig.h,v 1.17 2020/03/05 15:18:55 riastradh Exp $	*/
      2 
      3 /*
      4  *    Stack-less Just-In-Time compiler
      5  *
      6  *    Copyright Zoltan Herczeg (hzmester (at) freemail.hu). All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without modification, are
      9  * permitted provided that the following conditions are met:
     10  *
     11  *   1. Redistributions of source code must retain the above copyright notice, this list of
     12  *      conditions and the following disclaimer.
     13  *
     14  *   2. Redistributions in binary form must reproduce the above copyright notice, this list
     15  *      of conditions and the following disclaimer in the documentation and/or other materials
     16  *      provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
     19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
     21  * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     23  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     26  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #ifndef _SLJIT_CONFIG_H_
     30 #define _SLJIT_CONFIG_H_
     31 
     32 /* --------------------------------------------------------------------- */
     33 /*  Custom defines                                                       */
     34 /* --------------------------------------------------------------------- */
     35 
     36 /* Put your custom defines here. This empty section will never change
     37    which helps maintaining patches (with diff / patch utilities). */
     38 
     39 /* --------------------------------------------------------------------- */
     40 /*  Architecture                                                         */
     41 /* --------------------------------------------------------------------- */
     42 
     43 /* Architecture selection. */
     44 /* #define SLJIT_CONFIG_X86_32 1 */
     45 /* #define SLJIT_CONFIG_X86_64 1 */
     46 /* #define SLJIT_CONFIG_ARM_V5 1 */
     47 /* #define SLJIT_CONFIG_ARM_V7 1 */
     48 /* #define SLJIT_CONFIG_ARM_THUMB2 1 */
     49 /* #define SLJIT_CONFIG_ARM_64 1 */
     50 /* #define SLJIT_CONFIG_PPC_32 1 */
     51 /* #define SLJIT_CONFIG_PPC_64 1 */
     52 /* #define SLJIT_CONFIG_MIPS_32 1 */
     53 /* #define SLJIT_CONFIG_MIPS_64 1 */
     54 /* #define SLJIT_CONFIG_SPARC_32 1 */
     55 /* #define SLJIT_CONFIG_TILEGX 1 */
     56 
     57 /* #define SLJIT_CONFIG_AUTO 1 */
     58 /* #define SLJIT_CONFIG_UNSUPPORTED 1 */
     59 
     60 #include <machine/sljit_machdep.h>
     61 
     62 #if defined(_KERNEL) && !defined(SLJIT_MALLOC)
     63 #define SLJIT_MALLOC(size, allocator_data) malloc((size), M_TEMP, M_WAITOK)
     64 #endif
     65 
     66 #if defined(_KERNEL) && !defined(SLJIT_FREE)
     67 #define SLJIT_FREE(ptr, allocator_data) free((ptr), M_TEMP)
     68 #endif
     69 
     70 #if defined(_KERNEL) && !defined(SLJIT_CACHE_FLUSH)
     71 #error "SLJIT_CACHE_FLUSH must be defined."
     72 #endif
     73 
     74 
     75 #ifdef _KERNEL
     76 
     77 #ifdef DIAGNOSTIC
     78 #define SLJIT_DEBUG 1
     79 #else
     80 #define SLJIT_DEBUG 0
     81 #endif
     82 
     83 #define SLJIT_ASSERT(x) KASSERT(x)
     84 #define SLJIT_ASSERT_STOP() \
     85 	panic("Should never been reached " __FILE__ ":%d\n", __LINE__)
     86 #endif
     87 
     88 #ifdef _KERNEL
     89 #define SLJIT_VERBOSE 0
     90 #endif
     91 
     92 #ifdef _KERNEL
     93 #define SLJIT_IS_FPU_AVAILABLE 0
     94 #endif
     95 
     96 #ifdef _KERNEL
     97 #include <sys/cdefs.h>
     98 #include <sys/malloc.h>
     99 #include <sys/param.h>
    100 #endif
    101 
    102 /* --------------------------------------------------------------------- */
    103 /*  Utilities                                                            */
    104 /* --------------------------------------------------------------------- */
    105 
    106 /* Useful for thread-safe compiling of global functions. */
    107 #ifndef SLJIT_UTIL_GLOBAL_LOCK
    108 /* Enabled by default */
    109 #define SLJIT_UTIL_GLOBAL_LOCK 1
    110 #endif
    111 
    112 /* Implements a stack like data structure (by using mmap / VirtualAlloc). */
    113 #ifndef SLJIT_UTIL_STACK
    114 /* Enabled by default */
    115 #define SLJIT_UTIL_STACK 1
    116 #endif
    117 
    118 /* Single threaded application. Does not require any locks. */
    119 #ifndef SLJIT_SINGLE_THREADED
    120 /* Disabled by default. */
    121 #define SLJIT_SINGLE_THREADED 0
    122 #endif
    123 
    124 /* --------------------------------------------------------------------- */
    125 /*  Configuration                                                        */
    126 /* --------------------------------------------------------------------- */
    127 
    128 /* If SLJIT_STD_MACROS_DEFINED is not defined, the application should
    129    define SLJIT_MALLOC, SLJIT_FREE, SLJIT_MEMCPY, and NULL. */
    130 #ifndef SLJIT_STD_MACROS_DEFINED
    131 /* Disabled by default. */
    132 #define SLJIT_STD_MACROS_DEFINED 0
    133 #endif
    134 
    135 /* Executable code allocation:
    136    If SLJIT_EXECUTABLE_ALLOCATOR is not defined, the application should
    137    define SLJIT_MALLOC_EXEC, SLJIT_FREE_EXEC, and SLJIT_EXEC_OFFSET. */
    138 #ifndef SLJIT_EXECUTABLE_ALLOCATOR
    139 /* Enabled by default. */
    140 #define SLJIT_EXECUTABLE_ALLOCATOR 1
    141 
    142 /* When SLJIT_PROT_EXECUTABLE_ALLOCATOR is enabled SLJIT uses
    143    an allocator which does not set writable and executable
    144    permission flags at the same time. The trade-of is increased
    145    memory consumption and disabled dynamic code modifications. */
    146 #ifndef SLJIT_PROT_EXECUTABLE_ALLOCATOR
    147 /* Disabled by default. */
    148 #define SLJIT_PROT_EXECUTABLE_ALLOCATOR 0
    149 #endif
    150 
    151 #endif
    152 
    153 /* Force cdecl calling convention even if a better calling
    154    convention (e.g. fastcall) is supported by the C compiler.
    155    If this option is enabled, C functions without
    156    SLJIT_CALL can also be called from JIT code. */
    157 #ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
    158 /* Disabled by default */
    159 #define SLJIT_USE_CDECL_CALLING_CONVENTION 0
    160 #endif
    161 
    162 /* Return with error when an invalid argument is passed. */
    163 #ifndef SLJIT_ARGUMENT_CHECKS
    164 /* Disabled by default */
    165 #define SLJIT_ARGUMENT_CHECKS 0
    166 #endif
    167 
    168 /* Debug checks (assertions, etc.). */
    169 #ifndef SLJIT_DEBUG
    170 /* Enabled by default */
    171 #define SLJIT_DEBUG 1
    172 #endif
    173 
    174 /* Verbose operations. */
    175 #ifndef SLJIT_VERBOSE
    176 /* Enabled by default */
    177 #define SLJIT_VERBOSE 1
    178 #endif
    179 
    180 /*
    181   SLJIT_IS_FPU_AVAILABLE
    182     The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE.
    183       zero value - FPU is NOT present.
    184       nonzero value - FPU is present.
    185 */
    186 
    187 /* For further configurations, see the beginning of sljitConfigInternal.h */
    188 
    189 #endif
    190