1*8fd614bdSriastradh /*	$NetBSD: sljitConfig.h,v 1.17 2020/03/05 15:18:55 riastradh Exp $	*/
2637c186aSalnsn 
30675068dSalnsn /*
40675068dSalnsn  *    Stack-less Just-In-Time compiler
50675068dSalnsn  *
6632be62bSalnsn  *    Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
70675068dSalnsn  *
80675068dSalnsn  * Redistribution and use in source and binary forms, with or without modification, are
90675068dSalnsn  * permitted provided that the following conditions are met:
100675068dSalnsn  *
110675068dSalnsn  *   1. Redistributions of source code must retain the above copyright notice, this list of
120675068dSalnsn  *      conditions and the following disclaimer.
130675068dSalnsn  *
140675068dSalnsn  *   2. Redistributions in binary form must reproduce the above copyright notice, this list
150675068dSalnsn  *      of conditions and the following disclaimer in the documentation and/or other materials
160675068dSalnsn  *      provided with the distribution.
170675068dSalnsn  *
180675068dSalnsn  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
190675068dSalnsn  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
200675068dSalnsn  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
210675068dSalnsn  * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
220675068dSalnsn  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
230675068dSalnsn  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
240675068dSalnsn  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
250675068dSalnsn  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
260675068dSalnsn  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
270675068dSalnsn  */
280675068dSalnsn 
290675068dSalnsn #ifndef _SLJIT_CONFIG_H_
300675068dSalnsn #define _SLJIT_CONFIG_H_
310675068dSalnsn 
320675068dSalnsn /* --------------------------------------------------------------------- */
330675068dSalnsn /*  Custom defines                                                       */
340675068dSalnsn /* --------------------------------------------------------------------- */
350675068dSalnsn 
360675068dSalnsn /* Put your custom defines here. This empty section will never change
370675068dSalnsn    which helps maintaining patches (with diff / patch utilities). */
380675068dSalnsn 
390675068dSalnsn /* --------------------------------------------------------------------- */
400675068dSalnsn /*  Architecture                                                         */
410675068dSalnsn /* --------------------------------------------------------------------- */
420675068dSalnsn 
430675068dSalnsn /* Architecture selection. */
440675068dSalnsn /* #define SLJIT_CONFIG_X86_32 1 */
450675068dSalnsn /* #define SLJIT_CONFIG_X86_64 1 */
460675068dSalnsn /* #define SLJIT_CONFIG_ARM_V5 1 */
470675068dSalnsn /* #define SLJIT_CONFIG_ARM_V7 1 */
480675068dSalnsn /* #define SLJIT_CONFIG_ARM_THUMB2 1 */
4956b25969Salnsn /* #define SLJIT_CONFIG_ARM_64 1 */
500675068dSalnsn /* #define SLJIT_CONFIG_PPC_32 1 */
510675068dSalnsn /* #define SLJIT_CONFIG_PPC_64 1 */
520675068dSalnsn /* #define SLJIT_CONFIG_MIPS_32 1 */
5356b25969Salnsn /* #define SLJIT_CONFIG_MIPS_64 1 */
5473480e1eSalnsn /* #define SLJIT_CONFIG_SPARC_32 1 */
5556b25969Salnsn /* #define SLJIT_CONFIG_TILEGX 1 */
560675068dSalnsn 
570675068dSalnsn /* #define SLJIT_CONFIG_AUTO 1 */
580675068dSalnsn /* #define SLJIT_CONFIG_UNSUPPORTED 1 */
590675068dSalnsn 
6082a326c1Salnsn #include <machine/sljit_machdep.h>
61ec486d7dSalnsn 
62ec486d7dSalnsn #if defined(_KERNEL) && !defined(SLJIT_MALLOC)
63c4591c98Salnsn #define SLJIT_MALLOC(size, allocator_data) malloc((size), M_TEMP, M_WAITOK)
64ec486d7dSalnsn #endif
65ec486d7dSalnsn 
66ec486d7dSalnsn #if defined(_KERNEL) && !defined(SLJIT_FREE)
67c4591c98Salnsn #define SLJIT_FREE(ptr, allocator_data) free((ptr), M_TEMP)
68ec486d7dSalnsn #endif
69ec486d7dSalnsn 
70ec486d7dSalnsn #if defined(_KERNEL) && !defined(SLJIT_CACHE_FLUSH)
718863f4a0Salnsn #error "SLJIT_CACHE_FLUSH must be defined."
72ec486d7dSalnsn #endif
73ec486d7dSalnsn 
74ec486d7dSalnsn 
75ec486d7dSalnsn #ifdef _KERNEL
76276a323bSalnsn 
77ec486d7dSalnsn #ifdef DIAGNOSTIC
78ec486d7dSalnsn #define SLJIT_DEBUG 1
79ec486d7dSalnsn #else
80ec486d7dSalnsn #define SLJIT_DEBUG 0
81ec486d7dSalnsn #endif
82276a323bSalnsn 
83276a323bSalnsn #define SLJIT_ASSERT(x) KASSERT(x)
84276a323bSalnsn #define SLJIT_ASSERT_STOP() \
85276a323bSalnsn 	panic("Should never been reached " __FILE__ ":%d\n", __LINE__)
86ec486d7dSalnsn #endif
87ec486d7dSalnsn 
88ec486d7dSalnsn #ifdef _KERNEL
89ec486d7dSalnsn #define SLJIT_VERBOSE 0
90ec486d7dSalnsn #endif
91ec486d7dSalnsn 
92ec486d7dSalnsn #ifdef _KERNEL
9397cbbb06Salnsn #define SLJIT_IS_FPU_AVAILABLE 0
9497cbbb06Salnsn #endif
9597cbbb06Salnsn 
9697cbbb06Salnsn #ifdef _KERNEL
97ec486d7dSalnsn #include <sys/cdefs.h>
98ec486d7dSalnsn #include <sys/malloc.h>
99ee9691d5Salnsn #include <sys/param.h>
100ec486d7dSalnsn #endif
101ec486d7dSalnsn 
1020675068dSalnsn /* --------------------------------------------------------------------- */
1030675068dSalnsn /*  Utilities                                                            */
1040675068dSalnsn /* --------------------------------------------------------------------- */
1050675068dSalnsn 
1060675068dSalnsn /* Useful for thread-safe compiling of global functions. */
1070675068dSalnsn #ifndef SLJIT_UTIL_GLOBAL_LOCK
1080675068dSalnsn /* Enabled by default */
1090675068dSalnsn #define SLJIT_UTIL_GLOBAL_LOCK 1
1100675068dSalnsn #endif
1110675068dSalnsn 
1120675068dSalnsn /* Implements a stack like data structure (by using mmap / VirtualAlloc). */
1130675068dSalnsn #ifndef SLJIT_UTIL_STACK
1140675068dSalnsn /* Enabled by default */
1150675068dSalnsn #define SLJIT_UTIL_STACK 1
1160675068dSalnsn #endif
1170675068dSalnsn 
1180675068dSalnsn /* Single threaded application. Does not require any locks. */
1190675068dSalnsn #ifndef SLJIT_SINGLE_THREADED
1200675068dSalnsn /* Disabled by default. */
1210675068dSalnsn #define SLJIT_SINGLE_THREADED 0
1220675068dSalnsn #endif
1230675068dSalnsn 
1240675068dSalnsn /* --------------------------------------------------------------------- */
1250675068dSalnsn /*  Configuration                                                        */
1260675068dSalnsn /* --------------------------------------------------------------------- */
1270675068dSalnsn 
1280675068dSalnsn /* If SLJIT_STD_MACROS_DEFINED is not defined, the application should
129632be62bSalnsn    define SLJIT_MALLOC, SLJIT_FREE, SLJIT_MEMCPY, and NULL. */
1300675068dSalnsn #ifndef SLJIT_STD_MACROS_DEFINED
1310675068dSalnsn /* Disabled by default. */
1320675068dSalnsn #define SLJIT_STD_MACROS_DEFINED 0
1330675068dSalnsn #endif
1340675068dSalnsn 
1350675068dSalnsn /* Executable code allocation:
1360675068dSalnsn    If SLJIT_EXECUTABLE_ALLOCATOR is not defined, the application should
137632be62bSalnsn    define SLJIT_MALLOC_EXEC, SLJIT_FREE_EXEC, and SLJIT_EXEC_OFFSET. */
1380675068dSalnsn #ifndef SLJIT_EXECUTABLE_ALLOCATOR
1390675068dSalnsn /* Enabled by default. */
1400675068dSalnsn #define SLJIT_EXECUTABLE_ALLOCATOR 1
141632be62bSalnsn 
142632be62bSalnsn /* When SLJIT_PROT_EXECUTABLE_ALLOCATOR is enabled SLJIT uses
143632be62bSalnsn    an allocator which does not set writable and executable
144632be62bSalnsn    permission flags at the same time. The trade-of is increased
145632be62bSalnsn    memory consumption and disabled dynamic code modifications. */
146632be62bSalnsn #ifndef SLJIT_PROT_EXECUTABLE_ALLOCATOR
147632be62bSalnsn /* Disabled by default. */
148632be62bSalnsn #define SLJIT_PROT_EXECUTABLE_ALLOCATOR 0
149632be62bSalnsn #endif
150632be62bSalnsn 
1510675068dSalnsn #endif
1520675068dSalnsn 
153dfd7d8b1Salnsn /* Force cdecl calling convention even if a better calling
154dfd7d8b1Salnsn    convention (e.g. fastcall) is supported by the C compiler.
155dfd7d8b1Salnsn    If this option is enabled, C functions without
156dfd7d8b1Salnsn    SLJIT_CALL can also be called from JIT code. */
157dfd7d8b1Salnsn #ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
158dfd7d8b1Salnsn /* Disabled by default */
159dfd7d8b1Salnsn #define SLJIT_USE_CDECL_CALLING_CONVENTION 0
160dfd7d8b1Salnsn #endif
161dfd7d8b1Salnsn 
162dfd7d8b1Salnsn /* Return with error when an invalid argument is passed. */
163dfd7d8b1Salnsn #ifndef SLJIT_ARGUMENT_CHECKS
164dfd7d8b1Salnsn /* Disabled by default */
165dfd7d8b1Salnsn #define SLJIT_ARGUMENT_CHECKS 0
166dfd7d8b1Salnsn #endif
167dfd7d8b1Salnsn 
1680675068dSalnsn /* Debug checks (assertions, etc.). */
1690675068dSalnsn #ifndef SLJIT_DEBUG
1700675068dSalnsn /* Enabled by default */
1710675068dSalnsn #define SLJIT_DEBUG 1
1720675068dSalnsn #endif
1730675068dSalnsn 
174dfd7d8b1Salnsn /* Verbose operations. */
1750675068dSalnsn #ifndef SLJIT_VERBOSE
1760675068dSalnsn /* Enabled by default */
1770675068dSalnsn #define SLJIT_VERBOSE 1
1780675068dSalnsn #endif
1790675068dSalnsn 
18056b25969Salnsn /*
18156b25969Salnsn   SLJIT_IS_FPU_AVAILABLE
18256b25969Salnsn     The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE.
18356b25969Salnsn       zero value - FPU is NOT present.
18456b25969Salnsn       nonzero value - FPU is present.
18556b25969Salnsn */
18656b25969Salnsn 
18756b25969Salnsn /* For further configurations, see the beginning of sljitConfigInternal.h */
1880675068dSalnsn 
1890675068dSalnsn #endif
190