Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013, 2014 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
| 26 | |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 27 | // This file contains default configuration settings for MicroPython. |
| 28 | // You can override any of these options using mpconfigport.h file located |
| 29 | // in a directory of your port. |
| 30 | |
| 31 | #include <mpconfigport.h> |
| 32 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 33 | // Any options not explicitly set in mpconfigport.h will get default |
| 34 | // values below. |
| 35 | |
| 36 | /*****************************************************************************/ |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 37 | /* Memory allocation policy */ |
| 38 | |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame^] | 39 | // Initial amount for lexer indentation level |
| 40 | #ifndef MP_ALLOC_LEXER_INDENT_INIT |
| 41 | #define MP_ALLOC_LEXER_INDENT_INIT (10) |
| 42 | #endif |
| 43 | |
| 44 | // Increment for lexer indentation level |
| 45 | #ifndef MP_ALLOC_LEXEL_INDENT_INC |
| 46 | #define MP_ALLOC_LEXEL_INDENT_INC (8) |
| 47 | #endif |
| 48 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 49 | // Initial amount for parse rule stack |
| 50 | #ifndef MP_ALLOC_PARSE_RULE_INIT |
| 51 | #define MP_ALLOC_PARSE_RULE_INIT (64) |
| 52 | #endif |
| 53 | |
| 54 | // Increment for parse rule stack |
| 55 | #ifndef MP_ALLOC_PARSE_RULE_INC |
| 56 | #define MP_ALLOC_PARSE_RULE_INC (16) |
| 57 | #endif |
| 58 | |
| 59 | // Initial amount for parse result stack |
| 60 | #ifndef MP_ALLOC_PARSE_RESULT_INIT |
| 61 | #define MP_ALLOC_PARSE_RESULT_INIT (32) |
| 62 | #endif |
| 63 | |
| 64 | // Increment for parse result stack |
| 65 | #ifndef MP_ALLOC_PARSE_RESULT_INC |
| 66 | #define MP_ALLOC_PARSE_RESULT_INC (16) |
| 67 | #endif |
| 68 | |
| 69 | // Initial amount for ids in a scope |
| 70 | #ifndef MP_ALLOC_SCOPE_ID_INIT |
| 71 | #define MP_ALLOC_SCOPE_ID_INIT (4) |
| 72 | #endif |
| 73 | |
| 74 | // Increment for ids in a scope |
| 75 | #ifndef MP_ALLOC_SCOPE_ID_INC |
| 76 | #define MP_ALLOC_SCOPE_ID_INC (6) |
| 77 | #endif |
| 78 | |
| 79 | /*****************************************************************************/ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 80 | /* Micro Python emitters */ |
| 81 | |
| 82 | // Whether to emit CPython byte codes (for debugging/testing) |
| 83 | // Enabling this overrides all other emitters |
| 84 | #ifndef MICROPY_EMIT_CPYTHON |
| 85 | #define MICROPY_EMIT_CPYTHON (0) |
| 86 | #endif |
| 87 | |
| 88 | // Whether to emit x64 native code |
| 89 | #ifndef MICROPY_EMIT_X64 |
| 90 | #define MICROPY_EMIT_X64 (0) |
| 91 | #endif |
| 92 | |
| 93 | // Whether to emit thumb native code |
| 94 | #ifndef MICROPY_EMIT_THUMB |
| 95 | #define MICROPY_EMIT_THUMB (0) |
| 96 | #endif |
| 97 | |
| 98 | // Whether to enable the thumb inline assembler |
| 99 | #ifndef MICROPY_EMIT_INLINE_THUMB |
| 100 | #define MICROPY_EMIT_INLINE_THUMB (0) |
| 101 | #endif |
| 102 | |
| 103 | /*****************************************************************************/ |
| 104 | /* Internal debugging stuff */ |
| 105 | |
| 106 | // Whether to collect memory allocation stats |
| 107 | #ifndef MICROPY_MEM_STATS |
| 108 | #define MICROPY_MEM_STATS (0) |
| 109 | #endif |
| 110 | |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 111 | // Whether to build functions that print debugging info: |
Damien George | c596612 | 2014-02-15 16:10:44 +0000 | [diff] [blame] | 112 | // mp_token_show |
Damien George | 3417bc2 | 2014-05-10 10:36:38 +0100 | [diff] [blame] | 113 | // mp_bytecode_print |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 114 | // mp_parse_node_print |
| 115 | #ifndef MICROPY_DEBUG_PRINTERS |
| 116 | #define MICROPY_DEBUG_PRINTERS (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 117 | #endif |
| 118 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 119 | /*****************************************************************************/ |
| 120 | /* Fine control over Python features */ |
| 121 | |
Damien George | ffae48d | 2014-05-08 15:58:39 +0000 | [diff] [blame] | 122 | // Whether to enable constant optimisation; id = const(value) |
| 123 | #ifndef MICROPY_ENABLE_CONST |
| 124 | #define MICROPY_ENABLE_CONST (1) |
| 125 | #endif |
| 126 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 127 | // Whether to include the garbage collector |
| 128 | #ifndef MICROPY_ENABLE_GC |
| 129 | #define MICROPY_ENABLE_GC (0) |
| 130 | #endif |
| 131 | |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 132 | // Whether to enable finalisers in the garbage collector (ie call __del__) |
| 133 | #ifndef MICROPY_ENABLE_GC_FINALISER |
| 134 | #define MICROPY_ENABLE_GC_FINALISER (0) |
| 135 | #endif |
| 136 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 137 | // Whether to include REPL helper function |
| 138 | #ifndef MICROPY_ENABLE_REPL_HELPERS |
| 139 | #define MICROPY_ENABLE_REPL_HELPERS (0) |
| 140 | #endif |
| 141 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 142 | // Whether to include lexer helper function for unix |
| 143 | #ifndef MICROPY_ENABLE_LEXER_UNIX |
| 144 | #define MICROPY_ENABLE_LEXER_UNIX (0) |
| 145 | #endif |
| 146 | |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 147 | // Long int implementation |
| 148 | #define MICROPY_LONGINT_IMPL_NONE (0) |
| 149 | #define MICROPY_LONGINT_IMPL_LONGLONG (1) |
Damien George | 438c88d | 2014-02-22 19:25:23 +0000 | [diff] [blame] | 150 | #define MICROPY_LONGINT_IMPL_MPZ (2) |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 151 | |
| 152 | #ifndef MICROPY_LONGINT_IMPL |
| 153 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) |
| 154 | #endif |
| 155 | |
| 156 | #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |
| 157 | typedef long long mp_longint_impl_t; |
| 158 | #endif |
| 159 | |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 160 | // Whether to include information in the byte code to determine source |
| 161 | // line number (increases RAM usage, but doesn't slow byte code execution) |
| 162 | #ifndef MICROPY_ENABLE_SOURCE_LINE |
| 163 | #define MICROPY_ENABLE_SOURCE_LINE (0) |
| 164 | #endif |
| 165 | |
Damien George | 1463c1f | 2014-04-25 23:52:57 +0100 | [diff] [blame] | 166 | // Whether to include doc strings (increases RAM usage) |
| 167 | #ifndef MICROPY_ENABLE_DOC_STRING |
| 168 | #define MICROPY_ENABLE_DOC_STRING (0) |
| 169 | #endif |
| 170 | |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 171 | // Exception messages are short static strings (TODO) |
| 172 | #define MICROPY_ERROR_REPORTING_TERSE (1) |
| 173 | // Exception messages provide basic error details |
| 174 | #define MICROPY_ERROR_REPORTING_NORMAL (2) |
| 175 | // Exception messages provide full info, e.g. object names |
| 176 | #define MICROPY_ERROR_REPORTING_DETAILED (3) |
| 177 | |
| 178 | #ifndef MICROPY_ERROR_REPORTING |
| 179 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) |
| 180 | #endif |
| 181 | |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 182 | // Float and complex implementation |
| 183 | #define MICROPY_FLOAT_IMPL_NONE (0) |
| 184 | #define MICROPY_FLOAT_IMPL_FLOAT (1) |
| 185 | #define MICROPY_FLOAT_IMPL_DOUBLE (2) |
| 186 | |
| 187 | #ifndef MICROPY_FLOAT_IMPL |
| 188 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) |
| 189 | #endif |
| 190 | |
| 191 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
| 192 | #define MICROPY_ENABLE_FLOAT (1) |
| 193 | #define MICROPY_FLOAT_C_FUN(fun) fun##f |
| 194 | typedef float mp_float_t; |
| 195 | #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE |
| 196 | #define MICROPY_ENABLE_FLOAT (1) |
| 197 | #define MICROPY_FLOAT_C_FUN(fun) fun |
| 198 | typedef double mp_float_t; |
| 199 | #else |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 200 | #define MICROPY_ENABLE_FLOAT (0) |
| 201 | #endif |
| 202 | |
Damien George | 107c9fb | 2014-04-26 10:31:15 +0100 | [diff] [blame] | 203 | // Whether to provide "collections" module |
| 204 | #ifndef MICROPY_ENABLE_MOD_COLLECTIONS |
| 205 | #define MICROPY_ENABLE_MOD_COLLECTIONS (1) |
| 206 | #endif |
| 207 | |
Damien George | dbdfee1 | 2014-04-17 17:11:03 +0100 | [diff] [blame] | 208 | // Whether to provide "math" module |
| 209 | #ifndef MICROPY_ENABLE_MOD_MATH |
| 210 | #define MICROPY_ENABLE_MOD_MATH (1) |
| 211 | #endif |
| 212 | |
| 213 | // Whether to provide "cmath" module |
| 214 | #ifndef MICROPY_ENABLE_MOD_CMATH |
| 215 | #define MICROPY_ENABLE_MOD_CMATH (0) |
| 216 | #endif |
| 217 | |
Paul Sokolovsky | f9e54e0 | 2014-05-06 02:16:43 +0300 | [diff] [blame] | 218 | // Whether to provide "gc" module |
| 219 | #ifndef MICROPY_ENABLE_MOD_GC |
| 220 | #define MICROPY_ENABLE_MOD_GC (1) |
| 221 | #endif |
| 222 | |
Paul Sokolovsky | 98a627d | 2014-04-03 14:57:53 +0300 | [diff] [blame] | 223 | // Whether to provide "io" module |
| 224 | #ifndef MICROPY_ENABLE_MOD_IO |
| 225 | #define MICROPY_ENABLE_MOD_IO (1) |
| 226 | #endif |
| 227 | |
Paul Sokolovsky | e9db840 | 2014-04-10 03:45:38 +0300 | [diff] [blame] | 228 | // Whether to provide "struct" module |
| 229 | #ifndef MICROPY_ENABLE_MOD_STRUCT |
| 230 | #define MICROPY_ENABLE_MOD_STRUCT (1) |
| 231 | #endif |
| 232 | |
Paul Sokolovsky | 5500cde | 2014-04-13 06:43:18 +0300 | [diff] [blame] | 233 | // Whether to provide "sys" module |
| 234 | #ifndef MICROPY_ENABLE_MOD_SYS |
| 235 | #define MICROPY_ENABLE_MOD_SYS (1) |
| 236 | #endif |
| 237 | |
Paul Sokolovsky | 4165cd1 | 2014-04-13 07:00:37 +0300 | [diff] [blame] | 238 | #ifndef MICROPY_MOD_SYS_STDFILES |
| 239 | #define MICROPY_MOD_SYS_STDFILES (0) |
| 240 | #endif |
| 241 | |
Paul Sokolovsky | deaeaac | 2014-05-10 17:26:47 +0300 | [diff] [blame] | 242 | // sys.exit() availability |
| 243 | #ifndef MICROPY_SYS_EXIT |
| 244 | #define MICROPY_SYS_EXIT (0) |
| 245 | #endif |
| 246 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 247 | // Whether to support slice object and correspondingly |
| 248 | // slice subscript operators |
| 249 | #ifndef MICROPY_ENABLE_SLICE |
| 250 | #define MICROPY_ENABLE_SLICE (1) |
| 251 | #endif |
| 252 | |
Paul Sokolovsky | b181b58 | 2014-05-10 16:02:17 +0300 | [diff] [blame] | 253 | // Whether to support frozenset object |
| 254 | #ifndef MICROPY_ENABLE_FROZENSET |
Paul Sokolovsky | d80e247 | 2014-05-10 16:11:04 +0300 | [diff] [blame] | 255 | #define MICROPY_ENABLE_FROZENSET (0) |
Paul Sokolovsky | b181b58 | 2014-05-10 16:02:17 +0300 | [diff] [blame] | 256 | #endif |
| 257 | |
Damien George | 777b0f3 | 2014-04-13 18:59:45 +0100 | [diff] [blame] | 258 | // Whether to support the property object |
| 259 | #ifndef MICROPY_ENABLE_PROPERTY |
Damien George | c9f6f6b | 2014-04-17 17:02:30 +0100 | [diff] [blame] | 260 | #define MICROPY_ENABLE_PROPERTY (1) |
Damien George | 777b0f3 | 2014-04-13 18:59:45 +0100 | [diff] [blame] | 261 | #endif |
| 262 | |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 263 | // Enable features which improve CPython compatibility |
| 264 | // but may lead to more code size/memory usage. |
| 265 | // TODO: Originally intended as generic category to not |
| 266 | // add bunch of once-off options. May need refactoring later |
| 267 | #ifndef MICROPY_CPYTHON_COMPAT |
| 268 | #define MICROPY_CPYTHON_COMPAT (1) |
| 269 | #endif |
| 270 | |
Damien George | 354d15a | 2014-02-06 21:11:19 +0000 | [diff] [blame] | 271 | // Maximum length of a path in the filesystem |
| 272 | // So we can allocate a buffer on the stack for path manipulation in import |
| 273 | #ifndef MICROPY_PATH_MAX |
| 274 | #define MICROPY_PATH_MAX (512) |
| 275 | #endif |
| 276 | |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 277 | // Whether POSIX-semantics non-blocking streams are supported |
| 278 | #ifndef MICROPY_STREAMS_NON_BLOCK |
| 279 | #define MICROPY_STREAMS_NON_BLOCK (0) |
| 280 | #endif |
| 281 | |
Damien George | 3bb8bd8 | 2014-04-14 21:20:30 +0100 | [diff] [blame] | 282 | // Whether to use computed gotos in the VM, or a switch |
| 283 | // Computed gotos are roughly 10% faster, and increase VM code size by a little |
Damien George | 5b65f0c | 2014-04-17 23:24:13 +0100 | [diff] [blame] | 284 | #ifndef MICROPY_USE_COMPUTED_GOTO |
| 285 | #define MICROPY_USE_COMPUTED_GOTO (0) |
Damien George | 3bb8bd8 | 2014-04-14 21:20:30 +0100 | [diff] [blame] | 286 | #endif |
| 287 | |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 288 | // Additional builtin function definitions - see builtintables.c:builtin_object_table for format. |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 289 | #ifndef MICROPY_EXTRA_BUILTINS |
| 290 | #define MICROPY_EXTRA_BUILTINS |
| 291 | #endif |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 292 | |
| 293 | // Additional builtin module definitions - see builtintables.c:builtin_module_table for format. |
| 294 | #ifndef MICROPY_EXTRA_BUILTIN_MODULES |
| 295 | #define MICROPY_EXTRA_BUILTIN_MODULES |
| 296 | #endif |
| 297 | |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 298 | // Additional constant definitions for the compiler - see compile.c:mp_constants_table. |
| 299 | #ifndef MICROPY_EXTRA_CONSTANTS |
| 300 | #define MICROPY_EXTRA_CONSTANTS |
| 301 | #endif |
| 302 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 303 | /*****************************************************************************/ |
| 304 | /* Miscellaneous settings */ |
| 305 | |
Paul Sokolovsky | d5df6cd | 2014-02-12 18:15:40 +0200 | [diff] [blame] | 306 | // Allow to override static modifier for global objects, e.g. to use with |
| 307 | // object code analysis tools which don't support static symbols. |
| 308 | #ifndef STATIC |
| 309 | #define STATIC static |
| 310 | #endif |
| 311 | |
Paul Sokolovsky | fc5aac8 | 2014-01-12 16:10:19 +0200 | [diff] [blame] | 312 | #define BITS_PER_BYTE (8) |
| 313 | #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD) |
Paul Sokolovsky | c260bc5 | 2014-01-12 16:15:47 +0200 | [diff] [blame] | 314 | // machine_int_t value with most significant bit set |
Damien George | 2300537 | 2014-01-13 19:39:01 +0000 | [diff] [blame] | 315 | #define WORD_MSBIT_HIGH (((machine_uint_t)1) << (BYTES_PER_WORD * 8 - 1)) |
Paul Sokolovsky | fc5aac8 | 2014-01-12 16:10:19 +0200 | [diff] [blame] | 316 | |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 317 | #if !defined(MP_ENDIANNESS_LITTLE) && !defined(MP_ENDIANNESS_BIG) |
| 318 | // Just because most archs are such? |
| 319 | #define MP_ENDIANNESS_LITTLE (1) |
| 320 | #endif |
Andrew Scheller | cc83737 | 2014-04-14 02:39:56 +0100 | [diff] [blame] | 321 | // Ensure we don't accidentally set both endiannesses |
| 322 | #if MP_ENDIANNESS_BIG |
| 323 | #define MP_ENDIANNESS_LITTLE (0) |
| 324 | #endif |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 325 | |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 326 | // printf format spec to use for machine_int_t and friends |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 327 | #ifndef INT_FMT |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 328 | #ifdef __LP64__ |
| 329 | // Archs where machine_int_t == long, long != int |
| 330 | #define UINT_FMT "%lu" |
| 331 | #define INT_FMT "%ld" |
| 332 | #else |
| 333 | // Archs where machine_int_t == int |
| 334 | #define UINT_FMT "%u" |
| 335 | #define INT_FMT "%d" |
| 336 | #endif |
| 337 | #endif //INT_FMT |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 338 | |
| 339 | // Modifier for function which doesn't return |
stijn | 01d6be4 | 2014-05-05 12:18:27 +0200 | [diff] [blame] | 340 | #ifndef NORETURN |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 341 | #define NORETURN __attribute__((noreturn)) |
stijn | 01d6be4 | 2014-05-05 12:18:27 +0200 | [diff] [blame] | 342 | #endif |