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