blob: 76aff4681d32a55e047a0e8a450587e80180bdbd [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
Damien Georgec408ed92017-06-26 12:29:20 +10002 * This file is part of the MicroPython project, http://micropython.org/
Damien George04b91472014-05-03 23:27:38 +01003 *
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 Steffen299bc622017-06-29 23:14:58 +020026#ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
27#define MICROPY_INCLUDED_PY_MPCONFIG_H
Damien George04b91472014-05-03 23:27:38 +010028
Jim Mussared69e34b62023-10-04 11:20:47 +110029// 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 Georgeaba83e62019-01-26 00:44:35 +110032#define MICROPY_VERSION_MAJOR 1
Damien George44dc6eb2024-10-28 11:08:24 +110033#define MICROPY_VERSION_MINOR 25
Damien George294baf52023-04-26 15:42:28 +100034#define MICROPY_VERSION_MICRO 0
Damien George44dc6eb2024-10-28 11:08:24 +110035#define MICROPY_VERSION_PRERELEASE 1
Damien George7cd59c52018-12-15 15:13:33 +110036
Jim Mussared69e34b62023-10-04 11:20:47 +110037// 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 George7cd59c52018-12-15 15:13:33 +110042
Jim Mussared69e34b62023-10-04 11:20:47 +110043// 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 George7cd59c52018-12-15 15:13:33 +110047 MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \
48 MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \
49 MP_STRINGIFY(MICROPY_VERSION_MICRO)
Jim Mussared69e34b62023-10-04 11:20:47 +110050#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 George7cd59c52018-12-15 15:13:33 +110055
Jim Mussared3bf70f12023-10-10 16:50:28 +110056// 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 Sokolovskyb372bfc2014-01-03 17:15:53 +020062// This file contains default configuration settings for MicroPython.
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020063// You can override any of the options below using mpconfigport.h file
64// located in a directory of your port.
Paul Sokolovskyb372bfc2014-01-03 17:15:53 +020065
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020066// mpconfigport.h is a file containing configuration settings for a
67// particular port. mpconfigport.h is actually a default name for
Ville Skyttäca16c382017-05-29 10:08:14 +030068// such config, and it can be overridden using MP_CONFIGFILE preprocessor
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020069// 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 Mussared01374d92021-08-14 01:43:15 +100075// 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 Mussared605266e2022-08-16 01:28:31 +100088#ifdef MP_CONFIGFILE
89#include MP_CONFIGFILE
90#else
91#include <mpconfigport.h>
92#endif
93
Jim Mussared01374d92021-08-14 01:43:15 +100094// 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 George136f6752014-01-07 14:54:15 +0000106// Any options not explicitly set in mpconfigport.h will get default
107// values below.
108
109/*****************************************************************************/
Damien George567184e2015-03-29 14:05:46 +0100110/* Object representation */
111
Damien Georgec408ed92017-06-26 12:29:20 +1000112// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +0100113// - xxxx...xxx1 : a small int, bits 1 and above are the value
Damien George6f0c83f2020-01-08 23:58:40 +1100114// - 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 George567184e2015-03-29 14:05:46 +0100116// - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
117#define MICROPY_OBJ_REPR_A (0)
118
Damien Georgec408ed92017-06-26 12:29:20 +1000119// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +0100120// - xxxx...xx01 : a small int, bits 2 and above are the value
Damien George6f0c83f2020-01-08 23:58:40 +1100121// - 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 George567184e2015-03-29 14:05:46 +0100123// - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
124#define MICROPY_OBJ_REPR_B (1)
125
Damien George8b8d1892015-11-06 23:25:10 +0000126// A MicroPython object is a machine word having the following form (called R):
Damien George183edef2015-10-17 23:20:57 +0100127// - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
Damien George6f0c83f2020-01-08 23:58:40 +1100128// - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value
129// - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value
Damien George183edef2015-10-17 23:20:57 +0100130// - 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 George6f0c83f2020-01-08 23:58:40 +1100134// 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 George183edef2015-10-17 23:20:57 +0100136// This scheme only works with 32-bit word size and float enabled.
137#define MICROPY_OBJ_REPR_C (2)
138
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000139// 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 George2759bec2017-12-11 22:39:12 +1100143// - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000144// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
Damien George6f0c83f2020-01-08 23:58:40 +1100145// - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000146// - 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 George567184e2015-03-29 14:05:46 +0100153#ifndef MICROPY_OBJ_REPR
154#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
155#endif
156
Damien Georged96cfd12020-01-09 00:00:27 +1100157// 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 George567184e2015-03-29 14:05:46 +0100164/*****************************************************************************/
Damien George66e18f02014-05-05 13:19:03 +0100165/* Memory allocation policy */
166
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200167// Number of bytes in memory allocation/GC block. Any size allocated will be
168// rounded up to be multiples of this.
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200169#ifndef MICROPY_BYTES_PER_GC_BLOCK
Damien Georgead4656b2021-02-04 16:39:09 +1100170#define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD)
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200171#endif
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200172
Damien Georgefd40a9c2015-01-01 22:04:46 +0000173// 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 Laethem31cf5282018-02-23 18:59:31 +0100178// 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 George5ffe1d82016-08-26 15:35:26 +1000187// 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 Hogben828df542016-10-31 14:52:11 +0000190// A memory manager which always clears memory can set this to 0.
Damien George5ffe1d82016-08-26 15:35:26 +1000191// 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 Hogben828df542016-10-31 14:52:11 +0000194#define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
Damien George5ffe1d82016-08-26 15:35:26 +1000195#endif
196
Paul Sokolovsky93e353e2016-07-21 00:37:30 +0300197// Support automatic GC when reaching allocation threshold,
198// configurable by gc.threshold().
199#ifndef MICROPY_GC_ALLOC_THRESHOLD
Jim Mussared01374d92021-08-14 01:43:15 +1000200#define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky93e353e2016-07-21 00:37:30 +0300201#endif
202
Damien Georgeade9a052015-06-13 21:53:22 +0100203// 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 Georgee1199ec2014-05-10 17:48:01 +0100211// Initial amount for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100212#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
213#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
Damien Georgee1199ec2014-05-10 17:48:01 +0100214#endif
215
216// Increment for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100217#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
218#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
Damien Georgee1199ec2014-05-10 17:48:01 +0100219#endif
220
Damien George66e18f02014-05-05 13:19:03 +0100221// Initial amount for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100222#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
223#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
Damien George66e18f02014-05-05 13:19:03 +0100224#endif
225
226// Increment for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100227#ifndef MICROPY_ALLOC_PARSE_RULE_INC
228#define MICROPY_ALLOC_PARSE_RULE_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100229#endif
230
231// Initial amount for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100232#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
233#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
Damien George66e18f02014-05-05 13:19:03 +0100234#endif
235
236// Increment for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100237#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
238#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100239#endif
240
Damien George5042bce2014-05-25 22:06:06 +0100241// 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 George58e0f4a2015-09-23 10:50:43 +0100246// 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 George66e18f02014-05-05 13:19:03 +0100252// Initial amount for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100253#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
254#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
Damien George66e18f02014-05-05 13:19:03 +0100255#endif
256
257// Increment for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100258#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 George66e18f02014-05-05 13:19:03 +0100266#endif
267
Paul Sokolovsky346aacf2014-11-05 00:27:15 +0200268// Initial size of module dict
269#ifndef MICROPY_MODULE_DICT_SIZE
270#define MICROPY_MODULE_DICT_SIZE (1)
271#endif
272
matejcik1a2ffda2021-03-22 11:20:22 +0100273// 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 Georged8914522015-02-27 09:54:12 +0000278// 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 George95836f82015-01-11 22:27:30 +0000284// 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 Georgec3bd9412015-07-20 11:03:13 +0000291// Number of bytes used to store qstr hash
292#ifndef MICROPY_QSTR_BYTES_IN_HASH
Jim Mussaredd4190812023-10-31 10:47:45 +1100293#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
Damien Georgec3bd9412015-07-20 11:03:13 +0000294#define MICROPY_QSTR_BYTES_IN_HASH (2)
Jim Mussaredd4190812023-10-31 10:47:45 +1100295#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
Jim Mussared01374d92021-08-14 01:43:15 +1000296#define MICROPY_QSTR_BYTES_IN_HASH (1)
Jim Mussaredd4190812023-10-31 10:47:45 +1100297#else
298#define MICROPY_QSTR_BYTES_IN_HASH (0)
Jim Mussared01374d92021-08-14 01:43:15 +1000299#endif
Damien Georgec3bd9412015-07-20 11:03:13 +0000300#endif
301
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200302// Avoid using C stack when making Python function calls. C stack still
303// may be used if there's no free heap.
Paul Sokolovsky20397572015-03-28 01:14:44 +0200304#ifndef MICROPY_STACKLESS
305#define MICROPY_STACKLESS (0)
306#endif
307
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200308// 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 Sokolovskyf32020e2015-11-25 23:22:31 +0200315// 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 George66e18f02014-05-05 13:19:03 +0100325/*****************************************************************************/
Damien Georgec408ed92017-06-26 12:29:20 +1000326/* MicroPython emitters */
Damien George136f6752014-01-07 14:54:15 +0000327
Damien Georged8c834c2015-11-02 21:55:42 +0000328// Whether to support loading of persistent code
329#ifndef MICROPY_PERSISTENT_CODE_LOAD
330#define MICROPY_PERSISTENT_CODE_LOAD (0)
331#endif
332
Jim Mussaredb2b5bcc2023-08-23 13:30:20 +1000333// 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 Georged8c834c2015-11-02 21:55:42 +0000336#ifndef MICROPY_PERSISTENT_CODE_SAVE
Jim Mussaredb2b5bcc2023-08-23 13:30:20 +1000337#define MICROPY_PERSISTENT_CODE_SAVE (MICROPY_PY_SYS_SETTRACE)
Damien Georged8c834c2015-11-02 21:55:42 +0000338#endif
339
David CARLIERcb309282021-01-16 20:48:19 +0000340// 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 Georgec8e9c0d2015-11-02 17:27:18 +0000345// Whether generated code can persist independently of the VM/runtime instance
Damien Georged8c834c2015-11-02 21:55:42 +0000346// This is enabled automatically when needed by other features
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000347#ifndef MICROPY_PERSISTENT_CODE
Damien George0a2e9652016-01-31 22:24:16 +0000348#define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000349#endif
350
Damien Georgef2040bf2021-10-22 22:22:47 +1100351// Whether bytecode uses a qstr_table to map internal qstr indices in the bytecode
352// to global qstr values in the runtime (behaviour when feature is enabled), or
353// just stores global qstr values directly in the bytecode. This must be enabled
354// if MICROPY_PERSISTENT_CODE is enabled.
355#ifndef MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
356#define MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE (MICROPY_PERSISTENT_CODE)
357#endif
358
Damien George136f6752014-01-07 14:54:15 +0000359// Whether to emit x64 native code
360#ifndef MICROPY_EMIT_X64
361#define MICROPY_EMIT_X64 (0)
362#endif
363
Damien Georgec90f59e2014-09-06 23:06:36 +0100364// Whether to emit x86 native code
365#ifndef MICROPY_EMIT_X86
366#define MICROPY_EMIT_X86 (0)
367#endif
368
Damien George136f6752014-01-07 14:54:15 +0000369// Whether to emit thumb native code
370#ifndef MICROPY_EMIT_THUMB
371#define MICROPY_EMIT_THUMB (0)
372#endif
373
graham sanderson40d20102020-12-12 13:04:10 -0600374// Whether to emit ARMv7-M instruction support in thumb native code
375#ifndef MICROPY_EMIT_THUMB_ARMV7M
376#define MICROPY_EMIT_THUMB_ARMV7M (1)
377#endif
378
Damien George136f6752014-01-07 14:54:15 +0000379// Whether to enable the thumb inline assembler
380#ifndef MICROPY_EMIT_INLINE_THUMB
381#define MICROPY_EMIT_INLINE_THUMB (0)
382#endif
383
=50089722015-04-14 13:14:57 +0100384// Whether to enable float support in the Thumb2 inline assembler
385#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
386#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
387#endif
388
Fabian Vogtfe3d16e2014-08-16 22:55:53 +0200389// Whether to emit ARM native code
390#ifndef MICROPY_EMIT_ARM
391#define MICROPY_EMIT_ARM (0)
392#endif
393
Damien George8e5aced2016-12-09 16:39:39 +1100394// Whether to emit Xtensa native code
395#ifndef MICROPY_EMIT_XTENSA
396#define MICROPY_EMIT_XTENSA (0)
397#endif
398
Damien Georgef76b1bf2016-12-09 17:03:33 +1100399// Whether to enable the Xtensa inline assembler
400#ifndef MICROPY_EMIT_INLINE_XTENSA
401#define MICROPY_EMIT_INLINE_XTENSA (0)
402#endif
403
Damien George9adedce2019-09-13 13:15:12 +1000404// Whether to emit Xtensa-Windowed native code
405#ifndef MICROPY_EMIT_XTENSAWIN
406#define MICROPY_EMIT_XTENSAWIN (0)
407#endif
408
Alessandro Gatti8338f662024-06-08 11:00:08 +0200409// Whether to emit RISC-V RV32 native code
410#ifndef MICROPY_EMIT_RV32
411#define MICROPY_EMIT_RV32 (0)
412#endif
413
Alessandro Gatti268acb72024-08-25 16:28:35 +0200414// Whether to enable the RISC-V RV32 inline assembler
415#ifndef MICROPY_EMIT_INLINE_RV32
416#define MICROPY_EMIT_INLINE_RV32 (0)
417#endif
418
Damien George2ac4af62014-08-15 16:45:41 +0100419// Convenience definition for whether any native emitter is enabled
Damien George9dbc7872024-03-07 11:38:27 +1100420#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 George9adedce2019-09-13 13:15:12 +1000421
Damien George1fb01bd2022-05-10 13:56:24 +1000422// Some architectures cannot read byte-wise from executable memory. In this case
423// the prelude for a native function (which usually sits after the machine code)
424// must be separated and placed somewhere where it can be read byte-wise.
425#define MICROPY_EMIT_NATIVE_PRELUDE_SEPARATE_FROM_MACHINE_CODE (MICROPY_EMIT_XTENSAWIN)
Damien George2ac4af62014-08-15 16:45:41 +0100426
Damien Georgead297a12016-12-09 13:17:49 +1100427// Convenience definition for whether any inline assembler emitter is enabled
Alessandro Gatti268acb72024-08-25 16:28:35 +0200428#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA || MICROPY_EMIT_INLINE_RV32)
Damien Georgead297a12016-12-09 13:17:49 +1100429
Jun Wub152bbd2019-05-06 00:31:11 -0700430// Convenience definition for whether any native or inline assembler emitter is enabled
431#define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)
432
Damien George136f6752014-01-07 14:54:15 +0000433/*****************************************************************************/
Damien George58ebde42014-05-21 20:32:59 +0100434/* Compiler configuration */
435
Damien Georgedd5353a2015-12-18 12:35:44 +0000436// Whether to include the compiler
437#ifndef MICROPY_ENABLE_COMPILER
Jim Mussared01374d92021-08-14 01:43:15 +1000438#define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgedd5353a2015-12-18 12:35:44 +0000439#endif
440
Damien Georgeea235202016-02-11 22:30:53 +0000441// Whether the compiler is dynamically configurable (ie at runtime)
Damien Georgea4f1d822019-05-29 21:17:29 +1000442// This will disable the ability to execute native/viper code
Damien Georgeea235202016-02-11 22:30:53 +0000443#ifndef MICROPY_DYNAMIC_COMPILER
444#define MICROPY_DYNAMIC_COMPILER (0)
445#endif
446
Damien George2b8e88c2023-06-24 17:02:58 +1000447// Whether the compiler allows compiling top-level await expressions
448#ifndef MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
449#define MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT (0)
450#endif
451
Damien George64f2b212015-10-08 14:58:15 +0100452// Whether to enable constant folding; eg 1+2 rewritten as 3
453#ifndef MICROPY_COMP_CONST_FOLDING
Jim Mussared01374d92021-08-14 01:43:15 +1000454#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George64f2b212015-10-08 14:58:15 +0100455#endif
456
Damien George35c0cff2022-03-31 14:27:47 +1100457// Whether to compile constant tuples immediately to their respective objects; eg (1, True)
458// Otherwise the tuple will be built at runtime
459#ifndef MICROPY_COMP_CONST_TUPLE
460#define MICROPY_COMP_CONST_TUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
461#endif
462
Damien George07796932019-02-27 00:10:04 +1100463// Whether to enable optimisations for constant literals, eg OrderedDict
464#ifndef MICROPY_COMP_CONST_LITERAL
Jim Mussared01374d92021-08-14 01:43:15 +1000465#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George07796932019-02-27 00:10:04 +1100466#endif
467
Damien Georgeddd1e182015-01-10 14:07:24 +0000468// Whether to enable lookup of constants in modules; eg module.CONST
469#ifndef MICROPY_COMP_MODULE_CONST
Jim Mussared0e236ee2021-09-15 23:18:23 +1000470#define MICROPY_COMP_MODULE_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeddd1e182015-01-10 14:07:24 +0000471#endif
472
Damien George58ebde42014-05-21 20:32:59 +0100473// Whether to enable constant optimisation; id = const(value)
474#ifndef MICROPY_COMP_CONST
Jim Mussared01374d92021-08-14 01:43:15 +1000475#define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George58ebde42014-05-21 20:32:59 +0100476#endif
477
Damien George42e0c592015-03-14 13:11:35 +0000478// Whether to enable optimisation of: a, b = c, d
479// Costs 124 bytes (Thumb2)
480#ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
Jim Mussared01374d92021-08-14 01:43:15 +1000481#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George42e0c592015-03-14 13:11:35 +0000482#endif
483
484// Whether to enable optimisation of: a, b, c = d, e, f
Damien George253f2bd2018-02-04 13:35:21 +1100485// Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
Damien George42e0c592015-03-14 13:11:35 +0000486#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
Jim Mussared0e236ee2021-09-15 23:18:23 +1000487#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George42e0c592015-03-14 13:11:35 +0000488#endif
489
Damien Georgeae54fbf2017-04-22 14:58:01 +1000490// Whether to enable optimisation of: return a if b else c
491// Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
492#ifndef MICROPY_COMP_RETURN_IF_EXPR
Jim Mussared0e236ee2021-09-15 23:18:23 +1000493#define MICROPY_COMP_RETURN_IF_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeae54fbf2017-04-22 14:58:01 +1000494#endif
495
Damien George58ebde42014-05-21 20:32:59 +0100496/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +0000497/* Internal debugging stuff */
498
499// Whether to collect memory allocation stats
500#ifndef MICROPY_MEM_STATS
501#define MICROPY_MEM_STATS (0)
502#endif
503
Damien Georgeda2d2b62018-08-02 14:04:44 +1000504// The mp_print_t printer used for debugging output
505#ifndef MICROPY_DEBUG_PRINTER
506#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
507#endif
508
Damien Georgecbd2f742014-01-19 11:48:48 +0000509// Whether to build functions that print debugging info:
Damien George3417bc22014-05-10 10:36:38 +0100510// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000511// mp_parse_node_print
512#ifndef MICROPY_DEBUG_PRINTERS
513#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000514#endif
515
Stefan Naumannace9fb52017-07-24 18:55:14 +0200516// Whether to enable all debugging outputs (it will be extremely verbose)
517#ifndef MICROPY_DEBUG_VERBOSE
518#define MICROPY_DEBUG_VERBOSE (0)
519#endif
520
Damien George02cc2882019-03-08 15:48:20 +1100521// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
522#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
523#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
524#endif
525
Damien George843dcd42020-09-30 23:34:42 +1000526// Whether to print parse rule names (rather than integers) in mp_parse_node_print
527#ifndef MICROPY_DEBUG_PARSE_RULE_NAME
528#define MICROPY_DEBUG_PARSE_RULE_NAME (0)
529#endif
530
Damien George6d199342019-01-04 17:09:41 +1100531// Whether to enable a simple VM stack overflow check
532#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
533#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
534#endif
535
Jeff Epler84071592021-08-27 09:02:03 -0500536// Whether to enable extra instrumentation for valgrind
537#ifndef MICROPY_DEBUG_VALGRIND
538#define MICROPY_DEBUG_VALGRIND (0)
539#endif
540
Damien George136f6752014-01-07 14:54:15 +0000541/*****************************************************************************/
Damien Georgeee3fd462014-05-24 23:03:12 +0100542/* Optimisations */
543
544// Whether to use computed gotos in the VM, or a switch
Jim Mussaredb51e7e92021-08-19 17:49:33 +1000545// Computed gotos are roughly 10% faster, and increase VM code size by a little,
546// e.g. ~1kiB on Cortex M4.
Damien George44f0a4d2017-09-18 23:53:33 +1000547// Note: enabling this will use the gcc-specific extensions of ranged designated
548// initialisers and addresses of labels, which are not part of the C99 standard.
Damien Georgeee3fd462014-05-24 23:03:12 +0100549#ifndef MICROPY_OPT_COMPUTED_GOTO
550#define MICROPY_OPT_COMPUTED_GOTO (0)
551#endif
552
Jim Mussared7b89ad82021-08-19 22:46:40 +1000553// Optimise the fast path for loading attributes from instance types. Increases
554// Thumb2 code size by about 48 bytes.
555#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
Jim Mussared0e236ee2021-09-15 23:18:23 +1000556#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared7b89ad82021-08-19 22:46:40 +1000557#endif
558
Jim Mussared11ef8f22021-08-18 14:52:48 +1000559// Use extra RAM to cache map lookups by remembering the likely location of
560// the index. Avoids the hash computation on unordered maps, and avoids the
561// linear search on ordered (especially in-ROM) maps. Can provide a +10-15%
562// performance improvement on benchmarks involving lots of attribute access
563// or dictionary lookup.
564#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000565#define MICROPY_OPT_MAP_LOOKUP_CACHE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared11ef8f22021-08-18 14:52:48 +1000566#endif
567
568// How much RAM (in bytes) to use for the map lookup cache.
569#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE
570#define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128)
571#endif
572
Doug Currie2e2e15c2016-01-30 22:35:58 -0500573// Whether to use fast versions of bitwise operations (and, or, xor) when the
574// arguments are both positive. Increases Thumb2 code size by about 250 bytes.
575#ifndef MICROPY_OPT_MPZ_BITWISE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000576#define MICROPY_OPT_MPZ_BITWISE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Doug Currie2e2e15c2016-01-30 22:35:58 -0500577#endif
578
Christopher Swenson8c656752018-08-27 10:32:21 +1000579
580// Whether math.factorial is large, fast and recursive (1) or small and slow (0).
581#ifndef MICROPY_OPT_MATH_FACTORIAL
Jim Mussared0e236ee2021-09-15 23:18:23 +1000582#define MICROPY_OPT_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Christopher Swenson8c656752018-08-27 10:32:21 +1000583#endif
584
Damien Georgeee3fd462014-05-24 23:03:12 +0100585/*****************************************************************************/
586/* Python internal features */
Damien George136f6752014-01-07 14:54:15 +0000587
J. Neuschäfer7b050b32023-04-02 19:58:42 +0200588// Use a special long jump in nlrthumb.c, which may be necessary if nlr.o and
589// nlrthumb.o are linked far apart from each other.
590#ifndef MICROPY_NLR_THUMB_USE_LONG_JUMP
591#define MICROPY_NLR_THUMB_USE_LONG_JUMP (0)
592#endif
593
Damien George20993682018-02-20 18:00:44 +1100594// Whether to enable import of external modules
595// When disabled, only importing of built-in modules is supported
596// When enabled, a port must implement mp_import_stat (among other things)
597#ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
Jim Mussared01374d92021-08-14 01:43:15 +1000598#define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George20993682018-02-20 18:00:44 +1100599#endif
600
Damien George6b239c22016-11-16 16:04:57 +1100601// Whether to use the POSIX reader for importing files
602#ifndef MICROPY_READER_POSIX
603#define MICROPY_READER_POSIX (0)
604#endif
605
Damien Georgedcb9ea72017-01-27 15:10:09 +1100606// Whether to use the VFS reader for importing files
607#ifndef MICROPY_READER_VFS
608#define MICROPY_READER_VFS (0)
609#endif
610
Sean Burtone33bc592018-12-13 12:10:35 +0000611// Whether any readers have been defined
612#ifndef MICROPY_HAS_FILE_READER
613#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
614#endif
615
Damien George40d84302016-02-15 22:46:21 +0000616// Hook for the VM at the start of the opcode loop (can contain variable
617// definitions usable by the other hook functions)
618#ifndef MICROPY_VM_HOOK_INIT
619#define MICROPY_VM_HOOK_INIT
620#endif
621
622// Hook for the VM during the opcode loop (but only after jump opcodes)
623#ifndef MICROPY_VM_HOOK_LOOP
624#define MICROPY_VM_HOOK_LOOP
625#endif
626
627// Hook for the VM just before return opcode is finished being interpreted
628#ifndef MICROPY_VM_HOOK_RETURN
629#define MICROPY_VM_HOOK_RETURN
630#endif
631
Damien George916c3fd2021-04-25 22:24:49 +1000632// Hook for mp_sched_schedule when a function gets scheduled on sched_queue
633// (this macro executes within an atomic section)
634#ifndef MICROPY_SCHED_HOOK_SCHEDULED
635#define MICROPY_SCHED_HOOK_SCHEDULED
636#endif
637
Damien Georged3ebe482014-01-07 15:20:33 +0000638// Whether to include the garbage collector
639#ifndef MICROPY_ENABLE_GC
640#define MICROPY_ENABLE_GC (0)
641#endif
642
Ayke van Laethembcc827d2018-01-24 02:09:58 +0100643// Whether the garbage-collected heap can be split over multiple memory areas.
644#ifndef MICROPY_GC_SPLIT_HEAP
645#define MICROPY_GC_SPLIT_HEAP (0)
646#endif
647
Angus Gratton519c24d2023-08-02 16:49:44 +1000648// Whether regions should be added/removed from the split heap as needed.
649#ifndef MICROPY_GC_SPLIT_HEAP_AUTO
650#define MICROPY_GC_SPLIT_HEAP_AUTO (0)
651#endif
652
Laurens Valkfe120482021-10-26 10:47:04 +0200653// Hook to run code during time consuming garbage collector operations
David Lechner468ed212023-03-15 16:48:16 -0500654// *i* is the loop index variable (e.g. can be used to run every x loops)
Laurens Valkfe120482021-10-26 10:47:04 +0200655#ifndef MICROPY_GC_HOOK_LOOP
David Lechner468ed212023-03-15 16:48:16 -0500656#define MICROPY_GC_HOOK_LOOP(i)
Laurens Valkfe120482021-10-26 10:47:04 +0200657#endif
658
Damien Georgefca57012022-05-04 12:12:11 +1000659// Whether to provide m_tracked_calloc, m_tracked_free functions
660#ifndef MICROPY_TRACKED_ALLOC
661#define MICROPY_TRACKED_ALLOC (0)
662#endif
663
Damien George12bab722014-04-05 20:35:48 +0100664// Whether to enable finalisers in the garbage collector (ie call __del__)
Damien George7860c2a2014-11-05 21:16:41 +0000665#ifndef MICROPY_ENABLE_FINALISER
Jim Mussared0e236ee2021-09-15 23:18:23 +1000666#define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George12bab722014-04-05 20:35:48 +0100667#endif
668
Damien George02d830c2017-11-26 23:28:40 +1100669// Whether to enable a separate allocator for the Python stack.
670// If enabled then the code must call mp_pystack_init before mp_init.
671#ifndef MICROPY_ENABLE_PYSTACK
672#define MICROPY_ENABLE_PYSTACK (0)
673#endif
674
675// Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
676#ifndef MICROPY_PYSTACK_ALIGN
677#define MICROPY_PYSTACK_ALIGN (8)
678#endif
679
Paul Sokolovsky23668692014-06-25 03:03:34 +0300680// Whether to check C stack usage. C stack used for calling Python functions,
681// etc. Not checking means segfault on overflow.
682#ifndef MICROPY_STACK_CHECK
Jim Mussared0e236ee2021-09-15 23:18:23 +1000683#define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky23668692014-06-25 03:03:34 +0300684#endif
685
Angus Gratton86f2c282024-08-06 15:51:22 +1000686// Additional margin between the places in the runtime where Python stack is
687// checked and the actual end of the C stack. Needs to be large enough to avoid
688// overflows from function calls made between checks.
689#ifndef MICROPY_STACK_CHECK_MARGIN
690#define MICROPY_STACK_CHECK_MARGIN (0)
691#endif
692
Dave Hylands5b7fd202014-07-01 23:46:53 -0700693// Whether to have an emergency exception buffer
694#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
695#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
696#endif
697#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
Damien George69661f32020-02-27 15:36:53 +1100698#ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
699#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
700#endif
Dave Hylands5b7fd202014-07-01 23:46:53 -0700701#endif
702
Damien Georgebbb4b982017-04-10 17:19:36 +1000703// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
Damien George7f1da0a2016-12-15 13:00:19 +1100704#ifndef MICROPY_KBD_EXCEPTION
Jim Mussared0e236ee2021-09-15 23:18:23 +1000705#define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George7f1da0a2016-12-15 13:00:19 +1100706#endif
707
Paul Sokolovsky1c9210b2015-12-23 00:06:37 +0200708// Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
709// handler) - if supported by a particular port.
710#ifndef MICROPY_ASYNC_KBD_INTR
711#define MICROPY_ASYNC_KBD_INTR (0)
712#endif
713
Damien George136f6752014-01-07 14:54:15 +0000714// Whether to include REPL helper function
Damien George58ebde42014-05-21 20:32:59 +0100715#ifndef MICROPY_HELPER_REPL
Jim Mussared0e236ee2021-09-15 23:18:23 +1000716#define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George136f6752014-01-07 14:54:15 +0000717#endif
718
Yonatan Goldschmidt61d2b402019-12-25 09:27:38 +0200719// Allow enabling debug prints after each REPL line
720#ifndef MICROPY_REPL_INFO
Damien Georgec62351f2021-11-01 15:18:22 +1100721#define MICROPY_REPL_INFO (0)
Yonatan Goldschmidt61d2b402019-12-25 09:27:38 +0200722#endif
723
Tom Soulanille7d588b02015-07-09 16:32:36 -0700724// Whether to include emacs-style readline behavior in REPL
725#ifndef MICROPY_REPL_EMACS_KEYS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000726#define MICROPY_REPL_EMACS_KEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Tom Soulanille7d588b02015-07-09 16:32:36 -0700727#endif
728
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200729// Whether to include emacs-style word movement/kill readline behavior in REPL.
730// This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word
731// and backward-kill-word, respectively.
732#ifndef MICROPY_REPL_EMACS_WORDS_MOVE
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000733#define MICROPY_REPL_EMACS_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200734#endif
735
736// Whether to include extra convenience keys for word movement/kill in readline REPL.
737// This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word
738// respectively. Ctrl+Delete is not implemented because it's a very different escape sequence.
739// Depends on MICROPY_REPL_EMACS_WORDS_MOVE.
740#ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000741#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200742#endif
743
Damien George0af73012015-08-20 10:34:16 +0100744// Whether to implement auto-indent in REPL
745#ifndef MICROPY_REPL_AUTO_INDENT
Jim Mussared0e236ee2021-09-15 23:18:23 +1000746#define MICROPY_REPL_AUTO_INDENT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George0af73012015-08-20 10:34:16 +0100747#endif
748
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200749// Whether port requires event-driven REPL functions
750#ifndef MICROPY_REPL_EVENT_DRIVEN
751#define MICROPY_REPL_EVENT_DRIVEN (0)
752#endif
753
David Lechner81dbea12022-07-01 14:06:10 -0500754// The number of items to keep in the readline history.
755#ifndef MICROPY_READLINE_HISTORY_SIZE
756#define MICROPY_READLINE_HISTORY_SIZE (8)
757#endif
758
Damien Georged3ebe482014-01-07 15:20:33 +0000759// Whether to include lexer helper function for unix
Damien George58ebde42014-05-21 20:32:59 +0100760#ifndef MICROPY_HELPER_LEXER_UNIX
761#define MICROPY_HELPER_LEXER_UNIX (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000762#endif
763
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200764// Long int implementation
765#define MICROPY_LONGINT_IMPL_NONE (0)
766#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000767#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200768
769#ifndef MICROPY_LONGINT_IMPL
770#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
771#endif
772
773#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
774typedef long long mp_longint_impl_t;
775#endif
776
Damien George62ad1892014-01-29 21:51:51 +0000777// Whether to include information in the byte code to determine source
778// line number (increases RAM usage, but doesn't slow byte code execution)
779#ifndef MICROPY_ENABLE_SOURCE_LINE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000780#define MICROPY_ENABLE_SOURCE_LINE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George62ad1892014-01-29 21:51:51 +0000781#endif
782
Damien George1463c1f2014-04-25 23:52:57 +0100783// Whether to include doc strings (increases RAM usage)
784#ifndef MICROPY_ENABLE_DOC_STRING
785#define MICROPY_ENABLE_DOC_STRING (0)
786#endif
787
Damien Georged4b706c2021-04-22 12:13:58 +1000788// Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION)
789#define MICROPY_ERROR_REPORTING_NONE (0)
Damien George1e9a92f2014-11-06 17:36:16 +0000790// Exception messages are short static strings
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300791#define MICROPY_ERROR_REPORTING_TERSE (1)
792// Exception messages provide basic error details
793#define MICROPY_ERROR_REPORTING_NORMAL (2)
794// Exception messages provide full info, e.g. object names
795#define MICROPY_ERROR_REPORTING_DETAILED (3)
796
797#ifndef MICROPY_ERROR_REPORTING
Jim Mussared01374d92021-08-14 01:43:15 +1000798#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES
799#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
800#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300801#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
Jim Mussared01374d92021-08-14 01:43:15 +1000802#else
803#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
804#endif
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300805#endif
806
Paul Sokolovsky8a8c1fc2015-01-01 09:29:28 +0200807// Whether issue warnings during compiling/execution
808#ifndef MICROPY_WARNINGS
809#define MICROPY_WARNINGS (0)
810#endif
811
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +0300812// Whether to support warning categories
813#ifndef MICROPY_WARNINGS_CATEGORY
814#define MICROPY_WARNINGS_CATEGORY (0)
815#endif
816
David Lechner62849b72017-09-24 20:15:48 -0500817// This macro is used when printing runtime warnings and errors
818#ifndef MICROPY_ERROR_PRINTER
819#define MICROPY_ERROR_PRINTER (&mp_plat_print)
820#endif
821
Damien George0c36da02014-03-08 15:24:39 +0000822// Float and complex implementation
823#define MICROPY_FLOAT_IMPL_NONE (0)
824#define MICROPY_FLOAT_IMPL_FLOAT (1)
825#define MICROPY_FLOAT_IMPL_DOUBLE (2)
826
827#ifndef MICROPY_FLOAT_IMPL
828#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
829#endif
830
831#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
Damien Georgefb510b32014-06-01 13:32:54 +0100832#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100833#define MICROPY_FLOAT_CONST(x) x##F
Damien George0c36da02014-03-08 15:24:39 +0000834#define MICROPY_FLOAT_C_FUN(fun) fun##f
835typedef float mp_float_t;
836#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
Damien Georgefb510b32014-06-01 13:32:54 +0100837#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100838#define MICROPY_FLOAT_CONST(x) x
Damien George0c36da02014-03-08 15:24:39 +0000839#define MICROPY_FLOAT_C_FUN(fun) fun
840typedef double mp_float_t;
841#else
Damien Georgefb510b32014-06-01 13:32:54 +0100842#define MICROPY_PY_BUILTINS_FLOAT (0)
Damien George136f6752014-01-07 14:54:15 +0000843#endif
844
Paul Sokolovsky3b6f7b92014-06-20 01:48:35 +0300845#ifndef MICROPY_PY_BUILTINS_COMPLEX
846#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
847#endif
848
Matthias Urlichse520fa22023-10-25 19:17:47 +0200849// Whether to use the native _Float16 for 16-bit float support
850#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
851#ifdef __FLT16_MAX__
852#define MICROPY_FLOAT_USE_NATIVE_FLT16 (1)
853#else
854#define MICROPY_FLOAT_USE_NATIVE_FLT16 (0)
855#endif
856#endif
857
Damien Georgea73501b2017-04-06 17:27:33 +1000858// Whether to provide a high-quality hash for float and complex numbers.
859// Otherwise the default is a very simple but correct hashing function.
860#ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000861#define MICROPY_FLOAT_HIGH_QUALITY_HASH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien Georgea73501b2017-04-06 17:27:33 +1000862#endif
863
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200864// Enable features which improve CPython compatibility
865// but may lead to more code size/memory usage.
866// TODO: Originally intended as generic category to not
867// add bunch of once-off options. May need refactoring later
868#ifndef MICROPY_CPYTHON_COMPAT
Jim Mussared01374d92021-08-14 01:43:15 +1000869#define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200870#endif
871
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300872// Perform full checks as done by CPython. Disabling this
873// may produce incorrect results, if incorrect data is fed,
874// but should not lead to MicroPython crashes or similar
875// grave issues (in other words, only user app should be,
876// affected, not system).
877#ifndef MICROPY_FULL_CHECKS
Jim Mussared01374d92021-08-14 01:43:15 +1000878#define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300879#endif
880
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300881// Whether POSIX-semantics non-blocking streams are supported
882#ifndef MICROPY_STREAMS_NON_BLOCK
Jim Mussared0e236ee2021-09-15 23:18:23 +1000883#define MICROPY_STREAMS_NON_BLOCK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300884#endif
885
Paul Sokolovsky61e77a42016-07-30 20:05:56 +0300886// Whether to provide stream functions with POSIX-like signatures
887// (useful for porting existing libraries to MicroPython).
888#ifndef MICROPY_STREAMS_POSIX_API
889#define MICROPY_STREAMS_POSIX_API (0)
890#endif
891
Jim Mussared13c817e2023-06-05 15:52:57 +1000892// Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed
893// attribute lookups to a custom handler function.
Damien George3356b5e2021-07-27 00:38:21 +1000894#ifndef MICROPY_MODULE_ATTR_DELEGATION
Jim Mussared7d2ee8a2023-06-05 22:38:36 +1000895#define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_PY_SYS_ATTR_DELEGATION || MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3356b5e2021-07-27 00:38:21 +1000896#endif
897
Jim Mussared6a8114e2023-05-12 17:07:24 +1000898// Whether to call __init__ when importing builtin modules for the first time.
899// Modules using this need to handle the possibility that __init__ might be
900// called multiple times.
Damien George3c9c3682015-09-15 14:56:13 +0100901#ifndef MICROPY_MODULE_BUILTIN_INIT
Jim Mussared0e236ee2021-09-15 23:18:23 +1000902#define MICROPY_MODULE_BUILTIN_INIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3c9c3682015-09-15 14:56:13 +0100903#endif
904
Jim Mussareded90f302023-05-10 13:22:54 +1000905// Whether to allow built-in modules to have sub-packages (by making the
906// sub-package a member of their locals dict). Sub-packages should not be
907// registered with MP_REGISTER_MODULE, instead they should be added as
908// members of the parent's globals dict. To match CPython behavior,
909// their __name__ should be "foo.bar"(i.e. QSTR_foo_dot_bar) which will
910// require an entry in qstrdefs, although it does also work to just call
911// it "bar". Also, because subpackages can be accessed without being
912// imported (e.g. as foo.bar after `import foo`), they should not
913// have __init__ methods. Instead, the top-level package's __init__ should
914// initialise all sub-packages.
915#ifndef MICROPY_MODULE_BUILTIN_SUBPACKAGES
916#define MICROPY_MODULE_BUILTIN_SUBPACKAGES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
917#endif
918
Paul m. p. P454cca62018-10-22 18:34:29 +0200919// Whether to support module-level __getattr__ (see PEP 562)
920#ifndef MICROPY_MODULE_GETATTR
Jim Mussared01374d92021-08-14 01:43:15 +1000921#define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul m. p. P454cca62018-10-22 18:34:29 +0200922#endif
923
Jim Mussareda7fa18c2020-02-26 15:24:09 +1100924// Whether to enable importing foo.py with __name__ set to '__main__'
925// Used by the unix port for the -m flag.
926#ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT
927#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0)
928#endif
929
Damien George0a2e9652016-01-31 22:24:16 +0000930// Whether frozen modules are supported in the form of strings
931#ifndef MICROPY_MODULE_FROZEN_STR
932#define MICROPY_MODULE_FROZEN_STR (0)
933#endif
934
935// Whether frozen modules are supported in the form of .mpy files
936#ifndef MICROPY_MODULE_FROZEN_MPY
937#define MICROPY_MODULE_FROZEN_MPY (0)
938#endif
939
940// Convenience macro for whether frozen modules are supported
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200941#ifndef MICROPY_MODULE_FROZEN
Damien George0a2e9652016-01-31 22:24:16 +0000942#define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200943#endif
944
Damien George78d702c2014-12-09 16:19:48 +0000945// Whether you can override builtins in the builtins module
946#ifndef MICROPY_CAN_OVERRIDE_BUILTINS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000947#define MICROPY_CAN_OVERRIDE_BUILTINS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George78d702c2014-12-09 16:19:48 +0000948#endif
949
Damien George06593fb2015-06-19 12:49:10 +0000950// Whether to check that the "self" argument of a builtin method has the
951// correct type. Such an explicit check is only needed if a builtin
952// method escapes to Python land without a first argument, eg
953// list.append([], 1). Without this check such calls will have undefined
954// behaviour (usually segfault) if the first argument is the wrong type.
955#ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
Jim Mussared01374d92021-08-14 01:43:15 +1000956#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George06593fb2015-06-19 12:49:10 +0000957#endif
958
Damien George3f56fd62016-05-10 10:54:06 +0100959// Whether to use internally defined errno's (otherwise system provided ones)
960#ifndef MICROPY_USE_INTERNAL_ERRNO
961#define MICROPY_USE_INTERNAL_ERRNO (0)
962#endif
963
Delio Brignolie2ac8bb2016-08-21 11:33:37 +0200964// Whether to use internally defined *printf() functions (otherwise external ones)
965#ifndef MICROPY_USE_INTERNAL_PRINTF
966#define MICROPY_USE_INTERNAL_PRINTF (1)
967#endif
968
Damien George78dc2db2023-03-09 13:56:23 +1100969// The mp_print_t printer used for printf output when MICROPY_USE_INTERNAL_PRINTF is enabled
970#ifndef MICROPY_INTERNAL_PRINTF_PRINTER
971#define MICROPY_INTERNAL_PRINTF_PRINTER (&mp_plat_print)
972#endif
973
Damien Georged54208a2022-12-16 17:31:21 +1100974// Whether to support mp_sched_vm_abort to asynchronously abort to the top level.
975#ifndef MICROPY_ENABLE_VM_ABORT
976#define MICROPY_ENABLE_VM_ABORT (0)
977#endif
978
Damien George6e74d242017-02-16 18:05:06 +1100979// Support for internal scheduler
980#ifndef MICROPY_ENABLE_SCHEDULER
Jim Mussared0e236ee2021-09-15 23:18:23 +1000981#define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George6e74d242017-02-16 18:05:06 +1100982#endif
983
Damien George75506e42022-03-23 17:13:03 +1100984// Whether the scheduler supports scheduling static nodes with C callbacks
985#ifndef MICROPY_SCHEDULER_STATIC_NODES
986#define MICROPY_SCHEDULER_STATIC_NODES (0)
987#endif
988
Damien George6e74d242017-02-16 18:05:06 +1100989// Maximum number of entries in the scheduler
990#ifndef MICROPY_SCHEDULER_DEPTH
991#define MICROPY_SCHEDULER_DEPTH (4)
992#endif
993
Damien Georgedcb9ea72017-01-27 15:10:09 +1100994// Support for generic VFS sub-system
995#ifndef MICROPY_VFS
996#define MICROPY_VFS (0)
997#endif
998
Damien George8b6bd432024-11-15 11:16:04 +1100999// Whether to include support for writable filesystems.
1000#ifndef MICROPY_VFS_WRITABLE
1001#define MICROPY_VFS_WRITABLE (1)
1002#endif
1003
Damien George8d82b0e2018-06-06 13:11:33 +10001004// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
Jim Mussared89a0fef2022-09-13 14:57:24 +10001005#ifndef MICROPY_VFS_POSIX
Damien George8d82b0e2018-06-06 13:11:33 +10001006#define MICROPY_VFS_POSIX (0)
1007#endif
1008
Damien Georgea8b9e712018-06-06 14:31:29 +10001009// Support for VFS FAT component, to mount a FAT filesystem within VFS
Jim Mussared89a0fef2022-09-13 14:57:24 +10001010#ifndef MICROPY_VFS_FAT
Damien Georgea8b9e712018-06-06 14:31:29 +10001011#define MICROPY_VFS_FAT (0)
1012#endif
1013
Jim Mussared89a0fef2022-09-13 14:57:24 +10001014// Support for VFS LittleFS v1 component, to mount a LFSv1 filesystem within VFS
1015#ifndef MICROPY_VFS_LFS1
1016#define MICROPY_VFS_LFS1 (0)
1017#endif
1018
1019// Support for VFS LittleFS v2 component, to mount a LFSv2 filesystem within VFS
1020#ifndef MICROPY_VFS_LFS2
1021#define MICROPY_VFS_LFS2 (0)
1022#endif
1023
Damien George50637ff2022-03-04 10:52:35 +11001024// Support for ROMFS.
1025#ifndef MICROPY_VFS_ROM
1026#define MICROPY_VFS_ROM (0)
1027#endif
1028
Damien Georgeee3fd462014-05-24 23:03:12 +01001029/*****************************************************************************/
1030/* Fine control over Python builtins, classes, modules, etc */
1031
Damien Georgeda154fd2017-04-01 23:52:24 +11001032// Whether to support multiple inheritance of Python classes. Multiple
1033// inheritance makes some C functions inherently recursive, and adds a bit of
1034// code overhead.
1035#ifndef MICROPY_MULTIPLE_INHERITANCE
Jim Mussared01374d92021-08-14 01:43:15 +10001036#define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeda154fd2017-04-01 23:52:24 +11001037#endif
1038
stijn3cc17c62015-02-14 18:44:31 +01001039// Whether to implement attributes on functions
1040#ifndef MICROPY_PY_FUNCTION_ATTRS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001041#define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijn3cc17c62015-02-14 18:44:31 +01001042#endif
1043
Damien George36c10522018-05-25 17:09:54 +10001044// Whether to support the descriptors __get__, __set__, __delete__
1045// This costs some code size and makes load/store/delete of instance
1046// attributes slower for the classes that use this feature
stijn28fa84b2015-02-14 18:43:54 +01001047#ifndef MICROPY_PY_DESCRIPTORS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001048#define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijn28fa84b2015-02-14 18:43:54 +01001049#endif
1050
dmazzella18e65692017-01-03 11:00:12 +01001051// Whether to support class __delattr__ and __setattr__ methods
Damien George36c10522018-05-25 17:09:54 +10001052// This costs some code size and makes store/delete of instance
1053// attributes slower for the classes that use this feature
dmazzella18e65692017-01-03 11:00:12 +01001054#ifndef MICROPY_PY_DELATTR_SETATTR
Jim Mussared0e236ee2021-09-15 23:18:23 +10001055#define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
dmazzella18e65692017-01-03 11:00:12 +01001056#endif
1057
pohmelie81ebba72016-01-27 23:23:11 +03001058// Support for async/await/async for/async with
1059#ifndef MICROPY_PY_ASYNC_AWAIT
Jim Mussared01374d92021-08-14 01:43:15 +10001060#define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
pohmelie81ebba72016-01-27 23:23:11 +03001061#endif
1062
Jim Mussared692d36d2021-08-13 01:44:08 +10001063// Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+)
1064#ifndef MICROPY_PY_FSTRINGS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001065#define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared692d36d2021-08-13 01:44:08 +10001066#endif
1067
Damien George17839502020-06-16 21:42:44 +10001068// Support for assignment expressions with := (see PEP 572, Python 3.8+)
1069#ifndef MICROPY_PY_ASSIGN_EXPR
Jim Mussared01374d92021-08-14 01:43:15 +10001070#define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George17839502020-06-16 21:42:44 +10001071#endif
1072
Paul Sokolovsky63644012017-10-21 12:13:44 +03001073// Non-standard .pend_throw() method for generators, allowing for
1074// Future-like behavior with respect to exception handling: an
1075// exception set with .pend_throw() will activate on the next call
1076// to generator's .send() or .__next__(). (This is useful to implement
1077// async schedulers.)
1078#ifndef MICROPY_PY_GENERATOR_PEND_THROW
Jim Mussared01374d92021-08-14 01:43:15 +10001079#define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky63644012017-10-21 12:13:44 +03001080#endif
1081
Paul Sokolovskya1b442b2016-07-22 00:46:24 +03001082// Issue a warning when comparing str and bytes objects
Paul Sokolovsky707cae72016-07-22 00:34:34 +03001083#ifndef MICROPY_PY_STR_BYTES_CMP_WARN
1084#define MICROPY_PY_STR_BYTES_CMP_WARN (0)
1085#endif
1086
Jim Mussared28aaab92021-07-13 18:01:12 +10001087// Add bytes.hex and bytes.fromhex
1088#ifndef MICROPY_PY_BUILTINS_BYTES_HEX
1089#define MICROPY_PY_BUILTINS_BYTES_HEX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1090#endif
1091
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +03001092// Whether str object is proper unicode
1093#ifndef MICROPY_PY_BUILTINS_STR_UNICODE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001094#define MICROPY_PY_BUILTINS_STR_UNICODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George8546ce12014-06-28 10:29:22 +01001095#endif
Damien Georgeb3a50f02014-06-28 10:27:15 +01001096
tll68c28172017-06-24 08:38:32 +08001097// Whether to check for valid UTF-8 when converting bytes to str
1098#ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
1099#define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
1100#endif
1101
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +03001102// Whether str.center() method provided
1103#ifndef MICROPY_PY_BUILTINS_STR_CENTER
Jim Mussared0e236ee2021-09-15 23:18:23 +10001104#define MICROPY_PY_BUILTINS_STR_CENTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +03001105#endif
1106
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +03001107// Whether str.count() method provided
1108#ifndef MICROPY_PY_BUILTINS_STR_COUNT
Jim Mussared01374d92021-08-14 01:43:15 +10001109#define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +03001110#endif
1111
Paul Sokolovsky2da5d412018-08-15 15:17:41 +03001112// Whether str % (...) formatting operator provided
1113#ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
Jim Mussared01374d92021-08-14 01:43:15 +10001114#define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky2da5d412018-08-15 15:17:41 +03001115#endif
1116
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +03001117// Whether str.partition()/str.rpartition() method provided
1118#ifndef MICROPY_PY_BUILTINS_STR_PARTITION
Jim Mussared0e236ee2021-09-15 23:18:23 +10001119#define MICROPY_PY_BUILTINS_STR_PARTITION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +03001120#endif
1121
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +03001122// Whether str.splitlines() method provided
1123#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001124#define MICROPY_PY_BUILTINS_STR_SPLITLINES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +03001125#endif
1126
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001127// Whether to support bytearray object
1128#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
Jim Mussared01374d92021-08-14 01:43:15 +10001129#define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +03001130#endif
1131
Damien George62e821c2025-01-19 23:30:59 +11001132// Whether to support code objects, and how many features they have
1133#define MICROPY_PY_BUILTINS_CODE_NONE (0)
1134#define MICROPY_PY_BUILTINS_CODE_MINIMUM (1)
1135#define MICROPY_PY_BUILTINS_CODE_BASIC (2)
1136#define MICROPY_PY_BUILTINS_CODE_FULL (3)
1137#ifndef MICROPY_PY_BUILTINS_CODE
1138#define MICROPY_PY_BUILTINS_CODE (MICROPY_PY_SYS_SETTRACE ? MICROPY_PY_BUILTINS_CODE_FULL : (MICROPY_PY_BUILTINS_COMPILE ? MICROPY_PY_BUILTINS_CODE_MINIMUM : MICROPY_PY_BUILTINS_CODE_NONE))
1139#endif
1140
Paul Sokolovskyfbb83352018-08-06 01:25:41 +03001141// Whether to support dict.fromkeys() class method
1142#ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
Jim Mussared01374d92021-08-14 01:43:15 +10001143#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskyfbb83352018-08-06 01:25:41 +03001144#endif
1145
Damien Georgedd4f4532014-10-23 13:34:35 +01001146// Whether to support memoryview object
1147#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
Jim Mussared0e236ee2021-09-15 23:18:23 +10001148#define MICROPY_PY_BUILTINS_MEMORYVIEW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgedd4f4532014-10-23 13:34:35 +01001149#endif
1150
stijn90fae912019-05-08 16:16:17 +02001151// Whether to support memoryview.itemsize attribute
1152#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001153#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn90fae912019-05-08 16:16:17 +02001154#endif
1155
Damien George3ebd4d02014-06-01 13:46:47 +01001156// Whether to support set object
1157#ifndef MICROPY_PY_BUILTINS_SET
Jim Mussared01374d92021-08-14 01:43:15 +10001158#define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George3ebd4d02014-06-01 13:46:47 +01001159#endif
1160
Damien Georgefb510b32014-06-01 13:32:54 +01001161// Whether to support slice subscript operators and slice object
1162#ifndef MICROPY_PY_BUILTINS_SLICE
Jim Mussared01374d92021-08-14 01:43:15 +10001163#define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001164#endif
1165
Tom Soulanilleaeb62f92015-09-11 14:31:32 -07001166// Whether to support slice attribute read access,
1167// i.e. slice.start, slice.stop, slice.step
1168#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001169#define MICROPY_PY_BUILTINS_SLICE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Tom Soulanilleaeb62f92015-09-11 14:31:32 -07001170#endif
1171
Nicko van Someren4c939552019-11-16 17:07:11 -07001172// Whether to support the .indices(len) method on slice objects
1173#ifndef MICROPY_PY_BUILTINS_SLICE_INDICES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001174#define MICROPY_PY_BUILTINS_SLICE_INDICES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Nicko van Someren4c939552019-11-16 17:07:11 -07001175#endif
1176
Damien Georgeee3fd462014-05-24 23:03:12 +01001177// Whether to support frozenset object
Damien Georgefb510b32014-06-01 13:32:54 +01001178#ifndef MICROPY_PY_BUILTINS_FROZENSET
Jim Mussared0e236ee2021-09-15 23:18:23 +10001179#define MICROPY_PY_BUILTINS_FROZENSET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001180#endif
1181
Damien Georgefb510b32014-06-01 13:32:54 +01001182// Whether to support property object
1183#ifndef MICROPY_PY_BUILTINS_PROPERTY
Jim Mussared01374d92021-08-14 01:43:15 +10001184#define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001185#endif
1186
Peter D. Grayb2a237d2015-03-06 14:48:14 -05001187// Whether to implement the start/stop/step attributes (readback) on
1188// the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
1189#ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
Jim Mussared01374d92021-08-14 01:43:15 +10001190#define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Peter D. Grayb2a237d2015-03-06 14:48:14 -05001191#endif
1192
Damien Georged77da832018-02-14 23:17:06 +11001193// Whether to support binary ops [only (in)equality is defined] between range
1194// objects. With this option disabled all range objects that are not exactly
1195// the same object will compare as not-equal. With it enabled the semantics
1196// match CPython and ranges are equal if they yield the same sequence of items.
1197#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001198#define MICROPY_PY_BUILTINS_RANGE_BINOP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien Georged77da832018-02-14 23:17:06 +11001199#endif
1200
Damien Georgecf490a72023-10-03 11:24:50 +11001201// Support for calling next() with second argument
stijn42863832019-01-03 15:19:42 +01001202#ifndef MICROPY_PY_BUILTINS_NEXT2
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001203#define MICROPY_PY_BUILTINS_NEXT2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn42863832019-01-03 15:19:42 +01001204#endif
1205
Jan Klusacekb318ebf2018-01-09 22:47:35 +01001206// Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
1207#ifndef MICROPY_PY_BUILTINS_ROUND_INT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001208#define MICROPY_PY_BUILTINS_ROUND_INT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jan Klusacekb318ebf2018-01-09 22:47:35 +01001209#endif
1210
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001211// Whether to support complete set of special methods for user
1212// classes, or only the most used ones. "Inplace" methods are
1213// controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
1214// "Reverse" methods are controlled by
1215// MICROPY_PY_REVERSE_SPECIAL_METHODS below.
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +02001216#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001217#define MICROPY_PY_ALL_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +02001218#endif
1219
Damien Georgecf490a72023-10-03 11:24:50 +11001220// Whether to support all inplace arithmetic operation methods
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001221// (__imul__, etc.)
1222#ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001223#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001224#endif
1225
Damien Georgecf490a72023-10-03 11:24:50 +11001226// Whether to support reverse arithmetic operation methods
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001227// (__radd__, etc.). Additionally gated by
1228// MICROPY_PY_ALL_SPECIAL_METHODS.
Paul Sokolovskyeb84a832017-09-10 17:05:20 +03001229#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001230#define MICROPY_PY_REVERSE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyeb84a832017-09-10 17:05:20 +03001231#endif
1232
Damien Georgec9fc6202014-10-25 21:59:14 +01001233// Whether to support compile function
1234#ifndef MICROPY_PY_BUILTINS_COMPILE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001235#define MICROPY_PY_BUILTINS_COMPILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgec9fc6202014-10-25 21:59:14 +01001236#endif
1237
Paul Sokolovskye2d44e32015-04-06 23:50:37 +03001238// Whether to support enumerate function(type)
1239#ifndef MICROPY_PY_BUILTINS_ENUMERATE
Jim Mussared01374d92021-08-14 01:43:15 +10001240#define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskye2d44e32015-04-06 23:50:37 +03001241#endif
1242
Damien Georgedd5353a2015-12-18 12:35:44 +00001243// Whether to support eval and exec functions
1244// By default they are supported if the compiler is enabled
1245#ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
1246#define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
1247#endif
1248
Damien George2a3e2b92014-12-19 13:36:17 +00001249// Whether to support the Python 2 execfile function
1250#ifndef MICROPY_PY_BUILTINS_EXECFILE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001251#define MICROPY_PY_BUILTINS_EXECFILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George2a3e2b92014-12-19 13:36:17 +00001252#endif
1253
Paul Sokolovsky22ff3972015-08-20 01:01:56 +03001254// Whether to support filter function(type)
1255#ifndef MICROPY_PY_BUILTINS_FILTER
Jim Mussared01374d92021-08-14 01:43:15 +10001256#define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky22ff3972015-08-20 01:01:56 +03001257#endif
1258
Paul Sokolovsky282ca092015-04-07 00:16:51 +03001259// Whether to support reversed function(type)
1260#ifndef MICROPY_PY_BUILTINS_REVERSED
Jim Mussared01374d92021-08-14 01:43:15 +10001261#define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky282ca092015-04-07 00:16:51 +03001262#endif
1263
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +03001264// Whether to define "NotImplemented" special constant
1265#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
Jim Mussared0e236ee2021-09-15 23:18:23 +10001266#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +03001267#endif
1268
Damien Georgebc763022017-06-01 15:32:23 +10001269// Whether to provide the built-in input() function. The implementation of this
Damien George136369d2021-07-09 14:19:15 +10001270// uses shared/readline, so can only be enabled if the port uses this readline.
Damien Georgebc763022017-06-01 15:32:23 +10001271#ifndef MICROPY_PY_BUILTINS_INPUT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001272#define MICROPY_PY_BUILTINS_INPUT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgebc763022017-06-01 15:32:23 +10001273#endif
1274
pohmelie354e6882015-12-07 15:35:48 +03001275// Whether to support min/max functions
1276#ifndef MICROPY_PY_BUILTINS_MIN_MAX
Jim Mussared01374d92021-08-14 01:43:15 +10001277#define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
pohmelie354e6882015-12-07 15:35:48 +03001278#endif
1279
Damien Georgea19b5a02017-02-03 12:35:48 +11001280// Support for calls to pow() with 3 integer arguments
1281#ifndef MICROPY_PY_BUILTINS_POW3
Jim Mussared0e236ee2021-09-15 23:18:23 +10001282#define MICROPY_PY_BUILTINS_POW3 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgea19b5a02017-02-03 12:35:48 +11001283#endif
1284
Damien George9f04dfb2017-01-21 23:17:51 +11001285// Whether to provide the help function
1286#ifndef MICROPY_PY_BUILTINS_HELP
Jim Mussared0e236ee2021-09-15 23:18:23 +10001287#define MICROPY_PY_BUILTINS_HELP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George9f04dfb2017-01-21 23:17:51 +11001288#endif
1289
1290// Use this to configure the help text shown for help(). It should be a
1291// variable with the type "const char*". A sensible default is provided.
1292#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
1293#define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
1294#endif
1295
Damien Georgef5172af2017-01-22 12:12:54 +11001296// Add the ability to list the available modules when executing help('modules')
1297#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001298#define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgef5172af2017-01-22 12:12:54 +11001299#endif
1300
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001301// Whether to set __file__ for imported modules
1302#ifndef MICROPY_PY___FILE__
Jim Mussared01374d92021-08-14 01:43:15 +10001303#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001304#endif
1305
Damien George89deec02015-01-09 20:12:54 +00001306// Whether to provide mem-info related functions in micropython module
1307#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
Jim Mussared0e236ee2021-09-15 23:18:23 +10001308#define MICROPY_PY_MICROPYTHON_MEM_INFO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George89deec02015-01-09 20:12:54 +00001309#endif
1310
Damien George7e2a4882018-02-20 18:30:22 +11001311// Whether to provide "micropython.stack_use" function
1312#ifndef MICROPY_PY_MICROPYTHON_STACK_USE
1313#define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
1314#endif
1315
Andrew Leech86bfabe2019-06-28 16:35:51 +10001316// Whether to provide the "micropython.heap_locked" function
1317#ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001318#define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Andrew Leech86bfabe2019-06-28 16:35:51 +10001319#endif
1320
Andrew Leech7e146802022-09-26 11:02:31 +10001321// Support for micropython.RingIO()
1322#ifndef MICROPY_PY_MICROPYTHON_RINGIO
1323#define MICROPY_PY_MICROPYTHON_RINGIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1324#endif
1325
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001326// Whether to provide "array" module. Note that large chunk of the
1327// underlying code is shared with "bytearray" builtin type, so to
1328// get real savings, it should be disabled too.
1329#ifndef MICROPY_PY_ARRAY
Jim Mussared01374d92021-08-14 01:43:15 +10001330#define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001331#endif
1332
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001333// Whether to support slice assignments for array (and bytearray).
1334// This is rarely used, but adds ~0.5K of code.
1335#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
Jim Mussared0e236ee2021-09-15 23:18:23 +10001336#define MICROPY_PY_ARRAY_SLICE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001337#endif
1338
Damien George5aa311d2015-04-21 14:14:24 +00001339// Whether to support attrtuple type (MicroPython extension)
1340// It provides space-efficient tuples with attribute access
1341#ifndef MICROPY_PY_ATTRTUPLE
Jim Mussared01374d92021-08-14 01:43:15 +10001342#define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George5aa311d2015-04-21 14:14:24 +00001343#endif
1344
Damien Georgeee3fd462014-05-24 23:03:12 +01001345// Whether to provide "collections" module
1346#ifndef MICROPY_PY_COLLECTIONS
Jim Mussared01374d92021-08-14 01:43:15 +10001347#define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001348#endif
1349
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001350// Whether to provide "collections.deque" type
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001351#ifndef MICROPY_PY_COLLECTIONS_DEQUE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001352#define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001353#endif
1354
Dash Peters7dff38f2023-02-11 18:49:15 -08001355// Whether "collections.deque" supports iteration
1356#ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER
1357#define MICROPY_PY_COLLECTIONS_DEQUE_ITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1358#endif
1359
1360// Whether "collections.deque" supports subscription
1361#ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
1362#define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1363#endif
1364
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001365// Whether to provide "collections.OrderedDict" type
1366#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001367#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001368#endif
1369
stijn79ed58f2017-11-06 12:21:53 +01001370// Whether to provide the _asdict function for namedtuple
1371#ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001372#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn79ed58f2017-11-06 12:21:53 +01001373#endif
1374
Damien Georgeee3fd462014-05-24 23:03:12 +01001375// Whether to provide "math" module
1376#ifndef MICROPY_PY_MATH
Jim Mussared01374d92021-08-14 01:43:15 +10001377#define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001378#endif
1379
stijndd696722019-11-20 13:38:33 +01001380// Whether to provide all math module constants (Python 3.5+), or just pi and e.
1381#ifndef MICROPY_PY_MATH_CONSTANTS
1382#define MICROPY_PY_MATH_CONSTANTS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1383#endif
1384
Damien George5cbeace2015-02-22 14:48:18 +00001385// Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
1386#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001387#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George5cbeace2015-02-22 14:48:18 +00001388#endif
1389
Christopher Swenson8c656752018-08-27 10:32:21 +10001390// Whether to provide math.factorial function
1391#ifndef MICROPY_PY_MATH_FACTORIAL
Jim Mussared0e236ee2021-09-15 23:18:23 +10001392#define MICROPY_PY_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Christopher Swenson8c656752018-08-27 10:32:21 +10001393#endif
1394
stijnaf5c9982019-07-02 10:28:44 +02001395// Whether to provide math.isclose function
1396#ifndef MICROPY_PY_MATH_ISCLOSE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001397#define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijnaf5c9982019-07-02 10:28:44 +02001398#endif
1399
stijn81db22f2020-05-17 12:29:25 +02001400// Whether to provide fix for atan2 Inf handling.
1401#ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN
1402#define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0)
1403#endif
1404
1405// Whether to provide fix for fmod Inf handling.
1406#ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN
1407#define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0)
1408#endif
1409
1410// Whether to provide fix for modf negative zero handling.
1411#ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO
1412#define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0)
1413#endif
1414
stijn2e54d9d2020-09-08 15:22:34 +02001415// Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN.
1416#ifndef MICROPY_PY_MATH_POW_FIX_NAN
1417#define MICROPY_PY_MATH_POW_FIX_NAN (0)
1418#endif
1419
Angus Grattonb0c89372024-08-06 09:59:22 +10001420// Whether to provide fix for gamma(-inf) to raise ValueError
1421#ifndef MICROPY_PY_MATH_GAMMA_FIX_NEGINF
1422#define MICROPY_PY_MATH_GAMMA_FIX_NEGINF (0)
1423#endif
1424
Damien Georgeee3fd462014-05-24 23:03:12 +01001425// Whether to provide "cmath" module
1426#ifndef MICROPY_PY_CMATH
Jim Mussared0e236ee2021-09-15 23:18:23 +10001427#define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001428#endif
1429
Laurens Valkf724d902022-11-29 10:38:57 +01001430// Whether to provide "micropython" module
1431#ifndef MICROPY_PY_MICROPYTHON
Laurens Valk632d43e2022-11-29 12:31:09 +01001432#define MICROPY_PY_MICROPYTHON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Laurens Valkf724d902022-11-29 10:38:57 +01001433#endif
1434
Damien Georgeee3fd462014-05-24 23:03:12 +01001435// Whether to provide "gc" module
1436#ifndef MICROPY_PY_GC
Jim Mussared01374d92021-08-14 01:43:15 +10001437#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001438#endif
1439
Paul Sokolovsky755a55f2014-06-05 22:48:02 +03001440// Whether to return number of collected objects from gc.collect()
1441#ifndef MICROPY_PY_GC_COLLECT_RETVAL
1442#define MICROPY_PY_GC_COLLECT_RETVAL (0)
1443#endif
1444
Damien Georgeee3fd462014-05-24 23:03:12 +01001445// Whether to provide "io" module
1446#ifndef MICROPY_PY_IO
Jim Mussared01374d92021-08-14 01:43:15 +10001447#define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001448#endif
1449
Damien Georgeaf0932a2018-06-04 15:54:26 +10001450// Whether to provide "io.IOBase" class to support user streams
1451#ifndef MICROPY_PY_IO_IOBASE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001452#define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeaf0932a2018-06-04 15:54:26 +10001453#endif
1454
Damien Georgeee3fd462014-05-24 23:03:12 +01001455// Whether to provide "io.BytesIO" class
1456#ifndef MICROPY_PY_IO_BYTESIO
1457#define MICROPY_PY_IO_BYTESIO (1)
1458#endif
1459
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001460// Whether to provide "io.BufferedWriter" class
1461#ifndef MICROPY_PY_IO_BUFFEREDWRITER
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001462#define MICROPY_PY_IO_BUFFEREDWRITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001463#endif
1464
Damien Georgeee3fd462014-05-24 23:03:12 +01001465// Whether to provide "struct" module
1466#ifndef MICROPY_PY_STRUCT
Jim Mussared01374d92021-08-14 01:43:15 +10001467#define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001468#endif
1469
1470// Whether to provide "sys" module
1471#ifndef MICROPY_PY_SYS
Jim Mussared01374d92021-08-14 01:43:15 +10001472#define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001473#endif
1474
Damien Georgede43b502021-12-17 23:35:32 +11001475// Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init()
1476#ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS
Damien Georgefe9ffff2021-12-19 08:55:40 +11001477#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS)
Damien Georgede43b502021-12-17 23:35:32 +11001478#endif
1479
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001480// Whether to provide "sys.maxsize" constant
1481#ifndef MICROPY_PY_SYS_MAXSIZE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001482#define MICROPY_PY_SYS_MAXSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001483#endif
1484
Paul Sokolovsky1a1d11f2015-12-05 00:09:10 +02001485// Whether to provide "sys.modules" dictionary
1486#ifndef MICROPY_PY_SYS_MODULES
1487#define MICROPY_PY_SYS_MODULES (1)
1488#endif
1489
Paul Sokolovsky8b85d142015-04-25 03:17:41 +03001490// Whether to provide "sys.exc_info" function
1491// Avoid enabling this, this function is Python2 heritage
1492#ifndef MICROPY_PY_SYS_EXC_INFO
1493#define MICROPY_PY_SYS_EXC_INFO (0)
1494#endif
1495
Jim Mussared0e8dfaf2022-10-07 02:13:58 +11001496// Whether to provide "sys.executable", which is the absolute path to the
1497// micropython binary
1498// Intended for use on the "OS" ports (e.g. Unix)
1499#ifndef MICROPY_PY_SYS_EXECUTABLE
1500#define MICROPY_PY_SYS_EXECUTABLE (0)
1501#endif
1502
stijn85c02162023-12-04 15:54:59 +01001503// Whether to provide "sys.intern"
1504#ifndef MICROPY_PY_SYS_INTERN
1505#define MICROPY_PY_SYS_INTERN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
1506#endif
1507
Damien Georgeee3fd462014-05-24 23:03:12 +01001508// Whether to provide "sys.exit" function
1509#ifndef MICROPY_PY_SYS_EXIT
Paul Sokolovsky403c9302016-12-14 21:10:22 +03001510#define MICROPY_PY_SYS_EXIT (1)
Damien Georgeee3fd462014-05-24 23:03:12 +01001511#endif
1512
Milan Rossacb364702019-08-05 15:06:41 +02001513// Whether to provide "sys.atexit" function (MicroPython extension)
1514#ifndef MICROPY_PY_SYS_ATEXIT
1515#define MICROPY_PY_SYS_ATEXIT (0)
1516#endif
1517
Jim Mussared5e509752023-06-05 16:52:29 +10001518// Whether to provide the "sys.path" attribute (which forces module delegation
1519// and mutable sys attributes to be enabled).
1520// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in
1521// mp_init to an empty list. Otherwise the port must initialise it using
1522// `mp_sys_path = mp_obj_new_list(...)`.
1523#ifndef MICROPY_PY_SYS_PATH
1524#define MICROPY_PY_SYS_PATH (1)
1525#endif
1526
1527// Whether to provide the "sys.argv" attribute.
1528// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in
1529// mp_init to an empty list. Otherwise the port must initialise it using
1530// `mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), ...);`
1531#ifndef MICROPY_PY_SYS_ARGV
1532#define MICROPY_PY_SYS_ARGV (1)
1533#endif
1534
Damien Georgeac229312021-07-27 00:43:35 +10001535// Whether to provide sys.{ps1,ps2} mutable attributes, to control REPL prompts
1536#ifndef MICROPY_PY_SYS_PS1_PS2
1537#define MICROPY_PY_SYS_PS1_PS2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1538#endif
1539
Milan Rossa310b3d12019-08-14 16:09:36 +02001540// Whether to provide "sys.settrace" function
1541#ifndef MICROPY_PY_SYS_SETTRACE
1542#define MICROPY_PY_SYS_SETTRACE (0)
1543#endif
1544
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001545// Whether to provide "sys.getsizeof" function
1546#ifndef MICROPY_PY_SYS_GETSIZEOF
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001547#define MICROPY_PY_SYS_GETSIZEOF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001548#endif
1549
Damien Georgeee3fd462014-05-24 23:03:12 +01001550// Whether to provide sys.{stdin,stdout,stderr} objects
1551#ifndef MICROPY_PY_SYS_STDFILES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001552#define MICROPY_PY_SYS_STDFILES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3bb8bd82014-04-14 21:20:30 +01001553#endif
1554
Damien George3c4b5d42015-05-13 23:49:21 +01001555// Whether to provide sys.{stdin,stdout,stderr}.buffer object
1556// This is implemented per-port
1557#ifndef MICROPY_PY_SYS_STDIO_BUFFER
Jim Mussared0e236ee2021-09-15 23:18:23 +10001558#define MICROPY_PY_SYS_STDIO_BUFFER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3c4b5d42015-05-13 23:49:21 +01001559#endif
Paul Sokolovsky82158472014-06-28 03:03:47 +03001560
Damien Georgecac939d2021-07-27 00:41:27 +10001561// Whether to provide sys.tracebacklimit mutable attribute
1562#ifndef MICROPY_PY_SYS_TRACEBACKLIMIT
1563#define MICROPY_PY_SYS_TRACEBACKLIMIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
1564#endif
1565
Damien Georgebc181552021-07-27 00:39:04 +10001566// Whether the sys module supports attribute delegation
1567// This is enabled automatically when needed by other features
1568#ifndef MICROPY_PY_SYS_ATTR_DELEGATION
Jim Mussared5e509752023-06-05 16:52:29 +10001569#define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PATH || MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT)
Damien Georgebc181552021-07-27 00:39:04 +10001570#endif
1571
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001572// Whether to provide "errno" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001573#ifndef MICROPY_PY_ERRNO
1574#define MICROPY_PY_ERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George596a3fe2016-05-10 10:54:25 +01001575#endif
1576
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001577// Whether to provide the errno.errorcode dict
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001578#ifndef MICROPY_PY_ERRNO_ERRORCODE
1579#define MICROPY_PY_ERRNO_ERRORCODE (1)
Damien Georgef5634062017-02-22 12:53:42 +11001580#endif
1581
Damien Georgeef710282023-08-01 12:39:39 +10001582// Whether to provide "select" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001583#ifndef MICROPY_PY_SELECT
1584#define MICROPY_PY_SELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky8f5bc3f2016-11-20 23:49:45 +03001585#endif
1586
Damien Georgeef710282023-08-01 12:39:39 +10001587// Whether to enable POSIX optimisations in the "select" module (requires system poll)
1588#ifndef MICROPY_PY_SELECT_POSIX_OPTIMISATIONS
1589#define MICROPY_PY_SELECT_POSIX_OPTIMISATIONS (0)
1590#endif
1591
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001592// Whether to enable the select() function in the "select" module (baremetal
David Lechner87585042021-07-06 18:08:18 -05001593// implementation). This is present for compatibility but can be disabled to
1594// save space.
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001595#ifndef MICROPY_PY_SELECT_SELECT
1596#define MICROPY_PY_SELECT_SELECT (1)
David Lechner87585042021-07-06 18:08:18 -05001597#endif
1598
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001599// Whether to provide the "time" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001600#ifndef MICROPY_PY_TIME
1601#define MICROPY_PY_TIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES)
Damien George99555532023-03-10 12:16:00 +11001602#endif
1603
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001604// Whether to provide time.gmtime/localtime/mktime functions
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001605#ifndef MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME
1606#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (0)
Damien George99555532023-03-10 12:16:00 +11001607#endif
1608
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001609// Whether to provide time.time/time_ns functions
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001610#ifndef MICROPY_PY_TIME_TIME_TIME_NS
1611#define MICROPY_PY_TIME_TIME_TIME_NS (0)
Paul Sokolovskya9728442016-10-14 20:13:02 +03001612#endif
1613
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001614// Period of values returned by time.ticks_ms(), ticks_us(), ticks_cpu()
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001615// functions. Should be power of two. All functions above use the same
1616// period, so if underlying hardware/API has different periods, the
1617// minimum of them should be used. The value below is the maximum value
1618// this parameter can take (corresponding to 30 bit tick values on 32-bit
1619// system).
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001620#ifndef MICROPY_PY_TIME_TICKS_PERIOD
1621#define MICROPY_PY_TIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001622#endif
1623
Damien George27cc0772016-04-22 22:52:33 +00001624// Whether to provide "_thread" module
1625#ifndef MICROPY_PY_THREAD
1626#define MICROPY_PY_THREAD (0)
1627#endif
1628
Damien George4cec63a2016-05-26 10:42:53 +00001629// Whether to make the VM/runtime thread-safe using a global lock
1630// If not enabled then thread safety must be provided at the Python level
1631#ifndef MICROPY_PY_THREAD_GIL
1632#define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1633#endif
1634
Damien Georgef6c22a02017-02-06 10:50:43 +11001635// Number of VM jump-loops to do before releasing the GIL.
1636// Set this to 0 to disable the divisor.
1637#ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1638#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1639#endif
1640
Angus Gratton4bcbe882024-12-10 14:50:42 +11001641// Is a recursive mutex type in use?
1642#ifndef MICROPY_PY_THREAD_RECURSIVE_MUTEX
1643#define MICROPY_PY_THREAD_RECURSIVE_MUTEX (MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL)
1644#endif
1645
Paul Sokolovsky82158472014-06-28 03:03:47 +03001646// Extended modules
Paul Sokolovsky510296f2014-08-08 22:51:40 +03001647
Jim Mussared2fbc08c2023-06-08 15:51:50 +10001648#ifndef MICROPY_PY_ASYNCIO
1649#define MICROPY_PY_ASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgebc009fd2020-03-12 16:46:20 +11001650#endif
1651
Damien George8ac9c8f2024-06-19 17:27:31 +10001652#ifndef MICROPY_PY_ASYNCIO_TASK_QUEUE_PUSH_CALLBACK
1653#define MICROPY_PY_ASYNCIO_TASK_QUEUE_PUSH_CALLBACK (0)
1654#endif
1655
Paul Sokolovsky82158472014-06-28 03:03:47 +03001656#ifndef MICROPY_PY_UCTYPES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001657#define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky82158472014-06-28 03:03:47 +03001658#endif
1659
Paul Sokolovsky38151f32018-10-06 23:34:58 +03001660// Whether to provide SHORT, INT, LONG, etc. types in addition to
1661// exact-bitness types like INT16, INT32, etc.
1662#ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
1663#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
1664#endif
1665
Jim Mussared35339242023-06-26 13:52:10 +10001666// Whether to provide "deflate" module (decompression-only by default)
1667#ifndef MICROPY_PY_DEFLATE
1668#define MICROPY_PY_DEFLATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1669#endif
1670
1671// Whether to provide compression support in "deflate" module
1672#ifndef MICROPY_PY_DEFLATE_COMPRESS
1673#define MICROPY_PY_DEFLATE_COMPRESS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES)
1674#endif
1675
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001676#ifndef MICROPY_PY_JSON
1677#define MICROPY_PY_JSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George612045f2014-09-17 22:56:34 +01001678#endif
1679
Peter Zügerffc854f2021-02-03 09:24:25 +01001680// Whether to support the "separators" argument to dump, dumps
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001681#ifndef MICROPY_PY_JSON_SEPARATORS
1682#define MICROPY_PY_JSON_SEPARATORS (1)
Peter Zügerffc854f2021-02-03 09:24:25 +01001683#endif
1684
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001685#ifndef MICROPY_PY_OS
1686#define MICROPY_PY_OS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George926b5542022-03-03 17:59:30 +11001687#endif
1688
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001689#ifndef MICROPY_PY_OS_STATVFS
1690#define MICROPY_PY_OS_STATVFS (MICROPY_PY_OS)
Damien George0149cd62022-03-09 12:45:06 +11001691#endif
1692
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001693#ifndef MICROPY_PY_RE
1694#define MICROPY_PY_RE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyc71e0452014-09-12 18:48:07 +03001695#endif
1696
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001697#ifndef MICROPY_PY_RE_DEBUG
1698#define MICROPY_PY_RE_DEBUG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George7d851a22019-08-17 23:50:19 +10001699#endif
1700
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001701#ifndef MICROPY_PY_RE_MATCH_GROUPS
1702#define MICROPY_PY_RE_MATCH_GROUPS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George1f864602018-05-24 13:07:42 +10001703#endif
1704
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001705#ifndef MICROPY_PY_RE_MATCH_SPAN_START_END
1706#define MICROPY_PY_RE_MATCH_SPAN_START_END (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George1e9b8712018-05-24 13:08:15 +10001707#endif
1708
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001709#ifndef MICROPY_PY_RE_SUB
1710#define MICROPY_PY_RE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgee30a5fc2018-05-24 13:08:51 +10001711#endif
1712
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001713#ifndef MICROPY_PY_HEAPQ
1714#define MICROPY_PY_HEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgef5d69792014-10-22 17:37:18 +00001715#endif
1716
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001717#ifndef MICROPY_PY_HASHLIB
1718#define MICROPY_PY_HASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyf4b19c82014-11-22 01:19:13 +02001719#endif
1720
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001721#ifndef MICROPY_PY_HASHLIB_MD5
1722#define MICROPY_PY_HASHLIB_MD5 (0)
Paul Sokolovsky5fe37302018-08-19 11:58:22 +03001723#endif
1724
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001725#ifndef MICROPY_PY_HASHLIB_SHA1
1726#define MICROPY_PY_HASHLIB_SHA1 (0)
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001727#endif
1728
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001729#ifndef MICROPY_PY_HASHLIB_SHA256
1730#define MICROPY_PY_HASHLIB_SHA256 (1)
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001731#endif
1732
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001733#ifndef MICROPY_PY_CRYPTOLIB
1734#define MICROPY_PY_CRYPTOLIB (0)
Paul Sokolovsky567bc2d2018-01-07 15:13:56 +02001735#endif
1736
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001737// Depends on MICROPY_PY_CRYPTOLIB
1738#ifndef MICROPY_PY_CRYPTOLIB_CTR
1739#define MICROPY_PY_CRYPTOLIB_CTR (0)
Yonatan Goldschmidtef984362019-04-23 12:39:05 +03001740#endif
1741
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001742#ifndef MICROPY_PY_CRYPTOLIB_CONSTS
1743#define MICROPY_PY_CRYPTOLIB_CONSTS (0)
Yonatan Goldschmidt473fe452018-06-15 17:07:47 +03001744#endif
1745
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001746#ifndef MICROPY_PY_BINASCII
1747#define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskybfdc2052014-11-29 06:19:30 +02001748#endif
1749
Jim Mussared35339242023-06-26 13:52:10 +10001750// Depends on MICROPY_PY_DEFLATE
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001751#ifndef MICROPY_PY_BINASCII_CRC32
1752#define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyc4283672016-08-24 18:28:43 +03001753#endif
1754
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001755#ifndef MICROPY_PY_RANDOM
1756#define MICROPY_PY_RANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskya58a91e2016-01-17 12:10:28 +02001757#endif
1758
Damien Georgea53af6c2016-01-22 16:19:32 +00001759// Whether to include: randrange, randint, choice, random, uniform
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001760#ifndef MICROPY_PY_RANDOM_EXTRA_FUNCS
1761#define MICROPY_PY_RANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgea53af6c2016-01-22 16:19:32 +00001762#endif
1763
Paul Sokolovsky01162182015-05-03 20:25:40 +03001764#ifndef MICROPY_PY_MACHINE
1765#define MICROPY_PY_MACHINE (0)
1766#endif
1767
Damien Georgebfc3dde2024-03-14 11:09:14 +11001768// Whether to include: reset, reset_cause
1769#ifndef MICROPY_PY_MACHINE_RESET
1770#define MICROPY_PY_MACHINE_RESET (0)
1771#endif
1772
robert-hh2be45dd2024-07-06 09:18:22 +02001773// Maximum number of arguments for machine.freq()
1774#ifndef MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX
1775#define MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX (1)
1776#endif
1777
Jim Mussared870000f2021-08-10 01:09:04 +10001778// Whether to include: bitstream
1779#ifndef MICROPY_PY_MACHINE_BITSTREAM
1780#define MICROPY_PY_MACHINE_BITSTREAM (0)
1781#endif
1782
Damien George33168082016-05-31 14:25:19 +01001783// Whether to include: time_pulse_us
1784#ifndef MICROPY_PY_MACHINE_PULSE
1785#define MICROPY_PY_MACHINE_PULSE (0)
1786#endif
1787
Damien Georgedd134e42024-03-14 11:01:33 +11001788// Whether to provide the "machine.mem8/16/32" objects
1789#ifndef MICROPY_PY_MACHINE_MEMX
1790#define MICROPY_PY_MACHINE_MEMX (MICROPY_PY_MACHINE)
1791#endif
1792
Damien George23ccbcf2024-03-14 10:58:41 +11001793// Whether to provide the "machine.Signal" class
1794#ifndef MICROPY_PY_MACHINE_SIGNAL
1795#define MICROPY_PY_MACHINE_SIGNAL (MICROPY_PY_MACHINE)
1796#endif
1797
Damien Georged0837122016-04-12 13:42:35 +01001798#ifndef MICROPY_PY_MACHINE_I2C
1799#define MICROPY_PY_MACHINE_I2C (0)
1800#endif
1801
Damien George4a1ae992022-06-01 11:57:20 +10001802// Whether the low-level I2C transfer function supports a separate write as the first transfer
1803#ifndef MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1
1804#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (0)
1805#endif
1806
Damien George122d9012021-09-02 12:37:00 +10001807// Whether to provide the "machine.SoftI2C" class
1808#ifndef MICROPY_PY_MACHINE_SOFTI2C
1809#define MICROPY_PY_MACHINE_SOFTI2C (0)
1810#endif
1811
Damien George0823c1b2016-09-01 15:07:20 +10001812#ifndef MICROPY_PY_MACHINE_SPI
1813#define MICROPY_PY_MACHINE_SPI (0)
1814#endif
1815
Damien Georgeafe06342021-09-02 12:39:28 +10001816// Whether to provide the "machine.SoftSPI" class
1817#ifndef MICROPY_PY_MACHINE_SOFTSPI
1818#define MICROPY_PY_MACHINE_SOFTSPI (0)
1819#endif
1820
robert-hhee103602023-05-15 11:17:27 +02001821// Values of SPI.MSB and SPI.LSB constants
1822#ifndef MICROPY_PY_MACHINE_SPI_MSB
1823#define MICROPY_PY_MACHINE_SPI_MSB (0)
1824#define MICROPY_PY_MACHINE_SPI_LSB (1)
1825#endif
1826
Damien Georgecd35b8a2022-10-27 14:32:43 +11001827// Whether to provide the "machine.Timer" class
1828#ifndef MICROPY_PY_MACHINE_TIMER
1829#define MICROPY_PY_MACHINE_TIMER (0)
1830#endif
1831
Damien Georgeaab005c2022-04-04 23:07:35 +10001832// The default backlog value for socket.listen(backlog)
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001833#ifndef MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT
1834#define MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT (2)
Damien Georgeaab005c2022-04-04 23:07:35 +10001835#endif
1836
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001837#ifndef MICROPY_PY_SSL
1838#define MICROPY_PY_SSL (0)
Damien George772058a2022-01-07 23:59:17 +11001839#endif
1840
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001841// Whether to add finaliser code to ssl objects
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001842#ifndef MICROPY_PY_SSL_FINALISER
Jim Mussaredf3eccb12023-08-23 13:37:06 +10001843#define MICROPY_PY_SSL_FINALISER (MICROPY_ENABLE_FINALISER)
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001844#endif
1845
iabdalkader2644f572024-10-16 14:08:43 +02001846// Whether to add a root pointer for the current ssl object
1847#ifndef MICROPY_PY_SSL_MBEDTLS_NEED_ACTIVE_CONTEXT
1848#define MICROPY_PY_SSL_MBEDTLS_NEED_ACTIVE_CONTEXT (MICROPY_PY_SSL_ECDSA_SIGN_ALT)
1849#endif
1850
Damien Georgee7020462023-10-13 14:53:02 +11001851// Whether to provide the "vfs" module
1852#ifndef MICROPY_PY_VFS
robert-hh8fdcc252024-02-22 20:50:03 +01001853#define MICROPY_PY_VFS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES && MICROPY_VFS)
Damien Georgee7020462023-10-13 14:53:02 +11001854#endif
1855
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001856#ifndef MICROPY_PY_WEBSOCKET
1857#define MICROPY_PY_WEBSOCKET (0)
Paul Sokolovsky24342dd2016-03-24 19:14:12 +02001858#endif
1859
Damien George53ad6812016-04-08 11:08:37 +01001860#ifndef MICROPY_PY_FRAMEBUF
Jim Mussared0e236ee2021-09-15 23:18:23 +10001861#define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George53ad6812016-04-08 11:08:37 +01001862#endif
1863
Paul Sokolovsky737bd9c2016-07-02 14:57:42 +03001864#ifndef MICROPY_PY_BTREE
1865#define MICROPY_PY_BTREE (0)
1866#endif
1867
Damien Georged41f6dd2021-09-02 12:39:50 +10001868// Whether to provide the low-level "_onewire" module
1869#ifndef MICROPY_PY_ONEWIRE
1870#define MICROPY_PY_ONEWIRE (0)
1871#endif
1872
Jim Mussared975a6872023-07-21 13:39:36 +10001873// Whether to provide the "platform" module
1874#ifndef MICROPY_PY_PLATFORM
1875#define MICROPY_PY_PLATFORM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1876#endif
1877
Damien George58ebde42014-05-21 20:32:59 +01001878/*****************************************************************************/
1879/* Hooks for a port to add builtins */
1880
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001881// Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001882#ifndef MICROPY_PORT_BUILTINS
1883#define MICROPY_PORT_BUILTINS
Paul Sokolovsky910843e2014-02-14 12:02:34 +02001884#endif
Damien Georgecaac5422014-03-25 14:18:18 +00001885
stijn22cf0942022-01-05 16:04:58 +01001886// Additional builtin function definitions for extension by command-line, boards or variants.
1887// See modbuiltins.c:mp_module_builtins_globals_table for format.
1888#ifndef MICROPY_PORT_EXTRA_BUILTINS
1889#define MICROPY_PORT_EXTRA_BUILTINS
1890#endif
1891
Damien George57e99eb2014-04-10 22:42:11 +01001892// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
Damien George58ebde42014-05-21 20:32:59 +01001893#ifndef MICROPY_PORT_CONSTANTS
1894#define MICROPY_PORT_CONSTANTS
Damien George57e99eb2014-04-10 22:42:11 +01001895#endif
1896
Damien George136f6752014-01-07 14:54:15 +00001897/*****************************************************************************/
Damien George8fb5c8f2020-02-07 12:07:50 +11001898/* Hooks for a port to wrap functions with attributes */
1899
Damien George84125682021-09-24 12:49:51 +10001900#ifndef MICROPY_WRAP_MP_BINARY_OP
1901#define MICROPY_WRAP_MP_BINARY_OP(f) f
1902#endif
1903
1904#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE
1905#define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f
1906#endif
1907
1908#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL
1909#define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f
1910#endif
1911
1912#ifndef MICROPY_WRAP_MP_LOAD_NAME
1913#define MICROPY_WRAP_MP_LOAD_NAME(f) f
1914#endif
1915
1916#ifndef MICROPY_WRAP_MP_MAP_LOOKUP
1917#define MICROPY_WRAP_MP_MAP_LOOKUP(f) f
1918#endif
1919
1920#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE
1921#define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f
1922#endif
1923
Damien George7cbf8262021-04-28 10:52:19 +10001924#ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION
1925#define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f
1926#endif
1927
Damien Georgee9e9c762021-04-28 10:57:34 +10001928#ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT
1929#define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f
Damien George8fb5c8f2020-02-07 12:07:50 +11001930#endif
1931
Damien George544c3082020-04-23 16:18:14 +10001932#ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE
1933#define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f
1934#endif
1935
Damien Georged54208a2022-12-16 17:31:21 +11001936#ifndef MICROPY_WRAP_MP_SCHED_VM_ABORT
1937#define MICROPY_WRAP_MP_SCHED_VM_ABORT(f) f
1938#endif
1939
Damien George8fb5c8f2020-02-07 12:07:50 +11001940/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +00001941/* Miscellaneous settings */
1942
Damien George28631532015-02-08 13:42:00 +00001943// All uPy objects in ROM must be aligned on at least a 4 byte boundary
1944// so that the small-int/qstr/pointer distinction can be made. For machines
1945// that don't do this (eg 16-bit CPU), define the following macro to something
1946// like __attribute__((aligned(4))).
1947#ifndef MICROPY_OBJ_BASE_ALIGNMENT
1948#define MICROPY_OBJ_BASE_ALIGNMENT
1949#endif
1950
Damien George40047822022-04-21 16:30:23 +10001951// String used for the banner, and sys.version additional information
1952#ifndef MICROPY_BANNER_NAME_AND_VERSION
Jim Mussared3bf70f12023-10-10 16:50:28 +11001953#if MICROPY_PREVIEW_VERSION_2
1954#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython (with v2.0 preview) " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE
1955#else
Damien George40047822022-04-21 16:30:23 +10001956#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE
1957#endif
Jim Mussared3bf70f12023-10-10 16:50:28 +11001958#endif
Damien George40047822022-04-21 16:30:23 +10001959
Damien George402df832022-04-26 17:28:39 +10001960// String used for the second part of the banner, and sys.implementation._machine
1961#ifndef MICROPY_BANNER_MACHINE
1962#ifdef MICROPY_HW_BOARD_NAME
1963#define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME
1964#else
1965#define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version"
1966#endif
1967#endif
1968
Damien Georgead4656b2021-02-04 16:39:09 +11001969// Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
1970#ifndef MP_BYTES_PER_OBJ_WORD
1971#define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
Damien George4c307bf2017-04-01 11:39:38 +11001972#endif
1973
Damien George7e956fa2021-02-04 15:32:59 +11001974// Number of bits in a byte
1975#ifndef MP_BITS_PER_BYTE
1976#define MP_BITS_PER_BYTE (8)
Yonatan Goldschmidt1c849d62019-12-01 01:10:12 +02001977#endif
Damien George40f3c022014-07-03 13:25:24 +01001978// mp_int_t value with most significant bit set
Damien Georgec8911902021-02-04 16:39:46 +11001979#define MP_OBJ_WORD_MSBIT_HIGH (((mp_uint_t)1) << (MP_BYTES_PER_OBJ_WORD * MP_BITS_PER_BYTE - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +02001980
Damien Georgea9bcd512014-10-06 13:44:59 +00001981// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1982// defined and that they are the opposite of each other.
1983#if defined(MP_ENDIANNESS_LITTLE)
1984#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1985#elif defined(MP_ENDIANNESS_BIG)
1986#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1987#else
Damien George69661f32020-02-27 15:36:53 +11001988// Endianness not defined by port so try to autodetect it.
Damien Georgea9bcd512014-10-06 13:44:59 +00001989 #if defined(__BYTE_ORDER__)
1990 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1991 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001992 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Damien Georgea9bcd512014-10-06 13:44:59 +00001993 #define MP_ENDIANNESS_LITTLE (0)
1994 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001995 #else
Damien George4e4772b2015-05-30 23:12:30 +01001996 #include <endian.h>
1997 #if defined(__BYTE_ORDER)
1998 #if __BYTE_ORDER == __LITTLE_ENDIAN
1999 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10002000 #elif __BYTE_ORDER == __BIG_ENDIAN
Damien George4e4772b2015-05-30 23:12:30 +01002001 #define MP_ENDIANNESS_LITTLE (0)
2002 #endif
Damien George4e4772b2015-05-30 23:12:30 +01002003 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00002004 #endif
Damien George96303762018-05-07 13:36:52 +10002005 #ifndef MP_ENDIANNESS_LITTLE
2006 #error endianness not defined and cannot detect it
2007 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00002008 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
Andrew Schellercc837372014-04-14 02:39:56 +01002009#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +03002010
Damien George3c658a42014-08-24 16:28:17 +01002011// Make a pointer to RAM callable (eg set lower bit for Thumb code)
2012// (This scheme won't work if we want to mix Thumb and normal ARM code.)
2013#ifndef MICROPY_MAKE_POINTER_CALLABLE
2014#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
2015#endif
2016
Damien George5b22bde2024-09-25 14:06:00 +10002017// Whether native text/BSS/rodata memory loaded from .mpy files is explicitly tracked
2018// so that the GC cannot reclaim it.
2019//
2020// In general a port should let these options have their defaults, but the defaults here
2021// can be overridden if needed by defining both MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA
2022// and MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA.
2023#ifndef MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA
2024#if MICROPY_EMIT_MACHINE_CODE && MICROPY_PERSISTENT_CODE_LOAD
2025// Pointer tracking is required when loading native code is enabled.
2026#if defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC)
2027// If a port defined a custom allocator or commit function for native text, then the
2028// text does not need to be tracked (its allocation is managed by the port). But the
2029// BSS/rodata must be tracked (if there is any) because if there are any pointers to it
2030// in the function data, they aren't traced by the GC.
2031#define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (0)
2032#define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (1)
2033#else
2034// If a port uses the default allocator (the GC heap) then all native text is allocated
2035// on the GC heap. But it's not guaranteed that a pointer to the head of the block of
2036// native text (which may contain multiple native functions) will be retained for the GC
2037// to trace. This is because native functions can start inside the big block of text
2038// and so it's possible that the only GC-reachable pointers are pointers inside.
2039// Therefore the big block is explicitly tracked. If there is any BSS/rodata memory,
2040// then it does not need to be explicitly tracked because a pointer to it is stored into
2041// the function text via `mp_native_relocate()`.
2042#define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (1)
2043#define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (0)
2044#endif
2045#else // MICROPY_EMIT_MACHINE_CODE && MICROPY_PERSISTENT_CODE_LOAD
2046// Pointer tracking not needed when loading native code is disabled.
2047#define MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA (0)
2048#define MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA (0)
2049#endif
Fabian Vogtb7235b82014-09-03 16:59:33 +02002050#endif
2051
Damien George5b22bde2024-09-25 14:06:00 +10002052// If these macros are defined then the memory allocated by them does not need to be
2053// traced by the GC. But if they are left undefined then the GC heap will be used as
2054// the allocator and the memory must be traced by the GC. See also above logic for
2055// enabling MICROPY_PERSISTENT_CODE_TRACK_FUN_DATA and
2056// MICROPY_PERSISTENT_CODE_TRACK_BSS_RODATA.
2057#ifndef MP_PLAT_ALLOC_EXEC
2058#define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
Fabian Vogtb7235b82014-09-03 16:59:33 +02002059#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
2060#endif
2061
Angus Gratton519c24d2023-08-02 16:49:44 +10002062// Allocating new heap area at runtime requires port to be able to allocate from system heap
2063#if MICROPY_GC_SPLIT_HEAP_AUTO
2064#ifndef MP_PLAT_ALLOC_HEAP
2065#define MP_PLAT_ALLOC_HEAP(size) malloc(size)
2066#endif
2067#ifndef MP_PLAT_FREE_HEAP
2068#define MP_PLAT_FREE_HEAP(ptr) free(ptr)
2069#endif
2070#endif
2071
Damien George7f9d1d62015-04-09 23:56:15 +01002072// This macro is used to do all output (except when MICROPY_PY_IO is defined)
2073#ifndef MP_PLAT_PRINT_STRN
Damien George4300c7d2015-10-15 00:05:55 +01002074#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
Damien George7f9d1d62015-04-09 23:56:15 +01002075#endif
2076
Paul Sokolovsky722e5622014-09-06 19:17:23 +03002077#ifndef MP_SSIZE_MAX
2078#define MP_SSIZE_MAX SSIZE_MAX
2079#endif
2080
Damien George40f3c022014-07-03 13:25:24 +01002081// printf format spec to use for mp_int_t and friends
Damien George136f6752014-01-07 14:54:15 +00002082#ifndef INT_FMT
stijn3baf6b52015-11-20 15:59:06 +01002083#if defined(__LP64__)
Damien George40f3c022014-07-03 13:25:24 +01002084// Archs where mp_int_t == long, long != int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02002085#define UINT_FMT "%lu"
2086#define INT_FMT "%ld"
stijn3baf6b52015-11-20 15:59:06 +01002087#elif defined(_WIN64)
stijn0a4eb4d2015-12-18 10:20:33 +01002088#define UINT_FMT "%llu"
2089#define INT_FMT "%lld"
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02002090#else
Damien George40f3c022014-07-03 13:25:24 +01002091// Archs where mp_int_t == int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02002092#define UINT_FMT "%u"
2093#define INT_FMT "%d"
2094#endif
stijn84fa3312020-04-16 09:13:57 +02002095#endif // INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +03002096
2097// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +02002098#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +03002099#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +02002100#endif
mux5c8db482014-06-21 17:24:55 +02002101
2102// Modifier for weak functions
2103#ifndef MP_WEAK
2104#define MP_WEAK __attribute__((weak))
2105#endif
Paul Sokolovsky361909e2014-12-29 00:51:06 +02002106
Paul Sokolovsky0f5bf1a2016-06-15 23:52:00 +03002107// Modifier for functions which should be never inlined
2108#ifndef MP_NOINLINE
2109#define MP_NOINLINE __attribute__((noinline))
2110#endif
2111
Paul Sokolovsky1bc29112016-08-07 22:36:05 +03002112// Modifier for functions which should be always inlined
2113#ifndef MP_ALWAYSINLINE
2114#define MP_ALWAYSINLINE __attribute__((always_inline))
2115#endif
2116
Paul Sokolovsky361909e2014-12-29 00:51:06 +02002117// Condition is likely to be true, to help branch prediction
2118#ifndef MP_LIKELY
2119#define MP_LIKELY(x) __builtin_expect((x), 1)
2120#endif
2121
2122// Condition is likely to be false, to help branch prediction
2123#ifndef MP_UNLIKELY
2124#define MP_UNLIKELY(x) __builtin_expect((x), 0)
2125#endif
Damien George9ddbe292014-12-29 01:02:19 +00002126
Damien George0c80cb32019-08-19 15:50:02 +10002127// To annotate that code is unreachable
2128#ifndef MP_UNREACHABLE
2129#if defined(__GNUC__)
2130#define MP_UNREACHABLE __builtin_unreachable();
2131#else
2132#define MP_UNREACHABLE for (;;);
2133#endif
2134#endif
2135
Emil Renner Berthingccd92332019-11-28 12:47:21 +01002136// Explicitly annotate switch case fall throughs
2137#if defined(__GNUC__) && __GNUC__ >= 7
2138#define MP_FALLTHROUGH __attribute__((fallthrough));
2139#else
2140#define MP_FALLTHROUGH
2141#endif
2142
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002143#ifndef MP_HTOBE16
2144#if MP_ENDIANNESS_LITTLE
Damien Georgefeb25772020-03-20 21:47:07 +11002145#define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))
Damien George69661f32020-02-27 15:36:53 +11002146#define MP_BE16TOH(x) MP_HTOBE16(x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002147#else
Damien George69661f32020-02-27 15:36:53 +11002148#define MP_HTOBE16(x) (x)
2149#define MP_BE16TOH(x) (x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002150#endif
2151#endif
2152
2153#ifndef MP_HTOBE32
2154#if MP_ENDIANNESS_LITTLE
Damien Georgefeb25772020-03-20 21:47:07 +11002155#define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff)))
Damien George69661f32020-02-27 15:36:53 +11002156#define MP_BE32TOH(x) MP_HTOBE32(x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002157#else
Damien George69661f32020-02-27 15:36:53 +11002158#define MP_HTOBE32(x) (x)
2159#define MP_BE32TOH(x) (x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002160#endif
2161#endif
2162
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002163// Warning categories are by default implemented as strings, though
2164// hook is left for a port to define them as something else.
2165#if MICROPY_WARNINGS_CATEGORY
Damien George69661f32020-02-27 15:36:53 +11002166#ifndef MP_WARN_CAT
2167#define MP_WARN_CAT(x) #x
2168#endif
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002169#else
Damien George69661f32020-02-27 15:36:53 +11002170#undef MP_WARN_CAT
2171#define MP_WARN_CAT(x) (NULL)
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002172#endif
2173
Alexander Steffen299bc622017-06-29 23:14:58 +02002174#endif // MICROPY_INCLUDED_PY_MPCONFIG_H