sljitConfig.h revision 1.16 1 /* $NetBSD: sljitConfig.h,v 1.16 2020/03/05 08:08:33 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 _KERNEL_OPT
78 #include "opt_diagnostic.h"
79 #endif
80
81 #ifdef DIAGNOSTIC
82 #define SLJIT_DEBUG 1
83 #else
84 #define SLJIT_DEBUG 0
85 #endif
86
87 #define SLJIT_ASSERT(x) KASSERT(x)
88 #define SLJIT_ASSERT_STOP() \
89 panic("Should never been reached " __FILE__ ":%d\n", __LINE__)
90 #endif
91
92 #ifdef _KERNEL
93 #define SLJIT_VERBOSE 0
94 #endif
95
96 #ifdef _KERNEL
97 #define SLJIT_IS_FPU_AVAILABLE 0
98 #endif
99
100 #ifdef _KERNEL
101 #include <sys/cdefs.h>
102 #include <sys/malloc.h>
103 #include <sys/param.h>
104 #endif
105
106 /* --------------------------------------------------------------------- */
107 /* Utilities */
108 /* --------------------------------------------------------------------- */
109
110 /* Useful for thread-safe compiling of global functions. */
111 #ifndef SLJIT_UTIL_GLOBAL_LOCK
112 /* Enabled by default */
113 #define SLJIT_UTIL_GLOBAL_LOCK 1
114 #endif
115
116 /* Implements a stack like data structure (by using mmap / VirtualAlloc). */
117 #ifndef SLJIT_UTIL_STACK
118 /* Enabled by default */
119 #define SLJIT_UTIL_STACK 1
120 #endif
121
122 /* Single threaded application. Does not require any locks. */
123 #ifndef SLJIT_SINGLE_THREADED
124 /* Disabled by default. */
125 #define SLJIT_SINGLE_THREADED 0
126 #endif
127
128 /* --------------------------------------------------------------------- */
129 /* Configuration */
130 /* --------------------------------------------------------------------- */
131
132 /* If SLJIT_STD_MACROS_DEFINED is not defined, the application should
133 define SLJIT_MALLOC, SLJIT_FREE, SLJIT_MEMCPY, and NULL. */
134 #ifndef SLJIT_STD_MACROS_DEFINED
135 /* Disabled by default. */
136 #define SLJIT_STD_MACROS_DEFINED 0
137 #endif
138
139 /* Executable code allocation:
140 If SLJIT_EXECUTABLE_ALLOCATOR is not defined, the application should
141 define SLJIT_MALLOC_EXEC, SLJIT_FREE_EXEC, and SLJIT_EXEC_OFFSET. */
142 #ifndef SLJIT_EXECUTABLE_ALLOCATOR
143 /* Enabled by default. */
144 #define SLJIT_EXECUTABLE_ALLOCATOR 1
145
146 /* When SLJIT_PROT_EXECUTABLE_ALLOCATOR is enabled SLJIT uses
147 an allocator which does not set writable and executable
148 permission flags at the same time. The trade-of is increased
149 memory consumption and disabled dynamic code modifications. */
150 #ifndef SLJIT_PROT_EXECUTABLE_ALLOCATOR
151 /* Disabled by default. */
152 #define SLJIT_PROT_EXECUTABLE_ALLOCATOR 0
153 #endif
154
155 #endif
156
157 /* Force cdecl calling convention even if a better calling
158 convention (e.g. fastcall) is supported by the C compiler.
159 If this option is enabled, C functions without
160 SLJIT_CALL can also be called from JIT code. */
161 #ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
162 /* Disabled by default */
163 #define SLJIT_USE_CDECL_CALLING_CONVENTION 0
164 #endif
165
166 /* Return with error when an invalid argument is passed. */
167 #ifndef SLJIT_ARGUMENT_CHECKS
168 /* Disabled by default */
169 #define SLJIT_ARGUMENT_CHECKS 0
170 #endif
171
172 /* Debug checks (assertions, etc.). */
173 #ifndef SLJIT_DEBUG
174 /* Enabled by default */
175 #define SLJIT_DEBUG 1
176 #endif
177
178 /* Verbose operations. */
179 #ifndef SLJIT_VERBOSE
180 /* Enabled by default */
181 #define SLJIT_VERBOSE 1
182 #endif
183
184 /*
185 SLJIT_IS_FPU_AVAILABLE
186 The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE.
187 zero value - FPU is NOT present.
188 nonzero value - FPU is present.
189 */
190
191 /* For further configurations, see the beginning of sljitConfigInternal.h */
192
193 #endif
194