Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 2 | * This file is part of the MicroPython project, http://micropython.org/ |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 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 | */ |
Alexander Steffen | 299bc62 | 2017-06-29 23:14:58 +0200 | [diff] [blame] | 26 | #ifndef MICROPY_INCLUDED_PY_MPCONFIG_H |
| 27 | #define MICROPY_INCLUDED_PY_MPCONFIG_H |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 28 | |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 29 | // Current version of MicroPython |
Damien George | aba83e6 | 2019-01-26 00:44:35 +1100 | [diff] [blame] | 30 | #define MICROPY_VERSION_MAJOR 1 |
Damien George | da4b38e | 2022-01-17 09:50:31 +1100 | [diff] [blame] | 31 | #define MICROPY_VERSION_MINOR 18 |
Damien George | 3e25d61 | 2019-01-26 00:56:48 +1100 | [diff] [blame] | 32 | #define MICROPY_VERSION_MICRO 0 |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 33 | |
| 34 | // Combined version as a 32-bit number for convenience |
| 35 | #define MICROPY_VERSION ( \ |
| 36 | MICROPY_VERSION_MAJOR << 16 \ |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 37 | | MICROPY_VERSION_MINOR << 8 \ |
| 38 | | MICROPY_VERSION_MICRO) |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 39 | |
| 40 | // String version |
| 41 | #define MICROPY_VERSION_STRING \ |
| 42 | MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \ |
| 43 | MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \ |
| 44 | MP_STRINGIFY(MICROPY_VERSION_MICRO) |
| 45 | |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 46 | // This file contains default configuration settings for MicroPython. |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 47 | // You can override any of the options below using mpconfigport.h file |
| 48 | // located in a directory of your port. |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 49 | |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 50 | // mpconfigport.h is a file containing configuration settings for a |
| 51 | // particular port. mpconfigport.h is actually a default name for |
Ville Skyttä | ca16c38 | 2017-05-29 10:08:14 +0300 | [diff] [blame] | 52 | // such config, and it can be overridden using MP_CONFIGFILE preprocessor |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 53 | // define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"' |
| 54 | // argument to make when using standard MicroPython makefiles). |
| 55 | // This is useful to have more than one config per port, for example, |
| 56 | // release vs debug configs, etc. Note that if you switch from one config |
| 57 | // to another, you must rebuild from scratch using "-B" switch to make. |
| 58 | |
| 59 | #ifdef MP_CONFIGFILE |
| 60 | #include MP_CONFIGFILE |
| 61 | #else |
Damien George | 8340c48 | 2014-06-12 19:50:17 +0100 | [diff] [blame] | 62 | #include <mpconfigport.h> |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 63 | #endif |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 64 | |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 65 | // Disable all optional features (i.e. minimal port). |
| 66 | #define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0) |
| 67 | // Only enable core features (constrained flash, e.g. STM32L072) |
| 68 | #define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10) |
| 69 | // Enable most common features (small on-device flash, e.g. STM32F411) |
| 70 | #define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20) |
| 71 | // Enable convenience features (medium on-device flash, e.g. STM32F405) |
| 72 | #define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30) |
| 73 | // Enable all common features (large/external flash, rp2, unix) |
| 74 | #define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40) |
| 75 | // Enable everything (e.g. coverage) |
| 76 | #define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50) |
| 77 | |
| 78 | // Ports/boards should set this, but default to level=core. |
| 79 | #ifndef MICROPY_CONFIG_ROM_LEVEL |
| 80 | #define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) |
| 81 | #endif |
| 82 | |
| 83 | // Helper macros for "have at least this level". |
| 84 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) |
| 85 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) |
| 86 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) |
| 87 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) |
| 88 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) |
| 89 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 90 | // Any options not explicitly set in mpconfigport.h will get default |
| 91 | // values below. |
| 92 | |
| 93 | /*****************************************************************************/ |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 94 | /* Object representation */ |
| 95 | |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 96 | // A MicroPython object is a machine word having the following form: |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 97 | // - xxxx...xxx1 : a small int, bits 1 and above are the value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 98 | // - xxxx...x010 : a qstr, bits 3 and above are the value |
| 99 | // - xxxx...x110 : an immediate object, bits 3 and above are the value |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 100 | // - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object) |
| 101 | #define MICROPY_OBJ_REPR_A (0) |
| 102 | |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 103 | // A MicroPython object is a machine word having the following form: |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 104 | // - xxxx...xx01 : a small int, bits 2 and above are the value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 105 | // - xxxx...x011 : a qstr, bits 3 and above are the value |
| 106 | // - xxxx...x111 : an immediate object, bits 3 and above are the value |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 107 | // - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object) |
| 108 | #define MICROPY_OBJ_REPR_B (1) |
| 109 | |
Damien George | 8b8d189 | 2015-11-06 23:25:10 +0000 | [diff] [blame] | 110 | // A MicroPython object is a machine word having the following form (called R): |
Damien George | 183edef | 2015-10-17 23:20:57 +0100 | [diff] [blame] | 111 | // - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 112 | // - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value |
| 113 | // - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value |
Damien George | 183edef | 2015-10-17 23:20:57 +0100 | [diff] [blame] | 114 | // - s1111111 10000000 00000000 00000010 +/- inf |
| 115 | // - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0 |
| 116 | // - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff |
| 117 | // - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment) |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 118 | // Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000. |
| 119 | // This makes strs/immediates easier to encode/decode as they have zeros in the top 9 bits. |
Damien George | 183edef | 2015-10-17 23:20:57 +0100 | [diff] [blame] | 120 | // This scheme only works with 32-bit word size and float enabled. |
| 121 | #define MICROPY_OBJ_REPR_C (2) |
| 122 | |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 123 | // A MicroPython object is a 64-bit word having the following form (called R): |
| 124 | // - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff |
| 125 | // - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf |
| 126 | // - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan |
Damien George | 2759bec | 2017-12-11 22:39:12 +1100 | [diff] [blame] | 127 | // - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 128 | // - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 129 | // - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 130 | // - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment) |
| 131 | // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000. |
| 132 | // This makes pointers have all zeros in the top 32 bits. |
| 133 | // Small-ints and strs have 1 as LSB to make sure they don't look like pointers |
| 134 | // to the garbage collector. |
| 135 | #define MICROPY_OBJ_REPR_D (3) |
| 136 | |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 137 | #ifndef MICROPY_OBJ_REPR |
| 138 | #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) |
| 139 | #endif |
| 140 | |
Damien George | d96cfd1 | 2020-01-09 00:00:27 +1100 | [diff] [blame] | 141 | // Whether to encode None/False/True as immediate objects instead of pointers to |
| 142 | // real objects. Reduces code size by a decent amount without hurting |
| 143 | // performance, for all representations except D on some architectures. |
| 144 | #ifndef MICROPY_OBJ_IMMEDIATE_OBJS |
| 145 | #define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D) |
| 146 | #endif |
| 147 | |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 148 | /*****************************************************************************/ |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 149 | /* Memory allocation policy */ |
| 150 | |
Paul Sokolovsky | 75feece | 2015-12-03 01:40:52 +0200 | [diff] [blame] | 151 | // Number of bytes in memory allocation/GC block. Any size allocated will be |
| 152 | // rounded up to be multiples of this. |
Paul Sokolovsky | b4eccfd | 2015-12-03 01:57:50 +0200 | [diff] [blame] | 153 | #ifndef MICROPY_BYTES_PER_GC_BLOCK |
Damien George | ad4656b | 2021-02-04 16:39:09 +1100 | [diff] [blame] | 154 | #define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD) |
Paul Sokolovsky | b4eccfd | 2015-12-03 01:57:50 +0200 | [diff] [blame] | 155 | #endif |
Paul Sokolovsky | 75feece | 2015-12-03 01:40:52 +0200 | [diff] [blame] | 156 | |
Damien George | fd40a9c | 2015-01-01 22:04:46 +0000 | [diff] [blame] | 157 | // Number of words allocated (in BSS) to the GC stack (minimum is 1) |
| 158 | #ifndef MICROPY_ALLOC_GC_STACK_SIZE |
| 159 | #define MICROPY_ALLOC_GC_STACK_SIZE (64) |
| 160 | #endif |
| 161 | |
Ayke van Laethem | 31cf528 | 2018-02-23 18:59:31 +0100 | [diff] [blame] | 162 | // The C-type to use for entries in the GC stack. By default it allows the |
| 163 | // heap to be as large as the address space, but the bit-width of this type can |
| 164 | // be reduced to save memory when the heap is small enough. The type must be |
| 165 | // big enough to index all blocks in the heap, which is set by |
| 166 | // heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK. |
| 167 | #ifndef MICROPY_GC_STACK_ENTRY_TYPE |
| 168 | #define MICROPY_GC_STACK_ENTRY_TYPE size_t |
| 169 | #endif |
| 170 | |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 171 | // Be conservative and always clear to zero newly (re)allocated memory in the GC. |
| 172 | // This helps eliminate stray pointers that hold on to memory that's no longer |
| 173 | // used. It decreases performance due to unnecessary memory clearing. |
Colin Hogben | 828df54 | 2016-10-31 14:52:11 +0000 | [diff] [blame] | 174 | // A memory manager which always clears memory can set this to 0. |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 175 | // TODO Do analysis to understand why some memory is not properly cleared and |
| 176 | // find a more efficient way to clear it. |
| 177 | #ifndef MICROPY_GC_CONSERVATIVE_CLEAR |
Colin Hogben | 828df54 | 2016-10-31 14:52:11 +0000 | [diff] [blame] | 178 | #define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC) |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 179 | #endif |
| 180 | |
Paul Sokolovsky | 93e353e | 2016-07-21 00:37:30 +0300 | [diff] [blame] | 181 | // Support automatic GC when reaching allocation threshold, |
| 182 | // configurable by gc.threshold(). |
| 183 | #ifndef MICROPY_GC_ALLOC_THRESHOLD |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 184 | #define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 93e353e | 2016-07-21 00:37:30 +0300 | [diff] [blame] | 185 | #endif |
| 186 | |
Damien George | ade9a05 | 2015-06-13 21:53:22 +0100 | [diff] [blame] | 187 | // Number of bytes to allocate initially when creating new chunks to store |
| 188 | // interned string data. Smaller numbers lead to more chunks being needed |
| 189 | // and more wastage at the end of the chunk. Larger numbers lead to wasted |
| 190 | // space at the end when no more strings need interning. |
| 191 | #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT |
| 192 | #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128) |
| 193 | #endif |
| 194 | |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 195 | // Initial amount for lexer indentation level |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 196 | #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT |
| 197 | #define MICROPY_ALLOC_LEXER_INDENT_INIT (10) |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 198 | #endif |
| 199 | |
| 200 | // Increment for lexer indentation level |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 201 | #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC |
| 202 | #define MICROPY_ALLOC_LEXEL_INDENT_INC (8) |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 203 | #endif |
| 204 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 205 | // Initial amount for parse rule stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 206 | #ifndef MICROPY_ALLOC_PARSE_RULE_INIT |
| 207 | #define MICROPY_ALLOC_PARSE_RULE_INIT (64) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 208 | #endif |
| 209 | |
| 210 | // Increment for parse rule stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 211 | #ifndef MICROPY_ALLOC_PARSE_RULE_INC |
| 212 | #define MICROPY_ALLOC_PARSE_RULE_INC (16) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 213 | #endif |
| 214 | |
| 215 | // Initial amount for parse result stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 216 | #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT |
| 217 | #define MICROPY_ALLOC_PARSE_RESULT_INIT (32) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 218 | #endif |
| 219 | |
| 220 | // Increment for parse result stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 221 | #ifndef MICROPY_ALLOC_PARSE_RESULT_INC |
| 222 | #define MICROPY_ALLOC_PARSE_RESULT_INC (16) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 223 | #endif |
| 224 | |
Damien George | 5042bce | 2014-05-25 22:06:06 +0100 | [diff] [blame] | 225 | // Strings this length or less will be interned by the parser |
| 226 | #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN |
| 227 | #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10) |
| 228 | #endif |
| 229 | |
Damien George | 58e0f4a | 2015-09-23 10:50:43 +0100 | [diff] [blame] | 230 | // Number of bytes to allocate initially when creating new chunks to store |
| 231 | // parse nodes. Small leads to fragmentation, large leads to excess use. |
| 232 | #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT |
| 233 | #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128) |
| 234 | #endif |
| 235 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 236 | // Initial amount for ids in a scope |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 237 | #ifndef MICROPY_ALLOC_SCOPE_ID_INIT |
| 238 | #define MICROPY_ALLOC_SCOPE_ID_INIT (4) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 239 | #endif |
| 240 | |
| 241 | // Increment for ids in a scope |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 242 | #ifndef MICROPY_ALLOC_SCOPE_ID_INC |
| 243 | #define MICROPY_ALLOC_SCOPE_ID_INC (6) |
| 244 | #endif |
| 245 | |
| 246 | // Maximum length of a path in the filesystem |
| 247 | // So we can allocate a buffer on the stack for path manipulation in import |
| 248 | #ifndef MICROPY_ALLOC_PATH_MAX |
| 249 | #define MICROPY_ALLOC_PATH_MAX (512) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 250 | #endif |
| 251 | |
Paul Sokolovsky | 346aacf | 2014-11-05 00:27:15 +0200 | [diff] [blame] | 252 | // Initial size of module dict |
| 253 | #ifndef MICROPY_MODULE_DICT_SIZE |
| 254 | #define MICROPY_MODULE_DICT_SIZE (1) |
| 255 | #endif |
| 256 | |
matejcik | 1a2ffda | 2021-03-22 11:20:22 +0100 | [diff] [blame] | 257 | // Initial size of sys.modules dict |
| 258 | #ifndef MICROPY_LOADED_MODULES_DICT_SIZE |
| 259 | #define MICROPY_LOADED_MODULES_DICT_SIZE (3) |
| 260 | #endif |
| 261 | |
Damien George | d891452 | 2015-02-27 09:54:12 +0000 | [diff] [blame] | 262 | // Whether realloc/free should be passed allocated memory region size |
| 263 | // You must enable this if MICROPY_MEM_STATS is enabled |
| 264 | #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE |
| 265 | #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0) |
| 266 | #endif |
| 267 | |
Damien George | 95836f8 | 2015-01-11 22:27:30 +0000 | [diff] [blame] | 268 | // Number of bytes used to store qstr length |
| 269 | // Dictates hard limit on maximum Python identifier length, but 1 byte |
| 270 | // (limit of 255 bytes in an identifier) should be enough for everyone |
| 271 | #ifndef MICROPY_QSTR_BYTES_IN_LEN |
| 272 | #define MICROPY_QSTR_BYTES_IN_LEN (1) |
| 273 | #endif |
| 274 | |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 275 | // Number of bytes used to store qstr hash |
| 276 | #ifndef MICROPY_QSTR_BYTES_IN_HASH |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 277 | #if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 278 | #define MICROPY_QSTR_BYTES_IN_HASH (2) |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 279 | #else |
| 280 | #define MICROPY_QSTR_BYTES_IN_HASH (1) |
| 281 | #endif |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 282 | #endif |
| 283 | |
Paul Sokolovsky | 7f1c981 | 2015-03-28 01:14:45 +0200 | [diff] [blame] | 284 | // Avoid using C stack when making Python function calls. C stack still |
| 285 | // may be used if there's no free heap. |
Paul Sokolovsky | 2039757 | 2015-03-28 01:14:44 +0200 | [diff] [blame] | 286 | #ifndef MICROPY_STACKLESS |
| 287 | #define MICROPY_STACKLESS (0) |
| 288 | #endif |
| 289 | |
Paul Sokolovsky | 7f1c981 | 2015-03-28 01:14:45 +0200 | [diff] [blame] | 290 | // Never use C stack when making Python function calls. This may break |
| 291 | // testsuite as will subtly change which exception is thrown in case |
| 292 | // of too deep recursion and other similar cases. |
| 293 | #ifndef MICROPY_STACKLESS_STRICT |
| 294 | #define MICROPY_STACKLESS_STRICT (0) |
| 295 | #endif |
| 296 | |
Paul Sokolovsky | f32020e | 2015-11-25 23:22:31 +0200 | [diff] [blame] | 297 | // Don't use alloca calls. As alloca() is not part of ANSI C, this |
| 298 | // workaround option is provided for compilers lacking this de-facto |
| 299 | // standard function. The way it works is allocating from heap, and |
| 300 | // relying on garbage collection to free it eventually. This is of |
| 301 | // course much less optimal than real alloca(). |
| 302 | #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA |
| 303 | #undef alloca |
| 304 | #define alloca(x) m_malloc(x) |
| 305 | #endif |
| 306 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 307 | /*****************************************************************************/ |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 308 | /* MicroPython emitters */ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 309 | |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 310 | // Whether to support loading of persistent code |
| 311 | #ifndef MICROPY_PERSISTENT_CODE_LOAD |
| 312 | #define MICROPY_PERSISTENT_CODE_LOAD (0) |
| 313 | #endif |
| 314 | |
| 315 | // Whether to support saving of persistent code |
| 316 | #ifndef MICROPY_PERSISTENT_CODE_SAVE |
| 317 | #define MICROPY_PERSISTENT_CODE_SAVE (0) |
| 318 | #endif |
| 319 | |
David CARLIER | cb30928 | 2021-01-16 20:48:19 +0000 | [diff] [blame] | 320 | // Whether to support saving persistent code to a file via mp_raw_code_save_file |
| 321 | #ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE |
| 322 | #define MICROPY_PERSISTENT_CODE_SAVE_FILE (0) |
| 323 | #endif |
| 324 | |
Damien George | c8e9c0d | 2015-11-02 17:27:18 +0000 | [diff] [blame] | 325 | // Whether generated code can persist independently of the VM/runtime instance |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 326 | // This is enabled automatically when needed by other features |
Damien George | c8e9c0d | 2015-11-02 17:27:18 +0000 | [diff] [blame] | 327 | #ifndef MICROPY_PERSISTENT_CODE |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 328 | #define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY) |
Damien George | c8e9c0d | 2015-11-02 17:27:18 +0000 | [diff] [blame] | 329 | #endif |
| 330 | |
Damien George | f2040bf | 2021-10-22 22:22:47 +1100 | [diff] [blame] | 331 | // Whether bytecode uses a qstr_table to map internal qstr indices in the bytecode |
| 332 | // to global qstr values in the runtime (behaviour when feature is enabled), or |
| 333 | // just stores global qstr values directly in the bytecode. This must be enabled |
| 334 | // if MICROPY_PERSISTENT_CODE is enabled. |
| 335 | #ifndef MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE |
| 336 | #define MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE (MICROPY_PERSISTENT_CODE) |
| 337 | #endif |
| 338 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 339 | // Whether to emit x64 native code |
| 340 | #ifndef MICROPY_EMIT_X64 |
| 341 | #define MICROPY_EMIT_X64 (0) |
| 342 | #endif |
| 343 | |
Damien George | c90f59e | 2014-09-06 23:06:36 +0100 | [diff] [blame] | 344 | // Whether to emit x86 native code |
| 345 | #ifndef MICROPY_EMIT_X86 |
| 346 | #define MICROPY_EMIT_X86 (0) |
| 347 | #endif |
| 348 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 349 | // Whether to emit thumb native code |
| 350 | #ifndef MICROPY_EMIT_THUMB |
| 351 | #define MICROPY_EMIT_THUMB (0) |
| 352 | #endif |
| 353 | |
graham sanderson | 40d2010 | 2020-12-12 13:04:10 -0600 | [diff] [blame] | 354 | // Whether to emit ARMv7-M instruction support in thumb native code |
| 355 | #ifndef MICROPY_EMIT_THUMB_ARMV7M |
| 356 | #define MICROPY_EMIT_THUMB_ARMV7M (1) |
| 357 | #endif |
| 358 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 359 | // Whether to enable the thumb inline assembler |
| 360 | #ifndef MICROPY_EMIT_INLINE_THUMB |
| 361 | #define MICROPY_EMIT_INLINE_THUMB (0) |
| 362 | #endif |
| 363 | |
Damien George | e813541 | 2015-10-16 22:08:57 +0100 | [diff] [blame] | 364 | // Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler |
| 365 | #ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M |
| 366 | #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1) |
| 367 | #endif |
| 368 | |
= | 5008972 | 2015-04-14 13:14:57 +0100 | [diff] [blame] | 369 | // Whether to enable float support in the Thumb2 inline assembler |
| 370 | #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT |
| 371 | #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1) |
| 372 | #endif |
| 373 | |
Fabian Vogt | fe3d16e | 2014-08-16 22:55:53 +0200 | [diff] [blame] | 374 | // Whether to emit ARM native code |
| 375 | #ifndef MICROPY_EMIT_ARM |
| 376 | #define MICROPY_EMIT_ARM (0) |
| 377 | #endif |
| 378 | |
Damien George | 8e5aced | 2016-12-09 16:39:39 +1100 | [diff] [blame] | 379 | // Whether to emit Xtensa native code |
| 380 | #ifndef MICROPY_EMIT_XTENSA |
| 381 | #define MICROPY_EMIT_XTENSA (0) |
| 382 | #endif |
| 383 | |
Damien George | f76b1bf | 2016-12-09 17:03:33 +1100 | [diff] [blame] | 384 | // Whether to enable the Xtensa inline assembler |
| 385 | #ifndef MICROPY_EMIT_INLINE_XTENSA |
| 386 | #define MICROPY_EMIT_INLINE_XTENSA (0) |
| 387 | #endif |
| 388 | |
Damien George | 9adedce | 2019-09-13 13:15:12 +1000 | [diff] [blame] | 389 | // Whether to emit Xtensa-Windowed native code |
| 390 | #ifndef MICROPY_EMIT_XTENSAWIN |
| 391 | #define MICROPY_EMIT_XTENSAWIN (0) |
| 392 | #endif |
| 393 | |
Damien George | 2ac4af6 | 2014-08-15 16:45:41 +0100 | [diff] [blame] | 394 | // Convenience definition for whether any native emitter is enabled |
Damien George | 9adedce | 2019-09-13 13:15:12 +1000 | [diff] [blame] | 395 | #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN) |
| 396 | |
| 397 | // Select prelude-as-bytes-object for certain emitters |
| 398 | #define MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ (MICROPY_EMIT_XTENSAWIN) |
Damien George | 2ac4af6 | 2014-08-15 16:45:41 +0100 | [diff] [blame] | 399 | |
Damien George | ad297a1 | 2016-12-09 13:17:49 +1100 | [diff] [blame] | 400 | // Convenience definition for whether any inline assembler emitter is enabled |
Damien George | f76b1bf | 2016-12-09 17:03:33 +1100 | [diff] [blame] | 401 | #define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA) |
Damien George | ad297a1 | 2016-12-09 13:17:49 +1100 | [diff] [blame] | 402 | |
Jun Wu | b152bbd | 2019-05-06 00:31:11 -0700 | [diff] [blame] | 403 | // Convenience definition for whether any native or inline assembler emitter is enabled |
| 404 | #define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM) |
| 405 | |
Damien George | 9883d8e | 2020-07-27 23:52:38 +1000 | [diff] [blame] | 406 | // Whether native relocatable code loaded from .mpy files is explicitly tracked |
| 407 | // so that the GC cannot reclaim it. Needed on architectures that allocate |
| 408 | // executable memory on the MicroPython heap and don't explicitly track this |
| 409 | // data some other way. |
| 410 | #ifndef MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE |
| 411 | #if !MICROPY_EMIT_MACHINE_CODE || defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC) |
| 412 | #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (0) |
| 413 | #else |
| 414 | #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (1) |
| 415 | #endif |
| 416 | #endif |
| 417 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 418 | /*****************************************************************************/ |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 419 | /* Compiler configuration */ |
| 420 | |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 421 | // Whether to include the compiler |
| 422 | #ifndef MICROPY_ENABLE_COMPILER |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 423 | #define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 424 | #endif |
| 425 | |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 426 | // Whether the compiler is dynamically configurable (ie at runtime) |
Damien George | a4f1d82 | 2019-05-29 21:17:29 +1000 | [diff] [blame] | 427 | // This will disable the ability to execute native/viper code |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 428 | #ifndef MICROPY_DYNAMIC_COMPILER |
| 429 | #define MICROPY_DYNAMIC_COMPILER (0) |
| 430 | #endif |
| 431 | |
| 432 | // Configure dynamic compiler macros |
| 433 | #if MICROPY_DYNAMIC_COMPILER |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 434 | #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode) |
| 435 | #else |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 436 | #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE |
| 437 | #endif |
| 438 | |
Damien George | 64f2b21 | 2015-10-08 14:58:15 +0100 | [diff] [blame] | 439 | // Whether to enable constant folding; eg 1+2 rewritten as 3 |
| 440 | #ifndef MICROPY_COMP_CONST_FOLDING |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 441 | #define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 64f2b21 | 2015-10-08 14:58:15 +0100 | [diff] [blame] | 442 | #endif |
| 443 | |
Damien George | 35c0cff | 2022-03-31 14:27:47 +1100 | [diff] [blame] | 444 | // Whether to compile constant tuples immediately to their respective objects; eg (1, True) |
| 445 | // Otherwise the tuple will be built at runtime |
| 446 | #ifndef MICROPY_COMP_CONST_TUPLE |
| 447 | #define MICROPY_COMP_CONST_TUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
| 448 | #endif |
| 449 | |
Damien George | 0779693 | 2019-02-27 00:10:04 +1100 | [diff] [blame] | 450 | // Whether to enable optimisations for constant literals, eg OrderedDict |
| 451 | #ifndef MICROPY_COMP_CONST_LITERAL |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 452 | #define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 0779693 | 2019-02-27 00:10:04 +1100 | [diff] [blame] | 453 | #endif |
| 454 | |
Damien George | ddd1e18 | 2015-01-10 14:07:24 +0000 | [diff] [blame] | 455 | // Whether to enable lookup of constants in modules; eg module.CONST |
| 456 | #ifndef MICROPY_COMP_MODULE_CONST |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 457 | #define MICROPY_COMP_MODULE_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ddd1e18 | 2015-01-10 14:07:24 +0000 | [diff] [blame] | 458 | #endif |
| 459 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 460 | // Whether to enable constant optimisation; id = const(value) |
| 461 | #ifndef MICROPY_COMP_CONST |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 462 | #define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 463 | #endif |
| 464 | |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 465 | // Whether to enable optimisation of: a, b = c, d |
| 466 | // Costs 124 bytes (Thumb2) |
| 467 | #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 468 | #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 469 | #endif |
| 470 | |
| 471 | // Whether to enable optimisation of: a, b, c = d, e, f |
Damien George | 253f2bd | 2018-02-04 13:35:21 +1100 | [diff] [blame] | 472 | // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2) |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 473 | #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 474 | #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 475 | #endif |
| 476 | |
Damien George | ae54fbf | 2017-04-22 14:58:01 +1000 | [diff] [blame] | 477 | // Whether to enable optimisation of: return a if b else c |
| 478 | // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use |
| 479 | #ifndef MICROPY_COMP_RETURN_IF_EXPR |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 480 | #define MICROPY_COMP_RETURN_IF_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ae54fbf | 2017-04-22 14:58:01 +1000 | [diff] [blame] | 481 | #endif |
| 482 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 483 | /*****************************************************************************/ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 484 | /* Internal debugging stuff */ |
| 485 | |
| 486 | // Whether to collect memory allocation stats |
| 487 | #ifndef MICROPY_MEM_STATS |
| 488 | #define MICROPY_MEM_STATS (0) |
| 489 | #endif |
| 490 | |
Damien George | da2d2b6 | 2018-08-02 14:04:44 +1000 | [diff] [blame] | 491 | // The mp_print_t printer used for debugging output |
| 492 | #ifndef MICROPY_DEBUG_PRINTER |
| 493 | #define MICROPY_DEBUG_PRINTER (&mp_plat_print) |
| 494 | #endif |
| 495 | |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 496 | // Whether to build functions that print debugging info: |
Damien George | 3417bc2 | 2014-05-10 10:36:38 +0100 | [diff] [blame] | 497 | // mp_bytecode_print |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 498 | // mp_parse_node_print |
| 499 | #ifndef MICROPY_DEBUG_PRINTERS |
| 500 | #define MICROPY_DEBUG_PRINTERS (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 501 | #endif |
| 502 | |
Stefan Naumann | ace9fb5 | 2017-07-24 18:55:14 +0200 | [diff] [blame] | 503 | // Whether to enable all debugging outputs (it will be extremely verbose) |
| 504 | #ifndef MICROPY_DEBUG_VERBOSE |
| 505 | #define MICROPY_DEBUG_VERBOSE (0) |
| 506 | #endif |
| 507 | |
Damien George | 02cc288 | 2019-03-08 15:48:20 +1100 | [diff] [blame] | 508 | // Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL |
| 509 | #ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS |
| 510 | #define MICROPY_DEBUG_MP_OBJ_SENTINELS (0) |
| 511 | #endif |
| 512 | |
Damien George | 843dcd4 | 2020-09-30 23:34:42 +1000 | [diff] [blame] | 513 | // Whether to print parse rule names (rather than integers) in mp_parse_node_print |
| 514 | #ifndef MICROPY_DEBUG_PARSE_RULE_NAME |
| 515 | #define MICROPY_DEBUG_PARSE_RULE_NAME (0) |
| 516 | #endif |
| 517 | |
Damien George | 6d19934 | 2019-01-04 17:09:41 +1100 | [diff] [blame] | 518 | // Whether to enable a simple VM stack overflow check |
| 519 | #ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW |
| 520 | #define MICROPY_DEBUG_VM_STACK_OVERFLOW (0) |
| 521 | #endif |
| 522 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 523 | /*****************************************************************************/ |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 524 | /* Optimisations */ |
| 525 | |
| 526 | // Whether to use computed gotos in the VM, or a switch |
Jim Mussared | b51e7e9 | 2021-08-19 17:49:33 +1000 | [diff] [blame] | 527 | // Computed gotos are roughly 10% faster, and increase VM code size by a little, |
| 528 | // e.g. ~1kiB on Cortex M4. |
Damien George | 44f0a4d | 2017-09-18 23:53:33 +1000 | [diff] [blame] | 529 | // Note: enabling this will use the gcc-specific extensions of ranged designated |
| 530 | // initialisers and addresses of labels, which are not part of the C99 standard. |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 531 | #ifndef MICROPY_OPT_COMPUTED_GOTO |
| 532 | #define MICROPY_OPT_COMPUTED_GOTO (0) |
| 533 | #endif |
| 534 | |
Jim Mussared | 7b89ad8 | 2021-08-19 22:46:40 +1000 | [diff] [blame] | 535 | // Optimise the fast path for loading attributes from instance types. Increases |
| 536 | // Thumb2 code size by about 48 bytes. |
| 537 | #ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 538 | #define MICROPY_OPT_LOAD_ATTR_FAST_PATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Jim Mussared | 7b89ad8 | 2021-08-19 22:46:40 +1000 | [diff] [blame] | 539 | #endif |
| 540 | |
Jim Mussared | 11ef8f2 | 2021-08-18 14:52:48 +1000 | [diff] [blame] | 541 | // Use extra RAM to cache map lookups by remembering the likely location of |
| 542 | // the index. Avoids the hash computation on unordered maps, and avoids the |
| 543 | // linear search on ordered (especially in-ROM) maps. Can provide a +10-15% |
| 544 | // performance improvement on benchmarks involving lots of attribute access |
| 545 | // or dictionary lookup. |
| 546 | #ifndef MICROPY_OPT_MAP_LOOKUP_CACHE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 547 | #define MICROPY_OPT_MAP_LOOKUP_CACHE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Jim Mussared | 11ef8f2 | 2021-08-18 14:52:48 +1000 | [diff] [blame] | 548 | #endif |
| 549 | |
| 550 | // How much RAM (in bytes) to use for the map lookup cache. |
| 551 | #ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE |
| 552 | #define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128) |
| 553 | #endif |
| 554 | |
Doug Currie | 2e2e15c | 2016-01-30 22:35:58 -0500 | [diff] [blame] | 555 | // Whether to use fast versions of bitwise operations (and, or, xor) when the |
| 556 | // arguments are both positive. Increases Thumb2 code size by about 250 bytes. |
| 557 | #ifndef MICROPY_OPT_MPZ_BITWISE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 558 | #define MICROPY_OPT_MPZ_BITWISE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Doug Currie | 2e2e15c | 2016-01-30 22:35:58 -0500 | [diff] [blame] | 559 | #endif |
| 560 | |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 561 | |
| 562 | // Whether math.factorial is large, fast and recursive (1) or small and slow (0). |
| 563 | #ifndef MICROPY_OPT_MATH_FACTORIAL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 564 | #define MICROPY_OPT_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 565 | #endif |
| 566 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 567 | /*****************************************************************************/ |
| 568 | /* Python internal features */ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 569 | |
Damien George | 2099368 | 2018-02-20 18:00:44 +1100 | [diff] [blame] | 570 | // Whether to enable import of external modules |
| 571 | // When disabled, only importing of built-in modules is supported |
| 572 | // When enabled, a port must implement mp_import_stat (among other things) |
| 573 | #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 574 | #define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 2099368 | 2018-02-20 18:00:44 +1100 | [diff] [blame] | 575 | #endif |
| 576 | |
Damien George | 6b239c2 | 2016-11-16 16:04:57 +1100 | [diff] [blame] | 577 | // Whether to use the POSIX reader for importing files |
| 578 | #ifndef MICROPY_READER_POSIX |
| 579 | #define MICROPY_READER_POSIX (0) |
| 580 | #endif |
| 581 | |
Damien George | dcb9ea7 | 2017-01-27 15:10:09 +1100 | [diff] [blame] | 582 | // Whether to use the VFS reader for importing files |
| 583 | #ifndef MICROPY_READER_VFS |
| 584 | #define MICROPY_READER_VFS (0) |
| 585 | #endif |
| 586 | |
Sean Burton | e33bc59 | 2018-12-13 12:10:35 +0000 | [diff] [blame] | 587 | // Whether any readers have been defined |
| 588 | #ifndef MICROPY_HAS_FILE_READER |
| 589 | #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS) |
| 590 | #endif |
| 591 | |
Damien George | 40d8430 | 2016-02-15 22:46:21 +0000 | [diff] [blame] | 592 | // Hook for the VM at the start of the opcode loop (can contain variable |
| 593 | // definitions usable by the other hook functions) |
| 594 | #ifndef MICROPY_VM_HOOK_INIT |
| 595 | #define MICROPY_VM_HOOK_INIT |
| 596 | #endif |
| 597 | |
| 598 | // Hook for the VM during the opcode loop (but only after jump opcodes) |
| 599 | #ifndef MICROPY_VM_HOOK_LOOP |
| 600 | #define MICROPY_VM_HOOK_LOOP |
| 601 | #endif |
| 602 | |
| 603 | // Hook for the VM just before return opcode is finished being interpreted |
| 604 | #ifndef MICROPY_VM_HOOK_RETURN |
| 605 | #define MICROPY_VM_HOOK_RETURN |
| 606 | #endif |
| 607 | |
Damien George | 916c3fd | 2021-04-25 22:24:49 +1000 | [diff] [blame] | 608 | // Hook for mp_sched_schedule when a function gets scheduled on sched_queue |
| 609 | // (this macro executes within an atomic section) |
| 610 | #ifndef MICROPY_SCHED_HOOK_SCHEDULED |
| 611 | #define MICROPY_SCHED_HOOK_SCHEDULED |
| 612 | #endif |
| 613 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 614 | // Whether to include the garbage collector |
| 615 | #ifndef MICROPY_ENABLE_GC |
| 616 | #define MICROPY_ENABLE_GC (0) |
| 617 | #endif |
| 618 | |
Laurens Valk | fe12048 | 2021-10-26 10:47:04 +0200 | [diff] [blame] | 619 | // Hook to run code during time consuming garbage collector operations |
| 620 | #ifndef MICROPY_GC_HOOK_LOOP |
| 621 | #define MICROPY_GC_HOOK_LOOP |
| 622 | #endif |
| 623 | |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 624 | // Whether to enable finalisers in the garbage collector (ie call __del__) |
Damien George | 7860c2a | 2014-11-05 21:16:41 +0000 | [diff] [blame] | 625 | #ifndef MICROPY_ENABLE_FINALISER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 626 | #define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 627 | #endif |
| 628 | |
Damien George | 02d830c | 2017-11-26 23:28:40 +1100 | [diff] [blame] | 629 | // Whether to enable a separate allocator for the Python stack. |
| 630 | // If enabled then the code must call mp_pystack_init before mp_init. |
| 631 | #ifndef MICROPY_ENABLE_PYSTACK |
| 632 | #define MICROPY_ENABLE_PYSTACK (0) |
| 633 | #endif |
| 634 | |
| 635 | // Number of bytes that memory returned by mp_pystack_alloc will be aligned by. |
| 636 | #ifndef MICROPY_PYSTACK_ALIGN |
| 637 | #define MICROPY_PYSTACK_ALIGN (8) |
| 638 | #endif |
| 639 | |
Paul Sokolovsky | 2366869 | 2014-06-25 03:03:34 +0300 | [diff] [blame] | 640 | // Whether to check C stack usage. C stack used for calling Python functions, |
| 641 | // etc. Not checking means segfault on overflow. |
| 642 | #ifndef MICROPY_STACK_CHECK |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 643 | #define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 2366869 | 2014-06-25 03:03:34 +0300 | [diff] [blame] | 644 | #endif |
| 645 | |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 646 | // Whether to have an emergency exception buffer |
| 647 | #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
| 648 | #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) |
| 649 | #endif |
| 650 | #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 651 | #ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE |
| 652 | #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation |
| 653 | #endif |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 654 | #endif |
| 655 | |
Damien George | bbb4b98 | 2017-04-10 17:19:36 +1000 | [diff] [blame] | 656 | // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function |
Damien George | 7f1da0a | 2016-12-15 13:00:19 +1100 | [diff] [blame] | 657 | #ifndef MICROPY_KBD_EXCEPTION |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 658 | #define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 7f1da0a | 2016-12-15 13:00:19 +1100 | [diff] [blame] | 659 | #endif |
| 660 | |
Paul Sokolovsky | 1c9210b | 2015-12-23 00:06:37 +0200 | [diff] [blame] | 661 | // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt |
| 662 | // handler) - if supported by a particular port. |
| 663 | #ifndef MICROPY_ASYNC_KBD_INTR |
| 664 | #define MICROPY_ASYNC_KBD_INTR (0) |
| 665 | #endif |
| 666 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 667 | // Whether to include REPL helper function |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 668 | #ifndef MICROPY_HELPER_REPL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 669 | #define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 670 | #endif |
| 671 | |
Yonatan Goldschmidt | 61d2b40 | 2019-12-25 09:27:38 +0200 | [diff] [blame] | 672 | // Allow enabling debug prints after each REPL line |
| 673 | #ifndef MICROPY_REPL_INFO |
Damien George | c62351f | 2021-11-01 15:18:22 +1100 | [diff] [blame] | 674 | #define MICROPY_REPL_INFO (0) |
Yonatan Goldschmidt | 61d2b40 | 2019-12-25 09:27:38 +0200 | [diff] [blame] | 675 | #endif |
| 676 | |
Tom Soulanille | 7d588b0 | 2015-07-09 16:32:36 -0700 | [diff] [blame] | 677 | // Whether to include emacs-style readline behavior in REPL |
| 678 | #ifndef MICROPY_REPL_EMACS_KEYS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 679 | #define MICROPY_REPL_EMACS_KEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Tom Soulanille | 7d588b0 | 2015-07-09 16:32:36 -0700 | [diff] [blame] | 680 | #endif |
| 681 | |
Yonatan Goldschmidt | 853aaa0 | 2019-12-14 23:42:03 +0200 | [diff] [blame] | 682 | // Whether to include emacs-style word movement/kill readline behavior in REPL. |
| 683 | // This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word |
| 684 | // and backward-kill-word, respectively. |
| 685 | #ifndef MICROPY_REPL_EMACS_WORDS_MOVE |
| 686 | #define MICROPY_REPL_EMACS_WORDS_MOVE (0) |
| 687 | #endif |
| 688 | |
| 689 | // Whether to include extra convenience keys for word movement/kill in readline REPL. |
| 690 | // This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word |
| 691 | // respectively. Ctrl+Delete is not implemented because it's a very different escape sequence. |
| 692 | // Depends on MICROPY_REPL_EMACS_WORDS_MOVE. |
| 693 | #ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE |
| 694 | #define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (0) |
| 695 | #endif |
| 696 | |
Damien George | 0af7301 | 2015-08-20 10:34:16 +0100 | [diff] [blame] | 697 | // Whether to implement auto-indent in REPL |
| 698 | #ifndef MICROPY_REPL_AUTO_INDENT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 699 | #define MICROPY_REPL_AUTO_INDENT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 0af7301 | 2015-08-20 10:34:16 +0100 | [diff] [blame] | 700 | #endif |
| 701 | |
Paul Sokolovsky | 87bc8e2 | 2015-01-15 10:46:27 +0200 | [diff] [blame] | 702 | // Whether port requires event-driven REPL functions |
| 703 | #ifndef MICROPY_REPL_EVENT_DRIVEN |
| 704 | #define MICROPY_REPL_EVENT_DRIVEN (0) |
| 705 | #endif |
| 706 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 707 | // Whether to include lexer helper function for unix |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 708 | #ifndef MICROPY_HELPER_LEXER_UNIX |
| 709 | #define MICROPY_HELPER_LEXER_UNIX (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 710 | #endif |
| 711 | |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 712 | // Long int implementation |
| 713 | #define MICROPY_LONGINT_IMPL_NONE (0) |
| 714 | #define MICROPY_LONGINT_IMPL_LONGLONG (1) |
Damien George | 438c88d | 2014-02-22 19:25:23 +0000 | [diff] [blame] | 715 | #define MICROPY_LONGINT_IMPL_MPZ (2) |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 716 | |
| 717 | #ifndef MICROPY_LONGINT_IMPL |
| 718 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) |
| 719 | #endif |
| 720 | |
| 721 | #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |
| 722 | typedef long long mp_longint_impl_t; |
| 723 | #endif |
| 724 | |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 725 | // Whether to include information in the byte code to determine source |
| 726 | // line number (increases RAM usage, but doesn't slow byte code execution) |
| 727 | #ifndef MICROPY_ENABLE_SOURCE_LINE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 728 | #define MICROPY_ENABLE_SOURCE_LINE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 729 | #endif |
| 730 | |
Damien George | 1463c1f | 2014-04-25 23:52:57 +0100 | [diff] [blame] | 731 | // Whether to include doc strings (increases RAM usage) |
| 732 | #ifndef MICROPY_ENABLE_DOC_STRING |
| 733 | #define MICROPY_ENABLE_DOC_STRING (0) |
| 734 | #endif |
| 735 | |
Damien George | d4b706c | 2021-04-22 12:13:58 +1000 | [diff] [blame] | 736 | // Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION) |
| 737 | #define MICROPY_ERROR_REPORTING_NONE (0) |
Damien George | 1e9a92f | 2014-11-06 17:36:16 +0000 | [diff] [blame] | 738 | // Exception messages are short static strings |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 739 | #define MICROPY_ERROR_REPORTING_TERSE (1) |
| 740 | // Exception messages provide basic error details |
| 741 | #define MICROPY_ERROR_REPORTING_NORMAL (2) |
| 742 | // Exception messages provide full info, e.g. object names |
| 743 | #define MICROPY_ERROR_REPORTING_DETAILED (3) |
| 744 | |
| 745 | #ifndef MICROPY_ERROR_REPORTING |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 746 | #if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES |
| 747 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) |
| 748 | #elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 749 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 750 | #else |
| 751 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) |
| 752 | #endif |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 753 | #endif |
| 754 | |
Paul Sokolovsky | 8a8c1fc | 2015-01-01 09:29:28 +0200 | [diff] [blame] | 755 | // Whether issue warnings during compiling/execution |
| 756 | #ifndef MICROPY_WARNINGS |
| 757 | #define MICROPY_WARNINGS (0) |
| 758 | #endif |
| 759 | |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 760 | // Whether to support warning categories |
| 761 | #ifndef MICROPY_WARNINGS_CATEGORY |
| 762 | #define MICROPY_WARNINGS_CATEGORY (0) |
| 763 | #endif |
| 764 | |
David Lechner | 62849b7 | 2017-09-24 20:15:48 -0500 | [diff] [blame] | 765 | // This macro is used when printing runtime warnings and errors |
| 766 | #ifndef MICROPY_ERROR_PRINTER |
| 767 | #define MICROPY_ERROR_PRINTER (&mp_plat_print) |
| 768 | #endif |
| 769 | |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 770 | // Float and complex implementation |
| 771 | #define MICROPY_FLOAT_IMPL_NONE (0) |
| 772 | #define MICROPY_FLOAT_IMPL_FLOAT (1) |
| 773 | #define MICROPY_FLOAT_IMPL_DOUBLE (2) |
| 774 | |
| 775 | #ifndef MICROPY_FLOAT_IMPL |
| 776 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) |
| 777 | #endif |
| 778 | |
| 779 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 780 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
Damien George | 561844f | 2016-11-03 12:33:01 +1100 | [diff] [blame] | 781 | #define MICROPY_FLOAT_CONST(x) x##F |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 782 | #define MICROPY_FLOAT_C_FUN(fun) fun##f |
| 783 | typedef float mp_float_t; |
| 784 | #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 785 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
Damien George | 561844f | 2016-11-03 12:33:01 +1100 | [diff] [blame] | 786 | #define MICROPY_FLOAT_CONST(x) x |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 787 | #define MICROPY_FLOAT_C_FUN(fun) fun |
| 788 | typedef double mp_float_t; |
| 789 | #else |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 790 | #define MICROPY_PY_BUILTINS_FLOAT (0) |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 791 | #endif |
| 792 | |
Paul Sokolovsky | 3b6f7b9 | 2014-06-20 01:48:35 +0300 | [diff] [blame] | 793 | #ifndef MICROPY_PY_BUILTINS_COMPLEX |
| 794 | #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) |
| 795 | #endif |
| 796 | |
Damien George | a73501b | 2017-04-06 17:27:33 +1000 | [diff] [blame] | 797 | // Whether to provide a high-quality hash for float and complex numbers. |
| 798 | // Otherwise the default is a very simple but correct hashing function. |
| 799 | #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH |
| 800 | #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0) |
| 801 | #endif |
| 802 | |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 803 | // Enable features which improve CPython compatibility |
| 804 | // but may lead to more code size/memory usage. |
| 805 | // TODO: Originally intended as generic category to not |
| 806 | // add bunch of once-off options. May need refactoring later |
| 807 | #ifndef MICROPY_CPYTHON_COMPAT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 808 | #define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 809 | #endif |
| 810 | |
Paul Sokolovsky | 9a97397 | 2017-04-02 21:20:07 +0300 | [diff] [blame] | 811 | // Perform full checks as done by CPython. Disabling this |
| 812 | // may produce incorrect results, if incorrect data is fed, |
| 813 | // but should not lead to MicroPython crashes or similar |
| 814 | // grave issues (in other words, only user app should be, |
| 815 | // affected, not system). |
| 816 | #ifndef MICROPY_FULL_CHECKS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 817 | #define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 9a97397 | 2017-04-02 21:20:07 +0300 | [diff] [blame] | 818 | #endif |
| 819 | |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 820 | // Whether POSIX-semantics non-blocking streams are supported |
| 821 | #ifndef MICROPY_STREAMS_NON_BLOCK |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 822 | #define MICROPY_STREAMS_NON_BLOCK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 823 | #endif |
| 824 | |
Paul Sokolovsky | 61e77a4 | 2016-07-30 20:05:56 +0300 | [diff] [blame] | 825 | // Whether to provide stream functions with POSIX-like signatures |
| 826 | // (useful for porting existing libraries to MicroPython). |
| 827 | #ifndef MICROPY_STREAMS_POSIX_API |
| 828 | #define MICROPY_STREAMS_POSIX_API (0) |
| 829 | #endif |
| 830 | |
Damien George | 3356b5e | 2021-07-27 00:38:21 +1000 | [diff] [blame] | 831 | // Whether modules can use MP_MODULE_ATTR_DELEGATION_ENTRY() to delegate failed |
| 832 | // attribute lookups. |
| 833 | #ifndef MICROPY_MODULE_ATTR_DELEGATION |
| 834 | #define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 835 | #endif |
| 836 | |
Damien George | 3c9c368 | 2015-09-15 14:56:13 +0100 | [diff] [blame] | 837 | // Whether to call __init__ when importing builtin modules for the first time |
| 838 | #ifndef MICROPY_MODULE_BUILTIN_INIT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 839 | #define MICROPY_MODULE_BUILTIN_INIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 3c9c368 | 2015-09-15 14:56:13 +0100 | [diff] [blame] | 840 | #endif |
| 841 | |
Paul m. p. P | 454cca6 | 2018-10-22 18:34:29 +0200 | [diff] [blame] | 842 | // Whether to support module-level __getattr__ (see PEP 562) |
| 843 | #ifndef MICROPY_MODULE_GETATTR |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 844 | #define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul m. p. P | 454cca6 | 2018-10-22 18:34:29 +0200 | [diff] [blame] | 845 | #endif |
| 846 | |
Damien George | c14a816 | 2014-10-12 11:46:04 +0100 | [diff] [blame] | 847 | // Whether module weak links are supported |
| 848 | #ifndef MICROPY_MODULE_WEAK_LINKS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 849 | #define MICROPY_MODULE_WEAK_LINKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | c14a816 | 2014-10-12 11:46:04 +0100 | [diff] [blame] | 850 | #endif |
| 851 | |
Jim Mussared | a7fa18c | 2020-02-26 15:24:09 +1100 | [diff] [blame] | 852 | // Whether to enable importing foo.py with __name__ set to '__main__' |
| 853 | // Used by the unix port for the -m flag. |
| 854 | #ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT |
| 855 | #define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0) |
| 856 | #endif |
| 857 | |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 858 | // Whether frozen modules are supported in the form of strings |
| 859 | #ifndef MICROPY_MODULE_FROZEN_STR |
| 860 | #define MICROPY_MODULE_FROZEN_STR (0) |
| 861 | #endif |
| 862 | |
| 863 | // Whether frozen modules are supported in the form of .mpy files |
| 864 | #ifndef MICROPY_MODULE_FROZEN_MPY |
| 865 | #define MICROPY_MODULE_FROZEN_MPY (0) |
| 866 | #endif |
| 867 | |
| 868 | // Convenience macro for whether frozen modules are supported |
Paul Sokolovsky | 640e0b2 | 2015-01-20 11:52:12 +0200 | [diff] [blame] | 869 | #ifndef MICROPY_MODULE_FROZEN |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 870 | #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY) |
Paul Sokolovsky | 640e0b2 | 2015-01-20 11:52:12 +0200 | [diff] [blame] | 871 | #endif |
| 872 | |
Damien George | 78d702c | 2014-12-09 16:19:48 +0000 | [diff] [blame] | 873 | // Whether you can override builtins in the builtins module |
| 874 | #ifndef MICROPY_CAN_OVERRIDE_BUILTINS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 875 | #define MICROPY_CAN_OVERRIDE_BUILTINS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 78d702c | 2014-12-09 16:19:48 +0000 | [diff] [blame] | 876 | #endif |
| 877 | |
Damien George | 06593fb | 2015-06-19 12:49:10 +0000 | [diff] [blame] | 878 | // Whether to check that the "self" argument of a builtin method has the |
| 879 | // correct type. Such an explicit check is only needed if a builtin |
| 880 | // method escapes to Python land without a first argument, eg |
| 881 | // list.append([], 1). Without this check such calls will have undefined |
| 882 | // behaviour (usually segfault) if the first argument is the wrong type. |
| 883 | #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 884 | #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 06593fb | 2015-06-19 12:49:10 +0000 | [diff] [blame] | 885 | #endif |
| 886 | |
Damien George | 3f56fd6 | 2016-05-10 10:54:06 +0100 | [diff] [blame] | 887 | // Whether to use internally defined errno's (otherwise system provided ones) |
| 888 | #ifndef MICROPY_USE_INTERNAL_ERRNO |
| 889 | #define MICROPY_USE_INTERNAL_ERRNO (0) |
| 890 | #endif |
| 891 | |
Delio Brignoli | e2ac8bb | 2016-08-21 11:33:37 +0200 | [diff] [blame] | 892 | // Whether to use internally defined *printf() functions (otherwise external ones) |
| 893 | #ifndef MICROPY_USE_INTERNAL_PRINTF |
| 894 | #define MICROPY_USE_INTERNAL_PRINTF (1) |
| 895 | #endif |
| 896 | |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 897 | // Support for internal scheduler |
| 898 | #ifndef MICROPY_ENABLE_SCHEDULER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 899 | #define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 900 | #endif |
| 901 | |
Damien George | 75506e4 | 2022-03-23 17:13:03 +1100 | [diff] [blame] | 902 | // Whether the scheduler supports scheduling static nodes with C callbacks |
| 903 | #ifndef MICROPY_SCHEDULER_STATIC_NODES |
| 904 | #define MICROPY_SCHEDULER_STATIC_NODES (0) |
| 905 | #endif |
| 906 | |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 907 | // Maximum number of entries in the scheduler |
| 908 | #ifndef MICROPY_SCHEDULER_DEPTH |
| 909 | #define MICROPY_SCHEDULER_DEPTH (4) |
| 910 | #endif |
| 911 | |
Damien George | dcb9ea7 | 2017-01-27 15:10:09 +1100 | [diff] [blame] | 912 | // Support for generic VFS sub-system |
| 913 | #ifndef MICROPY_VFS |
| 914 | #define MICROPY_VFS (0) |
| 915 | #endif |
| 916 | |
Damien George | 8d82b0e | 2018-06-06 13:11:33 +1000 | [diff] [blame] | 917 | // Support for VFS POSIX component, to mount a POSIX filesystem within VFS |
| 918 | #ifndef MICROPY_VFS |
| 919 | #define MICROPY_VFS_POSIX (0) |
| 920 | #endif |
| 921 | |
Damien George | a8b9e71 | 2018-06-06 14:31:29 +1000 | [diff] [blame] | 922 | // Support for VFS FAT component, to mount a FAT filesystem within VFS |
| 923 | #ifndef MICROPY_VFS |
| 924 | #define MICROPY_VFS_FAT (0) |
| 925 | #endif |
| 926 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 927 | /*****************************************************************************/ |
| 928 | /* Fine control over Python builtins, classes, modules, etc */ |
| 929 | |
Damien George | da154fd | 2017-04-01 23:52:24 +1100 | [diff] [blame] | 930 | // Whether to support multiple inheritance of Python classes. Multiple |
| 931 | // inheritance makes some C functions inherently recursive, and adds a bit of |
| 932 | // code overhead. |
| 933 | #ifndef MICROPY_MULTIPLE_INHERITANCE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 934 | #define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | da154fd | 2017-04-01 23:52:24 +1100 | [diff] [blame] | 935 | #endif |
| 936 | |
stijn | 3cc17c6 | 2015-02-14 18:44:31 +0100 | [diff] [blame] | 937 | // Whether to implement attributes on functions |
| 938 | #ifndef MICROPY_PY_FUNCTION_ATTRS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 939 | #define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | 3cc17c6 | 2015-02-14 18:44:31 +0100 | [diff] [blame] | 940 | #endif |
| 941 | |
Damien George | 36c1052 | 2018-05-25 17:09:54 +1000 | [diff] [blame] | 942 | // Whether to support the descriptors __get__, __set__, __delete__ |
| 943 | // This costs some code size and makes load/store/delete of instance |
| 944 | // attributes slower for the classes that use this feature |
stijn | 28fa84b | 2015-02-14 18:43:54 +0100 | [diff] [blame] | 945 | #ifndef MICROPY_PY_DESCRIPTORS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 946 | #define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | 28fa84b | 2015-02-14 18:43:54 +0100 | [diff] [blame] | 947 | #endif |
| 948 | |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 949 | // Whether to support class __delattr__ and __setattr__ methods |
Damien George | 36c1052 | 2018-05-25 17:09:54 +1000 | [diff] [blame] | 950 | // This costs some code size and makes store/delete of instance |
| 951 | // attributes slower for the classes that use this feature |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 952 | #ifndef MICROPY_PY_DELATTR_SETATTR |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 953 | #define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 954 | #endif |
| 955 | |
pohmelie | 81ebba7 | 2016-01-27 23:23:11 +0300 | [diff] [blame] | 956 | // Support for async/await/async for/async with |
| 957 | #ifndef MICROPY_PY_ASYNC_AWAIT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 958 | #define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
pohmelie | 81ebba7 | 2016-01-27 23:23:11 +0300 | [diff] [blame] | 959 | #endif |
| 960 | |
Jim Mussared | 692d36d | 2021-08-13 01:44:08 +1000 | [diff] [blame] | 961 | // Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+) |
| 962 | #ifndef MICROPY_PY_FSTRINGS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 963 | #define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Jim Mussared | 692d36d | 2021-08-13 01:44:08 +1000 | [diff] [blame] | 964 | #endif |
| 965 | |
Damien George | 1783950 | 2020-06-16 21:42:44 +1000 | [diff] [blame] | 966 | // Support for assignment expressions with := (see PEP 572, Python 3.8+) |
| 967 | #ifndef MICROPY_PY_ASSIGN_EXPR |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 968 | #define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 1783950 | 2020-06-16 21:42:44 +1000 | [diff] [blame] | 969 | #endif |
| 970 | |
Paul Sokolovsky | 6364401 | 2017-10-21 12:13:44 +0300 | [diff] [blame] | 971 | // Non-standard .pend_throw() method for generators, allowing for |
| 972 | // Future-like behavior with respect to exception handling: an |
| 973 | // exception set with .pend_throw() will activate on the next call |
| 974 | // to generator's .send() or .__next__(). (This is useful to implement |
| 975 | // async schedulers.) |
| 976 | #ifndef MICROPY_PY_GENERATOR_PEND_THROW |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 977 | #define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 6364401 | 2017-10-21 12:13:44 +0300 | [diff] [blame] | 978 | #endif |
| 979 | |
Paul Sokolovsky | a1b442b | 2016-07-22 00:46:24 +0300 | [diff] [blame] | 980 | // Issue a warning when comparing str and bytes objects |
Paul Sokolovsky | 707cae7 | 2016-07-22 00:34:34 +0300 | [diff] [blame] | 981 | #ifndef MICROPY_PY_STR_BYTES_CMP_WARN |
| 982 | #define MICROPY_PY_STR_BYTES_CMP_WARN (0) |
| 983 | #endif |
| 984 | |
Paul Sokolovsky | 12bc13e | 2014-06-13 01:05:19 +0300 | [diff] [blame] | 985 | // Whether str object is proper unicode |
| 986 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 987 | #define MICROPY_PY_BUILTINS_STR_UNICODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 8546ce1 | 2014-06-28 10:29:22 +0100 | [diff] [blame] | 988 | #endif |
Damien George | b3a50f0 | 2014-06-28 10:27:15 +0100 | [diff] [blame] | 989 | |
tll | 68c2817 | 2017-06-24 08:38:32 +0800 | [diff] [blame] | 990 | // Whether to check for valid UTF-8 when converting bytes to str |
| 991 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK |
| 992 | #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE) |
| 993 | #endif |
| 994 | |
Paul Sokolovsky | 1b5abfc | 2016-05-22 00:13:44 +0300 | [diff] [blame] | 995 | // Whether str.center() method provided |
| 996 | #ifndef MICROPY_PY_BUILTINS_STR_CENTER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 997 | #define MICROPY_PY_BUILTINS_STR_CENTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 1b5abfc | 2016-05-22 00:13:44 +0300 | [diff] [blame] | 998 | #endif |
| 999 | |
Paul Sokolovsky | 5a91fce | 2018-08-05 23:56:19 +0300 | [diff] [blame] | 1000 | // Whether str.count() method provided |
| 1001 | #ifndef MICROPY_PY_BUILTINS_STR_COUNT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1002 | #define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 5a91fce | 2018-08-05 23:56:19 +0300 | [diff] [blame] | 1003 | #endif |
| 1004 | |
Paul Sokolovsky | 2da5d41 | 2018-08-15 15:17:41 +0300 | [diff] [blame] | 1005 | // Whether str % (...) formatting operator provided |
| 1006 | #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1007 | #define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 2da5d41 | 2018-08-15 15:17:41 +0300 | [diff] [blame] | 1008 | #endif |
| 1009 | |
Paul Sokolovsky | 56eb25f | 2016-08-07 06:46:55 +0300 | [diff] [blame] | 1010 | // Whether str.partition()/str.rpartition() method provided |
| 1011 | #ifndef MICROPY_PY_BUILTINS_STR_PARTITION |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1012 | #define MICROPY_PY_BUILTINS_STR_PARTITION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 56eb25f | 2016-08-07 06:46:55 +0300 | [diff] [blame] | 1013 | #endif |
| 1014 | |
Paul Sokolovsky | ac2f7a7 | 2015-04-04 00:09:23 +0300 | [diff] [blame] | 1015 | // Whether str.splitlines() method provided |
| 1016 | #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1017 | #define MICROPY_PY_BUILTINS_STR_SPLITLINES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | ac2f7a7 | 2015-04-04 00:09:23 +0300 | [diff] [blame] | 1018 | #endif |
| 1019 | |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1020 | // Whether to support bytearray object |
| 1021 | #ifndef MICROPY_PY_BUILTINS_BYTEARRAY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1022 | #define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 12bc13e | 2014-06-13 01:05:19 +0300 | [diff] [blame] | 1023 | #endif |
| 1024 | |
Paul Sokolovsky | fbb8335 | 2018-08-06 01:25:41 +0300 | [diff] [blame] | 1025 | // Whether to support dict.fromkeys() class method |
| 1026 | #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1027 | #define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | fbb8335 | 2018-08-06 01:25:41 +0300 | [diff] [blame] | 1028 | #endif |
| 1029 | |
Damien George | dd4f453 | 2014-10-23 13:34:35 +0100 | [diff] [blame] | 1030 | // Whether to support memoryview object |
| 1031 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1032 | #define MICROPY_PY_BUILTINS_MEMORYVIEW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | dd4f453 | 2014-10-23 13:34:35 +0100 | [diff] [blame] | 1033 | #endif |
| 1034 | |
stijn | 90fae91 | 2019-05-08 16:16:17 +0200 | [diff] [blame] | 1035 | // Whether to support memoryview.itemsize attribute |
| 1036 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE |
| 1037 | #define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0) |
| 1038 | #endif |
| 1039 | |
Damien George | 3ebd4d0 | 2014-06-01 13:46:47 +0100 | [diff] [blame] | 1040 | // Whether to support set object |
| 1041 | #ifndef MICROPY_PY_BUILTINS_SET |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1042 | #define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 3ebd4d0 | 2014-06-01 13:46:47 +0100 | [diff] [blame] | 1043 | #endif |
| 1044 | |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1045 | // Whether to support slice subscript operators and slice object |
| 1046 | #ifndef MICROPY_PY_BUILTINS_SLICE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1047 | #define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1048 | #endif |
| 1049 | |
Tom Soulanille | aeb62f9 | 2015-09-11 14:31:32 -0700 | [diff] [blame] | 1050 | // Whether to support slice attribute read access, |
| 1051 | // i.e. slice.start, slice.stop, slice.step |
| 1052 | #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1053 | #define MICROPY_PY_BUILTINS_SLICE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Tom Soulanille | aeb62f9 | 2015-09-11 14:31:32 -0700 | [diff] [blame] | 1054 | #endif |
| 1055 | |
Nicko van Someren | 4c93955 | 2019-11-16 17:07:11 -0700 | [diff] [blame] | 1056 | // Whether to support the .indices(len) method on slice objects |
| 1057 | #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1058 | #define MICROPY_PY_BUILTINS_SLICE_INDICES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Nicko van Someren | 4c93955 | 2019-11-16 17:07:11 -0700 | [diff] [blame] | 1059 | #endif |
| 1060 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1061 | // Whether to support frozenset object |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1062 | #ifndef MICROPY_PY_BUILTINS_FROZENSET |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1063 | #define MICROPY_PY_BUILTINS_FROZENSET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1064 | #endif |
| 1065 | |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1066 | // Whether to support property object |
| 1067 | #ifndef MICROPY_PY_BUILTINS_PROPERTY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1068 | #define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1069 | #endif |
| 1070 | |
Peter D. Gray | b2a237d | 2015-03-06 14:48:14 -0500 | [diff] [blame] | 1071 | // Whether to implement the start/stop/step attributes (readback) on |
| 1072 | // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). |
| 1073 | #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1074 | #define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Peter D. Gray | b2a237d | 2015-03-06 14:48:14 -0500 | [diff] [blame] | 1075 | #endif |
| 1076 | |
Damien George | d77da83 | 2018-02-14 23:17:06 +1100 | [diff] [blame] | 1077 | // Whether to support binary ops [only (in)equality is defined] between range |
| 1078 | // objects. With this option disabled all range objects that are not exactly |
| 1079 | // the same object will compare as not-equal. With it enabled the semantics |
| 1080 | // match CPython and ranges are equal if they yield the same sequence of items. |
| 1081 | #ifndef MICROPY_PY_BUILTINS_RANGE_BINOP |
| 1082 | #define MICROPY_PY_BUILTINS_RANGE_BINOP (0) |
| 1083 | #endif |
| 1084 | |
stijn | 4286383 | 2019-01-03 15:19:42 +0100 | [diff] [blame] | 1085 | // Support for callling next() with second argument |
| 1086 | #ifndef MICROPY_PY_BUILTINS_NEXT2 |
| 1087 | #define MICROPY_PY_BUILTINS_NEXT2 (0) |
| 1088 | #endif |
| 1089 | |
Jan Klusacek | b318ebf | 2018-01-09 22:47:35 +0100 | [diff] [blame] | 1090 | // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120 |
| 1091 | #ifndef MICROPY_PY_BUILTINS_ROUND_INT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1092 | #define MICROPY_PY_BUILTINS_ROUND_INT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Jan Klusacek | b318ebf | 2018-01-09 22:47:35 +0100 | [diff] [blame] | 1093 | #endif |
| 1094 | |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1095 | // Whether to support complete set of special methods for user |
| 1096 | // classes, or only the most used ones. "Inplace" methods are |
| 1097 | // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below. |
| 1098 | // "Reverse" methods are controlled by |
| 1099 | // MICROPY_PY_REVERSE_SPECIAL_METHODS below. |
Paul Sokolovsky | 98c4bc3 | 2015-01-30 01:42:49 +0200 | [diff] [blame] | 1100 | #ifndef MICROPY_PY_ALL_SPECIAL_METHODS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1101 | #define MICROPY_PY_ALL_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 98c4bc3 | 2015-01-30 01:42:49 +0200 | [diff] [blame] | 1102 | #endif |
| 1103 | |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1104 | // Whether to support all inplace arithmetic operarion methods |
| 1105 | // (__imul__, etc.) |
| 1106 | #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS |
| 1107 | #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0) |
| 1108 | #endif |
| 1109 | |
| 1110 | // Whether to support reverse arithmetic operarion methods |
| 1111 | // (__radd__, etc.). Additionally gated by |
| 1112 | // MICROPY_PY_ALL_SPECIAL_METHODS. |
Paul Sokolovsky | eb84a83 | 2017-09-10 17:05:20 +0300 | [diff] [blame] | 1113 | #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1114 | #define MICROPY_PY_REVERSE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | eb84a83 | 2017-09-10 17:05:20 +0300 | [diff] [blame] | 1115 | #endif |
| 1116 | |
Damien George | c9fc620 | 2014-10-25 21:59:14 +0100 | [diff] [blame] | 1117 | // Whether to support compile function |
| 1118 | #ifndef MICROPY_PY_BUILTINS_COMPILE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1119 | #define MICROPY_PY_BUILTINS_COMPILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | c9fc620 | 2014-10-25 21:59:14 +0100 | [diff] [blame] | 1120 | #endif |
| 1121 | |
Paul Sokolovsky | e2d44e3 | 2015-04-06 23:50:37 +0300 | [diff] [blame] | 1122 | // Whether to support enumerate function(type) |
| 1123 | #ifndef MICROPY_PY_BUILTINS_ENUMERATE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1124 | #define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | e2d44e3 | 2015-04-06 23:50:37 +0300 | [diff] [blame] | 1125 | #endif |
| 1126 | |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 1127 | // Whether to support eval and exec functions |
| 1128 | // By default they are supported if the compiler is enabled |
| 1129 | #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC |
| 1130 | #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER) |
| 1131 | #endif |
| 1132 | |
Damien George | 2a3e2b9 | 2014-12-19 13:36:17 +0000 | [diff] [blame] | 1133 | // Whether to support the Python 2 execfile function |
| 1134 | #ifndef MICROPY_PY_BUILTINS_EXECFILE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1135 | #define MICROPY_PY_BUILTINS_EXECFILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 2a3e2b9 | 2014-12-19 13:36:17 +0000 | [diff] [blame] | 1136 | #endif |
| 1137 | |
Paul Sokolovsky | 22ff397 | 2015-08-20 01:01:56 +0300 | [diff] [blame] | 1138 | // Whether to support filter function(type) |
| 1139 | #ifndef MICROPY_PY_BUILTINS_FILTER |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1140 | #define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 22ff397 | 2015-08-20 01:01:56 +0300 | [diff] [blame] | 1141 | #endif |
| 1142 | |
Paul Sokolovsky | 282ca09 | 2015-04-07 00:16:51 +0300 | [diff] [blame] | 1143 | // Whether to support reversed function(type) |
| 1144 | #ifndef MICROPY_PY_BUILTINS_REVERSED |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1145 | #define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 282ca09 | 2015-04-07 00:16:51 +0300 | [diff] [blame] | 1146 | #endif |
| 1147 | |
Paul Sokolovsky | 5ab5ac5 | 2015-05-04 19:45:53 +0300 | [diff] [blame] | 1148 | // Whether to define "NotImplemented" special constant |
| 1149 | #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1150 | #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 5ab5ac5 | 2015-05-04 19:45:53 +0300 | [diff] [blame] | 1151 | #endif |
| 1152 | |
Damien George | bc76302 | 2017-06-01 15:32:23 +1000 | [diff] [blame] | 1153 | // Whether to provide the built-in input() function. The implementation of this |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 1154 | // uses shared/readline, so can only be enabled if the port uses this readline. |
Damien George | bc76302 | 2017-06-01 15:32:23 +1000 | [diff] [blame] | 1155 | #ifndef MICROPY_PY_BUILTINS_INPUT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1156 | #define MICROPY_PY_BUILTINS_INPUT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | bc76302 | 2017-06-01 15:32:23 +1000 | [diff] [blame] | 1157 | #endif |
| 1158 | |
pohmelie | 354e688 | 2015-12-07 15:35:48 +0300 | [diff] [blame] | 1159 | // Whether to support min/max functions |
| 1160 | #ifndef MICROPY_PY_BUILTINS_MIN_MAX |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1161 | #define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
pohmelie | 354e688 | 2015-12-07 15:35:48 +0300 | [diff] [blame] | 1162 | #endif |
| 1163 | |
Damien George | a19b5a0 | 2017-02-03 12:35:48 +1100 | [diff] [blame] | 1164 | // Support for calls to pow() with 3 integer arguments |
| 1165 | #ifndef MICROPY_PY_BUILTINS_POW3 |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1166 | #define MICROPY_PY_BUILTINS_POW3 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | a19b5a0 | 2017-02-03 12:35:48 +1100 | [diff] [blame] | 1167 | #endif |
| 1168 | |
Damien George | 9f04dfb | 2017-01-21 23:17:51 +1100 | [diff] [blame] | 1169 | // Whether to provide the help function |
| 1170 | #ifndef MICROPY_PY_BUILTINS_HELP |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1171 | #define MICROPY_PY_BUILTINS_HELP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 9f04dfb | 2017-01-21 23:17:51 +1100 | [diff] [blame] | 1172 | #endif |
| 1173 | |
| 1174 | // Use this to configure the help text shown for help(). It should be a |
| 1175 | // variable with the type "const char*". A sensible default is provided. |
| 1176 | #ifndef MICROPY_PY_BUILTINS_HELP_TEXT |
| 1177 | #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text |
| 1178 | #endif |
| 1179 | |
Damien George | f5172af | 2017-01-22 12:12:54 +1100 | [diff] [blame] | 1180 | // Add the ability to list the available modules when executing help('modules') |
| 1181 | #ifndef MICROPY_PY_BUILTINS_HELP_MODULES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1182 | #define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | f5172af | 2017-01-22 12:12:54 +1100 | [diff] [blame] | 1183 | #endif |
| 1184 | |
Paul Sokolovsky | d0f5e61 | 2014-07-25 11:00:15 +0300 | [diff] [blame] | 1185 | // Whether to set __file__ for imported modules |
| 1186 | #ifndef MICROPY_PY___FILE__ |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1187 | #define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | d0f5e61 | 2014-07-25 11:00:15 +0300 | [diff] [blame] | 1188 | #endif |
| 1189 | |
Damien George | 89deec0 | 2015-01-09 20:12:54 +0000 | [diff] [blame] | 1190 | // Whether to provide mem-info related functions in micropython module |
| 1191 | #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1192 | #define MICROPY_PY_MICROPYTHON_MEM_INFO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 89deec0 | 2015-01-09 20:12:54 +0000 | [diff] [blame] | 1193 | #endif |
| 1194 | |
Damien George | 7e2a488 | 2018-02-20 18:30:22 +1100 | [diff] [blame] | 1195 | // Whether to provide "micropython.stack_use" function |
| 1196 | #ifndef MICROPY_PY_MICROPYTHON_STACK_USE |
| 1197 | #define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO) |
| 1198 | #endif |
| 1199 | |
Andrew Leech | 86bfabe | 2019-06-28 16:35:51 +1000 | [diff] [blame] | 1200 | // Whether to provide the "micropython.heap_locked" function |
| 1201 | #ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED |
| 1202 | #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (0) |
| 1203 | #endif |
| 1204 | |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1205 | // Whether to provide "array" module. Note that large chunk of the |
| 1206 | // underlying code is shared with "bytearray" builtin type, so to |
| 1207 | // get real savings, it should be disabled too. |
| 1208 | #ifndef MICROPY_PY_ARRAY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1209 | #define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1210 | #endif |
| 1211 | |
Paul Sokolovsky | cefcbb2 | 2015-02-27 22:16:05 +0200 | [diff] [blame] | 1212 | // Whether to support slice assignments for array (and bytearray). |
| 1213 | // This is rarely used, but adds ~0.5K of code. |
| 1214 | #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1215 | #define MICROPY_PY_ARRAY_SLICE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | cefcbb2 | 2015-02-27 22:16:05 +0200 | [diff] [blame] | 1216 | #endif |
| 1217 | |
Damien George | 5aa311d | 2015-04-21 14:14:24 +0000 | [diff] [blame] | 1218 | // Whether to support attrtuple type (MicroPython extension) |
| 1219 | // It provides space-efficient tuples with attribute access |
| 1220 | #ifndef MICROPY_PY_ATTRTUPLE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1221 | #define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 5aa311d | 2015-04-21 14:14:24 +0000 | [diff] [blame] | 1222 | #endif |
| 1223 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1224 | // Whether to provide "collections" module |
| 1225 | #ifndef MICROPY_PY_COLLECTIONS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1226 | #define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1227 | #endif |
| 1228 | |
Paul Sokolovsky | 970eedc | 2018-02-06 00:06:42 +0200 | [diff] [blame] | 1229 | // Whether to provide "ucollections.deque" type |
| 1230 | #ifndef MICROPY_PY_COLLECTIONS_DEQUE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1231 | #define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 970eedc | 2018-02-06 00:06:42 +0200 | [diff] [blame] | 1232 | #endif |
| 1233 | |
Paul Sokolovsky | 0ef01d0 | 2015-03-18 01:25:04 +0200 | [diff] [blame] | 1234 | // Whether to provide "collections.OrderedDict" type |
| 1235 | #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1236 | #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 0ef01d0 | 2015-03-18 01:25:04 +0200 | [diff] [blame] | 1237 | #endif |
| 1238 | |
stijn | 79ed58f | 2017-11-06 12:21:53 +0100 | [diff] [blame] | 1239 | // Whether to provide the _asdict function for namedtuple |
| 1240 | #ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT |
| 1241 | #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0) |
| 1242 | #endif |
| 1243 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1244 | // Whether to provide "math" module |
| 1245 | #ifndef MICROPY_PY_MATH |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1246 | #define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1247 | #endif |
| 1248 | |
stijn | dd69672 | 2019-11-20 13:38:33 +0100 | [diff] [blame] | 1249 | // Whether to provide all math module constants (Python 3.5+), or just pi and e. |
| 1250 | #ifndef MICROPY_PY_MATH_CONSTANTS |
| 1251 | #define MICROPY_PY_MATH_CONSTANTS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1252 | #endif |
| 1253 | |
Damien George | 5cbeace | 2015-02-22 14:48:18 +0000 | [diff] [blame] | 1254 | // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} |
| 1255 | #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1256 | #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 5cbeace | 2015-02-22 14:48:18 +0000 | [diff] [blame] | 1257 | #endif |
| 1258 | |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 1259 | // Whether to provide math.factorial function |
| 1260 | #ifndef MICROPY_PY_MATH_FACTORIAL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1261 | #define MICROPY_PY_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 1262 | #endif |
| 1263 | |
stijn | af5c998 | 2019-07-02 10:28:44 +0200 | [diff] [blame] | 1264 | // Whether to provide math.isclose function |
| 1265 | #ifndef MICROPY_PY_MATH_ISCLOSE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1266 | #define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | af5c998 | 2019-07-02 10:28:44 +0200 | [diff] [blame] | 1267 | #endif |
| 1268 | |
stijn | 81db22f | 2020-05-17 12:29:25 +0200 | [diff] [blame] | 1269 | // Whether to provide fix for atan2 Inf handling. |
| 1270 | #ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN |
| 1271 | #define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0) |
| 1272 | #endif |
| 1273 | |
| 1274 | // Whether to provide fix for fmod Inf handling. |
| 1275 | #ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN |
| 1276 | #define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0) |
| 1277 | #endif |
| 1278 | |
| 1279 | // Whether to provide fix for modf negative zero handling. |
| 1280 | #ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO |
| 1281 | #define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0) |
| 1282 | #endif |
| 1283 | |
stijn | 2e54d9d | 2020-09-08 15:22:34 +0200 | [diff] [blame] | 1284 | // Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN. |
| 1285 | #ifndef MICROPY_PY_MATH_POW_FIX_NAN |
| 1286 | #define MICROPY_PY_MATH_POW_FIX_NAN (0) |
| 1287 | #endif |
| 1288 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1289 | // Whether to provide "cmath" module |
| 1290 | #ifndef MICROPY_PY_CMATH |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1291 | #define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1292 | #endif |
| 1293 | |
| 1294 | // Whether to provide "gc" module |
| 1295 | #ifndef MICROPY_PY_GC |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1296 | #define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1297 | #endif |
| 1298 | |
Paul Sokolovsky | 755a55f | 2014-06-05 22:48:02 +0300 | [diff] [blame] | 1299 | // Whether to return number of collected objects from gc.collect() |
| 1300 | #ifndef MICROPY_PY_GC_COLLECT_RETVAL |
| 1301 | #define MICROPY_PY_GC_COLLECT_RETVAL (0) |
| 1302 | #endif |
| 1303 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1304 | // Whether to provide "io" module |
| 1305 | #ifndef MICROPY_PY_IO |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1306 | #define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1307 | #endif |
| 1308 | |
Damien George | af0932a | 2018-06-04 15:54:26 +1000 | [diff] [blame] | 1309 | // Whether to provide "io.IOBase" class to support user streams |
| 1310 | #ifndef MICROPY_PY_IO_IOBASE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1311 | #define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | af0932a | 2018-06-04 15:54:26 +1000 | [diff] [blame] | 1312 | #endif |
| 1313 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1314 | // Whether to provide "io.FileIO" class |
| 1315 | #ifndef MICROPY_PY_IO_FILEIO |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1316 | #define MICROPY_PY_IO_FILEIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1317 | #endif |
| 1318 | |
| 1319 | // Whether to provide "io.BytesIO" class |
| 1320 | #ifndef MICROPY_PY_IO_BYTESIO |
| 1321 | #define MICROPY_PY_IO_BYTESIO (1) |
| 1322 | #endif |
| 1323 | |
Paul Sokolovsky | 5d93dfb | 2016-03-25 01:10:49 +0200 | [diff] [blame] | 1324 | // Whether to provide "io.BufferedWriter" class |
| 1325 | #ifndef MICROPY_PY_IO_BUFFEREDWRITER |
| 1326 | #define MICROPY_PY_IO_BUFFEREDWRITER (0) |
| 1327 | #endif |
| 1328 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1329 | // Whether to provide "struct" module |
| 1330 | #ifndef MICROPY_PY_STRUCT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1331 | #define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1332 | #endif |
| 1333 | |
| 1334 | // Whether to provide "sys" module |
| 1335 | #ifndef MICROPY_PY_SYS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1336 | #define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1337 | #endif |
| 1338 | |
Damien George | de43b50 | 2021-12-17 23:35:32 +1100 | [diff] [blame] | 1339 | // Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init() |
| 1340 | #ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS |
Damien George | fe9ffff | 2021-12-19 08:55:40 +1100 | [diff] [blame] | 1341 | #define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS) |
Damien George | de43b50 | 2021-12-17 23:35:32 +1100 | [diff] [blame] | 1342 | #endif |
| 1343 | |
Paul Sokolovsky | 4e0eeeb | 2014-07-03 16:50:11 +0300 | [diff] [blame] | 1344 | // Whether to provide "sys.maxsize" constant |
| 1345 | #ifndef MICROPY_PY_SYS_MAXSIZE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1346 | #define MICROPY_PY_SYS_MAXSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 4e0eeeb | 2014-07-03 16:50:11 +0300 | [diff] [blame] | 1347 | #endif |
| 1348 | |
Paul Sokolovsky | 1a1d11f | 2015-12-05 00:09:10 +0200 | [diff] [blame] | 1349 | // Whether to provide "sys.modules" dictionary |
| 1350 | #ifndef MICROPY_PY_SYS_MODULES |
| 1351 | #define MICROPY_PY_SYS_MODULES (1) |
| 1352 | #endif |
| 1353 | |
Paul Sokolovsky | 8b85d14 | 2015-04-25 03:17:41 +0300 | [diff] [blame] | 1354 | // Whether to provide "sys.exc_info" function |
| 1355 | // Avoid enabling this, this function is Python2 heritage |
| 1356 | #ifndef MICROPY_PY_SYS_EXC_INFO |
| 1357 | #define MICROPY_PY_SYS_EXC_INFO (0) |
| 1358 | #endif |
| 1359 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1360 | // Whether to provide "sys.exit" function |
| 1361 | #ifndef MICROPY_PY_SYS_EXIT |
Paul Sokolovsky | 403c930 | 2016-12-14 21:10:22 +0300 | [diff] [blame] | 1362 | #define MICROPY_PY_SYS_EXIT (1) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1363 | #endif |
| 1364 | |
Milan Rossa | cb36470 | 2019-08-05 15:06:41 +0200 | [diff] [blame] | 1365 | // Whether to provide "sys.atexit" function (MicroPython extension) |
| 1366 | #ifndef MICROPY_PY_SYS_ATEXIT |
| 1367 | #define MICROPY_PY_SYS_ATEXIT (0) |
| 1368 | #endif |
| 1369 | |
Damien George | ac22931 | 2021-07-27 00:43:35 +1000 | [diff] [blame] | 1370 | // Whether to provide sys.{ps1,ps2} mutable attributes, to control REPL prompts |
| 1371 | #ifndef MICROPY_PY_SYS_PS1_PS2 |
| 1372 | #define MICROPY_PY_SYS_PS1_PS2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1373 | #endif |
| 1374 | |
Milan Rossa | 310b3d1 | 2019-08-14 16:09:36 +0200 | [diff] [blame] | 1375 | // Whether to provide "sys.settrace" function |
| 1376 | #ifndef MICROPY_PY_SYS_SETTRACE |
| 1377 | #define MICROPY_PY_SYS_SETTRACE (0) |
| 1378 | #endif |
| 1379 | |
Paul Sokolovsky | bfc2092 | 2017-08-11 09:42:39 +0300 | [diff] [blame] | 1380 | // Whether to provide "sys.getsizeof" function |
| 1381 | #ifndef MICROPY_PY_SYS_GETSIZEOF |
| 1382 | #define MICROPY_PY_SYS_GETSIZEOF (0) |
| 1383 | #endif |
| 1384 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1385 | // Whether to provide sys.{stdin,stdout,stderr} objects |
| 1386 | #ifndef MICROPY_PY_SYS_STDFILES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1387 | #define MICROPY_PY_SYS_STDFILES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 3bb8bd8 | 2014-04-14 21:20:30 +0100 | [diff] [blame] | 1388 | #endif |
| 1389 | |
Damien George | 3c4b5d4 | 2015-05-13 23:49:21 +0100 | [diff] [blame] | 1390 | // Whether to provide sys.{stdin,stdout,stderr}.buffer object |
| 1391 | // This is implemented per-port |
| 1392 | #ifndef MICROPY_PY_SYS_STDIO_BUFFER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1393 | #define MICROPY_PY_SYS_STDIO_BUFFER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 3c4b5d4 | 2015-05-13 23:49:21 +0100 | [diff] [blame] | 1394 | #endif |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1395 | |
Damien George | cac939d | 2021-07-27 00:41:27 +1000 | [diff] [blame] | 1396 | // Whether to provide sys.tracebacklimit mutable attribute |
| 1397 | #ifndef MICROPY_PY_SYS_TRACEBACKLIMIT |
| 1398 | #define MICROPY_PY_SYS_TRACEBACKLIMIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
| 1399 | #endif |
| 1400 | |
Damien George | bc18155 | 2021-07-27 00:39:04 +1000 | [diff] [blame] | 1401 | // Whether the sys module supports attribute delegation |
| 1402 | // This is enabled automatically when needed by other features |
| 1403 | #ifndef MICROPY_PY_SYS_ATTR_DELEGATION |
Damien George | ac22931 | 2021-07-27 00:43:35 +1000 | [diff] [blame] | 1404 | #define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT) |
Damien George | bc18155 | 2021-07-27 00:39:04 +1000 | [diff] [blame] | 1405 | #endif |
| 1406 | |
Damien George | 596a3fe | 2016-05-10 10:54:25 +0100 | [diff] [blame] | 1407 | // Whether to provide "uerrno" module |
| 1408 | #ifndef MICROPY_PY_UERRNO |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1409 | #define MICROPY_PY_UERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 596a3fe | 2016-05-10 10:54:25 +0100 | [diff] [blame] | 1410 | #endif |
| 1411 | |
Damien George | f563406 | 2017-02-22 12:53:42 +1100 | [diff] [blame] | 1412 | // Whether to provide the uerrno.errorcode dict |
| 1413 | #ifndef MICROPY_PY_UERRNO_ERRORCODE |
| 1414 | #define MICROPY_PY_UERRNO_ERRORCODE (1) |
| 1415 | #endif |
| 1416 | |
Paul Sokolovsky | 8f5bc3f | 2016-11-20 23:49:45 +0300 | [diff] [blame] | 1417 | // Whether to provide "uselect" module (baremetal implementation) |
| 1418 | #ifndef MICROPY_PY_USELECT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1419 | #define MICROPY_PY_USELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 8f5bc3f | 2016-11-20 23:49:45 +0300 | [diff] [blame] | 1420 | #endif |
| 1421 | |
David Lechner | 8758504 | 2021-07-06 18:08:18 -0500 | [diff] [blame] | 1422 | // Whether to enable the select() function in the "uselect" module (baremetal |
| 1423 | // implementation). This is present for compatibility but can be disabled to |
| 1424 | // save space. |
| 1425 | #ifndef MICROPY_PY_USELECT_SELECT |
| 1426 | #define MICROPY_PY_USELECT_SELECT (1) |
| 1427 | #endif |
| 1428 | |
Paul Sokolovsky | a972844 | 2016-10-14 20:13:02 +0300 | [diff] [blame] | 1429 | // Whether to provide "utime" module functions implementation |
| 1430 | // in terms of mp_hal_* functions. |
| 1431 | #ifndef MICROPY_PY_UTIME_MP_HAL |
| 1432 | #define MICROPY_PY_UTIME_MP_HAL (0) |
| 1433 | #endif |
| 1434 | |
Paul Sokolovsky | 76146b3 | 2016-10-30 03:02:07 +0300 | [diff] [blame] | 1435 | // Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu() |
| 1436 | // functions. Should be power of two. All functions above use the same |
| 1437 | // period, so if underlying hardware/API has different periods, the |
| 1438 | // minimum of them should be used. The value below is the maximum value |
| 1439 | // this parameter can take (corresponding to 30 bit tick values on 32-bit |
| 1440 | // system). |
| 1441 | #ifndef MICROPY_PY_UTIME_TICKS_PERIOD |
| 1442 | #define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1) |
| 1443 | #endif |
| 1444 | |
Damien George | 27cc077 | 2016-04-22 22:52:33 +0000 | [diff] [blame] | 1445 | // Whether to provide "_thread" module |
| 1446 | #ifndef MICROPY_PY_THREAD |
| 1447 | #define MICROPY_PY_THREAD (0) |
| 1448 | #endif |
| 1449 | |
Damien George | 4cec63a | 2016-05-26 10:42:53 +0000 | [diff] [blame] | 1450 | // Whether to make the VM/runtime thread-safe using a global lock |
| 1451 | // If not enabled then thread safety must be provided at the Python level |
| 1452 | #ifndef MICROPY_PY_THREAD_GIL |
| 1453 | #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD) |
| 1454 | #endif |
| 1455 | |
Damien George | f6c22a0 | 2017-02-06 10:50:43 +1100 | [diff] [blame] | 1456 | // Number of VM jump-loops to do before releasing the GIL. |
| 1457 | // Set this to 0 to disable the divisor. |
| 1458 | #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR |
| 1459 | #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32) |
| 1460 | #endif |
| 1461 | |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1462 | // Extended modules |
Paul Sokolovsky | 510296f | 2014-08-08 22:51:40 +0300 | [diff] [blame] | 1463 | |
Damien George | bc009fd | 2020-03-12 16:46:20 +1100 | [diff] [blame] | 1464 | #ifndef MICROPY_PY_UASYNCIO |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1465 | #define MICROPY_PY_UASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | bc009fd | 2020-03-12 16:46:20 +1100 | [diff] [blame] | 1466 | #endif |
| 1467 | |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1468 | #ifndef MICROPY_PY_UCTYPES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1469 | #define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1470 | #endif |
| 1471 | |
Paul Sokolovsky | 38151f3 | 2018-10-06 23:34:58 +0300 | [diff] [blame] | 1472 | // Whether to provide SHORT, INT, LONG, etc. types in addition to |
| 1473 | // exact-bitness types like INT16, INT32, etc. |
| 1474 | #ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES |
| 1475 | #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1) |
| 1476 | #endif |
| 1477 | |
Paul Sokolovsky | 3416287 | 2014-10-12 08:16:34 -0700 | [diff] [blame] | 1478 | #ifndef MICROPY_PY_UZLIB |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1479 | #define MICROPY_PY_UZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 3416287 | 2014-10-12 08:16:34 -0700 | [diff] [blame] | 1480 | #endif |
| 1481 | |
Damien George | 612045f | 2014-09-17 22:56:34 +0100 | [diff] [blame] | 1482 | #ifndef MICROPY_PY_UJSON |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1483 | #define MICROPY_PY_UJSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 612045f | 2014-09-17 22:56:34 +0100 | [diff] [blame] | 1484 | #endif |
| 1485 | |
Peter Züger | ffc854f | 2021-02-03 09:24:25 +0100 | [diff] [blame] | 1486 | // Whether to support the "separators" argument to dump, dumps |
| 1487 | #ifndef MICROPY_PY_UJSON_SEPARATORS |
| 1488 | #define MICROPY_PY_UJSON_SEPARATORS (1) |
| 1489 | #endif |
| 1490 | |
Damien George | 926b554 | 2022-03-03 17:59:30 +1100 | [diff] [blame] | 1491 | #ifndef MICROPY_PY_UOS |
| 1492 | #define MICROPY_PY_UOS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1493 | #endif |
| 1494 | |
Damien George | 0149cd6 | 2022-03-09 12:45:06 +1100 | [diff] [blame] | 1495 | #ifndef MICROPY_PY_UOS_STATVFS |
| 1496 | #define MICROPY_PY_UOS_STATVFS (MICROPY_PY_UOS) |
| 1497 | #endif |
| 1498 | |
Paul Sokolovsky | c71e045 | 2014-09-12 18:48:07 +0300 | [diff] [blame] | 1499 | #ifndef MICROPY_PY_URE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1500 | #define MICROPY_PY_URE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | c71e045 | 2014-09-12 18:48:07 +0300 | [diff] [blame] | 1501 | #endif |
| 1502 | |
Damien George | 7d851a2 | 2019-08-17 23:50:19 +1000 | [diff] [blame] | 1503 | #ifndef MICROPY_PY_URE_DEBUG |
| 1504 | #define MICROPY_PY_URE_DEBUG (0) |
| 1505 | #endif |
| 1506 | |
Damien George | 1f86460 | 2018-05-24 13:07:42 +1000 | [diff] [blame] | 1507 | #ifndef MICROPY_PY_URE_MATCH_GROUPS |
| 1508 | #define MICROPY_PY_URE_MATCH_GROUPS (0) |
| 1509 | #endif |
| 1510 | |
Damien George | 1e9b871 | 2018-05-24 13:08:15 +1000 | [diff] [blame] | 1511 | #ifndef MICROPY_PY_URE_MATCH_SPAN_START_END |
| 1512 | #define MICROPY_PY_URE_MATCH_SPAN_START_END (0) |
| 1513 | #endif |
| 1514 | |
Damien George | e30a5fc | 2018-05-24 13:08:51 +1000 | [diff] [blame] | 1515 | #ifndef MICROPY_PY_URE_SUB |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1516 | #define MICROPY_PY_URE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | e30a5fc | 2018-05-24 13:08:51 +1000 | [diff] [blame] | 1517 | #endif |
| 1518 | |
Damien George | f5d6979 | 2014-10-22 17:37:18 +0000 | [diff] [blame] | 1519 | #ifndef MICROPY_PY_UHEAPQ |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1520 | #define MICROPY_PY_UHEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | f5d6979 | 2014-10-22 17:37:18 +0000 | [diff] [blame] | 1521 | #endif |
| 1522 | |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1523 | // Optimized heap queue for relative timestamps (only used by uasyncio v2) |
Paul Sokolovsky | d02f6a9 | 2016-12-22 00:29:32 +0300 | [diff] [blame] | 1524 | #ifndef MICROPY_PY_UTIMEQ |
| 1525 | #define MICROPY_PY_UTIMEQ (0) |
| 1526 | #endif |
| 1527 | |
Paul Sokolovsky | f4b19c8 | 2014-11-22 01:19:13 +0200 | [diff] [blame] | 1528 | #ifndef MICROPY_PY_UHASHLIB |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1529 | #define MICROPY_PY_UHASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | f4b19c8 | 2014-11-22 01:19:13 +0200 | [diff] [blame] | 1530 | #endif |
| 1531 | |
Paul Sokolovsky | 5fe3730 | 2018-08-19 11:58:22 +0300 | [diff] [blame] | 1532 | #ifndef MICROPY_PY_UHASHLIB_MD5 |
| 1533 | #define MICROPY_PY_UHASHLIB_MD5 (0) |
| 1534 | #endif |
| 1535 | |
Yonatan Goldschmidt | 6630354 | 2018-06-09 02:48:29 +0300 | [diff] [blame] | 1536 | #ifndef MICROPY_PY_UHASHLIB_SHA1 |
| 1537 | #define MICROPY_PY_UHASHLIB_SHA1 (0) |
| 1538 | #endif |
| 1539 | |
| 1540 | #ifndef MICROPY_PY_UHASHLIB_SHA256 |
| 1541 | #define MICROPY_PY_UHASHLIB_SHA256 (1) |
| 1542 | #endif |
| 1543 | |
Paul Sokolovsky | 567bc2d | 2018-01-07 15:13:56 +0200 | [diff] [blame] | 1544 | #ifndef MICROPY_PY_UCRYPTOLIB |
| 1545 | #define MICROPY_PY_UCRYPTOLIB (0) |
| 1546 | #endif |
| 1547 | |
Yonatan Goldschmidt | ef98436 | 2019-04-23 12:39:05 +0300 | [diff] [blame] | 1548 | // Depends on MICROPY_PY_UCRYPTOLIB |
| 1549 | #ifndef MICROPY_PY_UCRYPTOLIB_CTR |
| 1550 | #define MICROPY_PY_UCRYPTOLIB_CTR (0) |
| 1551 | #endif |
| 1552 | |
Yonatan Goldschmidt | 473fe45 | 2018-06-15 17:07:47 +0300 | [diff] [blame] | 1553 | #ifndef MICROPY_PY_UCRYPTOLIB_CONSTS |
| 1554 | #define MICROPY_PY_UCRYPTOLIB_CONSTS (0) |
| 1555 | #endif |
| 1556 | |
Paul Sokolovsky | bfdc205 | 2014-11-29 06:19:30 +0200 | [diff] [blame] | 1557 | #ifndef MICROPY_PY_UBINASCII |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1558 | #define MICROPY_PY_UBINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | bfdc205 | 2014-11-29 06:19:30 +0200 | [diff] [blame] | 1559 | #endif |
| 1560 | |
Paul Sokolovsky | c428367 | 2016-08-24 18:28:43 +0300 | [diff] [blame] | 1561 | // Depends on MICROPY_PY_UZLIB |
| 1562 | #ifndef MICROPY_PY_UBINASCII_CRC32 |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1563 | #define MICROPY_PY_UBINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | c428367 | 2016-08-24 18:28:43 +0300 | [diff] [blame] | 1564 | #endif |
| 1565 | |
Paul Sokolovsky | a58a91e | 2016-01-17 12:10:28 +0200 | [diff] [blame] | 1566 | #ifndef MICROPY_PY_URANDOM |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1567 | #define MICROPY_PY_URANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | a58a91e | 2016-01-17 12:10:28 +0200 | [diff] [blame] | 1568 | #endif |
| 1569 | |
Damien George | a53af6c | 2016-01-22 16:19:32 +0000 | [diff] [blame] | 1570 | // Whether to include: randrange, randint, choice, random, uniform |
| 1571 | #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1572 | #define MICROPY_PY_URANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | a53af6c | 2016-01-22 16:19:32 +0000 | [diff] [blame] | 1573 | #endif |
| 1574 | |
Paul Sokolovsky | 0116218 | 2015-05-03 20:25:40 +0300 | [diff] [blame] | 1575 | #ifndef MICROPY_PY_MACHINE |
| 1576 | #define MICROPY_PY_MACHINE (0) |
| 1577 | #endif |
| 1578 | |
Jim Mussared | 870000f | 2021-08-10 01:09:04 +1000 | [diff] [blame] | 1579 | // Whether to include: bitstream |
| 1580 | #ifndef MICROPY_PY_MACHINE_BITSTREAM |
| 1581 | #define MICROPY_PY_MACHINE_BITSTREAM (0) |
| 1582 | #endif |
| 1583 | |
Damien George | 3316808 | 2016-05-31 14:25:19 +0100 | [diff] [blame] | 1584 | // Whether to include: time_pulse_us |
| 1585 | #ifndef MICROPY_PY_MACHINE_PULSE |
| 1586 | #define MICROPY_PY_MACHINE_PULSE (0) |
| 1587 | #endif |
| 1588 | |
Damien George | d083712 | 2016-04-12 13:42:35 +0100 | [diff] [blame] | 1589 | #ifndef MICROPY_PY_MACHINE_I2C |
| 1590 | #define MICROPY_PY_MACHINE_I2C (0) |
| 1591 | #endif |
| 1592 | |
Damien George | 122d901 | 2021-09-02 12:37:00 +1000 | [diff] [blame] | 1593 | // Whether to provide the "machine.SoftI2C" class |
| 1594 | #ifndef MICROPY_PY_MACHINE_SOFTI2C |
| 1595 | #define MICROPY_PY_MACHINE_SOFTI2C (0) |
| 1596 | #endif |
| 1597 | |
Damien George | 0823c1b | 2016-09-01 15:07:20 +1000 | [diff] [blame] | 1598 | #ifndef MICROPY_PY_MACHINE_SPI |
| 1599 | #define MICROPY_PY_MACHINE_SPI (0) |
| 1600 | #endif |
| 1601 | |
Damien George | afe0634 | 2021-09-02 12:39:28 +1000 | [diff] [blame] | 1602 | // Whether to provide the "machine.SoftSPI" class |
| 1603 | #ifndef MICROPY_PY_MACHINE_SOFTSPI |
| 1604 | #define MICROPY_PY_MACHINE_SOFTSPI (0) |
| 1605 | #endif |
| 1606 | |
Damien George | aab005c | 2022-04-04 23:07:35 +1000 | [diff] [blame] | 1607 | // The default backlog value for socket.listen(backlog) |
| 1608 | #ifndef MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT |
| 1609 | #define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (2) |
| 1610 | #endif |
| 1611 | |
Paul Sokolovsky | aaa8867 | 2015-10-06 18:10:00 +0300 | [diff] [blame] | 1612 | #ifndef MICROPY_PY_USSL |
| 1613 | #define MICROPY_PY_USSL (0) |
Damien George | 772058a | 2022-01-07 23:59:17 +1100 | [diff] [blame] | 1614 | #endif |
| 1615 | |
Eric Poulsen | 74ec52d | 2017-10-26 21:17:35 -0700 | [diff] [blame] | 1616 | // Whether to add finaliser code to ussl objects |
Damien George | 772058a | 2022-01-07 23:59:17 +1100 | [diff] [blame] | 1617 | #ifndef MICROPY_PY_USSL_FINALISER |
Eric Poulsen | 74ec52d | 2017-10-26 21:17:35 -0700 | [diff] [blame] | 1618 | #define MICROPY_PY_USSL_FINALISER (0) |
Paul Sokolovsky | aaa8867 | 2015-10-06 18:10:00 +0300 | [diff] [blame] | 1619 | #endif |
| 1620 | |
Yonatan Goldschmidt | bc4f8b4 | 2019-02-10 22:35:18 +0200 | [diff] [blame] | 1621 | #ifndef MICROPY_PY_UWEBSOCKET |
| 1622 | #define MICROPY_PY_UWEBSOCKET (0) |
Paul Sokolovsky | 24342dd | 2016-03-24 19:14:12 +0200 | [diff] [blame] | 1623 | #endif |
| 1624 | |
Damien George | 53ad681 | 2016-04-08 11:08:37 +0100 | [diff] [blame] | 1625 | #ifndef MICROPY_PY_FRAMEBUF |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1626 | #define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 53ad681 | 2016-04-08 11:08:37 +0100 | [diff] [blame] | 1627 | #endif |
| 1628 | |
Paul Sokolovsky | 737bd9c | 2016-07-02 14:57:42 +0300 | [diff] [blame] | 1629 | #ifndef MICROPY_PY_BTREE |
| 1630 | #define MICROPY_PY_BTREE (0) |
| 1631 | #endif |
| 1632 | |
Damien George | d41f6dd | 2021-09-02 12:39:50 +1000 | [diff] [blame] | 1633 | // Whether to provide the low-level "_onewire" module |
| 1634 | #ifndef MICROPY_PY_ONEWIRE |
| 1635 | #define MICROPY_PY_ONEWIRE (0) |
| 1636 | #endif |
| 1637 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 1638 | /*****************************************************************************/ |
| 1639 | /* Hooks for a port to add builtins */ |
| 1640 | |
Yonatan Goldschmidt | 343401c | 2019-02-03 21:24:16 +0200 | [diff] [blame] | 1641 | // Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format. |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 1642 | #ifndef MICROPY_PORT_BUILTINS |
| 1643 | #define MICROPY_PORT_BUILTINS |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 1644 | #endif |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 1645 | |
stijn | 22cf094 | 2022-01-05 16:04:58 +0100 | [diff] [blame] | 1646 | // Additional builtin function definitions for extension by command-line, boards or variants. |
| 1647 | // See modbuiltins.c:mp_module_builtins_globals_table for format. |
| 1648 | #ifndef MICROPY_PORT_EXTRA_BUILTINS |
| 1649 | #define MICROPY_PORT_EXTRA_BUILTINS |
| 1650 | #endif |
| 1651 | |
Yonatan Goldschmidt | 343401c | 2019-02-03 21:24:16 +0200 | [diff] [blame] | 1652 | // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format. |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 1653 | #ifndef MICROPY_PORT_BUILTIN_MODULES |
| 1654 | #define MICROPY_PORT_BUILTIN_MODULES |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 1655 | #endif |
| 1656 | |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 1657 | // Additional constant definitions for the compiler - see compile.c:mp_constants_table. |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 1658 | #ifndef MICROPY_PORT_CONSTANTS |
| 1659 | #define MICROPY_PORT_CONSTANTS |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 1660 | #endif |
| 1661 | |
Damien George | b4b10fd | 2015-01-01 23:30:53 +0000 | [diff] [blame] | 1662 | // Any root pointers for GC scanning - see mpstate.c |
| 1663 | #ifndef MICROPY_PORT_ROOT_POINTERS |
| 1664 | #define MICROPY_PORT_ROOT_POINTERS |
| 1665 | #endif |
| 1666 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 1667 | /*****************************************************************************/ |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 1668 | /* Hooks for a port to wrap functions with attributes */ |
| 1669 | |
Damien George | 8412568 | 2021-09-24 12:49:51 +1000 | [diff] [blame] | 1670 | #ifndef MICROPY_WRAP_MP_BINARY_OP |
| 1671 | #define MICROPY_WRAP_MP_BINARY_OP(f) f |
| 1672 | #endif |
| 1673 | |
| 1674 | #ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE |
| 1675 | #define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f |
| 1676 | #endif |
| 1677 | |
| 1678 | #ifndef MICROPY_WRAP_MP_LOAD_GLOBAL |
| 1679 | #define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f |
| 1680 | #endif |
| 1681 | |
| 1682 | #ifndef MICROPY_WRAP_MP_LOAD_NAME |
| 1683 | #define MICROPY_WRAP_MP_LOAD_NAME(f) f |
| 1684 | #endif |
| 1685 | |
| 1686 | #ifndef MICROPY_WRAP_MP_MAP_LOOKUP |
| 1687 | #define MICROPY_WRAP_MP_MAP_LOOKUP(f) f |
| 1688 | #endif |
| 1689 | |
| 1690 | #ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE |
| 1691 | #define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f |
| 1692 | #endif |
| 1693 | |
Damien George | 7cbf826 | 2021-04-28 10:52:19 +1000 | [diff] [blame] | 1694 | #ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION |
| 1695 | #define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f |
| 1696 | #endif |
| 1697 | |
Damien George | e9e9c76 | 2021-04-28 10:57:34 +1000 | [diff] [blame] | 1698 | #ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT |
| 1699 | #define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 1700 | #endif |
| 1701 | |
Damien George | 544c308 | 2020-04-23 16:18:14 +1000 | [diff] [blame] | 1702 | #ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE |
| 1703 | #define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f |
| 1704 | #endif |
| 1705 | |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 1706 | /*****************************************************************************/ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 1707 | /* Miscellaneous settings */ |
| 1708 | |
Damien George | 2863153 | 2015-02-08 13:42:00 +0000 | [diff] [blame] | 1709 | // All uPy objects in ROM must be aligned on at least a 4 byte boundary |
| 1710 | // so that the small-int/qstr/pointer distinction can be made. For machines |
| 1711 | // that don't do this (eg 16-bit CPU), define the following macro to something |
| 1712 | // like __attribute__((aligned(4))). |
| 1713 | #ifndef MICROPY_OBJ_BASE_ALIGNMENT |
| 1714 | #define MICROPY_OBJ_BASE_ALIGNMENT |
| 1715 | #endif |
| 1716 | |
Damien George | 4004782 | 2022-04-21 16:30:23 +1000 | [diff] [blame] | 1717 | // String used for the banner, and sys.version additional information |
| 1718 | #ifndef MICROPY_BANNER_NAME_AND_VERSION |
| 1719 | #define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE |
| 1720 | #endif |
| 1721 | |
Damien George | 402df83 | 2022-04-26 17:28:39 +1000 | [diff] [blame^] | 1722 | // String used for the second part of the banner, and sys.implementation._machine |
| 1723 | #ifndef MICROPY_BANNER_MACHINE |
| 1724 | #ifdef MICROPY_HW_BOARD_NAME |
| 1725 | #define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME |
| 1726 | #else |
| 1727 | #define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version" |
| 1728 | #endif |
| 1729 | #endif |
| 1730 | |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 1731 | // On embedded platforms, these will typically enable/disable irqs. |
| 1732 | #ifndef MICROPY_BEGIN_ATOMIC_SECTION |
Damien George | 4859edb | 2014-10-15 17:33:24 +0000 | [diff] [blame] | 1733 | #define MICROPY_BEGIN_ATOMIC_SECTION() (0) |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 1734 | #endif |
| 1735 | #ifndef MICROPY_END_ATOMIC_SECTION |
Damien George | 4859edb | 2014-10-15 17:33:24 +0000 | [diff] [blame] | 1736 | #define MICROPY_END_ATOMIC_SECTION(state) (void)(state) |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 1737 | #endif |
| 1738 | |
Paul Sokolovsky | d5df6cd | 2014-02-12 18:15:40 +0200 | [diff] [blame] | 1739 | // Allow to override static modifier for global objects, e.g. to use with |
| 1740 | // object code analysis tools which don't support static symbols. |
| 1741 | #ifndef STATIC |
| 1742 | #define STATIC static |
| 1743 | #endif |
| 1744 | |
Damien George | ad4656b | 2021-02-04 16:39:09 +1100 | [diff] [blame] | 1745 | // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t |
| 1746 | #ifndef MP_BYTES_PER_OBJ_WORD |
| 1747 | #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t)) |
Damien George | 4c307bf | 2017-04-01 11:39:38 +1100 | [diff] [blame] | 1748 | #endif |
| 1749 | |
Damien George | 7e956fa | 2021-02-04 15:32:59 +1100 | [diff] [blame] | 1750 | // Number of bits in a byte |
| 1751 | #ifndef MP_BITS_PER_BYTE |
| 1752 | #define MP_BITS_PER_BYTE (8) |
Yonatan Goldschmidt | 1c849d6 | 2019-12-01 01:10:12 +0200 | [diff] [blame] | 1753 | #endif |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 1754 | // mp_int_t value with most significant bit set |
Damien George | c891190 | 2021-02-04 16:39:46 +1100 | [diff] [blame] | 1755 | #define MP_OBJ_WORD_MSBIT_HIGH (((mp_uint_t)1) << (MP_BYTES_PER_OBJ_WORD * MP_BITS_PER_BYTE - 1)) |
Paul Sokolovsky | fc5aac8 | 2014-01-12 16:10:19 +0200 | [diff] [blame] | 1756 | |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1757 | // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are |
| 1758 | // defined and that they are the opposite of each other. |
| 1759 | #if defined(MP_ENDIANNESS_LITTLE) |
| 1760 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
| 1761 | #elif defined(MP_ENDIANNESS_BIG) |
| 1762 | #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG) |
| 1763 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1764 | // Endianness not defined by port so try to autodetect it. |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1765 | #if defined(__BYTE_ORDER__) |
| 1766 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 1767 | #define MP_ENDIANNESS_LITTLE (1) |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 1768 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1769 | #define MP_ENDIANNESS_LITTLE (0) |
| 1770 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1771 | #else |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 1772 | #include <endian.h> |
| 1773 | #if defined(__BYTE_ORDER) |
| 1774 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 1775 | #define MP_ENDIANNESS_LITTLE (1) |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 1776 | #elif __BYTE_ORDER == __BIG_ENDIAN |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 1777 | #define MP_ENDIANNESS_LITTLE (0) |
| 1778 | #endif |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 1779 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1780 | #endif |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 1781 | #ifndef MP_ENDIANNESS_LITTLE |
| 1782 | #error endianness not defined and cannot detect it |
| 1783 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 1784 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
Andrew Scheller | cc83737 | 2014-04-14 02:39:56 +0100 | [diff] [blame] | 1785 | #endif |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 1786 | |
Damien George | 3c658a4 | 2014-08-24 16:28:17 +0100 | [diff] [blame] | 1787 | // Make a pointer to RAM callable (eg set lower bit for Thumb code) |
| 1788 | // (This scheme won't work if we want to mix Thumb and normal ARM code.) |
| 1789 | #ifndef MICROPY_MAKE_POINTER_CALLABLE |
| 1790 | #define MICROPY_MAKE_POINTER_CALLABLE(p) (p) |
| 1791 | #endif |
| 1792 | |
Damien George | 7f9d1d6 | 2015-04-09 23:56:15 +0100 | [diff] [blame] | 1793 | // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them |
Damien George | 2127e9a | 2015-01-14 00:11:09 +0000 | [diff] [blame] | 1794 | // must be somehow reachable for marking by the GC, since the native code |
| 1795 | // generators store pointers to GC managed memory in the code. |
Fabian Vogt | b7235b8 | 2014-09-03 16:59:33 +0200 | [diff] [blame] | 1796 | #ifndef MP_PLAT_ALLOC_EXEC |
Damien George | 4dea922 | 2015-04-09 15:29:54 +0000 | [diff] [blame] | 1797 | #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0) |
Fabian Vogt | b7235b8 | 2014-09-03 16:59:33 +0200 | [diff] [blame] | 1798 | #endif |
| 1799 | |
| 1800 | #ifndef MP_PLAT_FREE_EXEC |
| 1801 | #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size) |
| 1802 | #endif |
| 1803 | |
Damien George | 7f9d1d6 | 2015-04-09 23:56:15 +0100 | [diff] [blame] | 1804 | // This macro is used to do all output (except when MICROPY_PY_IO is defined) |
| 1805 | #ifndef MP_PLAT_PRINT_STRN |
Damien George | 4300c7d | 2015-10-15 00:05:55 +0100 | [diff] [blame] | 1806 | #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) |
Damien George | 7f9d1d6 | 2015-04-09 23:56:15 +0100 | [diff] [blame] | 1807 | #endif |
| 1808 | |
Paul Sokolovsky | 722e562 | 2014-09-06 19:17:23 +0300 | [diff] [blame] | 1809 | #ifndef MP_SSIZE_MAX |
| 1810 | #define MP_SSIZE_MAX SSIZE_MAX |
| 1811 | #endif |
| 1812 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 1813 | // printf format spec to use for mp_int_t and friends |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 1814 | #ifndef INT_FMT |
stijn | 3baf6b5 | 2015-11-20 15:59:06 +0100 | [diff] [blame] | 1815 | #if defined(__LP64__) |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 1816 | // Archs where mp_int_t == long, long != int |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 1817 | #define UINT_FMT "%lu" |
| 1818 | #define INT_FMT "%ld" |
stijn | 3baf6b5 | 2015-11-20 15:59:06 +0100 | [diff] [blame] | 1819 | #elif defined(_WIN64) |
stijn | 0a4eb4d | 2015-12-18 10:20:33 +0100 | [diff] [blame] | 1820 | #define UINT_FMT "%llu" |
| 1821 | #define INT_FMT "%lld" |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 1822 | #else |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 1823 | // Archs where mp_int_t == int |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 1824 | #define UINT_FMT "%u" |
| 1825 | #define INT_FMT "%d" |
| 1826 | #endif |
stijn | 84fa331 | 2020-04-16 09:13:57 +0200 | [diff] [blame] | 1827 | #endif // INT_FMT |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 1828 | |
| 1829 | // Modifier for function which doesn't return |
stijn | 01d6be4 | 2014-05-05 12:18:27 +0200 | [diff] [blame] | 1830 | #ifndef NORETURN |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 1831 | #define NORETURN __attribute__((noreturn)) |
stijn | 01d6be4 | 2014-05-05 12:18:27 +0200 | [diff] [blame] | 1832 | #endif |
mux | 5c8db48 | 2014-06-21 17:24:55 +0200 | [diff] [blame] | 1833 | |
| 1834 | // Modifier for weak functions |
| 1835 | #ifndef MP_WEAK |
| 1836 | #define MP_WEAK __attribute__((weak)) |
| 1837 | #endif |
Paul Sokolovsky | 361909e | 2014-12-29 00:51:06 +0200 | [diff] [blame] | 1838 | |
Paul Sokolovsky | 0f5bf1a | 2016-06-15 23:52:00 +0300 | [diff] [blame] | 1839 | // Modifier for functions which should be never inlined |
| 1840 | #ifndef MP_NOINLINE |
| 1841 | #define MP_NOINLINE __attribute__((noinline)) |
| 1842 | #endif |
| 1843 | |
Paul Sokolovsky | 1bc2911 | 2016-08-07 22:36:05 +0300 | [diff] [blame] | 1844 | // Modifier for functions which should be always inlined |
| 1845 | #ifndef MP_ALWAYSINLINE |
| 1846 | #define MP_ALWAYSINLINE __attribute__((always_inline)) |
| 1847 | #endif |
| 1848 | |
Paul Sokolovsky | 361909e | 2014-12-29 00:51:06 +0200 | [diff] [blame] | 1849 | // Condition is likely to be true, to help branch prediction |
| 1850 | #ifndef MP_LIKELY |
| 1851 | #define MP_LIKELY(x) __builtin_expect((x), 1) |
| 1852 | #endif |
| 1853 | |
| 1854 | // Condition is likely to be false, to help branch prediction |
| 1855 | #ifndef MP_UNLIKELY |
| 1856 | #define MP_UNLIKELY(x) __builtin_expect((x), 0) |
| 1857 | #endif |
Damien George | 9ddbe29 | 2014-12-29 01:02:19 +0000 | [diff] [blame] | 1858 | |
Damien George | 0c80cb3 | 2019-08-19 15:50:02 +1000 | [diff] [blame] | 1859 | // To annotate that code is unreachable |
| 1860 | #ifndef MP_UNREACHABLE |
| 1861 | #if defined(__GNUC__) |
| 1862 | #define MP_UNREACHABLE __builtin_unreachable(); |
| 1863 | #else |
| 1864 | #define MP_UNREACHABLE for (;;); |
| 1865 | #endif |
| 1866 | #endif |
| 1867 | |
Emil Renner Berthing | ccd9233 | 2019-11-28 12:47:21 +0100 | [diff] [blame] | 1868 | // Explicitly annotate switch case fall throughs |
| 1869 | #if defined(__GNUC__) && __GNUC__ >= 7 |
| 1870 | #define MP_FALLTHROUGH __attribute__((fallthrough)); |
| 1871 | #else |
| 1872 | #define MP_FALLTHROUGH |
| 1873 | #endif |
| 1874 | |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 1875 | #ifndef MP_HTOBE16 |
| 1876 | #if MP_ENDIANNESS_LITTLE |
Damien George | feb2577 | 2020-03-20 21:47:07 +1100 | [diff] [blame] | 1877 | #define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))) |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1878 | #define MP_BE16TOH(x) MP_HTOBE16(x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 1879 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1880 | #define MP_HTOBE16(x) (x) |
| 1881 | #define MP_BE16TOH(x) (x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 1882 | #endif |
| 1883 | #endif |
| 1884 | |
| 1885 | #ifndef MP_HTOBE32 |
| 1886 | #if MP_ENDIANNESS_LITTLE |
Damien George | feb2577 | 2020-03-20 21:47:07 +1100 | [diff] [blame] | 1887 | #define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff))) |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1888 | #define MP_BE32TOH(x) MP_HTOBE32(x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 1889 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1890 | #define MP_HTOBE32(x) (x) |
| 1891 | #define MP_BE32TOH(x) (x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 1892 | #endif |
| 1893 | #endif |
| 1894 | |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 1895 | // Warning categories are by default implemented as strings, though |
| 1896 | // hook is left for a port to define them as something else. |
| 1897 | #if MICROPY_WARNINGS_CATEGORY |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1898 | #ifndef MP_WARN_CAT |
| 1899 | #define MP_WARN_CAT(x) #x |
| 1900 | #endif |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 1901 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 1902 | #undef MP_WARN_CAT |
| 1903 | #define MP_WARN_CAT(x) (NULL) |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 1904 | #endif |
| 1905 | |
Milan Rossa | 310b3d1 | 2019-08-14 16:09:36 +0200 | [diff] [blame] | 1906 | // Feature dependency check. |
| 1907 | #if MICROPY_PY_SYS_SETTRACE |
| 1908 | #if !MICROPY_PERSISTENT_CODE_SAVE |
| 1909 | #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_PERSISTENT_CODE_SAVE to be enabled" |
| 1910 | #endif |
| 1911 | #if MICROPY_COMP_CONST |
| 1912 | #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_COMP_CONST to be disabled" |
| 1913 | #endif |
| 1914 | #endif |
| 1915 | |
Alexander Steffen | 299bc62 | 2017-06-29 23:14:58 +0200 | [diff] [blame] | 1916 | #endif // MICROPY_INCLUDED_PY_MPCONFIG_H |