| 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 |
/* architecture selection: */ |
| 11 |
/* specify -DMRB_32BIT or -DMRB_64BIT to override */ |
| 12 |
#if !defined(MRB_32BIT) && !defined(MRB_64BIT) |
| 13 |
#if UINT64_MAX == SIZE_MAX |
| 14 |
#define MRB_64BIT |
| 15 |
#else |
| 16 |
#define MRB_32BIT |
| 17 |
#endif |
| 18 |
#endif |
| 19 |
|
| 20 |
#if defined(MRB_32BIT) && defined(MRB_64BIT) |
| 21 |
#error Cannot build for 32 and 64 bit architecture at the same time |
| 22 |
#endif |
| 23 |
|
| 24 |
/* configuration options: */ |
| 25 |
/* add -DMRB_USE_FLOAT32 to use float instead of double for floating-point numbers */ |
| 26 |
//#define MRB_USE_FLOAT32 |
| 27 |
|
| 28 |
/* exclude floating-point numbers */ |
| 29 |
//#define MRB_NO_FLOAT |
| 30 |
|
| 31 |
/* obsolete configuration */ |
| 32 |
#if defined(MRB_USE_FLOAT) |
| 33 |
# define MRB_USE_FLOAT32 |
| 34 |
#endif |
| 35 |
|
| 36 |
/* obsolete configuration */ |
| 37 |
#if defined(MRB_WITHOUT_FLOAT) |
| 38 |
# define MRB_NO_FLOAT |
| 39 |
#endif |
| 40 |
|
| 41 |
#if defined(MRB_USE_FLOAT32) && defined(MRB_NO_FLOAT) |
| 42 |
#error Cannot define MRB_USE_FLOAT32 and MRB_NO_FLOAT at the same time |
| 43 |
#endif |
| 44 |
|
| 45 |
/* add -DMRB_NO_METHOD_CACHE to disable method cache to save memory */ |
| 46 |
//#define MRB_NO_METHOD_CACHE |
| 47 |
/* size of the method cache (need to be the power of 2) */ |
| 48 |
//#define MRB_METHOD_CACHE_SIZE (1<<8) |
| 49 |
//#define MRB_USE_INLINE_METHOD_CACHE |
| 50 |
|
| 51 |
/* add -DMRB_USE_METHOD_T_STRUCT on machines that use higher bits of function pointers */ |
| 52 |
/* no MRB_USE_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */ |
| 53 |
#ifndef MRB_USE_METHOD_T_STRUCT |
| 54 |
// can't use highest 2 bits of function pointers at least on 32bit |
| 55 |
// Windows and 32bit Linux. |
| 56 |
# ifdef MRB_32BIT |
| 57 |
# define MRB_USE_METHOD_T_STRUCT |
| 58 |
# endif |
| 59 |
#endif |
| 60 |
|
| 61 |
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */ |
| 62 |
#ifndef MRB_ENDIAN_BIG |
| 63 |
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \ |
| 64 |
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) |
| 65 |
# define MRB_ENDIAN_BIG |
| 66 |
# endif |
| 67 |
#endif |
| 68 |
|
| 69 |
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT32 and MRB_NO_FLOAT */ |
| 70 |
//#define MRB_NAN_BOXING |
| 71 |
|
| 72 |
/* represent mrb_value as a word (natural unit of data for the processor) */ |
| 73 |
//#define MRB_WORD_BOXING |
| 74 |
|
| 75 |
/* represent mrb_value as a struct; occupies 2 words */ |
| 76 |
//#define MRB_NO_BOXING |
| 77 |
|
| 78 |
/* if no specific boxing type is chosen */ |
| 79 |
#if !defined(MRB_NAN_BOXING) && !defined(MRB_WORD_BOXING) && !defined(MRB_NO_BOXING) |
| 80 |
# define MRB_WORD_BOXING |
| 81 |
#endif |
| 82 |
|
| 83 |
/* if defined mruby allocates Float objects in the heap to keep full precision if needed */ |
| 84 |
//#define MRB_WORDBOX_NO_FLOAT_TRUNCATE |
| 85 |
|
| 86 |
/* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT64; |
| 87 |
Default for 32-bit CPU mode. */ |
| 88 |
//#define MRB_INT32 |
| 89 |
|
| 90 |
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT32; |
| 91 |
Default for 64-bit CPU mode (unless using MRB_NAN_BOXING). */ |
| 92 |
//#define MRB_INT64 |
| 93 |
|
| 94 |
/* if no specific integer type is chosen */ |
| 95 |
#if !defined(MRB_INT32) && !defined(MRB_INT64) |
| 96 |
# if defined(MRB_64BIT) && !defined(MRB_NAN_BOXING) |
| 97 |
/* Use 64bit integers on 64bit architecture (without MRB_NAN_BOXING) */ |
| 98 |
# define MRB_INT64 |
| 99 |
# else |
| 100 |
/* Otherwise use 32bit integers */ |
| 101 |
# define MRB_INT32 |
| 102 |
# endif |
| 103 |
#endif |
| 104 |
|
| 105 |
/* call malloc_trim(0) from mrb_full_gc() */ |
| 106 |
//#define MRB_USE_MALLOC_TRIM |
| 107 |
|
| 108 |
/* string class to handle UTF-8 encoding */ |
| 109 |
//#define MRB_UTF8_STRING |
| 110 |
|
| 111 |
/* maximum length of strings */ |
| 112 |
/* the default value is 1MB */ |
| 113 |
/* set this value to zero to skip the check */ |
| 114 |
//#define MRB_STR_LENGTH_MAX 1048576 |
| 115 |
|
| 116 |
/* maximum length of arrays */ |
| 117 |
/* the default value is 2**17 entries */ |
| 118 |
/* set this value to zero to skip the check */ |
| 119 |
//#define MRB_ARY_LENGTH_MAX 131072 |
| 120 |
|
| 121 |
/* argv max size in mrb_funcall */ |
| 122 |
//#define MRB_FUNCALL_ARGC_MAX 16 |
| 123 |
|
| 124 |
/* number of object per heap page */ |
| 125 |
//#define MRB_HEAP_PAGE_SIZE 1024 |
| 126 |
|
| 127 |
/* define if your platform does not support etext, edata */ |
| 128 |
//#define MRB_NO_DEFAULT_RO_DATA_P |
| 129 |
|
| 130 |
/* define if your platform supports etext, edata */ |
| 131 |
//#define MRB_USE_RO_DATA_P_ETEXT |
| 132 |
/* use MRB_USE_ETEXT_RO_DATA_P by default on Linux */ |
| 133 |
#if (defined(__linux__) && !defined(__KERNEL__)) |
| 134 |
#define MRB_USE_ETEXT_RO_DATA_P |
| 135 |
#endif |
| 136 |
|
| 137 |
/* you can provide and use mrb_ro_data_p() for your platform. |
| 138 |
prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */ |
| 139 |
//#define MRB_USE_CUSTOM_RO_DATA_P |
| 140 |
|
| 141 |
/* turn off generational GC by default */ |
| 142 |
//#define MRB_GC_TURN_OFF_GENERATIONAL |
| 143 |
|
| 144 |
/* default size of khash table bucket */ |
| 145 |
//#define KHASH_DEFAULT_SIZE 32 |
| 146 |
|
| 147 |
/* allocated memory address alignment */ |
| 148 |
//#define POOL_ALIGNMENT 4 |
| 149 |
|
| 150 |
/* page size of memory pool */ |
| 151 |
//#define POOL_PAGE_SIZE 16000 |
| 152 |
|
| 153 |
/* arena size */ |
| 154 |
//#define MRB_GC_ARENA_SIZE 100 |
| 155 |
|
| 156 |
/* fixed size GC arena */ |
| 157 |
//#define MRB_GC_FIXED_ARENA |
| 158 |
|
| 159 |
/* state atexit stack size */ |
| 160 |
//#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5 |
| 161 |
|
| 162 |
/* fixed size state atexit stack */ |
| 163 |
//#define MRB_FIXED_STATE_ATEXIT_STACK |
| 164 |
|
| 165 |
/* -DMRB_NO_XXXX to drop following features */ |
| 166 |
//#define MRB_NO_STDIO /* use of stdio */ |
| 167 |
|
| 168 |
/* -DMRB_USE_XXXX to enable following features */ |
| 169 |
//#define MRB_USE_DEBUG_HOOK /* hooks for debugger */ |
| 170 |
//#define MRB_USE_ALL_SYMBOLS /* Symbol.all_symbols */ |
| 171 |
|
| 172 |
/* obsolete configurations */ |
| 173 |
#ifdef MRB_METHOD_T_STRUCT |
| 174 |
# define MRB_USE_METHOD_T_STRUCT |
| 175 |
#endif |
| 176 |
#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO) |
| 177 |
# define MRB_NO_STDIO |
| 178 |
#endif |
| 179 |
#if defined(MRB_DISABLE_DIRECT_THREADING) || defined(MRB_NO_DIRECT_THREADING) |
| 180 |
# define MRB_USE_VM_SWITCH_DISPATCH |
| 181 |
#endif |
| 182 |
#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK) |
| 183 |
# define MRB_USE_DEBUG_HOOK |
| 184 |
#endif |
| 185 |
#ifdef MRB_ENABLE_ALL_SYMBOLS |
| 186 |
# define MRB_USE_ALL_SYMBOLS |
| 187 |
#endif |
| 188 |
#ifdef MRB_ENABLE_CXX_ABI |
| 189 |
# define MRB_USE_CXX_ABI |
| 190 |
#endif |
| 191 |
#ifdef MRB_ENABLE_CXX_EXCEPTION |
| 192 |
# define MRB_USE_CXX_EXCEPTION |
| 193 |
#endif |
| 194 |
|
| 195 |
/* end of configuration */ |
| 196 |
|
| 197 |
#ifndef MRB_NO_STDIO |
| 198 |
# include <stdio.h> |
| 199 |
#endif |
| 200 |
|
| 201 |
/* |
| 202 |
** mruby tuning profiles |
| 203 |
**/ |
| 204 |
|
| 205 |
/* A profile for micro controllers */ |
| 206 |
#if defined(MRB_CONSTRAINED_BASELINE_PROFILE) |
| 207 |
# ifndef MRB_NO_METHOD_CACHE |
| 208 |
# define MRB_NO_METHOD_CACHE |
| 209 |
# endif |
| 210 |
|
| 211 |
# ifndef KHASH_DEFAULT_SIZE |
| 212 |
# define KHASH_DEFAULT_SIZE 16 |
| 213 |
# endif |
| 214 |
|
| 215 |
# ifndef MRB_HEAP_PAGE_SIZE |
| 216 |
# define MRB_HEAP_PAGE_SIZE 256 |
| 217 |
# endif |
| 218 |
|
| 219 |
/* A profile for default mruby */ |
| 220 |
#elif defined(MRB_BASELINE_PROFILE) |
| 221 |
|
| 222 |
/* A profile for desktop computers or workstations; rich memory! */ |
| 223 |
#elif defined(MRB_MAIN_PROFILE) |
| 224 |
# ifndef MRB_METHOD_CACHE_SIZE |
| 225 |
# define MRB_METHOD_CACHE_SIZE (1<<10) |
| 226 |
# endif |
| 227 |
|
| 228 |
# ifndef MRB_HEAP_PAGE_SIZE |
| 229 |
# define MRB_HEAP_PAGE_SIZE 4096 |
| 230 |
# endif |
| 231 |
|
| 232 |
/* A profile for server; mruby vm is long life */ |
| 233 |
#elif defined(MRB_HIGH_PROFILE) |
| 234 |
# ifndef MRB_METHOD_CACHE_SIZE |
| 235 |
# define MRB_METHOD_CACHE_SIZE (1<<12) |
| 236 |
# endif |
| 237 |
|
| 238 |
# ifndef MRB_HEAP_PAGE_SIZE |
| 239 |
# define MRB_HEAP_PAGE_SIZE 4096 |
| 240 |
# endif |
| 241 |
#endif |
| 242 |
|
| 243 |
#endif /* MRUBYCONF_H */ |