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 | /*****************************************************************************/ |
| 37 | /* Micro Python emitters */ |
| 38 | |
| 39 | // Whether to emit CPython byte codes (for debugging/testing) |
| 40 | // Enabling this overrides all other emitters |
| 41 | #ifndef MICROPY_EMIT_CPYTHON |
| 42 | #define MICROPY_EMIT_CPYTHON (0) |
| 43 | #endif |
| 44 | |
| 45 | // Whether to emit x64 native code |
| 46 | #ifndef MICROPY_EMIT_X64 |
| 47 | #define MICROPY_EMIT_X64 (0) |
| 48 | #endif |
| 49 | |
| 50 | // Whether to emit thumb native code |
| 51 | #ifndef MICROPY_EMIT_THUMB |
| 52 | #define MICROPY_EMIT_THUMB (0) |
| 53 | #endif |
| 54 | |
| 55 | // Whether to enable the thumb inline assembler |
| 56 | #ifndef MICROPY_EMIT_INLINE_THUMB |
| 57 | #define MICROPY_EMIT_INLINE_THUMB (0) |
| 58 | #endif |
| 59 | |
| 60 | /*****************************************************************************/ |
| 61 | /* Internal debugging stuff */ |
| 62 | |
| 63 | // Whether to collect memory allocation stats |
| 64 | #ifndef MICROPY_MEM_STATS |
| 65 | #define MICROPY_MEM_STATS (0) |
| 66 | #endif |
| 67 | |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 68 | // Whether to build functions that print debugging info: |
Damien George | c596612 | 2014-02-15 16:10:44 +0000 | [diff] [blame] | 69 | // mp_token_show |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 70 | // mp_byte_code_print |
| 71 | // mp_parse_node_print |
| 72 | #ifndef MICROPY_DEBUG_PRINTERS |
| 73 | #define MICROPY_DEBUG_PRINTERS (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 74 | #endif |
| 75 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 76 | /*****************************************************************************/ |
| 77 | /* Fine control over Python features */ |
| 78 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 79 | // Whether to include the garbage collector |
| 80 | #ifndef MICROPY_ENABLE_GC |
| 81 | #define MICROPY_ENABLE_GC (0) |
| 82 | #endif |
| 83 | |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 84 | // Whether to enable finalisers in the garbage collector (ie call __del__) |
| 85 | #ifndef MICROPY_ENABLE_GC_FINALISER |
| 86 | #define MICROPY_ENABLE_GC_FINALISER (0) |
| 87 | #endif |
| 88 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 89 | // Whether to include REPL helper function |
| 90 | #ifndef MICROPY_ENABLE_REPL_HELPERS |
| 91 | #define MICROPY_ENABLE_REPL_HELPERS (0) |
| 92 | #endif |
| 93 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 94 | // Whether to include lexer helper function for unix |
| 95 | #ifndef MICROPY_ENABLE_LEXER_UNIX |
| 96 | #define MICROPY_ENABLE_LEXER_UNIX (0) |
| 97 | #endif |
| 98 | |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 99 | // Long int implementation |
| 100 | #define MICROPY_LONGINT_IMPL_NONE (0) |
| 101 | #define MICROPY_LONGINT_IMPL_LONGLONG (1) |
Damien George | 438c88d | 2014-02-22 19:25:23 +0000 | [diff] [blame] | 102 | #define MICROPY_LONGINT_IMPL_MPZ (2) |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 103 | |
| 104 | #ifndef MICROPY_LONGINT_IMPL |
| 105 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) |
| 106 | #endif |
| 107 | |
| 108 | #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |
| 109 | typedef long long mp_longint_impl_t; |
| 110 | #endif |
| 111 | |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 112 | // Whether to include information in the byte code to determine source |
| 113 | // line number (increases RAM usage, but doesn't slow byte code execution) |
| 114 | #ifndef MICROPY_ENABLE_SOURCE_LINE |
| 115 | #define MICROPY_ENABLE_SOURCE_LINE (0) |
| 116 | #endif |
| 117 | |
Damien George | 1463c1f | 2014-04-25 23:52:57 +0100 | [diff] [blame] | 118 | // Whether to include doc strings (increases RAM usage) |
| 119 | #ifndef MICROPY_ENABLE_DOC_STRING |
| 120 | #define MICROPY_ENABLE_DOC_STRING (0) |
| 121 | #endif |
| 122 | |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 123 | // Exception messages are short static strings (TODO) |
| 124 | #define MICROPY_ERROR_REPORTING_TERSE (1) |
| 125 | // Exception messages provide basic error details |
| 126 | #define MICROPY_ERROR_REPORTING_NORMAL (2) |
| 127 | // Exception messages provide full info, e.g. object names |
| 128 | #define MICROPY_ERROR_REPORTING_DETAILED (3) |
| 129 | |
| 130 | #ifndef MICROPY_ERROR_REPORTING |
| 131 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) |
| 132 | #endif |
| 133 | |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 134 | // Float and complex implementation |
| 135 | #define MICROPY_FLOAT_IMPL_NONE (0) |
| 136 | #define MICROPY_FLOAT_IMPL_FLOAT (1) |
| 137 | #define MICROPY_FLOAT_IMPL_DOUBLE (2) |
| 138 | |
| 139 | #ifndef MICROPY_FLOAT_IMPL |
| 140 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) |
| 141 | #endif |
| 142 | |
| 143 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
| 144 | #define MICROPY_ENABLE_FLOAT (1) |
| 145 | #define MICROPY_FLOAT_C_FUN(fun) fun##f |
| 146 | typedef float mp_float_t; |
| 147 | #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE |
| 148 | #define MICROPY_ENABLE_FLOAT (1) |
| 149 | #define MICROPY_FLOAT_C_FUN(fun) fun |
| 150 | typedef double mp_float_t; |
| 151 | #else |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 152 | #define MICROPY_ENABLE_FLOAT (0) |
| 153 | #endif |
| 154 | |
Damien George | 107c9fb | 2014-04-26 10:31:15 +0100 | [diff] [blame] | 155 | // Whether to provide "collections" module |
| 156 | #ifndef MICROPY_ENABLE_MOD_COLLECTIONS |
| 157 | #define MICROPY_ENABLE_MOD_COLLECTIONS (1) |
| 158 | #endif |
| 159 | |
Damien George | dbdfee1 | 2014-04-17 17:11:03 +0100 | [diff] [blame] | 160 | // Whether to provide "math" module |
| 161 | #ifndef MICROPY_ENABLE_MOD_MATH |
| 162 | #define MICROPY_ENABLE_MOD_MATH (1) |
| 163 | #endif |
| 164 | |
| 165 | // Whether to provide "cmath" module |
| 166 | #ifndef MICROPY_ENABLE_MOD_CMATH |
| 167 | #define MICROPY_ENABLE_MOD_CMATH (0) |
| 168 | #endif |
| 169 | |
Paul Sokolovsky | 98a627d | 2014-04-03 14:57:53 +0300 | [diff] [blame] | 170 | // Whether to provide "io" module |
| 171 | #ifndef MICROPY_ENABLE_MOD_IO |
| 172 | #define MICROPY_ENABLE_MOD_IO (1) |
| 173 | #endif |
| 174 | |
Paul Sokolovsky | e9db840 | 2014-04-10 03:45:38 +0300 | [diff] [blame] | 175 | // Whether to provide "struct" module |
| 176 | #ifndef MICROPY_ENABLE_MOD_STRUCT |
| 177 | #define MICROPY_ENABLE_MOD_STRUCT (1) |
| 178 | #endif |
| 179 | |
Paul Sokolovsky | 5500cde | 2014-04-13 06:43:18 +0300 | [diff] [blame] | 180 | // Whether to provide "sys" module |
| 181 | #ifndef MICROPY_ENABLE_MOD_SYS |
| 182 | #define MICROPY_ENABLE_MOD_SYS (1) |
| 183 | #endif |
| 184 | |
Paul Sokolovsky | 4165cd1 | 2014-04-13 07:00:37 +0300 | [diff] [blame] | 185 | #ifndef MICROPY_MOD_SYS_STDFILES |
| 186 | #define MICROPY_MOD_SYS_STDFILES (0) |
| 187 | #endif |
| 188 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 189 | // Whether to support slice object and correspondingly |
| 190 | // slice subscript operators |
| 191 | #ifndef MICROPY_ENABLE_SLICE |
| 192 | #define MICROPY_ENABLE_SLICE (1) |
| 193 | #endif |
| 194 | |
Damien George | 777b0f3 | 2014-04-13 18:59:45 +0100 | [diff] [blame] | 195 | // Whether to support the property object |
| 196 | #ifndef MICROPY_ENABLE_PROPERTY |
Damien George | c9f6f6b | 2014-04-17 17:02:30 +0100 | [diff] [blame] | 197 | #define MICROPY_ENABLE_PROPERTY (1) |
Damien George | 777b0f3 | 2014-04-13 18:59:45 +0100 | [diff] [blame] | 198 | #endif |
| 199 | |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 200 | // Enable features which improve CPython compatibility |
| 201 | // but may lead to more code size/memory usage. |
| 202 | // TODO: Originally intended as generic category to not |
| 203 | // add bunch of once-off options. May need refactoring later |
| 204 | #ifndef MICROPY_CPYTHON_COMPAT |
| 205 | #define MICROPY_CPYTHON_COMPAT (1) |
| 206 | #endif |
| 207 | |
Damien George | 354d15a | 2014-02-06 21:11:19 +0000 | [diff] [blame] | 208 | // Maximum length of a path in the filesystem |
| 209 | // So we can allocate a buffer on the stack for path manipulation in import |
| 210 | #ifndef MICROPY_PATH_MAX |
| 211 | #define MICROPY_PATH_MAX (512) |
| 212 | #endif |
| 213 | |
Damien George | 3bb8bd8 | 2014-04-14 21:20:30 +0100 | [diff] [blame] | 214 | // Whether to use computed gotos in the VM, or a switch |
| 215 | // 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] | 216 | #ifndef MICROPY_USE_COMPUTED_GOTO |
| 217 | #define MICROPY_USE_COMPUTED_GOTO (0) |
Damien George | 3bb8bd8 | 2014-04-14 21:20:30 +0100 | [diff] [blame] | 218 | #endif |
| 219 | |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 220 | // Additional builtin function definitions - see builtintables.c:builtin_object_table for format. |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 221 | #ifndef MICROPY_EXTRA_BUILTINS |
| 222 | #define MICROPY_EXTRA_BUILTINS |
| 223 | #endif |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 224 | |
| 225 | // Additional builtin module definitions - see builtintables.c:builtin_module_table for format. |
| 226 | #ifndef MICROPY_EXTRA_BUILTIN_MODULES |
| 227 | #define MICROPY_EXTRA_BUILTIN_MODULES |
| 228 | #endif |
| 229 | |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 230 | // Additional constant definitions for the compiler - see compile.c:mp_constants_table. |
| 231 | #ifndef MICROPY_EXTRA_CONSTANTS |
| 232 | #define MICROPY_EXTRA_CONSTANTS |
| 233 | #endif |
| 234 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 235 | /*****************************************************************************/ |
| 236 | /* Miscellaneous settings */ |
| 237 | |
Paul Sokolovsky | d5df6cd | 2014-02-12 18:15:40 +0200 | [diff] [blame] | 238 | // Allow to override static modifier for global objects, e.g. to use with |
| 239 | // object code analysis tools which don't support static symbols. |
| 240 | #ifndef STATIC |
| 241 | #define STATIC static |
| 242 | #endif |
| 243 | |
Paul Sokolovsky | fc5aac8 | 2014-01-12 16:10:19 +0200 | [diff] [blame] | 244 | #define BITS_PER_BYTE (8) |
| 245 | #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD) |
Paul Sokolovsky | c260bc5 | 2014-01-12 16:15:47 +0200 | [diff] [blame] | 246 | // machine_int_t value with most significant bit set |
Damien George | 2300537 | 2014-01-13 19:39:01 +0000 | [diff] [blame] | 247 | #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] | 248 | |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 249 | #if !defined(MP_ENDIANNESS_LITTLE) && !defined(MP_ENDIANNESS_BIG) |
| 250 | // Just because most archs are such? |
| 251 | #define MP_ENDIANNESS_LITTLE (1) |
| 252 | #endif |
Andrew Scheller | cc83737 | 2014-04-14 02:39:56 +0100 | [diff] [blame] | 253 | // Ensure we don't accidentally set both endiannesses |
| 254 | #if MP_ENDIANNESS_BIG |
| 255 | #define MP_ENDIANNESS_LITTLE (0) |
| 256 | #endif |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 257 | |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 258 | // printf format spec to use for machine_int_t and friends |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 259 | #ifndef INT_FMT |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 260 | #ifdef __LP64__ |
| 261 | // Archs where machine_int_t == long, long != int |
| 262 | #define UINT_FMT "%lu" |
| 263 | #define INT_FMT "%ld" |
| 264 | #else |
| 265 | // Archs where machine_int_t == int |
| 266 | #define UINT_FMT "%u" |
| 267 | #define INT_FMT "%d" |
| 268 | #endif |
| 269 | #endif //INT_FMT |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 270 | |
| 271 | // Modifier for function which doesn't return |
| 272 | #define NORETURN __attribute__((noreturn)) |