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 | |
Jim Mussared | 69e34b6 | 2023-10-04 11:20:47 +1100 | [diff] [blame] | 29 | // Current version of MicroPython. This is used by sys.implementation.version |
| 30 | // as well as a fallback to generate MICROPY_GIT_TAG if the git repo or tags |
| 31 | // are unavailable. |
Damien George | aba83e6 | 2019-01-26 00:44:35 +1100 | [diff] [blame] | 32 | #define MICROPY_VERSION_MAJOR 1 |
Damien George | 28901b2 | 2025-04-21 17:07:30 +1000 | [diff] [blame] | 33 | #define MICROPY_VERSION_MINOR 26 |
Damien George | 294baf5 | 2023-04-26 15:42:28 +1000 | [diff] [blame] | 34 | #define MICROPY_VERSION_MICRO 0 |
Damien George | 28901b2 | 2025-04-21 17:07:30 +1000 | [diff] [blame] | 35 | #define MICROPY_VERSION_PRERELEASE 1 |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 36 | |
Jim Mussared | 69e34b6 | 2023-10-04 11:20:47 +1100 | [diff] [blame] | 37 | // Combined version as a 32-bit number for convenience to allow version |
| 38 | // comparison. Doesn't include prerelease state. |
| 39 | // e.g. #if MICROPY_VERSION < MICROPY_MAKE_VERSION(1, 22, 0) |
| 40 | #define MICROPY_MAKE_VERSION(major, minor, patch) (major << 16 | minor << 8 | patch) |
| 41 | #define MICROPY_VERSION MICROPY_MAKE_VERSION(MICROPY_VERSION_MAJOR, MICROPY_VERSION_MINOR, MICROPY_VERSION_MICRO) |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 42 | |
Jim Mussared | 69e34b6 | 2023-10-04 11:20:47 +1100 | [diff] [blame] | 43 | // String version. This is only used directly for platform.platform and |
| 44 | // os.uname().release. All other version info available in the firmware (e.g. |
| 45 | // the REPL banner) comes from MICROPY_GIT_TAG. |
| 46 | #define MICROPY_VERSION_STRING_BASE \ |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 47 | MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \ |
| 48 | MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \ |
| 49 | MP_STRINGIFY(MICROPY_VERSION_MICRO) |
Jim Mussared | 69e34b6 | 2023-10-04 11:20:47 +1100 | [diff] [blame] | 50 | #if MICROPY_VERSION_PRERELEASE |
| 51 | #define MICROPY_VERSION_STRING MICROPY_VERSION_STRING_BASE "-preview" |
| 52 | #else |
| 53 | #define MICROPY_VERSION_STRING MICROPY_VERSION_STRING_BASE |
| 54 | #endif |
Damien George | 7cd59c5 | 2018-12-15 15:13:33 +1100 | [diff] [blame] | 55 | |
Jim Mussared | 3bf70f1 | 2023-10-10 16:50:28 +1100 | [diff] [blame] | 56 | // If this is enabled, then in-progress/breaking changes slated for the 2.x |
| 57 | // release will be enabled. |
| 58 | #ifndef MICROPY_PREVIEW_VERSION_2 |
| 59 | #define MICROPY_PREVIEW_VERSION_2 (0) |
| 60 | #endif |
| 61 | |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 62 | // This file contains default configuration settings for MicroPython. |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 63 | // You can override any of the options below using mpconfigport.h file |
| 64 | // located in a directory of your port. |
Paul Sokolovsky | b372bfc | 2014-01-03 17:15:53 +0200 | [diff] [blame] | 65 | |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 66 | // mpconfigport.h is a file containing configuration settings for a |
| 67 | // particular port. mpconfigport.h is actually a default name for |
Ville Skyttä | ca16c38 | 2017-05-29 10:08:14 +0300 | [diff] [blame] | 68 | // such config, and it can be overridden using MP_CONFIGFILE preprocessor |
Paul Sokolovsky | b1422de | 2014-10-29 04:08:49 +0200 | [diff] [blame] | 69 | // define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"' |
| 70 | // argument to make when using standard MicroPython makefiles). |
| 71 | // This is useful to have more than one config per port, for example, |
| 72 | // release vs debug configs, etc. Note that if you switch from one config |
| 73 | // to another, you must rebuild from scratch using "-B" switch to make. |
| 74 | |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 75 | // Disable all optional features (i.e. minimal port). |
| 76 | #define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0) |
| 77 | // Only enable core features (constrained flash, e.g. STM32L072) |
| 78 | #define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10) |
| 79 | // Enable most common features (small on-device flash, e.g. STM32F411) |
| 80 | #define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20) |
| 81 | // Enable convenience features (medium on-device flash, e.g. STM32F405) |
| 82 | #define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30) |
| 83 | // Enable all common features (large/external flash, rp2, unix) |
| 84 | #define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40) |
| 85 | // Enable everything (e.g. coverage) |
| 86 | #define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50) |
| 87 | |
Jim Mussared | 605266e | 2022-08-16 01:28:31 +1000 | [diff] [blame] | 88 | #ifdef MP_CONFIGFILE |
| 89 | #include MP_CONFIGFILE |
| 90 | #else |
| 91 | #include <mpconfigport.h> |
| 92 | #endif |
| 93 | |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 94 | // Ports/boards should set this, but default to level=core. |
| 95 | #ifndef MICROPY_CONFIG_ROM_LEVEL |
| 96 | #define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) |
| 97 | #endif |
| 98 | |
| 99 | // Helper macros for "have at least this level". |
| 100 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) |
| 101 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) |
| 102 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) |
| 103 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) |
| 104 | #define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) |
| 105 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 106 | // Any options not explicitly set in mpconfigport.h will get default |
| 107 | // values below. |
| 108 | |
| 109 | /*****************************************************************************/ |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 110 | /* Object representation */ |
| 111 | |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 112 | // A MicroPython object is a machine word having the following form: |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 113 | // - xxxx...xxx1 : a small int, bits 1 and above are the value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 114 | // - xxxx...x010 : a qstr, bits 3 and above are the value |
| 115 | // - xxxx...x110 : an immediate object, bits 3 and above are the value |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 116 | // - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object) |
| 117 | #define MICROPY_OBJ_REPR_A (0) |
| 118 | |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 119 | // A MicroPython object is a machine word having the following form: |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 120 | // - xxxx...xx01 : a small int, bits 2 and above are the value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 121 | // - xxxx...x011 : a qstr, bits 3 and above are the value |
| 122 | // - xxxx...x111 : an immediate object, bits 3 and above are the value |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 123 | // - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object) |
| 124 | #define MICROPY_OBJ_REPR_B (1) |
| 125 | |
Damien George | 8b8d189 | 2015-11-06 23:25:10 +0000 | [diff] [blame] | 126 | // 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] | 127 | // - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 128 | // - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value |
| 129 | // - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value |
Damien George | 183edef | 2015-10-17 23:20:57 +0100 | [diff] [blame] | 130 | // - s1111111 10000000 00000000 00000010 +/- inf |
| 131 | // - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0 |
| 132 | // - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff |
| 133 | // - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment) |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 134 | // Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000. |
| 135 | // 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] | 136 | // This scheme only works with 32-bit word size and float enabled. |
| 137 | #define MICROPY_OBJ_REPR_C (2) |
| 138 | |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 139 | // A MicroPython object is a 64-bit word having the following form (called R): |
| 140 | // - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff |
| 141 | // - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf |
| 142 | // - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan |
Damien George | 2759bec | 2017-12-11 22:39:12 +1100 | [diff] [blame] | 143 | // - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 144 | // - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str |
Damien George | 6f0c83f | 2020-01-08 23:58:40 +1100 | [diff] [blame] | 145 | // - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object |
Damien George | b8cfb0d | 2015-11-27 17:09:11 +0000 | [diff] [blame] | 146 | // - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment) |
| 147 | // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000. |
| 148 | // This makes pointers have all zeros in the top 32 bits. |
| 149 | // Small-ints and strs have 1 as LSB to make sure they don't look like pointers |
| 150 | // to the garbage collector. |
| 151 | #define MICROPY_OBJ_REPR_D (3) |
| 152 | |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 153 | #ifndef MICROPY_OBJ_REPR |
| 154 | #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) |
| 155 | #endif |
| 156 | |
Damien George | d96cfd1 | 2020-01-09 00:00:27 +1100 | [diff] [blame] | 157 | // Whether to encode None/False/True as immediate objects instead of pointers to |
| 158 | // real objects. Reduces code size by a decent amount without hurting |
| 159 | // performance, for all representations except D on some architectures. |
| 160 | #ifndef MICROPY_OBJ_IMMEDIATE_OBJS |
| 161 | #define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D) |
| 162 | #endif |
| 163 | |
Damien George | 567184e | 2015-03-29 14:05:46 +0100 | [diff] [blame] | 164 | /*****************************************************************************/ |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 165 | /* Memory allocation policy */ |
| 166 | |
Paul Sokolovsky | 75feece | 2015-12-03 01:40:52 +0200 | [diff] [blame] | 167 | // Number of bytes in memory allocation/GC block. Any size allocated will be |
| 168 | // rounded up to be multiples of this. |
Paul Sokolovsky | b4eccfd | 2015-12-03 01:57:50 +0200 | [diff] [blame] | 169 | #ifndef MICROPY_BYTES_PER_GC_BLOCK |
Damien George | ad4656b | 2021-02-04 16:39:09 +1100 | [diff] [blame] | 170 | #define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD) |
Paul Sokolovsky | b4eccfd | 2015-12-03 01:57:50 +0200 | [diff] [blame] | 171 | #endif |
Paul Sokolovsky | 75feece | 2015-12-03 01:40:52 +0200 | [diff] [blame] | 172 | |
Damien George | fd40a9c | 2015-01-01 22:04:46 +0000 | [diff] [blame] | 173 | // Number of words allocated (in BSS) to the GC stack (minimum is 1) |
| 174 | #ifndef MICROPY_ALLOC_GC_STACK_SIZE |
| 175 | #define MICROPY_ALLOC_GC_STACK_SIZE (64) |
| 176 | #endif |
| 177 | |
Ayke van Laethem | 31cf528 | 2018-02-23 18:59:31 +0100 | [diff] [blame] | 178 | // The C-type to use for entries in the GC stack. By default it allows the |
| 179 | // heap to be as large as the address space, but the bit-width of this type can |
| 180 | // be reduced to save memory when the heap is small enough. The type must be |
| 181 | // big enough to index all blocks in the heap, which is set by |
| 182 | // heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK. |
| 183 | #ifndef MICROPY_GC_STACK_ENTRY_TYPE |
| 184 | #define MICROPY_GC_STACK_ENTRY_TYPE size_t |
| 185 | #endif |
| 186 | |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 187 | // Be conservative and always clear to zero newly (re)allocated memory in the GC. |
| 188 | // This helps eliminate stray pointers that hold on to memory that's no longer |
| 189 | // used. It decreases performance due to unnecessary memory clearing. |
Colin Hogben | 828df54 | 2016-10-31 14:52:11 +0000 | [diff] [blame] | 190 | // A memory manager which always clears memory can set this to 0. |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 191 | // TODO Do analysis to understand why some memory is not properly cleared and |
| 192 | // find a more efficient way to clear it. |
| 193 | #ifndef MICROPY_GC_CONSERVATIVE_CLEAR |
Colin Hogben | 828df54 | 2016-10-31 14:52:11 +0000 | [diff] [blame] | 194 | #define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC) |
Damien George | 5ffe1d8 | 2016-08-26 15:35:26 +1000 | [diff] [blame] | 195 | #endif |
| 196 | |
Paul Sokolovsky | 93e353e | 2016-07-21 00:37:30 +0300 | [diff] [blame] | 197 | // Support automatic GC when reaching allocation threshold, |
| 198 | // configurable by gc.threshold(). |
| 199 | #ifndef MICROPY_GC_ALLOC_THRESHOLD |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 200 | #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] | 201 | #endif |
| 202 | |
Damien George | ade9a05 | 2015-06-13 21:53:22 +0100 | [diff] [blame] | 203 | // Number of bytes to allocate initially when creating new chunks to store |
| 204 | // interned string data. Smaller numbers lead to more chunks being needed |
| 205 | // and more wastage at the end of the chunk. Larger numbers lead to wasted |
| 206 | // space at the end when no more strings need interning. |
| 207 | #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT |
| 208 | #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128) |
| 209 | #endif |
| 210 | |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 211 | // Initial amount for lexer indentation level |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 212 | #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT |
| 213 | #define MICROPY_ALLOC_LEXER_INDENT_INIT (10) |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 214 | #endif |
| 215 | |
| 216 | // Increment for lexer indentation level |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 217 | #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC |
| 218 | #define MICROPY_ALLOC_LEXEL_INDENT_INC (8) |
Damien George | e1199ec | 2014-05-10 17:48:01 +0100 | [diff] [blame] | 219 | #endif |
| 220 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 221 | // Initial amount for parse rule stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 222 | #ifndef MICROPY_ALLOC_PARSE_RULE_INIT |
| 223 | #define MICROPY_ALLOC_PARSE_RULE_INIT (64) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 224 | #endif |
| 225 | |
| 226 | // Increment for parse rule stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 227 | #ifndef MICROPY_ALLOC_PARSE_RULE_INC |
| 228 | #define MICROPY_ALLOC_PARSE_RULE_INC (16) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 229 | #endif |
| 230 | |
| 231 | // Initial amount for parse result stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 232 | #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT |
| 233 | #define MICROPY_ALLOC_PARSE_RESULT_INIT (32) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 234 | #endif |
| 235 | |
| 236 | // Increment for parse result stack |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 237 | #ifndef MICROPY_ALLOC_PARSE_RESULT_INC |
| 238 | #define MICROPY_ALLOC_PARSE_RESULT_INC (16) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 239 | #endif |
| 240 | |
Damien George | 5042bce | 2014-05-25 22:06:06 +0100 | [diff] [blame] | 241 | // Strings this length or less will be interned by the parser |
| 242 | #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN |
| 243 | #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10) |
| 244 | #endif |
| 245 | |
Damien George | 58e0f4a | 2015-09-23 10:50:43 +0100 | [diff] [blame] | 246 | // Number of bytes to allocate initially when creating new chunks to store |
| 247 | // parse nodes. Small leads to fragmentation, large leads to excess use. |
| 248 | #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT |
| 249 | #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128) |
| 250 | #endif |
| 251 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 252 | // Initial amount for ids in a scope |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 253 | #ifndef MICROPY_ALLOC_SCOPE_ID_INIT |
| 254 | #define MICROPY_ALLOC_SCOPE_ID_INIT (4) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 255 | #endif |
| 256 | |
| 257 | // Increment for ids in a scope |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 258 | #ifndef MICROPY_ALLOC_SCOPE_ID_INC |
| 259 | #define MICROPY_ALLOC_SCOPE_ID_INC (6) |
| 260 | #endif |
| 261 | |
| 262 | // Maximum length of a path in the filesystem |
| 263 | // So we can allocate a buffer on the stack for path manipulation in import |
| 264 | #ifndef MICROPY_ALLOC_PATH_MAX |
| 265 | #define MICROPY_ALLOC_PATH_MAX (512) |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 266 | #endif |
| 267 | |
Paul Sokolovsky | 346aacf | 2014-11-05 00:27:15 +0200 | [diff] [blame] | 268 | // Initial size of module dict |
| 269 | #ifndef MICROPY_MODULE_DICT_SIZE |
| 270 | #define MICROPY_MODULE_DICT_SIZE (1) |
| 271 | #endif |
| 272 | |
matejcik | 1a2ffda | 2021-03-22 11:20:22 +0100 | [diff] [blame] | 273 | // Initial size of sys.modules dict |
| 274 | #ifndef MICROPY_LOADED_MODULES_DICT_SIZE |
| 275 | #define MICROPY_LOADED_MODULES_DICT_SIZE (3) |
| 276 | #endif |
| 277 | |
Damien George | d891452 | 2015-02-27 09:54:12 +0000 | [diff] [blame] | 278 | // Whether realloc/free should be passed allocated memory region size |
| 279 | // You must enable this if MICROPY_MEM_STATS is enabled |
| 280 | #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE |
| 281 | #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0) |
| 282 | #endif |
| 283 | |
Damien George | 95836f8 | 2015-01-11 22:27:30 +0000 | [diff] [blame] | 284 | // Number of bytes used to store qstr length |
| 285 | // Dictates hard limit on maximum Python identifier length, but 1 byte |
| 286 | // (limit of 255 bytes in an identifier) should be enough for everyone |
| 287 | #ifndef MICROPY_QSTR_BYTES_IN_LEN |
| 288 | #define MICROPY_QSTR_BYTES_IN_LEN (1) |
| 289 | #endif |
| 290 | |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 291 | // Number of bytes used to store qstr hash |
| 292 | #ifndef MICROPY_QSTR_BYTES_IN_HASH |
Jim Mussared | d419081 | 2023-10-31 10:47:45 +1100 | [diff] [blame] | 293 | #if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 294 | #define MICROPY_QSTR_BYTES_IN_HASH (2) |
Jim Mussared | d419081 | 2023-10-31 10:47:45 +1100 | [diff] [blame] | 295 | #elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 296 | #define MICROPY_QSTR_BYTES_IN_HASH (1) |
Jim Mussared | d419081 | 2023-10-31 10:47:45 +1100 | [diff] [blame] | 297 | #else |
| 298 | #define MICROPY_QSTR_BYTES_IN_HASH (0) |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 299 | #endif |
Damien George | c3bd941 | 2015-07-20 11:03:13 +0000 | [diff] [blame] | 300 | #endif |
| 301 | |
Paul Sokolovsky | 7f1c981 | 2015-03-28 01:14:45 +0200 | [diff] [blame] | 302 | // Avoid using C stack when making Python function calls. C stack still |
| 303 | // may be used if there's no free heap. |
Paul Sokolovsky | 2039757 | 2015-03-28 01:14:44 +0200 | [diff] [blame] | 304 | #ifndef MICROPY_STACKLESS |
| 305 | #define MICROPY_STACKLESS (0) |
| 306 | #endif |
| 307 | |
Paul Sokolovsky | 7f1c981 | 2015-03-28 01:14:45 +0200 | [diff] [blame] | 308 | // Never use C stack when making Python function calls. This may break |
| 309 | // testsuite as will subtly change which exception is thrown in case |
| 310 | // of too deep recursion and other similar cases. |
| 311 | #ifndef MICROPY_STACKLESS_STRICT |
| 312 | #define MICROPY_STACKLESS_STRICT (0) |
| 313 | #endif |
| 314 | |
Paul Sokolovsky | f32020e | 2015-11-25 23:22:31 +0200 | [diff] [blame] | 315 | // Don't use alloca calls. As alloca() is not part of ANSI C, this |
| 316 | // workaround option is provided for compilers lacking this de-facto |
| 317 | // standard function. The way it works is allocating from heap, and |
| 318 | // relying on garbage collection to free it eventually. This is of |
| 319 | // course much less optimal than real alloca(). |
| 320 | #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA |
| 321 | #undef alloca |
| 322 | #define alloca(x) m_malloc(x) |
| 323 | #endif |
| 324 | |
Damien George | 66e18f0 | 2014-05-05 13:19:03 +0100 | [diff] [blame] | 325 | /*****************************************************************************/ |
Damien George | c408ed9 | 2017-06-26 12:29:20 +1000 | [diff] [blame] | 326 | /* MicroPython emitters */ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 327 | |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 328 | // Whether to support loading of persistent code |
| 329 | #ifndef MICROPY_PERSISTENT_CODE_LOAD |
| 330 | #define MICROPY_PERSISTENT_CODE_LOAD (0) |
| 331 | #endif |
| 332 | |
Jim Mussared | b2b5bcc | 2023-08-23 13:30:20 +1000 | [diff] [blame] | 333 | // Whether to support saving of persistent code, i.e. for mpy-cross to |
| 334 | // generate .mpy files. Enabling this enables additional metadata on raw code |
| 335 | // objects which is also required for sys.settrace. |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 336 | #ifndef MICROPY_PERSISTENT_CODE_SAVE |
Jim Mussared | b2b5bcc | 2023-08-23 13:30:20 +1000 | [diff] [blame] | 337 | #define MICROPY_PERSISTENT_CODE_SAVE (MICROPY_PY_SYS_SETTRACE) |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 338 | #endif |
| 339 | |
David CARLIER | cb30928 | 2021-01-16 20:48:19 +0000 | [diff] [blame] | 340 | // Whether to support saving persistent code to a file via mp_raw_code_save_file |
| 341 | #ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE |
| 342 | #define MICROPY_PERSISTENT_CODE_SAVE_FILE (0) |
| 343 | #endif |
| 344 | |
Damien George | a11ba77 | 2024-07-17 16:06:12 +1000 | [diff] [blame] | 345 | // Whether to support converting functions to persistent code (bytes) |
| 346 | #ifndef MICROPY_PERSISTENT_CODE_SAVE_FUN |
Damien George | c3a18d7 | 2025-01-20 22:24:10 +1100 | [diff] [blame] | 347 | #define MICROPY_PERSISTENT_CODE_SAVE_FUN (MICROPY_PY_MARSHAL) |
Damien George | a11ba77 | 2024-07-17 16:06:12 +1000 | [diff] [blame] | 348 | #endif |
| 349 | |
Damien George | c8e9c0d | 2015-11-02 17:27:18 +0000 | [diff] [blame] | 350 | // Whether generated code can persist independently of the VM/runtime instance |
Damien George | d8c834c | 2015-11-02 21:55:42 +0000 | [diff] [blame] | 351 | // This is enabled automatically when needed by other features |
Damien George | c8e9c0d | 2015-11-02 17:27:18 +0000 | [diff] [blame] | 352 | #ifndef MICROPY_PERSISTENT_CODE |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 353 | #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] | 354 | #endif |
| 355 | |
Damien George | f2040bf | 2021-10-22 22:22:47 +1100 | [diff] [blame] | 356 | // Whether bytecode uses a qstr_table to map internal qstr indices in the bytecode |
| 357 | // to global qstr values in the runtime (behaviour when feature is enabled), or |
| 358 | // just stores global qstr values directly in the bytecode. This must be enabled |
| 359 | // if MICROPY_PERSISTENT_CODE is enabled. |
| 360 | #ifndef MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE |
| 361 | #define MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE (MICROPY_PERSISTENT_CODE) |
| 362 | #endif |
| 363 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 364 | // Whether to emit x64 native code |
| 365 | #ifndef MICROPY_EMIT_X64 |
| 366 | #define MICROPY_EMIT_X64 (0) |
| 367 | #endif |
| 368 | |
Damien George | c90f59e | 2014-09-06 23:06:36 +0100 | [diff] [blame] | 369 | // Whether to emit x86 native code |
| 370 | #ifndef MICROPY_EMIT_X86 |
| 371 | #define MICROPY_EMIT_X86 (0) |
| 372 | #endif |
| 373 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 374 | // Whether to emit thumb native code |
| 375 | #ifndef MICROPY_EMIT_THUMB |
| 376 | #define MICROPY_EMIT_THUMB (0) |
| 377 | #endif |
| 378 | |
graham sanderson | 40d2010 | 2020-12-12 13:04:10 -0600 | [diff] [blame] | 379 | // Whether to emit ARMv7-M instruction support in thumb native code |
| 380 | #ifndef MICROPY_EMIT_THUMB_ARMV7M |
| 381 | #define MICROPY_EMIT_THUMB_ARMV7M (1) |
| 382 | #endif |
| 383 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 384 | // Whether to enable the thumb inline assembler |
| 385 | #ifndef MICROPY_EMIT_INLINE_THUMB |
| 386 | #define MICROPY_EMIT_INLINE_THUMB (0) |
| 387 | #endif |
| 388 | |
= | 5008972 | 2015-04-14 13:14:57 +0100 | [diff] [blame] | 389 | // Whether to enable float support in the Thumb2 inline assembler |
| 390 | #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT |
| 391 | #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1) |
| 392 | #endif |
| 393 | |
Fabian Vogt | fe3d16e | 2014-08-16 22:55:53 +0200 | [diff] [blame] | 394 | // Whether to emit ARM native code |
| 395 | #ifndef MICROPY_EMIT_ARM |
| 396 | #define MICROPY_EMIT_ARM (0) |
| 397 | #endif |
| 398 | |
Damien George | 8e5aced | 2016-12-09 16:39:39 +1100 | [diff] [blame] | 399 | // Whether to emit Xtensa native code |
| 400 | #ifndef MICROPY_EMIT_XTENSA |
| 401 | #define MICROPY_EMIT_XTENSA (0) |
| 402 | #endif |
| 403 | |
Damien George | f76b1bf | 2016-12-09 17:03:33 +1100 | [diff] [blame] | 404 | // Whether to enable the Xtensa inline assembler |
| 405 | #ifndef MICROPY_EMIT_INLINE_XTENSA |
| 406 | #define MICROPY_EMIT_INLINE_XTENSA (0) |
| 407 | #endif |
| 408 | |
Alessandro Gatti | 1006ed6 | 2025-01-25 09:33:41 +0100 | [diff] [blame] | 409 | // Whether to support uncommon Xtensa inline assembler opcodes |
| 410 | #ifndef MICROPY_EMIT_INLINE_XTENSA_UNCOMMON_OPCODES |
| 411 | #define MICROPY_EMIT_INLINE_XTENSA_UNCOMMON_OPCODES (0) |
| 412 | #endif |
| 413 | |
Damien George | 9adedce | 2019-09-13 13:15:12 +1000 | [diff] [blame] | 414 | // Whether to emit Xtensa-Windowed native code |
| 415 | #ifndef MICROPY_EMIT_XTENSAWIN |
| 416 | #define MICROPY_EMIT_XTENSAWIN (0) |
| 417 | #endif |
| 418 | |
Alessandro Gatti | 8338f66 | 2024-06-08 11:00:08 +0200 | [diff] [blame] | 419 | // Whether to emit RISC-V RV32 native code |
| 420 | #ifndef MICROPY_EMIT_RV32 |
| 421 | #define MICROPY_EMIT_RV32 (0) |
| 422 | #endif |
| 423 | |
Alessandro Gatti | 268acb7 | 2024-08-25 16:28:35 +0200 | [diff] [blame] | 424 | // Whether to enable the RISC-V RV32 inline assembler |
| 425 | #ifndef MICROPY_EMIT_INLINE_RV32 |
| 426 | #define MICROPY_EMIT_INLINE_RV32 (0) |
| 427 | #endif |
| 428 | |
Alessandro Gatti | 2ab06b6 | 2025-06-26 21:56:26 +0200 | [diff] [blame] | 429 | // Whether to enable the human-readable native instructions emitter |
| 430 | #ifndef MICROPY_EMIT_NATIVE_DEBUG |
| 431 | #define MICROPY_EMIT_NATIVE_DEBUG (0) |
| 432 | #endif |
| 433 | |
Damien George | 2ac4af6 | 2014-08-15 16:45:41 +0100 | [diff] [blame] | 434 | // Convenience definition for whether any native emitter is enabled |
Damien George | 9dbc787 | 2024-03-07 11:38:27 +1100 | [diff] [blame] | 435 | #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN || MICROPY_EMIT_RV32 || MICROPY_EMIT_NATIVE_DEBUG) |
Damien George | 9adedce | 2019-09-13 13:15:12 +1000 | [diff] [blame] | 436 | |
Damien George | 1fb01bd | 2022-05-10 13:56:24 +1000 | [diff] [blame] | 437 | // Some architectures cannot read byte-wise from executable memory. In this case |
| 438 | // the prelude for a native function (which usually sits after the machine code) |
| 439 | // must be separated and placed somewhere where it can be read byte-wise. |
| 440 | #define MICROPY_EMIT_NATIVE_PRELUDE_SEPARATE_FROM_MACHINE_CODE (MICROPY_EMIT_XTENSAWIN) |
Damien George | 2ac4af6 | 2014-08-15 16:45:41 +0100 | [diff] [blame] | 441 | |
Damien George | ad297a1 | 2016-12-09 13:17:49 +1100 | [diff] [blame] | 442 | // Convenience definition for whether any inline assembler emitter is enabled |
Alessandro Gatti | 268acb7 | 2024-08-25 16:28:35 +0200 | [diff] [blame] | 443 | #define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA || MICROPY_EMIT_INLINE_RV32) |
Damien George | ad297a1 | 2016-12-09 13:17:49 +1100 | [diff] [blame] | 444 | |
Jun Wu | b152bbd | 2019-05-06 00:31:11 -0700 | [diff] [blame] | 445 | // Convenience definition for whether any native or inline assembler emitter is enabled |
| 446 | #define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM) |
| 447 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 448 | /*****************************************************************************/ |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 449 | /* Compiler configuration */ |
| 450 | |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 451 | // Whether to include the compiler |
| 452 | #ifndef MICROPY_ENABLE_COMPILER |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 453 | #define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 454 | #endif |
| 455 | |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 456 | // Whether the compiler is dynamically configurable (ie at runtime) |
Damien George | a4f1d82 | 2019-05-29 21:17:29 +1000 | [diff] [blame] | 457 | // This will disable the ability to execute native/viper code |
Damien George | ea23520 | 2016-02-11 22:30:53 +0000 | [diff] [blame] | 458 | #ifndef MICROPY_DYNAMIC_COMPILER |
| 459 | #define MICROPY_DYNAMIC_COMPILER (0) |
| 460 | #endif |
| 461 | |
Damien George | 2b8e88c | 2023-06-24 17:02:58 +1000 | [diff] [blame] | 462 | // Whether the compiler allows compiling top-level await expressions |
| 463 | #ifndef MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT |
| 464 | #define MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT (0) |
| 465 | #endif |
| 466 | |
Damien George | 64f2b21 | 2015-10-08 14:58:15 +0100 | [diff] [blame] | 467 | // Whether to enable constant folding; eg 1+2 rewritten as 3 |
| 468 | #ifndef MICROPY_COMP_CONST_FOLDING |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 469 | #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] | 470 | #endif |
| 471 | |
Damien George | 35c0cff | 2022-03-31 14:27:47 +1100 | [diff] [blame] | 472 | // Whether to compile constant tuples immediately to their respective objects; eg (1, True) |
| 473 | // Otherwise the tuple will be built at runtime |
| 474 | #ifndef MICROPY_COMP_CONST_TUPLE |
| 475 | #define MICROPY_COMP_CONST_TUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
| 476 | #endif |
| 477 | |
Damien George | 0779693 | 2019-02-27 00:10:04 +1100 | [diff] [blame] | 478 | // Whether to enable optimisations for constant literals, eg OrderedDict |
| 479 | #ifndef MICROPY_COMP_CONST_LITERAL |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 480 | #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] | 481 | #endif |
| 482 | |
Damien George | ddd1e18 | 2015-01-10 14:07:24 +0000 | [diff] [blame] | 483 | // Whether to enable lookup of constants in modules; eg module.CONST |
| 484 | #ifndef MICROPY_COMP_MODULE_CONST |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 485 | #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] | 486 | #endif |
| 487 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 488 | // Whether to enable constant optimisation; id = const(value) |
| 489 | #ifndef MICROPY_COMP_CONST |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 490 | #define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 491 | #endif |
| 492 | |
Yoctopuce dev | 69ead7d | 2025-01-28 00:26:08 +0100 | [diff] [blame] | 493 | // Whether to enable float constant folding like 1.2+3.4 (when MICROPY_COMP_CONST_FOLDING is also enabled) |
| 494 | // and constant optimisation like id = const(1.2) (when MICROPY_COMP_CONST is also enabled) |
| 495 | // and constant lookup like math.inf (when MICROPY_COMP_MODULE_CONST is also enabled) |
| 496 | #ifndef MICROPY_COMP_CONST_FLOAT |
| 497 | #define MICROPY_COMP_CONST_FLOAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
| 498 | #endif |
| 499 | |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 500 | // Whether to enable optimisation of: a, b = c, d |
| 501 | // Costs 124 bytes (Thumb2) |
| 502 | #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 503 | #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] | 504 | #endif |
| 505 | |
| 506 | // Whether to enable optimisation of: a, b, c = d, e, f |
Damien George | 253f2bd | 2018-02-04 13:35:21 +1100 | [diff] [blame] | 507 | // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2) |
Damien George | 42e0c59 | 2015-03-14 13:11:35 +0000 | [diff] [blame] | 508 | #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 509 | #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] | 510 | #endif |
| 511 | |
Damien George | ae54fbf | 2017-04-22 14:58:01 +1000 | [diff] [blame] | 512 | // Whether to enable optimisation of: return a if b else c |
| 513 | // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use |
| 514 | #ifndef MICROPY_COMP_RETURN_IF_EXPR |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 515 | #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] | 516 | #endif |
| 517 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 518 | /*****************************************************************************/ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 519 | /* Internal debugging stuff */ |
| 520 | |
| 521 | // Whether to collect memory allocation stats |
| 522 | #ifndef MICROPY_MEM_STATS |
| 523 | #define MICROPY_MEM_STATS (0) |
| 524 | #endif |
| 525 | |
Damien George | da2d2b6 | 2018-08-02 14:04:44 +1000 | [diff] [blame] | 526 | // The mp_print_t printer used for debugging output |
| 527 | #ifndef MICROPY_DEBUG_PRINTER |
| 528 | #define MICROPY_DEBUG_PRINTER (&mp_plat_print) |
| 529 | #endif |
| 530 | |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 531 | // Whether to build functions that print debugging info: |
Damien George | 3417bc2 | 2014-05-10 10:36:38 +0100 | [diff] [blame] | 532 | // mp_bytecode_print |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 533 | // mp_parse_node_print |
| 534 | #ifndef MICROPY_DEBUG_PRINTERS |
| 535 | #define MICROPY_DEBUG_PRINTERS (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 536 | #endif |
| 537 | |
Stefan Naumann | ace9fb5 | 2017-07-24 18:55:14 +0200 | [diff] [blame] | 538 | // Whether to enable all debugging outputs (it will be extremely verbose) |
| 539 | #ifndef MICROPY_DEBUG_VERBOSE |
| 540 | #define MICROPY_DEBUG_VERBOSE (0) |
| 541 | #endif |
| 542 | |
Damien George | 02cc288 | 2019-03-08 15:48:20 +1100 | [diff] [blame] | 543 | // Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL |
| 544 | #ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS |
| 545 | #define MICROPY_DEBUG_MP_OBJ_SENTINELS (0) |
| 546 | #endif |
| 547 | |
Damien George | 843dcd4 | 2020-09-30 23:34:42 +1000 | [diff] [blame] | 548 | // Whether to print parse rule names (rather than integers) in mp_parse_node_print |
| 549 | #ifndef MICROPY_DEBUG_PARSE_RULE_NAME |
| 550 | #define MICROPY_DEBUG_PARSE_RULE_NAME (0) |
| 551 | #endif |
| 552 | |
Damien George | 6d19934 | 2019-01-04 17:09:41 +1100 | [diff] [blame] | 553 | // Whether to enable a simple VM stack overflow check |
| 554 | #ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW |
| 555 | #define MICROPY_DEBUG_VM_STACK_OVERFLOW (0) |
| 556 | #endif |
| 557 | |
Jeff Epler | 8407159 | 2021-08-27 09:02:03 -0500 | [diff] [blame] | 558 | // Whether to enable extra instrumentation for valgrind |
| 559 | #ifndef MICROPY_DEBUG_VALGRIND |
| 560 | #define MICROPY_DEBUG_VALGRIND (0) |
| 561 | #endif |
| 562 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 563 | /*****************************************************************************/ |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 564 | /* Optimisations */ |
| 565 | |
| 566 | // Whether to use computed gotos in the VM, or a switch |
Jim Mussared | b51e7e9 | 2021-08-19 17:49:33 +1000 | [diff] [blame] | 567 | // Computed gotos are roughly 10% faster, and increase VM code size by a little, |
| 568 | // e.g. ~1kiB on Cortex M4. |
Damien George | 44f0a4d | 2017-09-18 23:53:33 +1000 | [diff] [blame] | 569 | // Note: enabling this will use the gcc-specific extensions of ranged designated |
| 570 | // 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] | 571 | #ifndef MICROPY_OPT_COMPUTED_GOTO |
| 572 | #define MICROPY_OPT_COMPUTED_GOTO (0) |
| 573 | #endif |
| 574 | |
Jim Mussared | 7b89ad8 | 2021-08-19 22:46:40 +1000 | [diff] [blame] | 575 | // Optimise the fast path for loading attributes from instance types. Increases |
| 576 | // Thumb2 code size by about 48 bytes. |
| 577 | #ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 578 | #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] | 579 | #endif |
| 580 | |
Jim Mussared | 11ef8f2 | 2021-08-18 14:52:48 +1000 | [diff] [blame] | 581 | // Use extra RAM to cache map lookups by remembering the likely location of |
| 582 | // the index. Avoids the hash computation on unordered maps, and avoids the |
| 583 | // linear search on ordered (especially in-ROM) maps. Can provide a +10-15% |
| 584 | // performance improvement on benchmarks involving lots of attribute access |
| 585 | // or dictionary lookup. |
| 586 | #ifndef MICROPY_OPT_MAP_LOOKUP_CACHE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 587 | #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] | 588 | #endif |
| 589 | |
| 590 | // How much RAM (in bytes) to use for the map lookup cache. |
| 591 | #ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE |
| 592 | #define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128) |
| 593 | #endif |
| 594 | |
Doug Currie | 2e2e15c | 2016-01-30 22:35:58 -0500 | [diff] [blame] | 595 | // Whether to use fast versions of bitwise operations (and, or, xor) when the |
| 596 | // arguments are both positive. Increases Thumb2 code size by about 250 bytes. |
| 597 | #ifndef MICROPY_OPT_MPZ_BITWISE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 598 | #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] | 599 | #endif |
| 600 | |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 601 | |
| 602 | // Whether math.factorial is large, fast and recursive (1) or small and slow (0). |
| 603 | #ifndef MICROPY_OPT_MATH_FACTORIAL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 604 | #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] | 605 | #endif |
| 606 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 607 | /*****************************************************************************/ |
| 608 | /* Python internal features */ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 609 | |
J. Neuschäfer | 7b050b3 | 2023-04-02 19:58:42 +0200 | [diff] [blame] | 610 | // Use a special long jump in nlrthumb.c, which may be necessary if nlr.o and |
| 611 | // nlrthumb.o are linked far apart from each other. |
| 612 | #ifndef MICROPY_NLR_THUMB_USE_LONG_JUMP |
| 613 | #define MICROPY_NLR_THUMB_USE_LONG_JUMP (0) |
| 614 | #endif |
| 615 | |
Damien George | 2099368 | 2018-02-20 18:00:44 +1100 | [diff] [blame] | 616 | // Whether to enable import of external modules |
| 617 | // When disabled, only importing of built-in modules is supported |
| 618 | // When enabled, a port must implement mp_import_stat (among other things) |
| 619 | #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 620 | #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] | 621 | #endif |
| 622 | |
Damien George | 6b239c2 | 2016-11-16 16:04:57 +1100 | [diff] [blame] | 623 | // Whether to use the POSIX reader for importing files |
| 624 | #ifndef MICROPY_READER_POSIX |
| 625 | #define MICROPY_READER_POSIX (0) |
| 626 | #endif |
| 627 | |
Damien George | dcb9ea7 | 2017-01-27 15:10:09 +1100 | [diff] [blame] | 628 | // Whether to use the VFS reader for importing files |
| 629 | #ifndef MICROPY_READER_VFS |
| 630 | #define MICROPY_READER_VFS (0) |
| 631 | #endif |
| 632 | |
Sean Burton | e33bc59 | 2018-12-13 12:10:35 +0000 | [diff] [blame] | 633 | // Whether any readers have been defined |
| 634 | #ifndef MICROPY_HAS_FILE_READER |
| 635 | #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS) |
| 636 | #endif |
| 637 | |
Damien George | 40d8430 | 2016-02-15 22:46:21 +0000 | [diff] [blame] | 638 | // Hook for the VM at the start of the opcode loop (can contain variable |
| 639 | // definitions usable by the other hook functions) |
| 640 | #ifndef MICROPY_VM_HOOK_INIT |
| 641 | #define MICROPY_VM_HOOK_INIT |
| 642 | #endif |
| 643 | |
| 644 | // Hook for the VM during the opcode loop (but only after jump opcodes) |
| 645 | #ifndef MICROPY_VM_HOOK_LOOP |
| 646 | #define MICROPY_VM_HOOK_LOOP |
| 647 | #endif |
| 648 | |
| 649 | // Hook for the VM just before return opcode is finished being interpreted |
| 650 | #ifndef MICROPY_VM_HOOK_RETURN |
| 651 | #define MICROPY_VM_HOOK_RETURN |
| 652 | #endif |
| 653 | |
Damien George | 916c3fd | 2021-04-25 22:24:49 +1000 | [diff] [blame] | 654 | // Hook for mp_sched_schedule when a function gets scheduled on sched_queue |
| 655 | // (this macro executes within an atomic section) |
| 656 | #ifndef MICROPY_SCHED_HOOK_SCHEDULED |
| 657 | #define MICROPY_SCHED_HOOK_SCHEDULED |
| 658 | #endif |
| 659 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 660 | // Whether to include the garbage collector |
| 661 | #ifndef MICROPY_ENABLE_GC |
| 662 | #define MICROPY_ENABLE_GC (0) |
| 663 | #endif |
| 664 | |
Ayke van Laethem | bcc827d | 2018-01-24 02:09:58 +0100 | [diff] [blame] | 665 | // Whether the garbage-collected heap can be split over multiple memory areas. |
| 666 | #ifndef MICROPY_GC_SPLIT_HEAP |
| 667 | #define MICROPY_GC_SPLIT_HEAP (0) |
| 668 | #endif |
| 669 | |
Angus Gratton | 519c24d | 2023-08-02 16:49:44 +1000 | [diff] [blame] | 670 | // Whether regions should be added/removed from the split heap as needed. |
| 671 | #ifndef MICROPY_GC_SPLIT_HEAP_AUTO |
| 672 | #define MICROPY_GC_SPLIT_HEAP_AUTO (0) |
| 673 | #endif |
| 674 | |
Laurens Valk | fe12048 | 2021-10-26 10:47:04 +0200 | [diff] [blame] | 675 | // Hook to run code during time consuming garbage collector operations |
David Lechner | 468ed21 | 2023-03-15 16:48:16 -0500 | [diff] [blame] | 676 | // *i* is the loop index variable (e.g. can be used to run every x loops) |
Laurens Valk | fe12048 | 2021-10-26 10:47:04 +0200 | [diff] [blame] | 677 | #ifndef MICROPY_GC_HOOK_LOOP |
David Lechner | 468ed21 | 2023-03-15 16:48:16 -0500 | [diff] [blame] | 678 | #define MICROPY_GC_HOOK_LOOP(i) |
Laurens Valk | fe12048 | 2021-10-26 10:47:04 +0200 | [diff] [blame] | 679 | #endif |
| 680 | |
Damien George | fca5701 | 2022-05-04 12:12:11 +1000 | [diff] [blame] | 681 | // Whether to provide m_tracked_calloc, m_tracked_free functions |
| 682 | #ifndef MICROPY_TRACKED_ALLOC |
| 683 | #define MICROPY_TRACKED_ALLOC (0) |
| 684 | #endif |
| 685 | |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 686 | // Whether to enable finalisers in the garbage collector (ie call __del__) |
Damien George | 7860c2a | 2014-11-05 21:16:41 +0000 | [diff] [blame] | 687 | #ifndef MICROPY_ENABLE_FINALISER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 688 | #define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 689 | #endif |
| 690 | |
Damien George | 02d830c | 2017-11-26 23:28:40 +1100 | [diff] [blame] | 691 | // Whether to enable a separate allocator for the Python stack. |
| 692 | // If enabled then the code must call mp_pystack_init before mp_init. |
| 693 | #ifndef MICROPY_ENABLE_PYSTACK |
| 694 | #define MICROPY_ENABLE_PYSTACK (0) |
| 695 | #endif |
| 696 | |
| 697 | // Number of bytes that memory returned by mp_pystack_alloc will be aligned by. |
| 698 | #ifndef MICROPY_PYSTACK_ALIGN |
| 699 | #define MICROPY_PYSTACK_ALIGN (8) |
| 700 | #endif |
| 701 | |
Paul Sokolovsky | 2366869 | 2014-06-25 03:03:34 +0300 | [diff] [blame] | 702 | // Whether to check C stack usage. C stack used for calling Python functions, |
| 703 | // etc. Not checking means segfault on overflow. |
| 704 | #ifndef MICROPY_STACK_CHECK |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 705 | #define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 2366869 | 2014-06-25 03:03:34 +0300 | [diff] [blame] | 706 | #endif |
| 707 | |
Angus Gratton | 86f2c28 | 2024-08-06 15:51:22 +1000 | [diff] [blame] | 708 | // Additional margin between the places in the runtime where Python stack is |
| 709 | // checked and the actual end of the C stack. Needs to be large enough to avoid |
| 710 | // overflows from function calls made between checks. |
| 711 | #ifndef MICROPY_STACK_CHECK_MARGIN |
| 712 | #define MICROPY_STACK_CHECK_MARGIN (0) |
| 713 | #endif |
| 714 | |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 715 | // Whether to have an emergency exception buffer |
| 716 | #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
| 717 | #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) |
| 718 | #endif |
| 719 | #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 720 | #ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE |
| 721 | #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation |
| 722 | #endif |
Dave Hylands | 5b7fd20 | 2014-07-01 23:46:53 -0700 | [diff] [blame] | 723 | #endif |
| 724 | |
Damien George | bbb4b98 | 2017-04-10 17:19:36 +1000 | [diff] [blame] | 725 | // 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] | 726 | #ifndef MICROPY_KBD_EXCEPTION |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 727 | #define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 7f1da0a | 2016-12-15 13:00:19 +1100 | [diff] [blame] | 728 | #endif |
| 729 | |
Paul Sokolovsky | 1c9210b | 2015-12-23 00:06:37 +0200 | [diff] [blame] | 730 | // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt |
| 731 | // handler) - if supported by a particular port. |
| 732 | #ifndef MICROPY_ASYNC_KBD_INTR |
| 733 | #define MICROPY_ASYNC_KBD_INTR (0) |
| 734 | #endif |
| 735 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 736 | // Whether to include REPL helper function |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 737 | #ifndef MICROPY_HELPER_REPL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 738 | #define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 739 | #endif |
| 740 | |
Yonatan Goldschmidt | 61d2b40 | 2019-12-25 09:27:38 +0200 | [diff] [blame] | 741 | // Allow enabling debug prints after each REPL line |
| 742 | #ifndef MICROPY_REPL_INFO |
Damien George | c62351f | 2021-11-01 15:18:22 +1100 | [diff] [blame] | 743 | #define MICROPY_REPL_INFO (0) |
Yonatan Goldschmidt | 61d2b40 | 2019-12-25 09:27:38 +0200 | [diff] [blame] | 744 | #endif |
| 745 | |
Tom Soulanille | 7d588b0 | 2015-07-09 16:32:36 -0700 | [diff] [blame] | 746 | // Whether to include emacs-style readline behavior in REPL |
| 747 | #ifndef MICROPY_REPL_EMACS_KEYS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 748 | #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] | 749 | #endif |
| 750 | |
Yonatan Goldschmidt | 853aaa0 | 2019-12-14 23:42:03 +0200 | [diff] [blame] | 751 | // Whether to include emacs-style word movement/kill readline behavior in REPL. |
| 752 | // This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word |
| 753 | // and backward-kill-word, respectively. |
| 754 | #ifndef MICROPY_REPL_EMACS_WORDS_MOVE |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 755 | #define MICROPY_REPL_EMACS_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Yonatan Goldschmidt | 853aaa0 | 2019-12-14 23:42:03 +0200 | [diff] [blame] | 756 | #endif |
| 757 | |
| 758 | // Whether to include extra convenience keys for word movement/kill in readline REPL. |
| 759 | // This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word |
| 760 | // respectively. Ctrl+Delete is not implemented because it's a very different escape sequence. |
| 761 | // Depends on MICROPY_REPL_EMACS_WORDS_MOVE. |
| 762 | #ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 763 | #define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Yonatan Goldschmidt | 853aaa0 | 2019-12-14 23:42:03 +0200 | [diff] [blame] | 764 | #endif |
| 765 | |
Damien George | 0af7301 | 2015-08-20 10:34:16 +0100 | [diff] [blame] | 766 | // Whether to implement auto-indent in REPL |
| 767 | #ifndef MICROPY_REPL_AUTO_INDENT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 768 | #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] | 769 | #endif |
| 770 | |
Paul Sokolovsky | 87bc8e2 | 2015-01-15 10:46:27 +0200 | [diff] [blame] | 771 | // Whether port requires event-driven REPL functions |
| 772 | #ifndef MICROPY_REPL_EVENT_DRIVEN |
| 773 | #define MICROPY_REPL_EVENT_DRIVEN (0) |
| 774 | #endif |
| 775 | |
David Lechner | 81dbea1 | 2022-07-01 14:06:10 -0500 | [diff] [blame] | 776 | // The number of items to keep in the readline history. |
| 777 | #ifndef MICROPY_READLINE_HISTORY_SIZE |
| 778 | #define MICROPY_READLINE_HISTORY_SIZE (8) |
| 779 | #endif |
| 780 | |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 781 | // Whether to include lexer helper function for unix |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 782 | #ifndef MICROPY_HELPER_LEXER_UNIX |
| 783 | #define MICROPY_HELPER_LEXER_UNIX (0) |
Damien George | d3ebe48 | 2014-01-07 15:20:33 +0000 | [diff] [blame] | 784 | #endif |
| 785 | |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 786 | // Long int implementation |
| 787 | #define MICROPY_LONGINT_IMPL_NONE (0) |
| 788 | #define MICROPY_LONGINT_IMPL_LONGLONG (1) |
Damien George | 438c88d | 2014-02-22 19:25:23 +0000 | [diff] [blame] | 789 | #define MICROPY_LONGINT_IMPL_MPZ (2) |
Paul Sokolovsky | 48b3572 | 2014-01-12 17:30:48 +0200 | [diff] [blame] | 790 | |
| 791 | #ifndef MICROPY_LONGINT_IMPL |
| 792 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) |
| 793 | #endif |
| 794 | |
| 795 | #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |
| 796 | typedef long long mp_longint_impl_t; |
| 797 | #endif |
| 798 | |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 799 | // Whether to include information in the byte code to determine source |
| 800 | // line number (increases RAM usage, but doesn't slow byte code execution) |
| 801 | #ifndef MICROPY_ENABLE_SOURCE_LINE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 802 | #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] | 803 | #endif |
| 804 | |
Damien George | 1463c1f | 2014-04-25 23:52:57 +0100 | [diff] [blame] | 805 | // Whether to include doc strings (increases RAM usage) |
| 806 | #ifndef MICROPY_ENABLE_DOC_STRING |
| 807 | #define MICROPY_ENABLE_DOC_STRING (0) |
| 808 | #endif |
| 809 | |
Damien George | d4b706c | 2021-04-22 12:13:58 +1000 | [diff] [blame] | 810 | // Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION) |
| 811 | #define MICROPY_ERROR_REPORTING_NONE (0) |
Damien George | 1e9a92f | 2014-11-06 17:36:16 +0000 | [diff] [blame] | 812 | // Exception messages are short static strings |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 813 | #define MICROPY_ERROR_REPORTING_TERSE (1) |
| 814 | // Exception messages provide basic error details |
| 815 | #define MICROPY_ERROR_REPORTING_NORMAL (2) |
| 816 | // Exception messages provide full info, e.g. object names |
| 817 | #define MICROPY_ERROR_REPORTING_DETAILED (3) |
| 818 | |
| 819 | #ifndef MICROPY_ERROR_REPORTING |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 820 | #if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES |
| 821 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) |
| 822 | #elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 823 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 824 | #else |
| 825 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) |
| 826 | #endif |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 827 | #endif |
| 828 | |
Paul Sokolovsky | 8a8c1fc | 2015-01-01 09:29:28 +0200 | [diff] [blame] | 829 | // Whether issue warnings during compiling/execution |
| 830 | #ifndef MICROPY_WARNINGS |
| 831 | #define MICROPY_WARNINGS (0) |
| 832 | #endif |
| 833 | |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 834 | // Whether to support warning categories |
| 835 | #ifndef MICROPY_WARNINGS_CATEGORY |
| 836 | #define MICROPY_WARNINGS_CATEGORY (0) |
| 837 | #endif |
| 838 | |
David Lechner | 62849b7 | 2017-09-24 20:15:48 -0500 | [diff] [blame] | 839 | // This macro is used when printing runtime warnings and errors |
| 840 | #ifndef MICROPY_ERROR_PRINTER |
| 841 | #define MICROPY_ERROR_PRINTER (&mp_plat_print) |
| 842 | #endif |
| 843 | |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 844 | // Float and complex implementation |
| 845 | #define MICROPY_FLOAT_IMPL_NONE (0) |
| 846 | #define MICROPY_FLOAT_IMPL_FLOAT (1) |
| 847 | #define MICROPY_FLOAT_IMPL_DOUBLE (2) |
| 848 | |
| 849 | #ifndef MICROPY_FLOAT_IMPL |
| 850 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) |
| 851 | #endif |
| 852 | |
| 853 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 854 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
Damien George | 561844f | 2016-11-03 12:33:01 +1100 | [diff] [blame] | 855 | #define MICROPY_FLOAT_CONST(x) x##F |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 856 | #define MICROPY_FLOAT_C_FUN(fun) fun##f |
| 857 | typedef float mp_float_t; |
| 858 | #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 859 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
Damien George | 561844f | 2016-11-03 12:33:01 +1100 | [diff] [blame] | 860 | #define MICROPY_FLOAT_CONST(x) x |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 861 | #define MICROPY_FLOAT_C_FUN(fun) fun |
| 862 | typedef double mp_float_t; |
| 863 | #else |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 864 | #define MICROPY_PY_BUILTINS_FLOAT (0) |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 865 | #endif |
| 866 | |
Paul Sokolovsky | 3b6f7b9 | 2014-06-20 01:48:35 +0300 | [diff] [blame] | 867 | #ifndef MICROPY_PY_BUILTINS_COMPLEX |
| 868 | #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) |
| 869 | #endif |
| 870 | |
Yoctopuce dev | dbbaa95 | 2025-06-06 14:55:21 +0200 | [diff] [blame] | 871 | // Float to string conversion implementations |
| 872 | // |
| 873 | // Note that the EXACT method is only available if the compiler supports |
| 874 | // floating points larger than mp_float_t: |
| 875 | // - with MICROPY_FLOAT_IMPL_FLOAT, the compiler needs to support `double` |
| 876 | // - with MICROPY_FLOAT_IMPL_DOUBLE, the compiler needs to support `long double` |
| 877 | // |
| 878 | #define MICROPY_FLOAT_FORMAT_IMPL_BASIC (0) // smallest code, but inexact |
| 879 | #define MICROPY_FLOAT_FORMAT_IMPL_APPROX (1) // slightly bigger, almost perfect |
| 880 | #define MICROPY_FLOAT_FORMAT_IMPL_EXACT (2) // bigger code, and 100% exact repr |
| 881 | |
| 882 | #ifndef MICROPY_FLOAT_FORMAT_IMPL |
| 883 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
| 884 | #define MICROPY_FLOAT_FORMAT_IMPL (MICROPY_FLOAT_FORMAT_IMPL_APPROX) |
| 885 | #elif defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ > __SIZEOF_DOUBLE__ |
| 886 | #define MICROPY_FLOAT_FORMAT_IMPL (MICROPY_FLOAT_FORMAT_IMPL_EXACT) |
| 887 | #else |
| 888 | #define MICROPY_FLOAT_FORMAT_IMPL (MICROPY_FLOAT_FORMAT_IMPL_APPROX) |
| 889 | #endif |
| 890 | #endif |
| 891 | |
Matthias Urlichs | e520fa2 | 2023-10-25 19:17:47 +0200 | [diff] [blame] | 892 | // Whether to use the native _Float16 for 16-bit float support |
| 893 | #ifndef MICROPY_FLOAT_USE_NATIVE_FLT16 |
| 894 | #ifdef __FLT16_MAX__ |
| 895 | #define MICROPY_FLOAT_USE_NATIVE_FLT16 (1) |
| 896 | #else |
| 897 | #define MICROPY_FLOAT_USE_NATIVE_FLT16 (0) |
| 898 | #endif |
| 899 | #endif |
| 900 | |
Damien George | a73501b | 2017-04-06 17:27:33 +1000 | [diff] [blame] | 901 | // Whether to provide a high-quality hash for float and complex numbers. |
| 902 | // Otherwise the default is a very simple but correct hashing function. |
| 903 | #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 904 | #define MICROPY_FLOAT_HIGH_QUALITY_HASH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Damien George | a73501b | 2017-04-06 17:27:33 +1000 | [diff] [blame] | 905 | #endif |
| 906 | |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 907 | // Enable features which improve CPython compatibility |
| 908 | // but may lead to more code size/memory usage. |
| 909 | // TODO: Originally intended as generic category to not |
| 910 | // add bunch of once-off options. May need refactoring later |
| 911 | #ifndef MICROPY_CPYTHON_COMPAT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 912 | #define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | dcac880 | 2014-01-16 19:19:50 +0200 | [diff] [blame] | 913 | #endif |
| 914 | |
Paul Sokolovsky | 9a97397 | 2017-04-02 21:20:07 +0300 | [diff] [blame] | 915 | // Perform full checks as done by CPython. Disabling this |
| 916 | // may produce incorrect results, if incorrect data is fed, |
| 917 | // but should not lead to MicroPython crashes or similar |
| 918 | // grave issues (in other words, only user app should be, |
| 919 | // affected, not system). |
| 920 | #ifndef MICROPY_FULL_CHECKS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 921 | #define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | 9a97397 | 2017-04-02 21:20:07 +0300 | [diff] [blame] | 922 | #endif |
| 923 | |
Yoctopuce dev | df05cae | 2025-07-01 13:16:20 +0200 | [diff] [blame] | 924 | // Ports can choose to use timestamps based on 2000-01-01 or 1970-01-01 |
| 925 | // Default is timestamps based on 2000-01-01 |
| 926 | #if !defined(MICROPY_EPOCH_IS_2000) && !defined(MICROPY_EPOCH_IS_1970) |
| 927 | #define MICROPY_EPOCH_IS_2000 (1) |
| 928 | #define MICROPY_EPOCH_IS_1970 (0) |
| 929 | #elif !defined(MICROPY_EPOCH_IS_1970) |
| 930 | #define MICROPY_EPOCH_IS_1970 (1 - (MICROPY_EPOCH_IS_2000)) |
| 931 | #elif !defined(MICROPY_EPOCH_IS_2000) |
| 932 | #define MICROPY_EPOCH_IS_2000 (1 - (MICROPY_EPOCH_IS_1970)) |
| 933 | #endif |
| 934 | |
| 935 | // To maintain reasonable compatibility with CPython on embedded systems, |
| 936 | // and avoid breaking anytime soon, time functions are defined to work |
| 937 | // at least between 1970 and 2099 (included) on any machine. |
| 938 | // |
| 939 | // Specific ports can enable extended date support |
| 940 | // - after 2099 using MICROPY_TIME_SUPPORT_Y2100_AND_BEYOND |
| 941 | // - before 1970 using MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE |
| 942 | // The largest possible range is year 1600 to year 3000 |
| 943 | // |
| 944 | // By default, extended date support is only enabled for machines using 64 bit pointers, |
| 945 | // but it can be enabled by specific ports |
| 946 | #ifndef MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE |
| 947 | #if MP_SSIZE_MAX > 2147483647 |
| 948 | #define MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE (1) |
| 949 | #else |
| 950 | #define MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE (0) |
| 951 | #endif |
| 952 | #endif |
| 953 | |
| 954 | // When support for dates <1970 is enabled, supporting >=2100 does not cost anything |
| 955 | #ifndef MICROPY_TIME_SUPPORT_Y2100_AND_BEYOND |
| 956 | #define MICROPY_TIME_SUPPORT_Y2100_AND_BEYOND (MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE) |
| 957 | #endif |
| 958 | |
| 959 | // The type to be used to represent platform-specific timestamps depends on the choices above |
| 960 | #define MICROPY_TIMESTAMP_IMPL_LONG_LONG (0) |
| 961 | #define MICROPY_TIMESTAMP_IMPL_UINT (1) |
| 962 | #define MICROPY_TIMESTAMP_IMPL_TIME_T (2) |
| 963 | |
| 964 | #ifndef MICROPY_TIMESTAMP_IMPL |
| 965 | #if MICROPY_TIME_SUPPORT_Y2100_AND_BEYOND || MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE || MICROPY_EPOCH_IS_2000 |
| 966 | #define MICROPY_TIMESTAMP_IMPL (MICROPY_TIMESTAMP_IMPL_LONG_LONG) |
| 967 | #else |
| 968 | #define MICROPY_TIMESTAMP_IMPL (MICROPY_TIMESTAMP_IMPL_UINT) |
| 969 | #endif |
| 970 | #endif |
| 971 | |
| 972 | // `mp_timestamp_t` is the type that should be used by the port |
| 973 | // to represent timestamps, and is referenced to the platform epoch |
| 974 | #if MICROPY_TIMESTAMP_IMPL == MICROPY_TIMESTAMP_IMPL_LONG_LONG |
| 975 | typedef long long mp_timestamp_t; |
| 976 | #elif MICROPY_TIMESTAMP_IMPL == MICROPY_TIMESTAMP_IMPL_UINT |
| 977 | typedef mp_uint_t mp_timestamp_t; |
| 978 | #elif MICROPY_TIMESTAMP_IMPL == MICROPY_TIMESTAMP_IMPL_TIME_T |
| 979 | typedef time_t mp_timestamp_t; |
| 980 | #endif |
| 981 | |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 982 | // Whether POSIX-semantics non-blocking streams are supported |
| 983 | #ifndef MICROPY_STREAMS_NON_BLOCK |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 984 | #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] | 985 | #endif |
| 986 | |
Paul Sokolovsky | 61e77a4 | 2016-07-30 20:05:56 +0300 | [diff] [blame] | 987 | // Whether to provide stream functions with POSIX-like signatures |
| 988 | // (useful for porting existing libraries to MicroPython). |
| 989 | #ifndef MICROPY_STREAMS_POSIX_API |
| 990 | #define MICROPY_STREAMS_POSIX_API (0) |
| 991 | #endif |
| 992 | |
Jim Mussared | 13c817e | 2023-06-05 15:52:57 +1000 | [diff] [blame] | 993 | // Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed |
| 994 | // attribute lookups to a custom handler function. |
Damien George | 3356b5e | 2021-07-27 00:38:21 +1000 | [diff] [blame] | 995 | #ifndef MICROPY_MODULE_ATTR_DELEGATION |
Jim Mussared | 7d2ee8a | 2023-06-05 22:38:36 +1000 | [diff] [blame] | 996 | #define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_PY_SYS_ATTR_DELEGATION || MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 3356b5e | 2021-07-27 00:38:21 +1000 | [diff] [blame] | 997 | #endif |
| 998 | |
Jim Mussared | 6a8114e | 2023-05-12 17:07:24 +1000 | [diff] [blame] | 999 | // Whether to call __init__ when importing builtin modules for the first time. |
| 1000 | // Modules using this need to handle the possibility that __init__ might be |
| 1001 | // called multiple times. |
Damien George | 3c9c368 | 2015-09-15 14:56:13 +0100 | [diff] [blame] | 1002 | #ifndef MICROPY_MODULE_BUILTIN_INIT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1003 | #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] | 1004 | #endif |
| 1005 | |
Jim Mussared | ed90f30 | 2023-05-10 13:22:54 +1000 | [diff] [blame] | 1006 | // Whether to allow built-in modules to have sub-packages (by making the |
| 1007 | // sub-package a member of their locals dict). Sub-packages should not be |
| 1008 | // registered with MP_REGISTER_MODULE, instead they should be added as |
| 1009 | // members of the parent's globals dict. To match CPython behavior, |
| 1010 | // their __name__ should be "foo.bar"(i.e. QSTR_foo_dot_bar) which will |
| 1011 | // require an entry in qstrdefs, although it does also work to just call |
| 1012 | // it "bar". Also, because subpackages can be accessed without being |
| 1013 | // imported (e.g. as foo.bar after `import foo`), they should not |
| 1014 | // have __init__ methods. Instead, the top-level package's __init__ should |
| 1015 | // initialise all sub-packages. |
| 1016 | #ifndef MICROPY_MODULE_BUILTIN_SUBPACKAGES |
| 1017 | #define MICROPY_MODULE_BUILTIN_SUBPACKAGES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
| 1018 | #endif |
| 1019 | |
Paul m. p. P | 454cca6 | 2018-10-22 18:34:29 +0200 | [diff] [blame] | 1020 | // Whether to support module-level __getattr__ (see PEP 562) |
| 1021 | #ifndef MICROPY_MODULE_GETATTR |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1022 | #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] | 1023 | #endif |
| 1024 | |
Jim Mussared | a7fa18c | 2020-02-26 15:24:09 +1100 | [diff] [blame] | 1025 | // Whether to enable importing foo.py with __name__ set to '__main__' |
| 1026 | // Used by the unix port for the -m flag. |
| 1027 | #ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT |
| 1028 | #define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0) |
| 1029 | #endif |
| 1030 | |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 1031 | // Whether frozen modules are supported in the form of strings |
| 1032 | #ifndef MICROPY_MODULE_FROZEN_STR |
| 1033 | #define MICROPY_MODULE_FROZEN_STR (0) |
| 1034 | #endif |
| 1035 | |
| 1036 | // Whether frozen modules are supported in the form of .mpy files |
| 1037 | #ifndef MICROPY_MODULE_FROZEN_MPY |
| 1038 | #define MICROPY_MODULE_FROZEN_MPY (0) |
| 1039 | #endif |
| 1040 | |
| 1041 | // Convenience macro for whether frozen modules are supported |
Paul Sokolovsky | 640e0b2 | 2015-01-20 11:52:12 +0200 | [diff] [blame] | 1042 | #ifndef MICROPY_MODULE_FROZEN |
Damien George | 0a2e965 | 2016-01-31 22:24:16 +0000 | [diff] [blame] | 1043 | #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY) |
Paul Sokolovsky | 640e0b2 | 2015-01-20 11:52:12 +0200 | [diff] [blame] | 1044 | #endif |
| 1045 | |
Damien George | 78d702c | 2014-12-09 16:19:48 +0000 | [diff] [blame] | 1046 | // Whether you can override builtins in the builtins module |
| 1047 | #ifndef MICROPY_CAN_OVERRIDE_BUILTINS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1048 | #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] | 1049 | #endif |
| 1050 | |
Damien George | 06593fb | 2015-06-19 12:49:10 +0000 | [diff] [blame] | 1051 | // Whether to check that the "self" argument of a builtin method has the |
| 1052 | // correct type. Such an explicit check is only needed if a builtin |
| 1053 | // method escapes to Python land without a first argument, eg |
| 1054 | // list.append([], 1). Without this check such calls will have undefined |
| 1055 | // behaviour (usually segfault) if the first argument is the wrong type. |
| 1056 | #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1057 | #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] | 1058 | #endif |
| 1059 | |
Damien George | 3f56fd6 | 2016-05-10 10:54:06 +0100 | [diff] [blame] | 1060 | // Whether to use internally defined errno's (otherwise system provided ones) |
| 1061 | #ifndef MICROPY_USE_INTERNAL_ERRNO |
| 1062 | #define MICROPY_USE_INTERNAL_ERRNO (0) |
| 1063 | #endif |
| 1064 | |
Delio Brignoli | e2ac8bb | 2016-08-21 11:33:37 +0200 | [diff] [blame] | 1065 | // Whether to use internally defined *printf() functions (otherwise external ones) |
| 1066 | #ifndef MICROPY_USE_INTERNAL_PRINTF |
| 1067 | #define MICROPY_USE_INTERNAL_PRINTF (1) |
| 1068 | #endif |
| 1069 | |
Damien George | 78dc2db | 2023-03-09 13:56:23 +1100 | [diff] [blame] | 1070 | // The mp_print_t printer used for printf output when MICROPY_USE_INTERNAL_PRINTF is enabled |
| 1071 | #ifndef MICROPY_INTERNAL_PRINTF_PRINTER |
| 1072 | #define MICROPY_INTERNAL_PRINTF_PRINTER (&mp_plat_print) |
| 1073 | #endif |
| 1074 | |
Damien George | d54208a | 2022-12-16 17:31:21 +1100 | [diff] [blame] | 1075 | // Whether to support mp_sched_vm_abort to asynchronously abort to the top level. |
| 1076 | #ifndef MICROPY_ENABLE_VM_ABORT |
| 1077 | #define MICROPY_ENABLE_VM_ABORT (0) |
| 1078 | #endif |
| 1079 | |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 1080 | // Support for internal scheduler |
| 1081 | #ifndef MICROPY_ENABLE_SCHEDULER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1082 | #define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 1083 | #endif |
| 1084 | |
Damien George | 75506e4 | 2022-03-23 17:13:03 +1100 | [diff] [blame] | 1085 | // Whether the scheduler supports scheduling static nodes with C callbacks |
| 1086 | #ifndef MICROPY_SCHEDULER_STATIC_NODES |
| 1087 | #define MICROPY_SCHEDULER_STATIC_NODES (0) |
| 1088 | #endif |
| 1089 | |
Damien George | 6e74d24 | 2017-02-16 18:05:06 +1100 | [diff] [blame] | 1090 | // Maximum number of entries in the scheduler |
| 1091 | #ifndef MICROPY_SCHEDULER_DEPTH |
| 1092 | #define MICROPY_SCHEDULER_DEPTH (4) |
| 1093 | #endif |
| 1094 | |
Damien George | dcb9ea7 | 2017-01-27 15:10:09 +1100 | [diff] [blame] | 1095 | // Support for generic VFS sub-system |
| 1096 | #ifndef MICROPY_VFS |
| 1097 | #define MICROPY_VFS (0) |
| 1098 | #endif |
| 1099 | |
Damien George | 8b6bd43 | 2024-11-15 11:16:04 +1100 | [diff] [blame] | 1100 | // Whether to include support for writable filesystems. |
| 1101 | #ifndef MICROPY_VFS_WRITABLE |
| 1102 | #define MICROPY_VFS_WRITABLE (1) |
| 1103 | #endif |
| 1104 | |
Damien George | 89e6c58 | 2024-11-15 12:57:34 +1100 | [diff] [blame] | 1105 | // Whether to enable the mp_vfs_rom_ioctl C function, and vfs.rom_ioctl Python function |
| 1106 | #ifndef MICROPY_VFS_ROM_IOCTL |
| 1107 | #define MICROPY_VFS_ROM_IOCTL (MICROPY_VFS_ROM) |
| 1108 | #endif |
| 1109 | |
Damien George | 8d82b0e | 2018-06-06 13:11:33 +1000 | [diff] [blame] | 1110 | // Support for VFS POSIX component, to mount a POSIX filesystem within VFS |
Jim Mussared | 89a0fef | 2022-09-13 14:57:24 +1000 | [diff] [blame] | 1111 | #ifndef MICROPY_VFS_POSIX |
Damien George | 8d82b0e | 2018-06-06 13:11:33 +1000 | [diff] [blame] | 1112 | #define MICROPY_VFS_POSIX (0) |
| 1113 | #endif |
| 1114 | |
Jeff Epler | 59ee599 | 2025-07-19 06:38:18 -0500 | [diff] [blame] | 1115 | // Whether to include support for writable POSIX filesystems. |
| 1116 | #ifndef MICROPY_VFS_POSIX_WRITABLE |
| 1117 | #define MICROPY_VFS_POSIX_WRITABLE (1) |
| 1118 | #endif |
| 1119 | |
Damien George | a8b9e71 | 2018-06-06 14:31:29 +1000 | [diff] [blame] | 1120 | // Support for VFS FAT component, to mount a FAT filesystem within VFS |
Jim Mussared | 89a0fef | 2022-09-13 14:57:24 +1000 | [diff] [blame] | 1121 | #ifndef MICROPY_VFS_FAT |
Damien George | a8b9e71 | 2018-06-06 14:31:29 +1000 | [diff] [blame] | 1122 | #define MICROPY_VFS_FAT (0) |
| 1123 | #endif |
| 1124 | |
Jim Mussared | 89a0fef | 2022-09-13 14:57:24 +1000 | [diff] [blame] | 1125 | // Support for VFS LittleFS v1 component, to mount a LFSv1 filesystem within VFS |
| 1126 | #ifndef MICROPY_VFS_LFS1 |
| 1127 | #define MICROPY_VFS_LFS1 (0) |
| 1128 | #endif |
| 1129 | |
| 1130 | // Support for VFS LittleFS v2 component, to mount a LFSv2 filesystem within VFS |
| 1131 | #ifndef MICROPY_VFS_LFS2 |
| 1132 | #define MICROPY_VFS_LFS2 (0) |
| 1133 | #endif |
| 1134 | |
Damien George | 50637ff | 2022-03-04 10:52:35 +1100 | [diff] [blame] | 1135 | // Support for ROMFS. |
| 1136 | #ifndef MICROPY_VFS_ROM |
| 1137 | #define MICROPY_VFS_ROM (0) |
| 1138 | #endif |
| 1139 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1140 | /*****************************************************************************/ |
| 1141 | /* Fine control over Python builtins, classes, modules, etc */ |
| 1142 | |
Damien George | da154fd | 2017-04-01 23:52:24 +1100 | [diff] [blame] | 1143 | // Whether to support multiple inheritance of Python classes. Multiple |
| 1144 | // inheritance makes some C functions inherently recursive, and adds a bit of |
| 1145 | // code overhead. |
| 1146 | #ifndef MICROPY_MULTIPLE_INHERITANCE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1147 | #define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | da154fd | 2017-04-01 23:52:24 +1100 | [diff] [blame] | 1148 | #endif |
| 1149 | |
stijn | 3cc17c6 | 2015-02-14 18:44:31 +0100 | [diff] [blame] | 1150 | // Whether to implement attributes on functions |
| 1151 | #ifndef MICROPY_PY_FUNCTION_ATTRS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1152 | #define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | 3cc17c6 | 2015-02-14 18:44:31 +0100 | [diff] [blame] | 1153 | #endif |
| 1154 | |
Damien George | ceb8ba6 | 2025-01-20 22:23:48 +1100 | [diff] [blame] | 1155 | // Whether to implement the __code__ attribute on functions, and function constructor |
| 1156 | #ifndef MICROPY_PY_FUNCTION_ATTRS_CODE |
| 1157 | #define MICROPY_PY_FUNCTION_ATTRS_CODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES) |
| 1158 | #endif |
| 1159 | |
Damien George | 241ee16 | 2025-07-25 00:09:18 +1000 | [diff] [blame] | 1160 | // Whether bound_method can just use == (feature disabled), or requires a call to |
| 1161 | // mp_obj_equal (feature enabled), to test equality of the self and meth entities. |
| 1162 | // This is only needed if objects and functions can be identical without being the |
| 1163 | // same thing, eg when using an object proxy. |
| 1164 | #ifndef MICROPY_PY_BOUND_METHOD_FULL_EQUALITY_CHECK |
| 1165 | #define MICROPY_PY_BOUND_METHOD_FULL_EQUALITY_CHECK (0) |
| 1166 | #endif |
| 1167 | |
Anson Mansfield | d5dc554 | 2025-07-21 08:33:17 -0400 | [diff] [blame] | 1168 | // Whether to support the descriptors __get__, __set__, __delete__, __set_name__ |
Damien George | 36c1052 | 2018-05-25 17:09:54 +1000 | [diff] [blame] | 1169 | // This costs some code size and makes load/store/delete of instance |
| 1170 | // attributes slower for the classes that use this feature |
stijn | 28fa84b | 2015-02-14 18:43:54 +0100 | [diff] [blame] | 1171 | #ifndef MICROPY_PY_DESCRIPTORS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1172 | #define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | 28fa84b | 2015-02-14 18:43:54 +0100 | [diff] [blame] | 1173 | #endif |
| 1174 | |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 1175 | // Whether to support class __delattr__ and __setattr__ methods |
Damien George | 36c1052 | 2018-05-25 17:09:54 +1000 | [diff] [blame] | 1176 | // This costs some code size and makes store/delete of instance |
| 1177 | // attributes slower for the classes that use this feature |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 1178 | #ifndef MICROPY_PY_DELATTR_SETATTR |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1179 | #define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
dmazzella | 18e6569 | 2017-01-03 11:00:12 +0100 | [diff] [blame] | 1180 | #endif |
| 1181 | |
pohmelie | 81ebba7 | 2016-01-27 23:23:11 +0300 | [diff] [blame] | 1182 | // Support for async/await/async for/async with |
| 1183 | #ifndef MICROPY_PY_ASYNC_AWAIT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1184 | #define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
pohmelie | 81ebba7 | 2016-01-27 23:23:11 +0300 | [diff] [blame] | 1185 | #endif |
| 1186 | |
Jim Mussared | 692d36d | 2021-08-13 01:44:08 +1000 | [diff] [blame] | 1187 | // Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+) |
| 1188 | #ifndef MICROPY_PY_FSTRINGS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1189 | #define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Jim Mussared | 692d36d | 2021-08-13 01:44:08 +1000 | [diff] [blame] | 1190 | #endif |
| 1191 | |
Damien George | 1783950 | 2020-06-16 21:42:44 +1000 | [diff] [blame] | 1192 | // Support for assignment expressions with := (see PEP 572, Python 3.8+) |
| 1193 | #ifndef MICROPY_PY_ASSIGN_EXPR |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1194 | #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] | 1195 | #endif |
| 1196 | |
Paul Sokolovsky | 6364401 | 2017-10-21 12:13:44 +0300 | [diff] [blame] | 1197 | // Non-standard .pend_throw() method for generators, allowing for |
| 1198 | // Future-like behavior with respect to exception handling: an |
| 1199 | // exception set with .pend_throw() will activate on the next call |
| 1200 | // to generator's .send() or .__next__(). (This is useful to implement |
| 1201 | // async schedulers.) |
| 1202 | #ifndef MICROPY_PY_GENERATOR_PEND_THROW |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1203 | #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] | 1204 | #endif |
| 1205 | |
Paul Sokolovsky | a1b442b | 2016-07-22 00:46:24 +0300 | [diff] [blame] | 1206 | // Issue a warning when comparing str and bytes objects |
Paul Sokolovsky | 707cae7 | 2016-07-22 00:34:34 +0300 | [diff] [blame] | 1207 | #ifndef MICROPY_PY_STR_BYTES_CMP_WARN |
| 1208 | #define MICROPY_PY_STR_BYTES_CMP_WARN (0) |
| 1209 | #endif |
| 1210 | |
Jim Mussared | 28aaab9 | 2021-07-13 18:01:12 +1000 | [diff] [blame] | 1211 | // Add bytes.hex and bytes.fromhex |
| 1212 | #ifndef MICROPY_PY_BUILTINS_BYTES_HEX |
| 1213 | #define MICROPY_PY_BUILTINS_BYTES_HEX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1214 | #endif |
| 1215 | |
Paul Sokolovsky | 12bc13e | 2014-06-13 01:05:19 +0300 | [diff] [blame] | 1216 | // Whether str object is proper unicode |
| 1217 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1218 | #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] | 1219 | #endif |
Damien George | b3a50f0 | 2014-06-28 10:27:15 +0100 | [diff] [blame] | 1220 | |
tll | 68c2817 | 2017-06-24 08:38:32 +0800 | [diff] [blame] | 1221 | // Whether to check for valid UTF-8 when converting bytes to str |
| 1222 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK |
| 1223 | #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE) |
| 1224 | #endif |
| 1225 | |
Paul Sokolovsky | 1b5abfc | 2016-05-22 00:13:44 +0300 | [diff] [blame] | 1226 | // Whether str.center() method provided |
| 1227 | #ifndef MICROPY_PY_BUILTINS_STR_CENTER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1228 | #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] | 1229 | #endif |
| 1230 | |
Paul Sokolovsky | 5a91fce | 2018-08-05 23:56:19 +0300 | [diff] [blame] | 1231 | // Whether str.count() method provided |
| 1232 | #ifndef MICROPY_PY_BUILTINS_STR_COUNT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1233 | #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] | 1234 | #endif |
| 1235 | |
Paul Sokolovsky | 2da5d41 | 2018-08-15 15:17:41 +0300 | [diff] [blame] | 1236 | // Whether str % (...) formatting operator provided |
| 1237 | #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1238 | #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] | 1239 | #endif |
| 1240 | |
Paul Sokolovsky | 56eb25f | 2016-08-07 06:46:55 +0300 | [diff] [blame] | 1241 | // Whether str.partition()/str.rpartition() method provided |
| 1242 | #ifndef MICROPY_PY_BUILTINS_STR_PARTITION |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1243 | #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] | 1244 | #endif |
| 1245 | |
Paul Sokolovsky | ac2f7a7 | 2015-04-04 00:09:23 +0300 | [diff] [blame] | 1246 | // Whether str.splitlines() method provided |
| 1247 | #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1248 | #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] | 1249 | #endif |
| 1250 | |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1251 | // Whether to support bytearray object |
| 1252 | #ifndef MICROPY_PY_BUILTINS_BYTEARRAY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1253 | #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] | 1254 | #endif |
| 1255 | |
Damien George | 62e821c | 2025-01-19 23:30:59 +1100 | [diff] [blame] | 1256 | // Whether to support code objects, and how many features they have |
| 1257 | #define MICROPY_PY_BUILTINS_CODE_NONE (0) |
| 1258 | #define MICROPY_PY_BUILTINS_CODE_MINIMUM (1) |
| 1259 | #define MICROPY_PY_BUILTINS_CODE_BASIC (2) |
| 1260 | #define MICROPY_PY_BUILTINS_CODE_FULL (3) |
| 1261 | #ifndef MICROPY_PY_BUILTINS_CODE |
Damien George | ceb8ba6 | 2025-01-20 22:23:48 +1100 | [diff] [blame] | 1262 | #define MICROPY_PY_BUILTINS_CODE (MICROPY_PY_SYS_SETTRACE ? MICROPY_PY_BUILTINS_CODE_FULL : (MICROPY_PY_FUNCTION_ATTRS_CODE ? MICROPY_PY_BUILTINS_CODE_BASIC : (MICROPY_PY_BUILTINS_COMPILE ? MICROPY_PY_BUILTINS_CODE_MINIMUM : MICROPY_PY_BUILTINS_CODE_NONE))) |
Damien George | 62e821c | 2025-01-19 23:30:59 +1100 | [diff] [blame] | 1263 | #endif |
| 1264 | |
Paul Sokolovsky | fbb8335 | 2018-08-06 01:25:41 +0300 | [diff] [blame] | 1265 | // Whether to support dict.fromkeys() class method |
| 1266 | #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1267 | #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] | 1268 | #endif |
| 1269 | |
Damien George | dd4f453 | 2014-10-23 13:34:35 +0100 | [diff] [blame] | 1270 | // Whether to support memoryview object |
| 1271 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1272 | #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] | 1273 | #endif |
| 1274 | |
stijn | 90fae91 | 2019-05-08 16:16:17 +0200 | [diff] [blame] | 1275 | // Whether to support memoryview.itemsize attribute |
| 1276 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1277 | #define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
stijn | 90fae91 | 2019-05-08 16:16:17 +0200 | [diff] [blame] | 1278 | #endif |
| 1279 | |
Damien George | 3ebd4d0 | 2014-06-01 13:46:47 +0100 | [diff] [blame] | 1280 | // Whether to support set object |
| 1281 | #ifndef MICROPY_PY_BUILTINS_SET |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1282 | #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] | 1283 | #endif |
| 1284 | |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1285 | // Whether to support slice subscript operators and slice object |
| 1286 | #ifndef MICROPY_PY_BUILTINS_SLICE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1287 | #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] | 1288 | #endif |
| 1289 | |
Tom Soulanille | aeb62f9 | 2015-09-11 14:31:32 -0700 | [diff] [blame] | 1290 | // Whether to support slice attribute read access, |
| 1291 | // i.e. slice.start, slice.stop, slice.step |
| 1292 | #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1293 | #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] | 1294 | #endif |
| 1295 | |
Nicko van Someren | 4c93955 | 2019-11-16 17:07:11 -0700 | [diff] [blame] | 1296 | // Whether to support the .indices(len) method on slice objects |
| 1297 | #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1298 | #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] | 1299 | #endif |
| 1300 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1301 | // Whether to support frozenset object |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1302 | #ifndef MICROPY_PY_BUILTINS_FROZENSET |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1303 | #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] | 1304 | #endif |
| 1305 | |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 1306 | // Whether to support property object |
| 1307 | #ifndef MICROPY_PY_BUILTINS_PROPERTY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1308 | #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] | 1309 | #endif |
| 1310 | |
Peter D. Gray | b2a237d | 2015-03-06 14:48:14 -0500 | [diff] [blame] | 1311 | // Whether to implement the start/stop/step attributes (readback) on |
| 1312 | // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). |
| 1313 | #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1314 | #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] | 1315 | #endif |
| 1316 | |
Damien George | d77da83 | 2018-02-14 23:17:06 +1100 | [diff] [blame] | 1317 | // Whether to support binary ops [only (in)equality is defined] between range |
| 1318 | // objects. With this option disabled all range objects that are not exactly |
| 1319 | // the same object will compare as not-equal. With it enabled the semantics |
| 1320 | // match CPython and ranges are equal if they yield the same sequence of items. |
| 1321 | #ifndef MICROPY_PY_BUILTINS_RANGE_BINOP |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1322 | #define MICROPY_PY_BUILTINS_RANGE_BINOP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Damien George | d77da83 | 2018-02-14 23:17:06 +1100 | [diff] [blame] | 1323 | #endif |
| 1324 | |
Damien George | cf490a7 | 2023-10-03 11:24:50 +1100 | [diff] [blame] | 1325 | // Support for calling next() with second argument |
stijn | 4286383 | 2019-01-03 15:19:42 +0100 | [diff] [blame] | 1326 | #ifndef MICROPY_PY_BUILTINS_NEXT2 |
Damien George | 56e90cb | 2025-03-11 13:14:46 +1100 | [diff] [blame] | 1327 | #define MICROPY_PY_BUILTINS_NEXT2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) |
stijn | 4286383 | 2019-01-03 15:19:42 +0100 | [diff] [blame] | 1328 | #endif |
| 1329 | |
Jan Klusacek | b318ebf | 2018-01-09 22:47:35 +0100 | [diff] [blame] | 1330 | // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120 |
| 1331 | #ifndef MICROPY_PY_BUILTINS_ROUND_INT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1332 | #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] | 1333 | #endif |
| 1334 | |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1335 | // Whether to support complete set of special methods for user |
| 1336 | // classes, or only the most used ones. "Inplace" methods are |
| 1337 | // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below. |
| 1338 | // "Reverse" methods are controlled by |
| 1339 | // MICROPY_PY_REVERSE_SPECIAL_METHODS below. |
Paul Sokolovsky | 98c4bc3 | 2015-01-30 01:42:49 +0200 | [diff] [blame] | 1340 | #ifndef MICROPY_PY_ALL_SPECIAL_METHODS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1341 | #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] | 1342 | #endif |
| 1343 | |
Damien George | cf490a7 | 2023-10-03 11:24:50 +1100 | [diff] [blame] | 1344 | // Whether to support all inplace arithmetic operation methods |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1345 | // (__imul__, etc.) |
| 1346 | #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1347 | #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1348 | #endif |
| 1349 | |
Damien George | cf490a7 | 2023-10-03 11:24:50 +1100 | [diff] [blame] | 1350 | // Whether to support reverse arithmetic operation methods |
Paul Sokolovsky | 0e80f34 | 2017-10-27 22:29:15 +0300 | [diff] [blame] | 1351 | // (__radd__, etc.). Additionally gated by |
| 1352 | // MICROPY_PY_ALL_SPECIAL_METHODS. |
Paul Sokolovsky | eb84a83 | 2017-09-10 17:05:20 +0300 | [diff] [blame] | 1353 | #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1354 | #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] | 1355 | #endif |
| 1356 | |
Damien George | c9fc620 | 2014-10-25 21:59:14 +0100 | [diff] [blame] | 1357 | // Whether to support compile function |
| 1358 | #ifndef MICROPY_PY_BUILTINS_COMPILE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1359 | #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] | 1360 | #endif |
| 1361 | |
Paul Sokolovsky | e2d44e3 | 2015-04-06 23:50:37 +0300 | [diff] [blame] | 1362 | // Whether to support enumerate function(type) |
| 1363 | #ifndef MICROPY_PY_BUILTINS_ENUMERATE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1364 | #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] | 1365 | #endif |
| 1366 | |
Damien George | dd5353a | 2015-12-18 12:35:44 +0000 | [diff] [blame] | 1367 | // Whether to support eval and exec functions |
| 1368 | // By default they are supported if the compiler is enabled |
| 1369 | #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC |
| 1370 | #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER) |
| 1371 | #endif |
| 1372 | |
Damien George | 2a3e2b9 | 2014-12-19 13:36:17 +0000 | [diff] [blame] | 1373 | // Whether to support the Python 2 execfile function |
| 1374 | #ifndef MICROPY_PY_BUILTINS_EXECFILE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1375 | #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] | 1376 | #endif |
| 1377 | |
Paul Sokolovsky | 22ff397 | 2015-08-20 01:01:56 +0300 | [diff] [blame] | 1378 | // Whether to support filter function(type) |
| 1379 | #ifndef MICROPY_PY_BUILTINS_FILTER |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1380 | #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] | 1381 | #endif |
| 1382 | |
Paul Sokolovsky | 282ca09 | 2015-04-07 00:16:51 +0300 | [diff] [blame] | 1383 | // Whether to support reversed function(type) |
| 1384 | #ifndef MICROPY_PY_BUILTINS_REVERSED |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1385 | #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] | 1386 | #endif |
| 1387 | |
Paul Sokolovsky | 5ab5ac5 | 2015-05-04 19:45:53 +0300 | [diff] [blame] | 1388 | // Whether to define "NotImplemented" special constant |
| 1389 | #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1390 | #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] | 1391 | #endif |
| 1392 | |
Damien George | bc76302 | 2017-06-01 15:32:23 +1000 | [diff] [blame] | 1393 | // Whether to provide the built-in input() function. The implementation of this |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 1394 | // 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] | 1395 | #ifndef MICROPY_PY_BUILTINS_INPUT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1396 | #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] | 1397 | #endif |
| 1398 | |
pohmelie | 354e688 | 2015-12-07 15:35:48 +0300 | [diff] [blame] | 1399 | // Whether to support min/max functions |
| 1400 | #ifndef MICROPY_PY_BUILTINS_MIN_MAX |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1401 | #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] | 1402 | #endif |
| 1403 | |
Damien George | a19b5a0 | 2017-02-03 12:35:48 +1100 | [diff] [blame] | 1404 | // Support for calls to pow() with 3 integer arguments |
| 1405 | #ifndef MICROPY_PY_BUILTINS_POW3 |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1406 | #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] | 1407 | #endif |
| 1408 | |
Damien George | 9f04dfb | 2017-01-21 23:17:51 +1100 | [diff] [blame] | 1409 | // Whether to provide the help function |
| 1410 | #ifndef MICROPY_PY_BUILTINS_HELP |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1411 | #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] | 1412 | #endif |
| 1413 | |
| 1414 | // Use this to configure the help text shown for help(). It should be a |
| 1415 | // variable with the type "const char*". A sensible default is provided. |
| 1416 | #ifndef MICROPY_PY_BUILTINS_HELP_TEXT |
| 1417 | #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text |
| 1418 | #endif |
| 1419 | |
Damien George | f5172af | 2017-01-22 12:12:54 +1100 | [diff] [blame] | 1420 | // Add the ability to list the available modules when executing help('modules') |
| 1421 | #ifndef MICROPY_PY_BUILTINS_HELP_MODULES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1422 | #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] | 1423 | #endif |
| 1424 | |
Paul Sokolovsky | d0f5e61 | 2014-07-25 11:00:15 +0300 | [diff] [blame] | 1425 | // Whether to set __file__ for imported modules |
| 1426 | #ifndef MICROPY_PY___FILE__ |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1427 | #define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | d0f5e61 | 2014-07-25 11:00:15 +0300 | [diff] [blame] | 1428 | #endif |
| 1429 | |
Yoctopuce dev | 66c0148 | 2025-05-20 15:57:11 +0200 | [diff] [blame] | 1430 | // Whether to process __all__ when importing all public symbols from module |
| 1431 | #ifndef MICROPY_MODULE___ALL__ |
| 1432 | #define MICROPY_MODULE___ALL__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) |
| 1433 | #endif |
| 1434 | |
Damien George | 89deec0 | 2015-01-09 20:12:54 +0000 | [diff] [blame] | 1435 | // Whether to provide mem-info related functions in micropython module |
| 1436 | #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1437 | #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] | 1438 | #endif |
| 1439 | |
Damien George | 7e2a488 | 2018-02-20 18:30:22 +1100 | [diff] [blame] | 1440 | // Whether to provide "micropython.stack_use" function |
| 1441 | #ifndef MICROPY_PY_MICROPYTHON_STACK_USE |
| 1442 | #define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO) |
| 1443 | #endif |
| 1444 | |
Andrew Leech | 86bfabe | 2019-06-28 16:35:51 +1000 | [diff] [blame] | 1445 | // Whether to provide the "micropython.heap_locked" function |
| 1446 | #ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1447 | #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Andrew Leech | 86bfabe | 2019-06-28 16:35:51 +1000 | [diff] [blame] | 1448 | #endif |
| 1449 | |
Andrew Leech | 7e14680 | 2022-09-26 11:02:31 +1000 | [diff] [blame] | 1450 | // Support for micropython.RingIO() |
| 1451 | #ifndef MICROPY_PY_MICROPYTHON_RINGIO |
| 1452 | #define MICROPY_PY_MICROPYTHON_RINGIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1453 | #endif |
| 1454 | |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1455 | // Whether to provide "array" module. Note that large chunk of the |
| 1456 | // underlying code is shared with "bytearray" builtin type, so to |
| 1457 | // get real savings, it should be disabled too. |
| 1458 | #ifndef MICROPY_PY_ARRAY |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1459 | #define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Paul Sokolovsky | cb78f86 | 2014-06-27 20:39:09 +0300 | [diff] [blame] | 1460 | #endif |
| 1461 | |
Paul Sokolovsky | cefcbb2 | 2015-02-27 22:16:05 +0200 | [diff] [blame] | 1462 | // Whether to support slice assignments for array (and bytearray). |
| 1463 | // This is rarely used, but adds ~0.5K of code. |
| 1464 | #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1465 | #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] | 1466 | #endif |
| 1467 | |
Damien George | 5aa311d | 2015-04-21 14:14:24 +0000 | [diff] [blame] | 1468 | // Whether to support attrtuple type (MicroPython extension) |
| 1469 | // It provides space-efficient tuples with attribute access |
| 1470 | #ifndef MICROPY_PY_ATTRTUPLE |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1471 | #define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | 5aa311d | 2015-04-21 14:14:24 +0000 | [diff] [blame] | 1472 | #endif |
| 1473 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1474 | // Whether to provide "collections" module |
| 1475 | #ifndef MICROPY_PY_COLLECTIONS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1476 | #define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1477 | #endif |
| 1478 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1479 | // Whether to provide "collections.deque" type |
Paul Sokolovsky | 970eedc | 2018-02-06 00:06:42 +0200 | [diff] [blame] | 1480 | #ifndef MICROPY_PY_COLLECTIONS_DEQUE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1481 | #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] | 1482 | #endif |
| 1483 | |
Dash Peters | 7dff38f | 2023-02-11 18:49:15 -0800 | [diff] [blame] | 1484 | // Whether "collections.deque" supports iteration |
| 1485 | #ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER |
| 1486 | #define MICROPY_PY_COLLECTIONS_DEQUE_ITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1487 | #endif |
| 1488 | |
| 1489 | // Whether "collections.deque" supports subscription |
| 1490 | #ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR |
| 1491 | #define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1492 | #endif |
| 1493 | |
Paul Sokolovsky | 0ef01d0 | 2015-03-18 01:25:04 +0200 | [diff] [blame] | 1494 | // Whether to provide "collections.OrderedDict" type |
| 1495 | #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1496 | #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] | 1497 | #endif |
| 1498 | |
stijn | 79ed58f | 2017-11-06 12:21:53 +0100 | [diff] [blame] | 1499 | // Whether to provide the _asdict function for namedtuple |
| 1500 | #ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1501 | #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
stijn | 79ed58f | 2017-11-06 12:21:53 +0100 | [diff] [blame] | 1502 | #endif |
| 1503 | |
Damien George | c3a18d7 | 2025-01-20 22:24:10 +1100 | [diff] [blame] | 1504 | // Whether to provide "marshal" module |
| 1505 | #ifndef MICROPY_PY_MARSHAL |
| 1506 | #define MICROPY_PY_MARSHAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
| 1507 | #endif |
| 1508 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1509 | // Whether to provide "math" module |
| 1510 | #ifndef MICROPY_PY_MATH |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1511 | #define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1512 | #endif |
| 1513 | |
stijn | dd69672 | 2019-11-20 13:38:33 +0100 | [diff] [blame] | 1514 | // Whether to provide all math module constants (Python 3.5+), or just pi and e. |
| 1515 | #ifndef MICROPY_PY_MATH_CONSTANTS |
| 1516 | #define MICROPY_PY_MATH_CONSTANTS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1517 | #endif |
| 1518 | |
Damien George | 5cbeace | 2015-02-22 14:48:18 +0000 | [diff] [blame] | 1519 | // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} |
| 1520 | #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1521 | #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] | 1522 | #endif |
| 1523 | |
Christopher Swenson | 8c65675 | 2018-08-27 10:32:21 +1000 | [diff] [blame] | 1524 | // Whether to provide math.factorial function |
| 1525 | #ifndef MICROPY_PY_MATH_FACTORIAL |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1526 | #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] | 1527 | #endif |
| 1528 | |
stijn | af5c998 | 2019-07-02 10:28:44 +0200 | [diff] [blame] | 1529 | // Whether to provide math.isclose function |
| 1530 | #ifndef MICROPY_PY_MATH_ISCLOSE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1531 | #define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
stijn | af5c998 | 2019-07-02 10:28:44 +0200 | [diff] [blame] | 1532 | #endif |
| 1533 | |
stijn | 81db22f | 2020-05-17 12:29:25 +0200 | [diff] [blame] | 1534 | // Whether to provide fix for atan2 Inf handling. |
| 1535 | #ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN |
| 1536 | #define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0) |
| 1537 | #endif |
| 1538 | |
| 1539 | // Whether to provide fix for fmod Inf handling. |
| 1540 | #ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN |
| 1541 | #define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0) |
| 1542 | #endif |
| 1543 | |
| 1544 | // Whether to provide fix for modf negative zero handling. |
| 1545 | #ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO |
| 1546 | #define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0) |
| 1547 | #endif |
| 1548 | |
stijn | 2e54d9d | 2020-09-08 15:22:34 +0200 | [diff] [blame] | 1549 | // Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN. |
| 1550 | #ifndef MICROPY_PY_MATH_POW_FIX_NAN |
| 1551 | #define MICROPY_PY_MATH_POW_FIX_NAN (0) |
| 1552 | #endif |
| 1553 | |
Angus Gratton | b0c8937 | 2024-08-06 09:59:22 +1000 | [diff] [blame] | 1554 | // Whether to provide fix for gamma(-inf) to raise ValueError |
| 1555 | #ifndef MICROPY_PY_MATH_GAMMA_FIX_NEGINF |
| 1556 | #define MICROPY_PY_MATH_GAMMA_FIX_NEGINF (0) |
| 1557 | #endif |
| 1558 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1559 | // Whether to provide "cmath" module |
| 1560 | #ifndef MICROPY_PY_CMATH |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1561 | #define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1562 | #endif |
| 1563 | |
Laurens Valk | f724d90 | 2022-11-29 10:38:57 +0100 | [diff] [blame] | 1564 | // Whether to provide "micropython" module |
| 1565 | #ifndef MICROPY_PY_MICROPYTHON |
Laurens Valk | 632d43e | 2022-11-29 12:31:09 +0100 | [diff] [blame] | 1566 | #define MICROPY_PY_MICROPYTHON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Laurens Valk | f724d90 | 2022-11-29 10:38:57 +0100 | [diff] [blame] | 1567 | #endif |
| 1568 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1569 | // Whether to provide "gc" module |
| 1570 | #ifndef MICROPY_PY_GC |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1571 | #define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1572 | #endif |
| 1573 | |
Paul Sokolovsky | 755a55f | 2014-06-05 22:48:02 +0300 | [diff] [blame] | 1574 | // Whether to return number of collected objects from gc.collect() |
| 1575 | #ifndef MICROPY_PY_GC_COLLECT_RETVAL |
| 1576 | #define MICROPY_PY_GC_COLLECT_RETVAL (0) |
| 1577 | #endif |
| 1578 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1579 | // Whether to provide "io" module |
| 1580 | #ifndef MICROPY_PY_IO |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1581 | #define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1582 | #endif |
| 1583 | |
Damien George | af0932a | 2018-06-04 15:54:26 +1000 | [diff] [blame] | 1584 | // Whether to provide "io.IOBase" class to support user streams |
| 1585 | #ifndef MICROPY_PY_IO_IOBASE |
Damien George | d01a981 | 2025-05-07 13:49:12 +1000 | [diff] [blame] | 1586 | #define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | af0932a | 2018-06-04 15:54:26 +1000 | [diff] [blame] | 1587 | #endif |
| 1588 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1589 | // Whether to provide "io.BytesIO" class |
| 1590 | #ifndef MICROPY_PY_IO_BYTESIO |
| 1591 | #define MICROPY_PY_IO_BYTESIO (1) |
| 1592 | #endif |
| 1593 | |
Paul Sokolovsky | 5d93dfb | 2016-03-25 01:10:49 +0200 | [diff] [blame] | 1594 | // Whether to provide "io.BufferedWriter" class |
| 1595 | #ifndef MICROPY_PY_IO_BUFFEREDWRITER |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1596 | #define MICROPY_PY_IO_BUFFEREDWRITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Paul Sokolovsky | 5d93dfb | 2016-03-25 01:10:49 +0200 | [diff] [blame] | 1597 | #endif |
| 1598 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1599 | // Whether to provide "struct" module |
| 1600 | #ifndef MICROPY_PY_STRUCT |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1601 | #define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1602 | #endif |
| 1603 | |
| 1604 | // Whether to provide "sys" module |
| 1605 | #ifndef MICROPY_PY_SYS |
Jim Mussared | 01374d9 | 2021-08-14 01:43:15 +1000 | [diff] [blame] | 1606 | #define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1607 | #endif |
| 1608 | |
Damien George | de43b50 | 2021-12-17 23:35:32 +1100 | [diff] [blame] | 1609 | // Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init() |
| 1610 | #ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS |
Damien George | fe9ffff | 2021-12-19 08:55:40 +1100 | [diff] [blame] | 1611 | #define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS) |
Damien George | de43b50 | 2021-12-17 23:35:32 +1100 | [diff] [blame] | 1612 | #endif |
| 1613 | |
Paul Sokolovsky | 4e0eeeb | 2014-07-03 16:50:11 +0300 | [diff] [blame] | 1614 | // Whether to provide "sys.maxsize" constant |
| 1615 | #ifndef MICROPY_PY_SYS_MAXSIZE |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1616 | #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] | 1617 | #endif |
| 1618 | |
Paul Sokolovsky | 1a1d11f | 2015-12-05 00:09:10 +0200 | [diff] [blame] | 1619 | // Whether to provide "sys.modules" dictionary |
| 1620 | #ifndef MICROPY_PY_SYS_MODULES |
| 1621 | #define MICROPY_PY_SYS_MODULES (1) |
| 1622 | #endif |
| 1623 | |
Paul Sokolovsky | 8b85d14 | 2015-04-25 03:17:41 +0300 | [diff] [blame] | 1624 | // Whether to provide "sys.exc_info" function |
| 1625 | // Avoid enabling this, this function is Python2 heritage |
| 1626 | #ifndef MICROPY_PY_SYS_EXC_INFO |
| 1627 | #define MICROPY_PY_SYS_EXC_INFO (0) |
| 1628 | #endif |
| 1629 | |
Jim Mussared | 0e8dfaf | 2022-10-07 02:13:58 +1100 | [diff] [blame] | 1630 | // Whether to provide "sys.executable", which is the absolute path to the |
| 1631 | // micropython binary |
| 1632 | // Intended for use on the "OS" ports (e.g. Unix) |
| 1633 | #ifndef MICROPY_PY_SYS_EXECUTABLE |
| 1634 | #define MICROPY_PY_SYS_EXECUTABLE (0) |
| 1635 | #endif |
| 1636 | |
stijn | 85c0216 | 2023-12-04 15:54:59 +0100 | [diff] [blame] | 1637 | // Whether to provide "sys.intern" |
| 1638 | #ifndef MICROPY_PY_SYS_INTERN |
| 1639 | #define MICROPY_PY_SYS_INTERN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
| 1640 | #endif |
| 1641 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1642 | // Whether to provide "sys.exit" function |
| 1643 | #ifndef MICROPY_PY_SYS_EXIT |
Paul Sokolovsky | 403c930 | 2016-12-14 21:10:22 +0300 | [diff] [blame] | 1644 | #define MICROPY_PY_SYS_EXIT (1) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1645 | #endif |
| 1646 | |
Milan Rossa | cb36470 | 2019-08-05 15:06:41 +0200 | [diff] [blame] | 1647 | // Whether to provide "sys.atexit" function (MicroPython extension) |
| 1648 | #ifndef MICROPY_PY_SYS_ATEXIT |
| 1649 | #define MICROPY_PY_SYS_ATEXIT (0) |
| 1650 | #endif |
| 1651 | |
Jim Mussared | 5e50975 | 2023-06-05 16:52:29 +1000 | [diff] [blame] | 1652 | // Whether to provide the "sys.path" attribute (which forces module delegation |
| 1653 | // and mutable sys attributes to be enabled). |
| 1654 | // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in |
| 1655 | // mp_init to an empty list. Otherwise the port must initialise it using |
| 1656 | // `mp_sys_path = mp_obj_new_list(...)`. |
| 1657 | #ifndef MICROPY_PY_SYS_PATH |
| 1658 | #define MICROPY_PY_SYS_PATH (1) |
| 1659 | #endif |
| 1660 | |
| 1661 | // Whether to provide the "sys.argv" attribute. |
| 1662 | // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in |
| 1663 | // mp_init to an empty list. Otherwise the port must initialise it using |
| 1664 | // `mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), ...);` |
| 1665 | #ifndef MICROPY_PY_SYS_ARGV |
| 1666 | #define MICROPY_PY_SYS_ARGV (1) |
| 1667 | #endif |
| 1668 | |
Damien George | ac22931 | 2021-07-27 00:43:35 +1000 | [diff] [blame] | 1669 | // Whether to provide sys.{ps1,ps2} mutable attributes, to control REPL prompts |
| 1670 | #ifndef MICROPY_PY_SYS_PS1_PS2 |
| 1671 | #define MICROPY_PY_SYS_PS1_PS2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1672 | #endif |
| 1673 | |
Milan Rossa | 310b3d1 | 2019-08-14 16:09:36 +0200 | [diff] [blame] | 1674 | // Whether to provide "sys.settrace" function |
| 1675 | #ifndef MICROPY_PY_SYS_SETTRACE |
| 1676 | #define MICROPY_PY_SYS_SETTRACE (0) |
| 1677 | #endif |
| 1678 | |
Paul Sokolovsky | bfc2092 | 2017-08-11 09:42:39 +0300 | [diff] [blame] | 1679 | // Whether to provide "sys.getsizeof" function |
| 1680 | #ifndef MICROPY_PY_SYS_GETSIZEOF |
Jim Mussared | 3e5b1be | 2022-08-16 01:41:03 +1000 | [diff] [blame] | 1681 | #define MICROPY_PY_SYS_GETSIZEOF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Paul Sokolovsky | bfc2092 | 2017-08-11 09:42:39 +0300 | [diff] [blame] | 1682 | #endif |
| 1683 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 1684 | // Whether to provide sys.{stdin,stdout,stderr} objects |
| 1685 | #ifndef MICROPY_PY_SYS_STDFILES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1686 | #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] | 1687 | #endif |
| 1688 | |
Damien George | 3c4b5d4 | 2015-05-13 23:49:21 +0100 | [diff] [blame] | 1689 | // Whether to provide sys.{stdin,stdout,stderr}.buffer object |
| 1690 | // This is implemented per-port |
| 1691 | #ifndef MICROPY_PY_SYS_STDIO_BUFFER |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1692 | #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] | 1693 | #endif |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1694 | |
Damien George | cac939d | 2021-07-27 00:41:27 +1000 | [diff] [blame] | 1695 | // Whether to provide sys.tracebacklimit mutable attribute |
| 1696 | #ifndef MICROPY_PY_SYS_TRACEBACKLIMIT |
| 1697 | #define MICROPY_PY_SYS_TRACEBACKLIMIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
| 1698 | #endif |
| 1699 | |
Damien George | bc18155 | 2021-07-27 00:39:04 +1000 | [diff] [blame] | 1700 | // Whether the sys module supports attribute delegation |
| 1701 | // This is enabled automatically when needed by other features |
| 1702 | #ifndef MICROPY_PY_SYS_ATTR_DELEGATION |
Jim Mussared | 5e50975 | 2023-06-05 16:52:29 +1000 | [diff] [blame] | 1703 | #define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PATH || MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT) |
Damien George | bc18155 | 2021-07-27 00:39:04 +1000 | [diff] [blame] | 1704 | #endif |
| 1705 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1706 | // Whether to provide "errno" module |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1707 | #ifndef MICROPY_PY_ERRNO |
| 1708 | #define MICROPY_PY_ERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 596a3fe | 2016-05-10 10:54:25 +0100 | [diff] [blame] | 1709 | #endif |
| 1710 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1711 | // Whether to provide the errno.errorcode dict |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1712 | #ifndef MICROPY_PY_ERRNO_ERRORCODE |
| 1713 | #define MICROPY_PY_ERRNO_ERRORCODE (1) |
Damien George | f563406 | 2017-02-22 12:53:42 +1100 | [diff] [blame] | 1714 | #endif |
| 1715 | |
Damien George | ef71028 | 2023-08-01 12:39:39 +1000 | [diff] [blame] | 1716 | // Whether to provide "select" module |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1717 | #ifndef MICROPY_PY_SELECT |
| 1718 | #define MICROPY_PY_SELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 8f5bc3f | 2016-11-20 23:49:45 +0300 | [diff] [blame] | 1719 | #endif |
| 1720 | |
Damien George | ef71028 | 2023-08-01 12:39:39 +1000 | [diff] [blame] | 1721 | // Whether to enable POSIX optimisations in the "select" module (requires system poll) |
| 1722 | #ifndef MICROPY_PY_SELECT_POSIX_OPTIMISATIONS |
| 1723 | #define MICROPY_PY_SELECT_POSIX_OPTIMISATIONS (0) |
| 1724 | #endif |
| 1725 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1726 | // Whether to enable the select() function in the "select" module (baremetal |
David Lechner | 8758504 | 2021-07-06 18:08:18 -0500 | [diff] [blame] | 1727 | // implementation). This is present for compatibility but can be disabled to |
| 1728 | // save space. |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1729 | #ifndef MICROPY_PY_SELECT_SELECT |
| 1730 | #define MICROPY_PY_SELECT_SELECT (1) |
David Lechner | 8758504 | 2021-07-06 18:08:18 -0500 | [diff] [blame] | 1731 | #endif |
| 1732 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1733 | // Whether to provide the "time" module |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1734 | #ifndef MICROPY_PY_TIME |
| 1735 | #define MICROPY_PY_TIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) |
Damien George | 9955553 | 2023-03-10 12:16:00 +1100 | [diff] [blame] | 1736 | #endif |
| 1737 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1738 | // Whether to provide time.gmtime/localtime/mktime functions |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1739 | #ifndef MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME |
| 1740 | #define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (0) |
Damien George | 9955553 | 2023-03-10 12:16:00 +1100 | [diff] [blame] | 1741 | #endif |
| 1742 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1743 | // Whether to provide time.time/time_ns functions |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1744 | #ifndef MICROPY_PY_TIME_TIME_TIME_NS |
| 1745 | #define MICROPY_PY_TIME_TIME_TIME_NS (0) |
Paul Sokolovsky | a972844 | 2016-10-14 20:13:02 +0300 | [diff] [blame] | 1746 | #endif |
| 1747 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1748 | // Period of values returned by time.ticks_ms(), ticks_us(), ticks_cpu() |
Paul Sokolovsky | 76146b3 | 2016-10-30 03:02:07 +0300 | [diff] [blame] | 1749 | // functions. Should be power of two. All functions above use the same |
| 1750 | // period, so if underlying hardware/API has different periods, the |
| 1751 | // minimum of them should be used. The value below is the maximum value |
| 1752 | // this parameter can take (corresponding to 30 bit tick values on 32-bit |
| 1753 | // system). |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1754 | #ifndef MICROPY_PY_TIME_TICKS_PERIOD |
| 1755 | #define MICROPY_PY_TIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1) |
Paul Sokolovsky | 76146b3 | 2016-10-30 03:02:07 +0300 | [diff] [blame] | 1756 | #endif |
| 1757 | |
Damien George | 27cc077 | 2016-04-22 22:52:33 +0000 | [diff] [blame] | 1758 | // Whether to provide "_thread" module |
| 1759 | #ifndef MICROPY_PY_THREAD |
| 1760 | #define MICROPY_PY_THREAD (0) |
| 1761 | #endif |
| 1762 | |
Damien George | 4cec63a | 2016-05-26 10:42:53 +0000 | [diff] [blame] | 1763 | // Whether to make the VM/runtime thread-safe using a global lock |
| 1764 | // If not enabled then thread safety must be provided at the Python level |
| 1765 | #ifndef MICROPY_PY_THREAD_GIL |
| 1766 | #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD) |
| 1767 | #endif |
| 1768 | |
Damien George | f6c22a0 | 2017-02-06 10:50:43 +1100 | [diff] [blame] | 1769 | // Number of VM jump-loops to do before releasing the GIL. |
| 1770 | // Set this to 0 to disable the divisor. |
| 1771 | #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR |
| 1772 | #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32) |
| 1773 | #endif |
| 1774 | |
Angus Gratton | 4bcbe88 | 2024-12-10 14:50:42 +1100 | [diff] [blame] | 1775 | // Is a recursive mutex type in use? |
| 1776 | #ifndef MICROPY_PY_THREAD_RECURSIVE_MUTEX |
| 1777 | #define MICROPY_PY_THREAD_RECURSIVE_MUTEX (MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL) |
| 1778 | #endif |
| 1779 | |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1780 | // Extended modules |
Paul Sokolovsky | 510296f | 2014-08-08 22:51:40 +0300 | [diff] [blame] | 1781 | |
Jim Mussared | 2fbc08c | 2023-06-08 15:51:50 +1000 | [diff] [blame] | 1782 | #ifndef MICROPY_PY_ASYNCIO |
| 1783 | #define MICROPY_PY_ASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | bc009fd | 2020-03-12 16:46:20 +1100 | [diff] [blame] | 1784 | #endif |
| 1785 | |
Damien George | 8ac9c8f | 2024-06-19 17:27:31 +1000 | [diff] [blame] | 1786 | #ifndef MICROPY_PY_ASYNCIO_TASK_QUEUE_PUSH_CALLBACK |
| 1787 | #define MICROPY_PY_ASYNCIO_TASK_QUEUE_PUSH_CALLBACK (0) |
| 1788 | #endif |
| 1789 | |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1790 | #ifndef MICROPY_PY_UCTYPES |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 1791 | #define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | 8215847 | 2014-06-28 03:03:47 +0300 | [diff] [blame] | 1792 | #endif |
| 1793 | |
Paul Sokolovsky | 38151f3 | 2018-10-06 23:34:58 +0300 | [diff] [blame] | 1794 | // Whether to provide SHORT, INT, LONG, etc. types in addition to |
| 1795 | // exact-bitness types like INT16, INT32, etc. |
| 1796 | #ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES |
| 1797 | #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1) |
| 1798 | #endif |
| 1799 | |
Jim Mussared | 3533924 | 2023-06-26 13:52:10 +1000 | [diff] [blame] | 1800 | // Whether to provide "deflate" module (decompression-only by default) |
| 1801 | #ifndef MICROPY_PY_DEFLATE |
| 1802 | #define MICROPY_PY_DEFLATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1803 | #endif |
| 1804 | |
| 1805 | // Whether to provide compression support in "deflate" module |
| 1806 | #ifndef MICROPY_PY_DEFLATE_COMPRESS |
| 1807 | #define MICROPY_PY_DEFLATE_COMPRESS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES) |
| 1808 | #endif |
| 1809 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1810 | #ifndef MICROPY_PY_JSON |
| 1811 | #define MICROPY_PY_JSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 612045f | 2014-09-17 22:56:34 +0100 | [diff] [blame] | 1812 | #endif |
| 1813 | |
Peter Züger | ffc854f | 2021-02-03 09:24:25 +0100 | [diff] [blame] | 1814 | // Whether to support the "separators" argument to dump, dumps |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1815 | #ifndef MICROPY_PY_JSON_SEPARATORS |
| 1816 | #define MICROPY_PY_JSON_SEPARATORS (1) |
Peter Züger | ffc854f | 2021-02-03 09:24:25 +0100 | [diff] [blame] | 1817 | #endif |
| 1818 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1819 | #ifndef MICROPY_PY_OS |
| 1820 | #define MICROPY_PY_OS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 926b554 | 2022-03-03 17:59:30 +1100 | [diff] [blame] | 1821 | #endif |
| 1822 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1823 | #ifndef MICROPY_PY_OS_STATVFS |
| 1824 | #define MICROPY_PY_OS_STATVFS (MICROPY_PY_OS) |
Damien George | 0149cd6 | 2022-03-09 12:45:06 +1100 | [diff] [blame] | 1825 | #endif |
| 1826 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1827 | #ifndef MICROPY_PY_RE |
| 1828 | #define MICROPY_PY_RE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | c71e045 | 2014-09-12 18:48:07 +0300 | [diff] [blame] | 1829 | #endif |
| 1830 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1831 | #ifndef MICROPY_PY_RE_DEBUG |
| 1832 | #define MICROPY_PY_RE_DEBUG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Damien George | 7d851a2 | 2019-08-17 23:50:19 +1000 | [diff] [blame] | 1833 | #endif |
| 1834 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1835 | #ifndef MICROPY_PY_RE_MATCH_GROUPS |
| 1836 | #define MICROPY_PY_RE_MATCH_GROUPS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Damien George | 1f86460 | 2018-05-24 13:07:42 +1000 | [diff] [blame] | 1837 | #endif |
| 1838 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1839 | #ifndef MICROPY_PY_RE_MATCH_SPAN_START_END |
| 1840 | #define MICROPY_PY_RE_MATCH_SPAN_START_END (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) |
Damien George | 1e9b871 | 2018-05-24 13:08:15 +1000 | [diff] [blame] | 1841 | #endif |
| 1842 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1843 | #ifndef MICROPY_PY_RE_SUB |
| 1844 | #define MICROPY_PY_RE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | e30a5fc | 2018-05-24 13:08:51 +1000 | [diff] [blame] | 1845 | #endif |
| 1846 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1847 | #ifndef MICROPY_PY_HEAPQ |
| 1848 | #define MICROPY_PY_HEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | f5d6979 | 2014-10-22 17:37:18 +0000 | [diff] [blame] | 1849 | #endif |
| 1850 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1851 | #ifndef MICROPY_PY_HASHLIB |
| 1852 | #define MICROPY_PY_HASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | f4b19c8 | 2014-11-22 01:19:13 +0200 | [diff] [blame] | 1853 | #endif |
| 1854 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1855 | #ifndef MICROPY_PY_HASHLIB_MD5 |
| 1856 | #define MICROPY_PY_HASHLIB_MD5 (0) |
Paul Sokolovsky | 5fe3730 | 2018-08-19 11:58:22 +0300 | [diff] [blame] | 1857 | #endif |
| 1858 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1859 | #ifndef MICROPY_PY_HASHLIB_SHA1 |
| 1860 | #define MICROPY_PY_HASHLIB_SHA1 (0) |
Yonatan Goldschmidt | 6630354 | 2018-06-09 02:48:29 +0300 | [diff] [blame] | 1861 | #endif |
| 1862 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1863 | #ifndef MICROPY_PY_HASHLIB_SHA256 |
| 1864 | #define MICROPY_PY_HASHLIB_SHA256 (1) |
Yonatan Goldschmidt | 6630354 | 2018-06-09 02:48:29 +0300 | [diff] [blame] | 1865 | #endif |
| 1866 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1867 | #ifndef MICROPY_PY_CRYPTOLIB |
| 1868 | #define MICROPY_PY_CRYPTOLIB (0) |
Paul Sokolovsky | 567bc2d | 2018-01-07 15:13:56 +0200 | [diff] [blame] | 1869 | #endif |
| 1870 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1871 | // Depends on MICROPY_PY_CRYPTOLIB |
| 1872 | #ifndef MICROPY_PY_CRYPTOLIB_CTR |
| 1873 | #define MICROPY_PY_CRYPTOLIB_CTR (0) |
Yonatan Goldschmidt | ef98436 | 2019-04-23 12:39:05 +0300 | [diff] [blame] | 1874 | #endif |
| 1875 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1876 | #ifndef MICROPY_PY_CRYPTOLIB_CONSTS |
| 1877 | #define MICROPY_PY_CRYPTOLIB_CONSTS (0) |
Yonatan Goldschmidt | 473fe45 | 2018-06-15 17:07:47 +0300 | [diff] [blame] | 1878 | #endif |
| 1879 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1880 | #ifndef MICROPY_PY_BINASCII |
| 1881 | #define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | bfdc205 | 2014-11-29 06:19:30 +0200 | [diff] [blame] | 1882 | #endif |
| 1883 | |
Jim Mussared | 3533924 | 2023-06-26 13:52:10 +1000 | [diff] [blame] | 1884 | // Depends on MICROPY_PY_DEFLATE |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1885 | #ifndef MICROPY_PY_BINASCII_CRC32 |
| 1886 | #define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | c428367 | 2016-08-24 18:28:43 +0300 | [diff] [blame] | 1887 | #endif |
| 1888 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1889 | #ifndef MICROPY_PY_RANDOM |
| 1890 | #define MICROPY_PY_RANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Paul Sokolovsky | a58a91e | 2016-01-17 12:10:28 +0200 | [diff] [blame] | 1891 | #endif |
| 1892 | |
Damien George | a53af6c | 2016-01-22 16:19:32 +0000 | [diff] [blame] | 1893 | // Whether to include: randrange, randint, choice, random, uniform |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1894 | #ifndef MICROPY_PY_RANDOM_EXTRA_FUNCS |
| 1895 | #define MICROPY_PY_RANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | a53af6c | 2016-01-22 16:19:32 +0000 | [diff] [blame] | 1896 | #endif |
| 1897 | |
Paul Sokolovsky | 0116218 | 2015-05-03 20:25:40 +0300 | [diff] [blame] | 1898 | #ifndef MICROPY_PY_MACHINE |
| 1899 | #define MICROPY_PY_MACHINE (0) |
| 1900 | #endif |
| 1901 | |
Damien George | bfc3dde | 2024-03-14 11:09:14 +1100 | [diff] [blame] | 1902 | // Whether to include: reset, reset_cause |
| 1903 | #ifndef MICROPY_PY_MACHINE_RESET |
| 1904 | #define MICROPY_PY_MACHINE_RESET (0) |
| 1905 | #endif |
| 1906 | |
robert-hh | 2be45dd | 2024-07-06 09:18:22 +0200 | [diff] [blame] | 1907 | // Maximum number of arguments for machine.freq() |
| 1908 | #ifndef MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX |
| 1909 | #define MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX (1) |
| 1910 | #endif |
| 1911 | |
Jim Mussared | 870000f | 2021-08-10 01:09:04 +1000 | [diff] [blame] | 1912 | // Whether to include: bitstream |
| 1913 | #ifndef MICROPY_PY_MACHINE_BITSTREAM |
| 1914 | #define MICROPY_PY_MACHINE_BITSTREAM (0) |
| 1915 | #endif |
| 1916 | |
Damien George | 3316808 | 2016-05-31 14:25:19 +0100 | [diff] [blame] | 1917 | // Whether to include: time_pulse_us |
| 1918 | #ifndef MICROPY_PY_MACHINE_PULSE |
| 1919 | #define MICROPY_PY_MACHINE_PULSE (0) |
| 1920 | #endif |
| 1921 | |
Damien George | dd134e4 | 2024-03-14 11:01:33 +1100 | [diff] [blame] | 1922 | // Whether to provide the "machine.mem8/16/32" objects |
| 1923 | #ifndef MICROPY_PY_MACHINE_MEMX |
| 1924 | #define MICROPY_PY_MACHINE_MEMX (MICROPY_PY_MACHINE) |
| 1925 | #endif |
| 1926 | |
Damien George | 23ccbcf | 2024-03-14 10:58:41 +1100 | [diff] [blame] | 1927 | // Whether to provide the "machine.Signal" class |
| 1928 | #ifndef MICROPY_PY_MACHINE_SIGNAL |
| 1929 | #define MICROPY_PY_MACHINE_SIGNAL (MICROPY_PY_MACHINE) |
| 1930 | #endif |
| 1931 | |
Damien George | d083712 | 2016-04-12 13:42:35 +0100 | [diff] [blame] | 1932 | #ifndef MICROPY_PY_MACHINE_I2C |
| 1933 | #define MICROPY_PY_MACHINE_I2C (0) |
| 1934 | #endif |
| 1935 | |
Damien George | 4a1ae99 | 2022-06-01 11:57:20 +1000 | [diff] [blame] | 1936 | // Whether the low-level I2C transfer function supports a separate write as the first transfer |
| 1937 | #ifndef MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 |
| 1938 | #define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (0) |
| 1939 | #endif |
| 1940 | |
Damien George | 122d901 | 2021-09-02 12:37:00 +1000 | [diff] [blame] | 1941 | // Whether to provide the "machine.SoftI2C" class |
| 1942 | #ifndef MICROPY_PY_MACHINE_SOFTI2C |
| 1943 | #define MICROPY_PY_MACHINE_SOFTI2C (0) |
| 1944 | #endif |
| 1945 | |
Damien George | 0823c1b | 2016-09-01 15:07:20 +1000 | [diff] [blame] | 1946 | #ifndef MICROPY_PY_MACHINE_SPI |
| 1947 | #define MICROPY_PY_MACHINE_SPI (0) |
| 1948 | #endif |
| 1949 | |
Damien George | afe0634 | 2021-09-02 12:39:28 +1000 | [diff] [blame] | 1950 | // Whether to provide the "machine.SoftSPI" class |
| 1951 | #ifndef MICROPY_PY_MACHINE_SOFTSPI |
| 1952 | #define MICROPY_PY_MACHINE_SOFTSPI (0) |
| 1953 | #endif |
| 1954 | |
robert-hh | ee10360 | 2023-05-15 11:17:27 +0200 | [diff] [blame] | 1955 | // Values of SPI.MSB and SPI.LSB constants |
| 1956 | #ifndef MICROPY_PY_MACHINE_SPI_MSB |
| 1957 | #define MICROPY_PY_MACHINE_SPI_MSB (0) |
| 1958 | #define MICROPY_PY_MACHINE_SPI_LSB (1) |
| 1959 | #endif |
| 1960 | |
Damien George | cd35b8a | 2022-10-27 14:32:43 +1100 | [diff] [blame] | 1961 | // Whether to provide the "machine.Timer" class |
| 1962 | #ifndef MICROPY_PY_MACHINE_TIMER |
| 1963 | #define MICROPY_PY_MACHINE_TIMER (0) |
| 1964 | #endif |
| 1965 | |
Damien George | aab005c | 2022-04-04 23:07:35 +1000 | [diff] [blame] | 1966 | // The default backlog value for socket.listen(backlog) |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1967 | #ifndef MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT |
| 1968 | #define MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT (2) |
Damien George | aab005c | 2022-04-04 23:07:35 +1000 | [diff] [blame] | 1969 | #endif |
| 1970 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1971 | #ifndef MICROPY_PY_SSL |
| 1972 | #define MICROPY_PY_SSL (0) |
Damien George | 772058a | 2022-01-07 23:59:17 +1100 | [diff] [blame] | 1973 | #endif |
| 1974 | |
Jim Mussared | 7f5d5c7 | 2022-08-18 14:49:57 +1000 | [diff] [blame] | 1975 | // Whether to add finaliser code to ssl objects |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1976 | #ifndef MICROPY_PY_SSL_FINALISER |
Jim Mussared | f3eccb1 | 2023-08-23 13:37:06 +1000 | [diff] [blame] | 1977 | #define MICROPY_PY_SSL_FINALISER (MICROPY_ENABLE_FINALISER) |
Paul Sokolovsky | aaa8867 | 2015-10-06 18:10:00 +0300 | [diff] [blame] | 1978 | #endif |
| 1979 | |
iabdalkader | 2644f57 | 2024-10-16 14:08:43 +0200 | [diff] [blame] | 1980 | // Whether to add a root pointer for the current ssl object |
| 1981 | #ifndef MICROPY_PY_SSL_MBEDTLS_NEED_ACTIVE_CONTEXT |
| 1982 | #define MICROPY_PY_SSL_MBEDTLS_NEED_ACTIVE_CONTEXT (MICROPY_PY_SSL_ECDSA_SIGN_ALT) |
| 1983 | #endif |
| 1984 | |
Angus Gratton | 9b7d852 | 2025-06-05 15:32:38 +1000 | [diff] [blame] | 1985 | // Whether to support DTLS protocol (non-CPython feature) |
| 1986 | #ifndef MICROPY_PY_SSL_DTLS |
| 1987 | #define MICROPY_PY_SSL_DTLS (MICROPY_SSL_MBEDTLS && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 1988 | #endif |
| 1989 | |
Damien George | e702046 | 2023-10-13 14:53:02 +1100 | [diff] [blame] | 1990 | // Whether to provide the "vfs" module |
| 1991 | #ifndef MICROPY_PY_VFS |
robert-hh | 8fdcc25 | 2024-02-22 20:50:03 +0100 | [diff] [blame] | 1992 | #define MICROPY_PY_VFS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES && MICROPY_VFS) |
Damien George | e702046 | 2023-10-13 14:53:02 +1100 | [diff] [blame] | 1993 | #endif |
| 1994 | |
Jim Mussared | f5f9edf | 2022-08-18 15:01:26 +1000 | [diff] [blame] | 1995 | #ifndef MICROPY_PY_WEBSOCKET |
| 1996 | #define MICROPY_PY_WEBSOCKET (0) |
Paul Sokolovsky | 24342dd | 2016-03-24 19:14:12 +0200 | [diff] [blame] | 1997 | #endif |
| 1998 | |
Damien George | 53ad681 | 2016-04-08 11:08:37 +0100 | [diff] [blame] | 1999 | #ifndef MICROPY_PY_FRAMEBUF |
Jim Mussared | 0e236ee | 2021-09-15 23:18:23 +1000 | [diff] [blame] | 2000 | #define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
Damien George | 53ad681 | 2016-04-08 11:08:37 +0100 | [diff] [blame] | 2001 | #endif |
| 2002 | |
Paul Sokolovsky | 737bd9c | 2016-07-02 14:57:42 +0300 | [diff] [blame] | 2003 | #ifndef MICROPY_PY_BTREE |
| 2004 | #define MICROPY_PY_BTREE (0) |
| 2005 | #endif |
| 2006 | |
Damien George | d41f6dd | 2021-09-02 12:39:50 +1000 | [diff] [blame] | 2007 | // Whether to provide the low-level "_onewire" module |
| 2008 | #ifndef MICROPY_PY_ONEWIRE |
| 2009 | #define MICROPY_PY_ONEWIRE (0) |
| 2010 | #endif |
| 2011 | |
Jim Mussared | 975a687 | 2023-07-21 13:39:36 +1000 | [diff] [blame] | 2012 | // Whether to provide the "platform" module |
| 2013 | #ifndef MICROPY_PY_PLATFORM |
| 2014 | #define MICROPY_PY_PLATFORM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |
| 2015 | #endif |
| 2016 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 2017 | /*****************************************************************************/ |
| 2018 | /* Hooks for a port to add builtins */ |
| 2019 | |
Yonatan Goldschmidt | 343401c | 2019-02-03 21:24:16 +0200 | [diff] [blame] | 2020 | // 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] | 2021 | #ifndef MICROPY_PORT_BUILTINS |
| 2022 | #define MICROPY_PORT_BUILTINS |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 2023 | #endif |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 2024 | |
stijn | 22cf094 | 2022-01-05 16:04:58 +0100 | [diff] [blame] | 2025 | // Additional builtin function definitions for extension by command-line, boards or variants. |
| 2026 | // See modbuiltins.c:mp_module_builtins_globals_table for format. |
| 2027 | #ifndef MICROPY_PORT_EXTRA_BUILTINS |
| 2028 | #define MICROPY_PORT_EXTRA_BUILTINS |
| 2029 | #endif |
| 2030 | |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 2031 | // Additional constant definitions for the compiler - see compile.c:mp_constants_table. |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 2032 | #ifndef MICROPY_PORT_CONSTANTS |
| 2033 | #define MICROPY_PORT_CONSTANTS |
Damien George | 57e99eb | 2014-04-10 22:42:11 +0100 | [diff] [blame] | 2034 | #endif |
| 2035 | |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 2036 | /*****************************************************************************/ |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 2037 | /* Hooks for a port to wrap functions with attributes */ |
| 2038 | |
Damien George | 8412568 | 2021-09-24 12:49:51 +1000 | [diff] [blame] | 2039 | #ifndef MICROPY_WRAP_MP_BINARY_OP |
| 2040 | #define MICROPY_WRAP_MP_BINARY_OP(f) f |
| 2041 | #endif |
| 2042 | |
| 2043 | #ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE |
| 2044 | #define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f |
| 2045 | #endif |
| 2046 | |
| 2047 | #ifndef MICROPY_WRAP_MP_LOAD_GLOBAL |
| 2048 | #define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f |
| 2049 | #endif |
| 2050 | |
| 2051 | #ifndef MICROPY_WRAP_MP_LOAD_NAME |
| 2052 | #define MICROPY_WRAP_MP_LOAD_NAME(f) f |
| 2053 | #endif |
| 2054 | |
| 2055 | #ifndef MICROPY_WRAP_MP_MAP_LOOKUP |
| 2056 | #define MICROPY_WRAP_MP_MAP_LOOKUP(f) f |
| 2057 | #endif |
| 2058 | |
| 2059 | #ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE |
| 2060 | #define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f |
| 2061 | #endif |
| 2062 | |
Damien George | 7cbf826 | 2021-04-28 10:52:19 +1000 | [diff] [blame] | 2063 | #ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION |
| 2064 | #define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f |
| 2065 | #endif |
| 2066 | |
Damien George | e9e9c76 | 2021-04-28 10:57:34 +1000 | [diff] [blame] | 2067 | #ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT |
| 2068 | #define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 2069 | #endif |
| 2070 | |
Damien George | 544c308 | 2020-04-23 16:18:14 +1000 | [diff] [blame] | 2071 | #ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE |
| 2072 | #define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f |
| 2073 | #endif |
| 2074 | |
Damien George | d54208a | 2022-12-16 17:31:21 +1100 | [diff] [blame] | 2075 | #ifndef MICROPY_WRAP_MP_SCHED_VM_ABORT |
| 2076 | #define MICROPY_WRAP_MP_SCHED_VM_ABORT(f) f |
| 2077 | #endif |
| 2078 | |
Damien George | 8fb5c8f | 2020-02-07 12:07:50 +1100 | [diff] [blame] | 2079 | /*****************************************************************************/ |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 2080 | /* Miscellaneous settings */ |
| 2081 | |
Damien George | 2863153 | 2015-02-08 13:42:00 +0000 | [diff] [blame] | 2082 | // All uPy objects in ROM must be aligned on at least a 4 byte boundary |
| 2083 | // so that the small-int/qstr/pointer distinction can be made. For machines |
| 2084 | // that don't do this (eg 16-bit CPU), define the following macro to something |
| 2085 | // like __attribute__((aligned(4))). |
| 2086 | #ifndef MICROPY_OBJ_BASE_ALIGNMENT |
| 2087 | #define MICROPY_OBJ_BASE_ALIGNMENT |
| 2088 | #endif |
| 2089 | |
Damien George | 4004782 | 2022-04-21 16:30:23 +1000 | [diff] [blame] | 2090 | // String used for the banner, and sys.version additional information |
| 2091 | #ifndef MICROPY_BANNER_NAME_AND_VERSION |
Jim Mussared | 3bf70f1 | 2023-10-10 16:50:28 +1100 | [diff] [blame] | 2092 | #if MICROPY_PREVIEW_VERSION_2 |
| 2093 | #define MICROPY_BANNER_NAME_AND_VERSION "MicroPython (with v2.0 preview) " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE |
| 2094 | #else |
Damien George | 4004782 | 2022-04-21 16:30:23 +1000 | [diff] [blame] | 2095 | #define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE |
| 2096 | #endif |
Jim Mussared | 3bf70f1 | 2023-10-10 16:50:28 +1100 | [diff] [blame] | 2097 | #endif |
Damien George | 4004782 | 2022-04-21 16:30:23 +1000 | [diff] [blame] | 2098 | |
Damien George | 402df83 | 2022-04-26 17:28:39 +1000 | [diff] [blame] | 2099 | // String used for the second part of the banner, and sys.implementation._machine |
| 2100 | #ifndef MICROPY_BANNER_MACHINE |
| 2101 | #ifdef MICROPY_HW_BOARD_NAME |
| 2102 | #define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME |
| 2103 | #else |
| 2104 | #define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version" |
| 2105 | #endif |
| 2106 | #endif |
| 2107 | |
Damien George | ad4656b | 2021-02-04 16:39:09 +1100 | [diff] [blame] | 2108 | // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t |
| 2109 | #ifndef MP_BYTES_PER_OBJ_WORD |
| 2110 | #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t)) |
Damien George | 4c307bf | 2017-04-01 11:39:38 +1100 | [diff] [blame] | 2111 | #endif |
| 2112 | |
Damien George | 7e956fa | 2021-02-04 15:32:59 +1100 | [diff] [blame] | 2113 | // Number of bits in a byte |
| 2114 | #ifndef MP_BITS_PER_BYTE |
| 2115 | #define MP_BITS_PER_BYTE (8) |
Yonatan Goldschmidt | 1c849d6 | 2019-12-01 01:10:12 +0200 | [diff] [blame] | 2116 | #endif |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 2117 | // mp_int_t value with most significant bit set |
Damien George | c891190 | 2021-02-04 16:39:46 +1100 | [diff] [blame] | 2118 | #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] | 2119 | |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2120 | // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are |
| 2121 | // defined and that they are the opposite of each other. |
| 2122 | #if defined(MP_ENDIANNESS_LITTLE) |
| 2123 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
| 2124 | #elif defined(MP_ENDIANNESS_BIG) |
| 2125 | #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG) |
| 2126 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2127 | // Endianness not defined by port so try to autodetect it. |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2128 | #if defined(__BYTE_ORDER__) |
| 2129 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 2130 | #define MP_ENDIANNESS_LITTLE (1) |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 2131 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2132 | #define MP_ENDIANNESS_LITTLE (0) |
| 2133 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2134 | #else |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 2135 | #include <endian.h> |
| 2136 | #if defined(__BYTE_ORDER) |
| 2137 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 2138 | #define MP_ENDIANNESS_LITTLE (1) |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 2139 | #elif __BYTE_ORDER == __BIG_ENDIAN |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 2140 | #define MP_ENDIANNESS_LITTLE (0) |
| 2141 | #endif |
Damien George | 4e4772b | 2015-05-30 23:12:30 +0100 | [diff] [blame] | 2142 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2143 | #endif |
Damien George | 9630376 | 2018-05-07 13:36:52 +1000 | [diff] [blame] | 2144 | #ifndef MP_ENDIANNESS_LITTLE |
| 2145 | #error endianness not defined and cannot detect it |
| 2146 | #endif |
Damien George | a9bcd51 | 2014-10-06 13:44:59 +0000 | [diff] [blame] | 2147 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
Andrew Scheller | cc83737 | 2014-04-14 02:39:56 +0100 | [diff] [blame] | 2148 | #endif |
Paul Sokolovsky | 2da81fa | 2014-04-11 03:44:00 +0300 | [diff] [blame] | 2149 | |
Damien George | 3c658a4 | 2014-08-24 16:28:17 +0100 | [diff] [blame] | 2150 | // Make a pointer to RAM callable (eg set lower bit for Thumb code) |
| 2151 | // (This scheme won't work if we want to mix Thumb and normal ARM code.) |
| 2152 | #ifndef MICROPY_MAKE_POINTER_CALLABLE |
| 2153 | #define MICROPY_MAKE_POINTER_CALLABLE(p) (p) |
| 2154 | #endif |
| 2155 | |
Damien George | 5b22bde | 2024-09-25 14:06:00 +1000 | [diff] [blame] | 2156 | // Whether native text/BSS/rodata memory loaded from .mpy files is explicitly tracked |
| 2157 | // so that the GC cannot reclaim it. |
| 2158 | // |
| 2159 | // In general a port should let these options have their defaults, but the defaults here |
| 2160 | // can be overridden if needed by defining both MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA |
| 2161 | // and MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA. |
| 2162 | #ifndef MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA |
| 2163 | #if MICROPY_EMIT_MACHINE_CODE && MICROPY_PERSISTENT_CODE_LOAD |
| 2164 | // Pointer tracking is required when loading native code is enabled. |
| 2165 | #if defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC) |
| 2166 | // If a port defined a custom allocator or commit function for native text, then the |
| 2167 | // text does not need to be tracked (its allocation is managed by the port). But the |
| 2168 | // BSS/rodata must be tracked (if there is any) because if there are any pointers to it |
| 2169 | // in the function data, they aren't traced by the GC. |
| 2170 | #define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (0) |
| 2171 | #define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (1) |
| 2172 | #else |
| 2173 | // If a port uses the default allocator (the GC heap) then all native text is allocated |
| 2174 | // on the GC heap. But it's not guaranteed that a pointer to the head of the block of |
| 2175 | // native text (which may contain multiple native functions) will be retained for the GC |
| 2176 | // to trace. This is because native functions can start inside the big block of text |
| 2177 | // and so it's possible that the only GC-reachable pointers are pointers inside. |
| 2178 | // Therefore the big block is explicitly tracked. If there is any BSS/rodata memory, |
| 2179 | // then it does not need to be explicitly tracked because a pointer to it is stored into |
| 2180 | // the function text via `mp_native_relocate()`. |
| 2181 | #define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (1) |
| 2182 | #define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (0) |
| 2183 | #endif |
| 2184 | #else // MICROPY_EMIT_MACHINE_CODE && MICROPY_PERSISTENT_CODE_LOAD |
| 2185 | // Pointer tracking not needed when loading native code is disabled. |
| 2186 | #define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (0) |
| 2187 | #define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (0) |
| 2188 | #endif |
Fabian Vogt | b7235b8 | 2014-09-03 16:59:33 +0200 | [diff] [blame] | 2189 | #endif |
| 2190 | |
Damien George | 5b22bde | 2024-09-25 14:06:00 +1000 | [diff] [blame] | 2191 | // If these macros are defined then the memory allocated by them does not need to be |
| 2192 | // traced by the GC. But if they are left undefined then the GC heap will be used as |
| 2193 | // the allocator and the memory must be traced by the GC. See also above logic for |
| 2194 | // enabling MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA and |
| 2195 | // MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA. |
| 2196 | #ifndef MP_PLAT_ALLOC_EXEC |
| 2197 | #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] | 2198 | #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size) |
| 2199 | #endif |
| 2200 | |
Angus Gratton | 519c24d | 2023-08-02 16:49:44 +1000 | [diff] [blame] | 2201 | // Allocating new heap area at runtime requires port to be able to allocate from system heap |
| 2202 | #if MICROPY_GC_SPLIT_HEAP_AUTO |
| 2203 | #ifndef MP_PLAT_ALLOC_HEAP |
| 2204 | #define MP_PLAT_ALLOC_HEAP(size) malloc(size) |
| 2205 | #endif |
| 2206 | #ifndef MP_PLAT_FREE_HEAP |
| 2207 | #define MP_PLAT_FREE_HEAP(ptr) free(ptr) |
| 2208 | #endif |
| 2209 | #endif |
| 2210 | |
Damien George | 7f9d1d6 | 2015-04-09 23:56:15 +0100 | [diff] [blame] | 2211 | // This macro is used to do all output (except when MICROPY_PY_IO is defined) |
| 2212 | #ifndef MP_PLAT_PRINT_STRN |
Damien George | 4300c7d | 2015-10-15 00:05:55 +0100 | [diff] [blame] | 2213 | #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] | 2214 | #endif |
| 2215 | |
Paul Sokolovsky | 722e562 | 2014-09-06 19:17:23 +0300 | [diff] [blame] | 2216 | #ifndef MP_SSIZE_MAX |
| 2217 | #define MP_SSIZE_MAX SSIZE_MAX |
| 2218 | #endif |
| 2219 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 2220 | // printf format spec to use for mp_int_t and friends |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 2221 | #ifndef INT_FMT |
stijn | 3baf6b5 | 2015-11-20 15:59:06 +0100 | [diff] [blame] | 2222 | #if defined(__LP64__) |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 2223 | // Archs where mp_int_t == long, long != int |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 2224 | #define UINT_FMT "%lu" |
| 2225 | #define INT_FMT "%ld" |
Jeff Epler | 7493275 | 2025-07-18 06:37:26 -0500 | [diff] [blame] | 2226 | #define HEX_FMT "%lx" |
stijn | 3baf6b5 | 2015-11-20 15:59:06 +0100 | [diff] [blame] | 2227 | #elif defined(_WIN64) |
stijn | 0a4eb4d | 2015-12-18 10:20:33 +0100 | [diff] [blame] | 2228 | #define UINT_FMT "%llu" |
| 2229 | #define INT_FMT "%lld" |
Jeff Epler | 7493275 | 2025-07-18 06:37:26 -0500 | [diff] [blame] | 2230 | #define HEX_FMT "%llx" |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 2231 | #else |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 2232 | // Archs where mp_int_t == int |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 2233 | #define UINT_FMT "%u" |
| 2234 | #define INT_FMT "%d" |
Jeff Epler | 7493275 | 2025-07-18 06:37:26 -0500 | [diff] [blame] | 2235 | #define HEX_FMT "%x" |
Paul Sokolovsky | c90c0f6 | 2014-01-04 01:57:00 +0200 | [diff] [blame] | 2236 | #endif |
stijn | 84fa331 | 2020-04-16 09:13:57 +0200 | [diff] [blame] | 2237 | #endif // INT_FMT |
Paul Sokolovsky | e908591 | 2014-04-30 05:35:18 +0300 | [diff] [blame] | 2238 | |
| 2239 | // Modifier for function which doesn't return |
Alessandro Gatti | f47e214 | 2025-01-15 16:25:55 +0100 | [diff] [blame] | 2240 | #ifndef MP_NORETURN |
| 2241 | #define MP_NORETURN __attribute__((noreturn)) |
| 2242 | #endif |
| 2243 | |
| 2244 | #if !MICROPY_PREVIEW_VERSION_2 |
| 2245 | #define NORETURN MP_NORETURN |
stijn | 01d6be4 | 2014-05-05 12:18:27 +0200 | [diff] [blame] | 2246 | #endif |
mux | 5c8db48 | 2014-06-21 17:24:55 +0200 | [diff] [blame] | 2247 | |
| 2248 | // Modifier for weak functions |
| 2249 | #ifndef MP_WEAK |
| 2250 | #define MP_WEAK __attribute__((weak)) |
| 2251 | #endif |
Paul Sokolovsky | 361909e | 2014-12-29 00:51:06 +0200 | [diff] [blame] | 2252 | |
Paul Sokolovsky | 0f5bf1a | 2016-06-15 23:52:00 +0300 | [diff] [blame] | 2253 | // Modifier for functions which should be never inlined |
| 2254 | #ifndef MP_NOINLINE |
| 2255 | #define MP_NOINLINE __attribute__((noinline)) |
| 2256 | #endif |
| 2257 | |
Paul Sokolovsky | 1bc2911 | 2016-08-07 22:36:05 +0300 | [diff] [blame] | 2258 | // Modifier for functions which should be always inlined |
| 2259 | #ifndef MP_ALWAYSINLINE |
| 2260 | #define MP_ALWAYSINLINE __attribute__((always_inline)) |
| 2261 | #endif |
| 2262 | |
Paul Sokolovsky | 361909e | 2014-12-29 00:51:06 +0200 | [diff] [blame] | 2263 | // Condition is likely to be true, to help branch prediction |
| 2264 | #ifndef MP_LIKELY |
| 2265 | #define MP_LIKELY(x) __builtin_expect((x), 1) |
| 2266 | #endif |
| 2267 | |
| 2268 | // Condition is likely to be false, to help branch prediction |
| 2269 | #ifndef MP_UNLIKELY |
| 2270 | #define MP_UNLIKELY(x) __builtin_expect((x), 0) |
| 2271 | #endif |
Damien George | 9ddbe29 | 2014-12-29 01:02:19 +0000 | [diff] [blame] | 2272 | |
Damien George | 0c80cb3 | 2019-08-19 15:50:02 +1000 | [diff] [blame] | 2273 | // To annotate that code is unreachable |
| 2274 | #ifndef MP_UNREACHABLE |
| 2275 | #if defined(__GNUC__) |
| 2276 | #define MP_UNREACHABLE __builtin_unreachable(); |
| 2277 | #else |
| 2278 | #define MP_UNREACHABLE for (;;); |
| 2279 | #endif |
| 2280 | #endif |
| 2281 | |
Emil Renner Berthing | ccd9233 | 2019-11-28 12:47:21 +0100 | [diff] [blame] | 2282 | // Explicitly annotate switch case fall throughs |
| 2283 | #if defined(__GNUC__) && __GNUC__ >= 7 |
| 2284 | #define MP_FALLTHROUGH __attribute__((fallthrough)); |
| 2285 | #else |
| 2286 | #define MP_FALLTHROUGH |
| 2287 | #endif |
| 2288 | |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 2289 | #ifndef MP_HTOBE16 |
| 2290 | #if MP_ENDIANNESS_LITTLE |
Damien George | feb2577 | 2020-03-20 21:47:07 +1100 | [diff] [blame] | 2291 | #define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))) |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2292 | #define MP_BE16TOH(x) MP_HTOBE16(x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 2293 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2294 | #define MP_HTOBE16(x) (x) |
| 2295 | #define MP_BE16TOH(x) (x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 2296 | #endif |
| 2297 | #endif |
| 2298 | |
| 2299 | #ifndef MP_HTOBE32 |
| 2300 | #if MP_ENDIANNESS_LITTLE |
Damien George | feb2577 | 2020-03-20 21:47:07 +1100 | [diff] [blame] | 2301 | #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] | 2302 | #define MP_BE32TOH(x) MP_HTOBE32(x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 2303 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2304 | #define MP_HTOBE32(x) (x) |
| 2305 | #define MP_BE32TOH(x) (x) |
Paul Sokolovsky | 1b146e9 | 2017-11-08 19:45:18 +0200 | [diff] [blame] | 2306 | #endif |
| 2307 | #endif |
| 2308 | |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 2309 | // Warning categories are by default implemented as strings, though |
| 2310 | // hook is left for a port to define them as something else. |
| 2311 | #if MICROPY_WARNINGS_CATEGORY |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2312 | #ifndef MP_WARN_CAT |
| 2313 | #define MP_WARN_CAT(x) #x |
| 2314 | #endif |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 2315 | #else |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 2316 | #undef MP_WARN_CAT |
| 2317 | #define MP_WARN_CAT(x) (NULL) |
Paul Sokolovsky | 2f5d113 | 2018-12-21 14:20:55 +0300 | [diff] [blame] | 2318 | #endif |
| 2319 | |
Alexander Steffen | 299bc62 | 2017-06-29 23:14:58 +0200 | [diff] [blame] | 2320 | #endif // MICROPY_INCLUDED_PY_MPCONFIG_H |