1 | /*
|
---|
2 | ** mrbconf.h - mruby core configuration
|
---|
3 | **
|
---|
4 | ** See Copyright Notice in mruby.h
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef MRUBYCONF_H
|
---|
8 | #define MRUBYCONF_H
|
---|
9 |
|
---|
10 | #include <limits.h>
|
---|
11 | #include <stdint.h>
|
---|
12 |
|
---|
13 | /* architecture selection: */
|
---|
14 | /* specify -DMRB_32BIT or -DMRB_64BIT to override */
|
---|
15 | #if !defined(MRB_32BIT) && !defined(MRB_64BIT)
|
---|
16 | #if UINT64_MAX == SIZE_MAX
|
---|
17 | #define MRB_64BIT
|
---|
18 | #else
|
---|
19 | #define MRB_32BIT
|
---|
20 | #endif
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #if defined(MRB_32BIT) && defined(MRB_64BIT)
|
---|
24 | #error Cannot build for 32 and 64 bit architecture at the same time
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | /* configuration options: */
|
---|
28 | /* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
|
---|
29 | //#define MRB_USE_FLOAT
|
---|
30 |
|
---|
31 | /* exclude floating point numbers */
|
---|
32 | //#define MRB_WITHOUT_FLOAT
|
---|
33 |
|
---|
34 | /* add -DMRB_METHOD_CACHE to use method cache to improve performance */
|
---|
35 | //#define MRB_METHOD_CACHE
|
---|
36 | /* size of the method cache (need to be the power of 2) */
|
---|
37 | //#define MRB_METHOD_CACHE_SIZE (1<<7)
|
---|
38 |
|
---|
39 | /* add -DMRB_METHOD_T_STRUCT on machines that use higher bits of pointers */
|
---|
40 | /* no MRB_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */
|
---|
41 | #ifndef MRB_METHOD_T_STRUCT
|
---|
42 | // can't use highest 2 bits of function pointers on 32bit Windows.
|
---|
43 | # if defined(_WIN32) && !defined(_WIN64)
|
---|
44 | # define MRB_METHOD_T_STRUCT
|
---|
45 | # endif
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | /* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT64;
|
---|
49 | Default for 32-bit CPU mode. */
|
---|
50 | //#define MRB_INT32
|
---|
51 |
|
---|
52 | /* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT32;
|
---|
53 | Default for 64-bit CPU mode. */
|
---|
54 | //#define MRB_INT64
|
---|
55 |
|
---|
56 | /* if no specific integer type is chosen */
|
---|
57 | #if !defined(MRB_INT32) && !defined(MRB_INT64)
|
---|
58 | # if defined(MRB_64BIT) && !defined(MRB_NAN_BOXING)
|
---|
59 | /* Use 64bit integers on 64bit architecture (without MRB_NAN_BOXING) */
|
---|
60 | # define MRB_INT64
|
---|
61 | # else
|
---|
62 | /* Otherwise use 32bit integers */
|
---|
63 | # define MRB_INT32
|
---|
64 | # endif
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | /* define on big endian machines; used by MRB_NAN_BOXING, etc. */
|
---|
68 | #ifndef MRB_ENDIAN_BIG
|
---|
69 | # if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
|
---|
70 | (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
---|
71 | # define MRB_ENDIAN_BIG
|
---|
72 | # endif
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | /* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT and MRB_WITHOUT_FLOAT */
|
---|
76 | //#define MRB_NAN_BOXING
|
---|
77 |
|
---|
78 | /* represent mrb_value as a word (natural unit of data for the processor) */
|
---|
79 | //#define MRB_WORD_BOXING
|
---|
80 |
|
---|
81 | /* string class to handle UTF-8 encoding */
|
---|
82 | #define MRB_UTF8_STRING
|
---|
83 |
|
---|
84 | /* argv max size in mrb_funcall */
|
---|
85 | //#define MRB_FUNCALL_ARGC_MAX 16
|
---|
86 |
|
---|
87 | /* number of object per heap page */
|
---|
88 | //#define MRB_HEAP_PAGE_SIZE 1024
|
---|
89 |
|
---|
90 | /* if __ehdr_start is available, mruby can reduce memory used by symbols */
|
---|
91 | //#define MRB_USE_LINK_TIME_RO_DATA_P
|
---|
92 |
|
---|
93 | /* if MRB_USE_LINK_TIME_RO_DATA_P does not work,
|
---|
94 | you can try mrb_ro_data_p() that you have implemented yourself in any file;
|
---|
95 | prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */
|
---|
96 | //#define MRB_USE_CUSTOM_RO_DATA_P
|
---|
97 |
|
---|
98 | /* turn off generational GC by default */
|
---|
99 | //#define MRB_GC_TURN_OFF_GENERATIONAL
|
---|
100 |
|
---|
101 | /* default size of khash table bucket */
|
---|
102 | //#define KHASH_DEFAULT_SIZE 32
|
---|
103 |
|
---|
104 | /* allocated memory address alignment */
|
---|
105 | //#define POOL_ALIGNMENT 4
|
---|
106 |
|
---|
107 | /* page size of memory pool */
|
---|
108 | //#define POOL_PAGE_SIZE 16000
|
---|
109 |
|
---|
110 | /* initial minimum size for string buffer */
|
---|
111 | //#define MRB_STR_BUF_MIN_SIZE 128
|
---|
112 |
|
---|
113 | /* arena size */
|
---|
114 | //#define MRB_GC_ARENA_SIZE 100
|
---|
115 |
|
---|
116 | /* fixed size GC arena */
|
---|
117 | //#define MRB_GC_FIXED_ARENA
|
---|
118 |
|
---|
119 | /* state atexit stack size */
|
---|
120 | //#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
|
---|
121 |
|
---|
122 | /* fixed size state atexit stack */
|
---|
123 | //#define MRB_FIXED_STATE_ATEXIT_STACK
|
---|
124 |
|
---|
125 | /* -DMRB_DISABLE_XXXX to drop following features */
|
---|
126 | //#define MRB_DISABLE_STDIO /* use of stdio */
|
---|
127 |
|
---|
128 | /* -DMRB_ENABLE_XXXX to enable following features */
|
---|
129 | //#define MRB_ENABLE_DEBUG_HOOK /* hooks for debugger */
|
---|
130 | //#define MRB_ENABLE_ALL_SYMBOLS /* Symbols.all_symbols */
|
---|
131 |
|
---|
132 | /* end of configuration */
|
---|
133 |
|
---|
134 | /* define MRB_DISABLE_XXXX from DISABLE_XXX (for compatibility) */
|
---|
135 | #ifdef DISABLE_STDIO
|
---|
136 | #define MRB_DISABLE_STDIO
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | /* define MRB_ENABLE_XXXX from ENABLE_XXX (for compatibility) */
|
---|
140 | #ifdef ENABLE_DEBUG
|
---|
141 | #define MRB_ENABLE_DEBUG_HOOK
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | #ifndef MRB_DISABLE_STDIO
|
---|
145 | # include <stdio.h>
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | #ifndef FALSE
|
---|
149 | # define FALSE 0
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | #ifndef TRUE
|
---|
153 | # define TRUE 1
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | /*
|
---|
157 | ** mruby tuning profiles
|
---|
158 | **/
|
---|
159 |
|
---|
160 | /* A profile for micro controllers */
|
---|
161 | #if defined(MRB_CONSTRAINED_BASELINE_PROFILE)
|
---|
162 | # ifndef KHASH_DEFAULT_SIZE
|
---|
163 | # define KHASH_DEFAULT_SIZE 16
|
---|
164 | # endif
|
---|
165 |
|
---|
166 | # ifndef MRB_STR_BUF_MIN_SIZE
|
---|
167 | # define MRB_STR_BUF_MIN_SIZE 32
|
---|
168 | # endif
|
---|
169 |
|
---|
170 | # ifndef MRB_HEAP_PAGE_SIZE
|
---|
171 | # define MRB_HEAP_PAGE_SIZE 256
|
---|
172 | # endif
|
---|
173 |
|
---|
174 | /* A profile for default mruby */
|
---|
175 | #elif defined(MRB_BASELINE_PROFILE)
|
---|
176 |
|
---|
177 | /* A profile for desktop computers or workstations; rich memory! */
|
---|
178 | #elif defined(MRB_MAIN_PROFILE)
|
---|
179 | # ifndef MRB_METHOD_CACHE
|
---|
180 | # define MRB_METHOD_CACHE
|
---|
181 | # endif
|
---|
182 |
|
---|
183 | # ifndef MRB_METHOD_CACHE_SIZE
|
---|
184 | # define MRB_METHOD_CACHE_SIZE (1<<10)
|
---|
185 | # endif
|
---|
186 |
|
---|
187 | # ifndef MRB_IV_SEGMENT_SIZE
|
---|
188 | # define MRB_IV_SEGMENT_SIZE 32
|
---|
189 | # endif
|
---|
190 |
|
---|
191 | # ifndef MRB_HEAP_PAGE_SIZE
|
---|
192 | # define MRB_HEAP_PAGE_SIZE 4096
|
---|
193 | # endif
|
---|
194 |
|
---|
195 | /* A profile for server; mruby vm is long life */
|
---|
196 | #elif defined(MRB_HIGH_PROFILE)
|
---|
197 | # ifndef MRB_METHOD_CACHE
|
---|
198 | # define MRB_METHOD_CACHE
|
---|
199 | # endif
|
---|
200 |
|
---|
201 | # ifndef MRB_METHOD_CACHE_SIZE
|
---|
202 | # define MRB_METHOD_CACHE_SIZE (1<<12)
|
---|
203 | # endif
|
---|
204 |
|
---|
205 | # ifndef MRB_IV_SEGMENT_SIZE
|
---|
206 | # define MRB_IV_SEGMENT_SIZE 64
|
---|
207 | # endif
|
---|
208 |
|
---|
209 | # ifndef MRB_HEAP_PAGE_SIZE
|
---|
210 | # define MRB_HEAP_PAGE_SIZE 4096
|
---|
211 | # endif
|
---|
212 | #endif
|
---|
213 |
|
---|
214 | #endif /* MRUBYCONF_H */
|
---|