blob: 46c62913cca67978aee79bdc3429e22197d03af9 [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
Damien George7cd59c52018-12-15 15:13:33 +110029// Current version of MicroPython
Damien Georgeaba83e62019-01-26 00:44:35 +110030#define MICROPY_VERSION_MAJOR 1
Damien George294baf52023-04-26 15:42:28 +100031#define MICROPY_VERSION_MINOR 20
32#define MICROPY_VERSION_MICRO 0
Damien George7cd59c52018-12-15 15:13:33 +110033
34// Combined version as a 32-bit number for convenience
35#define MICROPY_VERSION ( \
36 MICROPY_VERSION_MAJOR << 16 \
Damien George69661f32020-02-27 15:36:53 +110037 | MICROPY_VERSION_MINOR << 8 \
38 | MICROPY_VERSION_MICRO)
Damien George7cd59c52018-12-15 15:13:33 +110039
40// String version
41#define MICROPY_VERSION_STRING \
42 MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \
43 MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \
44 MP_STRINGIFY(MICROPY_VERSION_MICRO)
45
Paul Sokolovskyb372bfc2014-01-03 17:15:53 +020046// This file contains default configuration settings for MicroPython.
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020047// You can override any of the options below using mpconfigport.h file
48// located in a directory of your port.
Paul Sokolovskyb372bfc2014-01-03 17:15:53 +020049
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020050// mpconfigport.h is a file containing configuration settings for a
51// particular port. mpconfigport.h is actually a default name for
Ville Skyttäca16c382017-05-29 10:08:14 +030052// such config, and it can be overridden using MP_CONFIGFILE preprocessor
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020053// define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
54// argument to make when using standard MicroPython makefiles).
55// This is useful to have more than one config per port, for example,
56// release vs debug configs, etc. Note that if you switch from one config
57// to another, you must rebuild from scratch using "-B" switch to make.
58
Jim Mussared01374d92021-08-14 01:43:15 +100059// Disable all optional features (i.e. minimal port).
60#define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0)
61// Only enable core features (constrained flash, e.g. STM32L072)
62#define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10)
63// Enable most common features (small on-device flash, e.g. STM32F411)
64#define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20)
65// Enable convenience features (medium on-device flash, e.g. STM32F405)
66#define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30)
67// Enable all common features (large/external flash, rp2, unix)
68#define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40)
69// Enable everything (e.g. coverage)
70#define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50)
71
Jim Mussared605266e2022-08-16 01:28:31 +100072#ifdef MP_CONFIGFILE
73#include MP_CONFIGFILE
74#else
75#include <mpconfigport.h>
76#endif
77
Jim Mussared01374d92021-08-14 01:43:15 +100078// Ports/boards should set this, but default to level=core.
79#ifndef MICROPY_CONFIG_ROM_LEVEL
80#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES)
81#endif
82
83// Helper macros for "have at least this level".
84#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES)
85#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES)
86#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)
87#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
88#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING)
89
Damien George136f6752014-01-07 14:54:15 +000090// Any options not explicitly set in mpconfigport.h will get default
91// values below.
92
93/*****************************************************************************/
Damien George567184e2015-03-29 14:05:46 +010094/* Object representation */
95
Damien Georgec408ed92017-06-26 12:29:20 +100096// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +010097// - xxxx...xxx1 : a small int, bits 1 and above are the value
Damien George6f0c83f2020-01-08 23:58:40 +110098// - xxxx...x010 : a qstr, bits 3 and above are the value
99// - xxxx...x110 : an immediate object, bits 3 and above are the value
Damien George567184e2015-03-29 14:05:46 +0100100// - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
101#define MICROPY_OBJ_REPR_A (0)
102
Damien Georgec408ed92017-06-26 12:29:20 +1000103// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +0100104// - xxxx...xx01 : a small int, bits 2 and above are the value
Damien George6f0c83f2020-01-08 23:58:40 +1100105// - xxxx...x011 : a qstr, bits 3 and above are the value
106// - xxxx...x111 : an immediate object, bits 3 and above are the value
Damien George567184e2015-03-29 14:05:46 +0100107// - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
108#define MICROPY_OBJ_REPR_B (1)
109
Damien George8b8d1892015-11-06 23:25:10 +0000110// A MicroPython object is a machine word having the following form (called R):
Damien George183edef2015-10-17 23:20:57 +0100111// - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
Damien George6f0c83f2020-01-08 23:58:40 +1100112// - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value
113// - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value
Damien George183edef2015-10-17 23:20:57 +0100114// - s1111111 10000000 00000000 00000010 +/- inf
115// - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
116// - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
117// - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
Damien George6f0c83f2020-01-08 23:58:40 +1100118// Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
119// This makes strs/immediates easier to encode/decode as they have zeros in the top 9 bits.
Damien George183edef2015-10-17 23:20:57 +0100120// This scheme only works with 32-bit word size and float enabled.
121#define MICROPY_OBJ_REPR_C (2)
122
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000123// A MicroPython object is a 64-bit word having the following form (called R):
124// - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
125// - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
126// - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
Damien George2759bec2017-12-11 22:39:12 +1100127// - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000128// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
Damien George6f0c83f2020-01-08 23:58:40 +1100129// - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000130// - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
131// Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
132// This makes pointers have all zeros in the top 32 bits.
133// Small-ints and strs have 1 as LSB to make sure they don't look like pointers
134// to the garbage collector.
135#define MICROPY_OBJ_REPR_D (3)
136
Damien George567184e2015-03-29 14:05:46 +0100137#ifndef MICROPY_OBJ_REPR
138#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
139#endif
140
Damien Georged96cfd12020-01-09 00:00:27 +1100141// Whether to encode None/False/True as immediate objects instead of pointers to
142// real objects. Reduces code size by a decent amount without hurting
143// performance, for all representations except D on some architectures.
144#ifndef MICROPY_OBJ_IMMEDIATE_OBJS
145#define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D)
146#endif
147
Damien George567184e2015-03-29 14:05:46 +0100148/*****************************************************************************/
Damien George66e18f02014-05-05 13:19:03 +0100149/* Memory allocation policy */
150
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200151// Number of bytes in memory allocation/GC block. Any size allocated will be
152// rounded up to be multiples of this.
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200153#ifndef MICROPY_BYTES_PER_GC_BLOCK
Damien Georgead4656b2021-02-04 16:39:09 +1100154#define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD)
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200155#endif
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200156
Damien Georgefd40a9c2015-01-01 22:04:46 +0000157// Number of words allocated (in BSS) to the GC stack (minimum is 1)
158#ifndef MICROPY_ALLOC_GC_STACK_SIZE
159#define MICROPY_ALLOC_GC_STACK_SIZE (64)
160#endif
161
Ayke van Laethem31cf5282018-02-23 18:59:31 +0100162// The C-type to use for entries in the GC stack. By default it allows the
163// heap to be as large as the address space, but the bit-width of this type can
164// be reduced to save memory when the heap is small enough. The type must be
165// big enough to index all blocks in the heap, which is set by
166// heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK.
167#ifndef MICROPY_GC_STACK_ENTRY_TYPE
168#define MICROPY_GC_STACK_ENTRY_TYPE size_t
169#endif
170
Damien George5ffe1d82016-08-26 15:35:26 +1000171// Be conservative and always clear to zero newly (re)allocated memory in the GC.
172// This helps eliminate stray pointers that hold on to memory that's no longer
173// used. It decreases performance due to unnecessary memory clearing.
Colin Hogben828df542016-10-31 14:52:11 +0000174// A memory manager which always clears memory can set this to 0.
Damien George5ffe1d82016-08-26 15:35:26 +1000175// TODO Do analysis to understand why some memory is not properly cleared and
176// find a more efficient way to clear it.
177#ifndef MICROPY_GC_CONSERVATIVE_CLEAR
Colin Hogben828df542016-10-31 14:52:11 +0000178#define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
Damien George5ffe1d82016-08-26 15:35:26 +1000179#endif
180
Paul Sokolovsky93e353e2016-07-21 00:37:30 +0300181// Support automatic GC when reaching allocation threshold,
182// configurable by gc.threshold().
183#ifndef MICROPY_GC_ALLOC_THRESHOLD
Jim Mussared01374d92021-08-14 01:43:15 +1000184#define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky93e353e2016-07-21 00:37:30 +0300185#endif
186
Damien Georgeade9a052015-06-13 21:53:22 +0100187// Number of bytes to allocate initially when creating new chunks to store
188// interned string data. Smaller numbers lead to more chunks being needed
189// and more wastage at the end of the chunk. Larger numbers lead to wasted
190// space at the end when no more strings need interning.
191#ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
192#define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
193#endif
194
Damien Georgee1199ec2014-05-10 17:48:01 +0100195// Initial amount for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100196#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
197#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
Damien Georgee1199ec2014-05-10 17:48:01 +0100198#endif
199
200// Increment for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100201#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
202#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
Damien Georgee1199ec2014-05-10 17:48:01 +0100203#endif
204
Damien George66e18f02014-05-05 13:19:03 +0100205// Initial amount for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100206#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
207#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
Damien George66e18f02014-05-05 13:19:03 +0100208#endif
209
210// Increment for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100211#ifndef MICROPY_ALLOC_PARSE_RULE_INC
212#define MICROPY_ALLOC_PARSE_RULE_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100213#endif
214
215// Initial amount for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100216#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
217#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
Damien George66e18f02014-05-05 13:19:03 +0100218#endif
219
220// Increment for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100221#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
222#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100223#endif
224
Damien George5042bce2014-05-25 22:06:06 +0100225// Strings this length or less will be interned by the parser
226#ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
227#define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
228#endif
229
Damien George58e0f4a2015-09-23 10:50:43 +0100230// Number of bytes to allocate initially when creating new chunks to store
231// parse nodes. Small leads to fragmentation, large leads to excess use.
232#ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
233#define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
234#endif
235
Damien George66e18f02014-05-05 13:19:03 +0100236// Initial amount for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100237#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
238#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
Damien George66e18f02014-05-05 13:19:03 +0100239#endif
240
241// Increment for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100242#ifndef MICROPY_ALLOC_SCOPE_ID_INC
243#define MICROPY_ALLOC_SCOPE_ID_INC (6)
244#endif
245
246// Maximum length of a path in the filesystem
247// So we can allocate a buffer on the stack for path manipulation in import
248#ifndef MICROPY_ALLOC_PATH_MAX
249#define MICROPY_ALLOC_PATH_MAX (512)
Damien George66e18f02014-05-05 13:19:03 +0100250#endif
251
Paul Sokolovsky346aacf2014-11-05 00:27:15 +0200252// Initial size of module dict
253#ifndef MICROPY_MODULE_DICT_SIZE
254#define MICROPY_MODULE_DICT_SIZE (1)
255#endif
256
matejcik1a2ffda2021-03-22 11:20:22 +0100257// Initial size of sys.modules dict
258#ifndef MICROPY_LOADED_MODULES_DICT_SIZE
259#define MICROPY_LOADED_MODULES_DICT_SIZE (3)
260#endif
261
Damien Georged8914522015-02-27 09:54:12 +0000262// Whether realloc/free should be passed allocated memory region size
263// You must enable this if MICROPY_MEM_STATS is enabled
264#ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
265#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
266#endif
267
Damien George95836f82015-01-11 22:27:30 +0000268// Number of bytes used to store qstr length
269// Dictates hard limit on maximum Python identifier length, but 1 byte
270// (limit of 255 bytes in an identifier) should be enough for everyone
271#ifndef MICROPY_QSTR_BYTES_IN_LEN
272#define MICROPY_QSTR_BYTES_IN_LEN (1)
273#endif
274
Damien Georgec3bd9412015-07-20 11:03:13 +0000275// Number of bytes used to store qstr hash
276#ifndef MICROPY_QSTR_BYTES_IN_HASH
Jim Mussared01374d92021-08-14 01:43:15 +1000277#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
Damien Georgec3bd9412015-07-20 11:03:13 +0000278#define MICROPY_QSTR_BYTES_IN_HASH (2)
Jim Mussared01374d92021-08-14 01:43:15 +1000279#else
280#define MICROPY_QSTR_BYTES_IN_HASH (1)
281#endif
Damien Georgec3bd9412015-07-20 11:03:13 +0000282#endif
283
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200284// Avoid using C stack when making Python function calls. C stack still
285// may be used if there's no free heap.
Paul Sokolovsky20397572015-03-28 01:14:44 +0200286#ifndef MICROPY_STACKLESS
287#define MICROPY_STACKLESS (0)
288#endif
289
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200290// Never use C stack when making Python function calls. This may break
291// testsuite as will subtly change which exception is thrown in case
292// of too deep recursion and other similar cases.
293#ifndef MICROPY_STACKLESS_STRICT
294#define MICROPY_STACKLESS_STRICT (0)
295#endif
296
Paul Sokolovskyf32020e2015-11-25 23:22:31 +0200297// Don't use alloca calls. As alloca() is not part of ANSI C, this
298// workaround option is provided for compilers lacking this de-facto
299// standard function. The way it works is allocating from heap, and
300// relying on garbage collection to free it eventually. This is of
301// course much less optimal than real alloca().
302#if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
303#undef alloca
304#define alloca(x) m_malloc(x)
305#endif
306
Damien George66e18f02014-05-05 13:19:03 +0100307/*****************************************************************************/
Damien Georgec408ed92017-06-26 12:29:20 +1000308/* MicroPython emitters */
Damien George136f6752014-01-07 14:54:15 +0000309
Damien Georged8c834c2015-11-02 21:55:42 +0000310// Whether to support loading of persistent code
311#ifndef MICROPY_PERSISTENT_CODE_LOAD
312#define MICROPY_PERSISTENT_CODE_LOAD (0)
313#endif
314
Jim Mussaredb2b5bcc2023-08-23 13:30:20 +1000315// Whether to support saving of persistent code, i.e. for mpy-cross to
316// generate .mpy files. Enabling this enables additional metadata on raw code
317// objects which is also required for sys.settrace.
Damien Georged8c834c2015-11-02 21:55:42 +0000318#ifndef MICROPY_PERSISTENT_CODE_SAVE
Jim Mussaredb2b5bcc2023-08-23 13:30:20 +1000319#define MICROPY_PERSISTENT_CODE_SAVE (MICROPY_PY_SYS_SETTRACE)
Damien Georged8c834c2015-11-02 21:55:42 +0000320#endif
321
David CARLIERcb309282021-01-16 20:48:19 +0000322// Whether to support saving persistent code to a file via mp_raw_code_save_file
323#ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE
324#define MICROPY_PERSISTENT_CODE_SAVE_FILE (0)
325#endif
326
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000327// Whether generated code can persist independently of the VM/runtime instance
Damien Georged8c834c2015-11-02 21:55:42 +0000328// This is enabled automatically when needed by other features
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000329#ifndef MICROPY_PERSISTENT_CODE
Damien George0a2e9652016-01-31 22:24:16 +0000330#define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000331#endif
332
Damien Georgef2040bf2021-10-22 22:22:47 +1100333// Whether bytecode uses a qstr_table to map internal qstr indices in the bytecode
334// to global qstr values in the runtime (behaviour when feature is enabled), or
335// just stores global qstr values directly in the bytecode. This must be enabled
336// if MICROPY_PERSISTENT_CODE is enabled.
337#ifndef MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
338#define MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE (MICROPY_PERSISTENT_CODE)
339#endif
340
Damien George136f6752014-01-07 14:54:15 +0000341// Whether to emit x64 native code
342#ifndef MICROPY_EMIT_X64
343#define MICROPY_EMIT_X64 (0)
344#endif
345
Damien Georgec90f59e2014-09-06 23:06:36 +0100346// Whether to emit x86 native code
347#ifndef MICROPY_EMIT_X86
348#define MICROPY_EMIT_X86 (0)
349#endif
350
Damien George136f6752014-01-07 14:54:15 +0000351// Whether to emit thumb native code
352#ifndef MICROPY_EMIT_THUMB
353#define MICROPY_EMIT_THUMB (0)
354#endif
355
graham sanderson40d20102020-12-12 13:04:10 -0600356// Whether to emit ARMv7-M instruction support in thumb native code
357#ifndef MICROPY_EMIT_THUMB_ARMV7M
358#define MICROPY_EMIT_THUMB_ARMV7M (1)
359#endif
360
Damien George136f6752014-01-07 14:54:15 +0000361// Whether to enable the thumb inline assembler
362#ifndef MICROPY_EMIT_INLINE_THUMB
363#define MICROPY_EMIT_INLINE_THUMB (0)
364#endif
365
=50089722015-04-14 13:14:57 +0100366// Whether to enable float support in the Thumb2 inline assembler
367#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
368#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
369#endif
370
Fabian Vogtfe3d16e2014-08-16 22:55:53 +0200371// Whether to emit ARM native code
372#ifndef MICROPY_EMIT_ARM
373#define MICROPY_EMIT_ARM (0)
374#endif
375
Damien George8e5aced2016-12-09 16:39:39 +1100376// Whether to emit Xtensa native code
377#ifndef MICROPY_EMIT_XTENSA
378#define MICROPY_EMIT_XTENSA (0)
379#endif
380
Damien Georgef76b1bf2016-12-09 17:03:33 +1100381// Whether to enable the Xtensa inline assembler
382#ifndef MICROPY_EMIT_INLINE_XTENSA
383#define MICROPY_EMIT_INLINE_XTENSA (0)
384#endif
385
Damien George9adedce2019-09-13 13:15:12 +1000386// Whether to emit Xtensa-Windowed native code
387#ifndef MICROPY_EMIT_XTENSAWIN
388#define MICROPY_EMIT_XTENSAWIN (0)
389#endif
390
Damien George2ac4af62014-08-15 16:45:41 +0100391// Convenience definition for whether any native emitter is enabled
Damien George9adedce2019-09-13 13:15:12 +1000392#define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN)
393
Damien George1fb01bd2022-05-10 13:56:24 +1000394// Some architectures cannot read byte-wise from executable memory. In this case
395// the prelude for a native function (which usually sits after the machine code)
396// must be separated and placed somewhere where it can be read byte-wise.
397#define MICROPY_EMIT_NATIVE_PRELUDE_SEPARATE_FROM_MACHINE_CODE (MICROPY_EMIT_XTENSAWIN)
Damien George2ac4af62014-08-15 16:45:41 +0100398
Damien Georgead297a12016-12-09 13:17:49 +1100399// Convenience definition for whether any inline assembler emitter is enabled
Damien Georgef76b1bf2016-12-09 17:03:33 +1100400#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)
Damien Georgead297a12016-12-09 13:17:49 +1100401
Jun Wub152bbd2019-05-06 00:31:11 -0700402// Convenience definition for whether any native or inline assembler emitter is enabled
403#define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)
404
Damien George9883d8e2020-07-27 23:52:38 +1000405// Whether native relocatable code loaded from .mpy files is explicitly tracked
406// so that the GC cannot reclaim it. Needed on architectures that allocate
407// executable memory on the MicroPython heap and don't explicitly track this
408// data some other way.
409#ifndef MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE
410#if !MICROPY_EMIT_MACHINE_CODE || defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC)
411#define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (0)
412#else
413#define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (1)
414#endif
415#endif
416
Damien George136f6752014-01-07 14:54:15 +0000417/*****************************************************************************/
Damien George58ebde42014-05-21 20:32:59 +0100418/* Compiler configuration */
419
Damien Georgedd5353a2015-12-18 12:35:44 +0000420// Whether to include the compiler
421#ifndef MICROPY_ENABLE_COMPILER
Jim Mussared01374d92021-08-14 01:43:15 +1000422#define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgedd5353a2015-12-18 12:35:44 +0000423#endif
424
Damien Georgeea235202016-02-11 22:30:53 +0000425// Whether the compiler is dynamically configurable (ie at runtime)
Damien Georgea4f1d822019-05-29 21:17:29 +1000426// This will disable the ability to execute native/viper code
Damien Georgeea235202016-02-11 22:30:53 +0000427#ifndef MICROPY_DYNAMIC_COMPILER
428#define MICROPY_DYNAMIC_COMPILER (0)
429#endif
430
Damien George64f2b212015-10-08 14:58:15 +0100431// Whether to enable constant folding; eg 1+2 rewritten as 3
432#ifndef MICROPY_COMP_CONST_FOLDING
Jim Mussared01374d92021-08-14 01:43:15 +1000433#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George64f2b212015-10-08 14:58:15 +0100434#endif
435
Damien George35c0cff2022-03-31 14:27:47 +1100436// Whether to compile constant tuples immediately to their respective objects; eg (1, True)
437// Otherwise the tuple will be built at runtime
438#ifndef MICROPY_COMP_CONST_TUPLE
439#define MICROPY_COMP_CONST_TUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
440#endif
441
Damien George07796932019-02-27 00:10:04 +1100442// Whether to enable optimisations for constant literals, eg OrderedDict
443#ifndef MICROPY_COMP_CONST_LITERAL
Jim Mussared01374d92021-08-14 01:43:15 +1000444#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George07796932019-02-27 00:10:04 +1100445#endif
446
Damien Georgeddd1e182015-01-10 14:07:24 +0000447// Whether to enable lookup of constants in modules; eg module.CONST
448#ifndef MICROPY_COMP_MODULE_CONST
Jim Mussared0e236ee2021-09-15 23:18:23 +1000449#define MICROPY_COMP_MODULE_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeddd1e182015-01-10 14:07:24 +0000450#endif
451
Damien George58ebde42014-05-21 20:32:59 +0100452// Whether to enable constant optimisation; id = const(value)
453#ifndef MICROPY_COMP_CONST
Jim Mussared01374d92021-08-14 01:43:15 +1000454#define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George58ebde42014-05-21 20:32:59 +0100455#endif
456
Damien George42e0c592015-03-14 13:11:35 +0000457// Whether to enable optimisation of: a, b = c, d
458// Costs 124 bytes (Thumb2)
459#ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
Jim Mussared01374d92021-08-14 01:43:15 +1000460#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George42e0c592015-03-14 13:11:35 +0000461#endif
462
463// Whether to enable optimisation of: a, b, c = d, e, f
Damien George253f2bd2018-02-04 13:35:21 +1100464// Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
Damien George42e0c592015-03-14 13:11:35 +0000465#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
Jim Mussared0e236ee2021-09-15 23:18:23 +1000466#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George42e0c592015-03-14 13:11:35 +0000467#endif
468
Damien Georgeae54fbf2017-04-22 14:58:01 +1000469// Whether to enable optimisation of: return a if b else c
470// Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
471#ifndef MICROPY_COMP_RETURN_IF_EXPR
Jim Mussared0e236ee2021-09-15 23:18:23 +1000472#define MICROPY_COMP_RETURN_IF_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeae54fbf2017-04-22 14:58:01 +1000473#endif
474
Damien George58ebde42014-05-21 20:32:59 +0100475/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +0000476/* Internal debugging stuff */
477
478// Whether to collect memory allocation stats
479#ifndef MICROPY_MEM_STATS
480#define MICROPY_MEM_STATS (0)
481#endif
482
Damien Georgeda2d2b62018-08-02 14:04:44 +1000483// The mp_print_t printer used for debugging output
484#ifndef MICROPY_DEBUG_PRINTER
485#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
486#endif
487
Damien Georgecbd2f742014-01-19 11:48:48 +0000488// Whether to build functions that print debugging info:
Damien George3417bc22014-05-10 10:36:38 +0100489// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000490// mp_parse_node_print
491#ifndef MICROPY_DEBUG_PRINTERS
492#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000493#endif
494
Stefan Naumannace9fb52017-07-24 18:55:14 +0200495// Whether to enable all debugging outputs (it will be extremely verbose)
496#ifndef MICROPY_DEBUG_VERBOSE
497#define MICROPY_DEBUG_VERBOSE (0)
498#endif
499
Damien George02cc2882019-03-08 15:48:20 +1100500// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
501#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
502#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
503#endif
504
Damien George843dcd42020-09-30 23:34:42 +1000505// Whether to print parse rule names (rather than integers) in mp_parse_node_print
506#ifndef MICROPY_DEBUG_PARSE_RULE_NAME
507#define MICROPY_DEBUG_PARSE_RULE_NAME (0)
508#endif
509
Damien George6d199342019-01-04 17:09:41 +1100510// Whether to enable a simple VM stack overflow check
511#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
512#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
513#endif
514
Jeff Epler84071592021-08-27 09:02:03 -0500515// Whether to enable extra instrumentation for valgrind
516#ifndef MICROPY_DEBUG_VALGRIND
517#define MICROPY_DEBUG_VALGRIND (0)
518#endif
519
Damien George136f6752014-01-07 14:54:15 +0000520/*****************************************************************************/
Damien Georgeee3fd462014-05-24 23:03:12 +0100521/* Optimisations */
522
523// Whether to use computed gotos in the VM, or a switch
Jim Mussaredb51e7e92021-08-19 17:49:33 +1000524// Computed gotos are roughly 10% faster, and increase VM code size by a little,
525// e.g. ~1kiB on Cortex M4.
Damien George44f0a4d2017-09-18 23:53:33 +1000526// Note: enabling this will use the gcc-specific extensions of ranged designated
527// initialisers and addresses of labels, which are not part of the C99 standard.
Damien Georgeee3fd462014-05-24 23:03:12 +0100528#ifndef MICROPY_OPT_COMPUTED_GOTO
529#define MICROPY_OPT_COMPUTED_GOTO (0)
530#endif
531
Jim Mussared7b89ad82021-08-19 22:46:40 +1000532// Optimise the fast path for loading attributes from instance types. Increases
533// Thumb2 code size by about 48 bytes.
534#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
Jim Mussared0e236ee2021-09-15 23:18:23 +1000535#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared7b89ad82021-08-19 22:46:40 +1000536#endif
537
Jim Mussared11ef8f22021-08-18 14:52:48 +1000538// Use extra RAM to cache map lookups by remembering the likely location of
539// the index. Avoids the hash computation on unordered maps, and avoids the
540// linear search on ordered (especially in-ROM) maps. Can provide a +10-15%
541// performance improvement on benchmarks involving lots of attribute access
542// or dictionary lookup.
543#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000544#define MICROPY_OPT_MAP_LOOKUP_CACHE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared11ef8f22021-08-18 14:52:48 +1000545#endif
546
547// How much RAM (in bytes) to use for the map lookup cache.
548#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE
549#define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128)
550#endif
551
Doug Currie2e2e15c2016-01-30 22:35:58 -0500552// Whether to use fast versions of bitwise operations (and, or, xor) when the
553// arguments are both positive. Increases Thumb2 code size by about 250 bytes.
554#ifndef MICROPY_OPT_MPZ_BITWISE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000555#define MICROPY_OPT_MPZ_BITWISE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Doug Currie2e2e15c2016-01-30 22:35:58 -0500556#endif
557
Christopher Swenson8c656752018-08-27 10:32:21 +1000558
559// Whether math.factorial is large, fast and recursive (1) or small and slow (0).
560#ifndef MICROPY_OPT_MATH_FACTORIAL
Jim Mussared0e236ee2021-09-15 23:18:23 +1000561#define MICROPY_OPT_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Christopher Swenson8c656752018-08-27 10:32:21 +1000562#endif
563
Damien Georgeee3fd462014-05-24 23:03:12 +0100564/*****************************************************************************/
565/* Python internal features */
Damien George136f6752014-01-07 14:54:15 +0000566
Damien George20993682018-02-20 18:00:44 +1100567// Whether to enable import of external modules
568// When disabled, only importing of built-in modules is supported
569// When enabled, a port must implement mp_import_stat (among other things)
570#ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
Jim Mussared01374d92021-08-14 01:43:15 +1000571#define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George20993682018-02-20 18:00:44 +1100572#endif
573
Damien George6b239c22016-11-16 16:04:57 +1100574// Whether to use the POSIX reader for importing files
575#ifndef MICROPY_READER_POSIX
576#define MICROPY_READER_POSIX (0)
577#endif
578
Damien Georgedcb9ea72017-01-27 15:10:09 +1100579// Whether to use the VFS reader for importing files
580#ifndef MICROPY_READER_VFS
581#define MICROPY_READER_VFS (0)
582#endif
583
Sean Burtone33bc592018-12-13 12:10:35 +0000584// Whether any readers have been defined
585#ifndef MICROPY_HAS_FILE_READER
586#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
587#endif
588
Damien George40d84302016-02-15 22:46:21 +0000589// Hook for the VM at the start of the opcode loop (can contain variable
590// definitions usable by the other hook functions)
591#ifndef MICROPY_VM_HOOK_INIT
592#define MICROPY_VM_HOOK_INIT
593#endif
594
595// Hook for the VM during the opcode loop (but only after jump opcodes)
596#ifndef MICROPY_VM_HOOK_LOOP
597#define MICROPY_VM_HOOK_LOOP
598#endif
599
600// Hook for the VM just before return opcode is finished being interpreted
601#ifndef MICROPY_VM_HOOK_RETURN
602#define MICROPY_VM_HOOK_RETURN
603#endif
604
Damien George916c3fd2021-04-25 22:24:49 +1000605// Hook for mp_sched_schedule when a function gets scheduled on sched_queue
606// (this macro executes within an atomic section)
607#ifndef MICROPY_SCHED_HOOK_SCHEDULED
608#define MICROPY_SCHED_HOOK_SCHEDULED
609#endif
610
Damien Georged3ebe482014-01-07 15:20:33 +0000611// Whether to include the garbage collector
612#ifndef MICROPY_ENABLE_GC
613#define MICROPY_ENABLE_GC (0)
614#endif
615
Ayke van Laethembcc827d2018-01-24 02:09:58 +0100616// Whether the garbage-collected heap can be split over multiple memory areas.
617#ifndef MICROPY_GC_SPLIT_HEAP
618#define MICROPY_GC_SPLIT_HEAP (0)
619#endif
620
Angus Gratton519c24d2023-08-02 16:49:44 +1000621// Whether regions should be added/removed from the split heap as needed.
622#ifndef MICROPY_GC_SPLIT_HEAP_AUTO
623#define MICROPY_GC_SPLIT_HEAP_AUTO (0)
624#endif
625
Laurens Valkfe120482021-10-26 10:47:04 +0200626// Hook to run code during time consuming garbage collector operations
David Lechner468ed212023-03-15 16:48:16 -0500627// *i* is the loop index variable (e.g. can be used to run every x loops)
Laurens Valkfe120482021-10-26 10:47:04 +0200628#ifndef MICROPY_GC_HOOK_LOOP
David Lechner468ed212023-03-15 16:48:16 -0500629#define MICROPY_GC_HOOK_LOOP(i)
Laurens Valkfe120482021-10-26 10:47:04 +0200630#endif
631
Damien Georgefca57012022-05-04 12:12:11 +1000632// Whether to provide m_tracked_calloc, m_tracked_free functions
633#ifndef MICROPY_TRACKED_ALLOC
634#define MICROPY_TRACKED_ALLOC (0)
635#endif
636
Damien George12bab722014-04-05 20:35:48 +0100637// Whether to enable finalisers in the garbage collector (ie call __del__)
Damien George7860c2a2014-11-05 21:16:41 +0000638#ifndef MICROPY_ENABLE_FINALISER
Jim Mussared0e236ee2021-09-15 23:18:23 +1000639#define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George12bab722014-04-05 20:35:48 +0100640#endif
641
Damien George02d830c2017-11-26 23:28:40 +1100642// Whether to enable a separate allocator for the Python stack.
643// If enabled then the code must call mp_pystack_init before mp_init.
644#ifndef MICROPY_ENABLE_PYSTACK
645#define MICROPY_ENABLE_PYSTACK (0)
646#endif
647
648// Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
649#ifndef MICROPY_PYSTACK_ALIGN
650#define MICROPY_PYSTACK_ALIGN (8)
651#endif
652
Paul Sokolovsky23668692014-06-25 03:03:34 +0300653// Whether to check C stack usage. C stack used for calling Python functions,
654// etc. Not checking means segfault on overflow.
655#ifndef MICROPY_STACK_CHECK
Jim Mussared0e236ee2021-09-15 23:18:23 +1000656#define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky23668692014-06-25 03:03:34 +0300657#endif
658
Dave Hylands5b7fd202014-07-01 23:46:53 -0700659// Whether to have an emergency exception buffer
660#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
661#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
662#endif
663#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
Damien George69661f32020-02-27 15:36:53 +1100664#ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
665#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
666#endif
Dave Hylands5b7fd202014-07-01 23:46:53 -0700667#endif
668
Damien Georgebbb4b982017-04-10 17:19:36 +1000669// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
Damien George7f1da0a2016-12-15 13:00:19 +1100670#ifndef MICROPY_KBD_EXCEPTION
Jim Mussared0e236ee2021-09-15 23:18:23 +1000671#define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George7f1da0a2016-12-15 13:00:19 +1100672#endif
673
Paul Sokolovsky1c9210b2015-12-23 00:06:37 +0200674// Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
675// handler) - if supported by a particular port.
676#ifndef MICROPY_ASYNC_KBD_INTR
677#define MICROPY_ASYNC_KBD_INTR (0)
678#endif
679
Damien George136f6752014-01-07 14:54:15 +0000680// Whether to include REPL helper function
Damien George58ebde42014-05-21 20:32:59 +0100681#ifndef MICROPY_HELPER_REPL
Jim Mussared0e236ee2021-09-15 23:18:23 +1000682#define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George136f6752014-01-07 14:54:15 +0000683#endif
684
Yonatan Goldschmidt61d2b402019-12-25 09:27:38 +0200685// Allow enabling debug prints after each REPL line
686#ifndef MICROPY_REPL_INFO
Damien Georgec62351f2021-11-01 15:18:22 +1100687#define MICROPY_REPL_INFO (0)
Yonatan Goldschmidt61d2b402019-12-25 09:27:38 +0200688#endif
689
Tom Soulanille7d588b02015-07-09 16:32:36 -0700690// Whether to include emacs-style readline behavior in REPL
691#ifndef MICROPY_REPL_EMACS_KEYS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000692#define MICROPY_REPL_EMACS_KEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Tom Soulanille7d588b02015-07-09 16:32:36 -0700693#endif
694
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200695// Whether to include emacs-style word movement/kill readline behavior in REPL.
696// This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word
697// and backward-kill-word, respectively.
698#ifndef MICROPY_REPL_EMACS_WORDS_MOVE
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000699#define MICROPY_REPL_EMACS_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200700#endif
701
702// Whether to include extra convenience keys for word movement/kill in readline REPL.
703// This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word
704// respectively. Ctrl+Delete is not implemented because it's a very different escape sequence.
705// Depends on MICROPY_REPL_EMACS_WORDS_MOVE.
706#ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000707#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Yonatan Goldschmidt853aaa02019-12-14 23:42:03 +0200708#endif
709
Damien George0af73012015-08-20 10:34:16 +0100710// Whether to implement auto-indent in REPL
711#ifndef MICROPY_REPL_AUTO_INDENT
Jim Mussared0e236ee2021-09-15 23:18:23 +1000712#define MICROPY_REPL_AUTO_INDENT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George0af73012015-08-20 10:34:16 +0100713#endif
714
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200715// Whether port requires event-driven REPL functions
716#ifndef MICROPY_REPL_EVENT_DRIVEN
717#define MICROPY_REPL_EVENT_DRIVEN (0)
718#endif
719
David Lechner81dbea12022-07-01 14:06:10 -0500720// The number of items to keep in the readline history.
721#ifndef MICROPY_READLINE_HISTORY_SIZE
722#define MICROPY_READLINE_HISTORY_SIZE (8)
723#endif
724
Damien Georged3ebe482014-01-07 15:20:33 +0000725// Whether to include lexer helper function for unix
Damien George58ebde42014-05-21 20:32:59 +0100726#ifndef MICROPY_HELPER_LEXER_UNIX
727#define MICROPY_HELPER_LEXER_UNIX (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000728#endif
729
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200730// Long int implementation
731#define MICROPY_LONGINT_IMPL_NONE (0)
732#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000733#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200734
735#ifndef MICROPY_LONGINT_IMPL
736#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
737#endif
738
739#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
740typedef long long mp_longint_impl_t;
741#endif
742
Damien George62ad1892014-01-29 21:51:51 +0000743// Whether to include information in the byte code to determine source
744// line number (increases RAM usage, but doesn't slow byte code execution)
745#ifndef MICROPY_ENABLE_SOURCE_LINE
Jim Mussared0e236ee2021-09-15 23:18:23 +1000746#define MICROPY_ENABLE_SOURCE_LINE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George62ad1892014-01-29 21:51:51 +0000747#endif
748
Damien George1463c1f2014-04-25 23:52:57 +0100749// Whether to include doc strings (increases RAM usage)
750#ifndef MICROPY_ENABLE_DOC_STRING
751#define MICROPY_ENABLE_DOC_STRING (0)
752#endif
753
Damien Georged4b706c2021-04-22 12:13:58 +1000754// Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION)
755#define MICROPY_ERROR_REPORTING_NONE (0)
Damien George1e9a92f2014-11-06 17:36:16 +0000756// Exception messages are short static strings
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300757#define MICROPY_ERROR_REPORTING_TERSE (1)
758// Exception messages provide basic error details
759#define MICROPY_ERROR_REPORTING_NORMAL (2)
760// Exception messages provide full info, e.g. object names
761#define MICROPY_ERROR_REPORTING_DETAILED (3)
762
763#ifndef MICROPY_ERROR_REPORTING
Jim Mussared01374d92021-08-14 01:43:15 +1000764#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES
765#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
766#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300767#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
Jim Mussared01374d92021-08-14 01:43:15 +1000768#else
769#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
770#endif
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300771#endif
772
Paul Sokolovsky8a8c1fc2015-01-01 09:29:28 +0200773// Whether issue warnings during compiling/execution
774#ifndef MICROPY_WARNINGS
775#define MICROPY_WARNINGS (0)
776#endif
777
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +0300778// Whether to support warning categories
779#ifndef MICROPY_WARNINGS_CATEGORY
780#define MICROPY_WARNINGS_CATEGORY (0)
781#endif
782
David Lechner62849b72017-09-24 20:15:48 -0500783// This macro is used when printing runtime warnings and errors
784#ifndef MICROPY_ERROR_PRINTER
785#define MICROPY_ERROR_PRINTER (&mp_plat_print)
786#endif
787
Damien George0c36da02014-03-08 15:24:39 +0000788// Float and complex implementation
789#define MICROPY_FLOAT_IMPL_NONE (0)
790#define MICROPY_FLOAT_IMPL_FLOAT (1)
791#define MICROPY_FLOAT_IMPL_DOUBLE (2)
792
793#ifndef MICROPY_FLOAT_IMPL
794#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
795#endif
796
797#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
Damien Georgefb510b32014-06-01 13:32:54 +0100798#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100799#define MICROPY_FLOAT_CONST(x) x##F
Damien George0c36da02014-03-08 15:24:39 +0000800#define MICROPY_FLOAT_C_FUN(fun) fun##f
801typedef float mp_float_t;
802#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
Damien Georgefb510b32014-06-01 13:32:54 +0100803#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100804#define MICROPY_FLOAT_CONST(x) x
Damien George0c36da02014-03-08 15:24:39 +0000805#define MICROPY_FLOAT_C_FUN(fun) fun
806typedef double mp_float_t;
807#else
Damien Georgefb510b32014-06-01 13:32:54 +0100808#define MICROPY_PY_BUILTINS_FLOAT (0)
Damien George136f6752014-01-07 14:54:15 +0000809#endif
810
Paul Sokolovsky3b6f7b92014-06-20 01:48:35 +0300811#ifndef MICROPY_PY_BUILTINS_COMPLEX
812#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
813#endif
814
Damien Georgea73501b2017-04-06 17:27:33 +1000815// Whether to provide a high-quality hash for float and complex numbers.
816// Otherwise the default is a very simple but correct hashing function.
817#ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
Jim Mussared3e5b1be2022-08-16 01:41:03 +1000818#define MICROPY_FLOAT_HIGH_QUALITY_HASH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien Georgea73501b2017-04-06 17:27:33 +1000819#endif
820
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200821// Enable features which improve CPython compatibility
822// but may lead to more code size/memory usage.
823// TODO: Originally intended as generic category to not
824// add bunch of once-off options. May need refactoring later
825#ifndef MICROPY_CPYTHON_COMPAT
Jim Mussared01374d92021-08-14 01:43:15 +1000826#define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200827#endif
828
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300829// Perform full checks as done by CPython. Disabling this
830// may produce incorrect results, if incorrect data is fed,
831// but should not lead to MicroPython crashes or similar
832// grave issues (in other words, only user app should be,
833// affected, not system).
834#ifndef MICROPY_FULL_CHECKS
Jim Mussared01374d92021-08-14 01:43:15 +1000835#define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300836#endif
837
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300838// Whether POSIX-semantics non-blocking streams are supported
839#ifndef MICROPY_STREAMS_NON_BLOCK
Jim Mussared0e236ee2021-09-15 23:18:23 +1000840#define MICROPY_STREAMS_NON_BLOCK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300841#endif
842
Paul Sokolovsky61e77a42016-07-30 20:05:56 +0300843// Whether to provide stream functions with POSIX-like signatures
844// (useful for porting existing libraries to MicroPython).
845#ifndef MICROPY_STREAMS_POSIX_API
846#define MICROPY_STREAMS_POSIX_API (0)
847#endif
848
Jim Mussared13c817e2023-06-05 15:52:57 +1000849// Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed
850// attribute lookups to a custom handler function.
Damien George3356b5e2021-07-27 00:38:21 +1000851#ifndef MICROPY_MODULE_ATTR_DELEGATION
Jim Mussared7d2ee8a2023-06-05 22:38:36 +1000852#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 +1000853#endif
854
Jim Mussared6a8114e2023-05-12 17:07:24 +1000855// Whether to call __init__ when importing builtin modules for the first time.
856// Modules using this need to handle the possibility that __init__ might be
857// called multiple times.
Damien George3c9c3682015-09-15 14:56:13 +0100858#ifndef MICROPY_MODULE_BUILTIN_INIT
Jim Mussared0e236ee2021-09-15 23:18:23 +1000859#define MICROPY_MODULE_BUILTIN_INIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3c9c3682015-09-15 14:56:13 +0100860#endif
861
Jim Mussareded90f302023-05-10 13:22:54 +1000862// Whether to allow built-in modules to have sub-packages (by making the
863// sub-package a member of their locals dict). Sub-packages should not be
864// registered with MP_REGISTER_MODULE, instead they should be added as
865// members of the parent's globals dict. To match CPython behavior,
866// their __name__ should be "foo.bar"(i.e. QSTR_foo_dot_bar) which will
867// require an entry in qstrdefs, although it does also work to just call
868// it "bar". Also, because subpackages can be accessed without being
869// imported (e.g. as foo.bar after `import foo`), they should not
870// have __init__ methods. Instead, the top-level package's __init__ should
871// initialise all sub-packages.
872#ifndef MICROPY_MODULE_BUILTIN_SUBPACKAGES
873#define MICROPY_MODULE_BUILTIN_SUBPACKAGES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
874#endif
875
Paul m. p. P454cca62018-10-22 18:34:29 +0200876// Whether to support module-level __getattr__ (see PEP 562)
877#ifndef MICROPY_MODULE_GETATTR
Jim Mussared01374d92021-08-14 01:43:15 +1000878#define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul m. p. P454cca62018-10-22 18:34:29 +0200879#endif
880
Jim Mussareda7fa18c2020-02-26 15:24:09 +1100881// Whether to enable importing foo.py with __name__ set to '__main__'
882// Used by the unix port for the -m flag.
883#ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT
884#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0)
885#endif
886
Damien George0a2e9652016-01-31 22:24:16 +0000887// Whether frozen modules are supported in the form of strings
888#ifndef MICROPY_MODULE_FROZEN_STR
889#define MICROPY_MODULE_FROZEN_STR (0)
890#endif
891
892// Whether frozen modules are supported in the form of .mpy files
893#ifndef MICROPY_MODULE_FROZEN_MPY
894#define MICROPY_MODULE_FROZEN_MPY (0)
895#endif
896
897// Convenience macro for whether frozen modules are supported
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200898#ifndef MICROPY_MODULE_FROZEN
Damien George0a2e9652016-01-31 22:24:16 +0000899#define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200900#endif
901
Damien George78d702c2014-12-09 16:19:48 +0000902// Whether you can override builtins in the builtins module
903#ifndef MICROPY_CAN_OVERRIDE_BUILTINS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000904#define MICROPY_CAN_OVERRIDE_BUILTINS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George78d702c2014-12-09 16:19:48 +0000905#endif
906
Damien George06593fb2015-06-19 12:49:10 +0000907// Whether to check that the "self" argument of a builtin method has the
908// correct type. Such an explicit check is only needed if a builtin
909// method escapes to Python land without a first argument, eg
910// list.append([], 1). Without this check such calls will have undefined
911// behaviour (usually segfault) if the first argument is the wrong type.
912#ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
Jim Mussared01374d92021-08-14 01:43:15 +1000913#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George06593fb2015-06-19 12:49:10 +0000914#endif
915
Damien George3f56fd62016-05-10 10:54:06 +0100916// Whether to use internally defined errno's (otherwise system provided ones)
917#ifndef MICROPY_USE_INTERNAL_ERRNO
918#define MICROPY_USE_INTERNAL_ERRNO (0)
919#endif
920
Delio Brignolie2ac8bb2016-08-21 11:33:37 +0200921// Whether to use internally defined *printf() functions (otherwise external ones)
922#ifndef MICROPY_USE_INTERNAL_PRINTF
923#define MICROPY_USE_INTERNAL_PRINTF (1)
924#endif
925
Damien George78dc2db2023-03-09 13:56:23 +1100926// The mp_print_t printer used for printf output when MICROPY_USE_INTERNAL_PRINTF is enabled
927#ifndef MICROPY_INTERNAL_PRINTF_PRINTER
928#define MICROPY_INTERNAL_PRINTF_PRINTER (&mp_plat_print)
929#endif
930
Damien Georged54208a2022-12-16 17:31:21 +1100931// Whether to support mp_sched_vm_abort to asynchronously abort to the top level.
932#ifndef MICROPY_ENABLE_VM_ABORT
933#define MICROPY_ENABLE_VM_ABORT (0)
934#endif
935
Damien George6e74d242017-02-16 18:05:06 +1100936// Support for internal scheduler
937#ifndef MICROPY_ENABLE_SCHEDULER
Jim Mussared0e236ee2021-09-15 23:18:23 +1000938#define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George6e74d242017-02-16 18:05:06 +1100939#endif
940
Damien George75506e42022-03-23 17:13:03 +1100941// Whether the scheduler supports scheduling static nodes with C callbacks
942#ifndef MICROPY_SCHEDULER_STATIC_NODES
943#define MICROPY_SCHEDULER_STATIC_NODES (0)
944#endif
945
Damien George6e74d242017-02-16 18:05:06 +1100946// Maximum number of entries in the scheduler
947#ifndef MICROPY_SCHEDULER_DEPTH
948#define MICROPY_SCHEDULER_DEPTH (4)
949#endif
950
Damien Georgedcb9ea72017-01-27 15:10:09 +1100951// Support for generic VFS sub-system
952#ifndef MICROPY_VFS
953#define MICROPY_VFS (0)
954#endif
955
Damien George8d82b0e2018-06-06 13:11:33 +1000956// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
Jim Mussared89a0fef2022-09-13 14:57:24 +1000957#ifndef MICROPY_VFS_POSIX
Damien George8d82b0e2018-06-06 13:11:33 +1000958#define MICROPY_VFS_POSIX (0)
959#endif
960
Damien Georgea8b9e712018-06-06 14:31:29 +1000961// Support for VFS FAT component, to mount a FAT filesystem within VFS
Jim Mussared89a0fef2022-09-13 14:57:24 +1000962#ifndef MICROPY_VFS_FAT
Damien Georgea8b9e712018-06-06 14:31:29 +1000963#define MICROPY_VFS_FAT (0)
964#endif
965
Jim Mussared89a0fef2022-09-13 14:57:24 +1000966// Support for VFS LittleFS v1 component, to mount a LFSv1 filesystem within VFS
967#ifndef MICROPY_VFS_LFS1
968#define MICROPY_VFS_LFS1 (0)
969#endif
970
971// Support for VFS LittleFS v2 component, to mount a LFSv2 filesystem within VFS
972#ifndef MICROPY_VFS_LFS2
973#define MICROPY_VFS_LFS2 (0)
974#endif
975
Damien Georgeee3fd462014-05-24 23:03:12 +0100976/*****************************************************************************/
977/* Fine control over Python builtins, classes, modules, etc */
978
Damien Georgeda154fd2017-04-01 23:52:24 +1100979// Whether to support multiple inheritance of Python classes. Multiple
980// inheritance makes some C functions inherently recursive, and adds a bit of
981// code overhead.
982#ifndef MICROPY_MULTIPLE_INHERITANCE
Jim Mussared01374d92021-08-14 01:43:15 +1000983#define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeda154fd2017-04-01 23:52:24 +1100984#endif
985
stijn3cc17c62015-02-14 18:44:31 +0100986// Whether to implement attributes on functions
987#ifndef MICROPY_PY_FUNCTION_ATTRS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000988#define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijn3cc17c62015-02-14 18:44:31 +0100989#endif
990
Damien George36c10522018-05-25 17:09:54 +1000991// Whether to support the descriptors __get__, __set__, __delete__
992// This costs some code size and makes load/store/delete of instance
993// attributes slower for the classes that use this feature
stijn28fa84b2015-02-14 18:43:54 +0100994#ifndef MICROPY_PY_DESCRIPTORS
Jim Mussared0e236ee2021-09-15 23:18:23 +1000995#define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijn28fa84b2015-02-14 18:43:54 +0100996#endif
997
dmazzella18e65692017-01-03 11:00:12 +0100998// Whether to support class __delattr__ and __setattr__ methods
Damien George36c10522018-05-25 17:09:54 +1000999// This costs some code size and makes store/delete of instance
1000// attributes slower for the classes that use this feature
dmazzella18e65692017-01-03 11:00:12 +01001001#ifndef MICROPY_PY_DELATTR_SETATTR
Jim Mussared0e236ee2021-09-15 23:18:23 +10001002#define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
dmazzella18e65692017-01-03 11:00:12 +01001003#endif
1004
pohmelie81ebba72016-01-27 23:23:11 +03001005// Support for async/await/async for/async with
1006#ifndef MICROPY_PY_ASYNC_AWAIT
Jim Mussared01374d92021-08-14 01:43:15 +10001007#define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
pohmelie81ebba72016-01-27 23:23:11 +03001008#endif
1009
Jim Mussared692d36d2021-08-13 01:44:08 +10001010// Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+)
1011#ifndef MICROPY_PY_FSTRINGS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001012#define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jim Mussared692d36d2021-08-13 01:44:08 +10001013#endif
1014
Damien George17839502020-06-16 21:42:44 +10001015// Support for assignment expressions with := (see PEP 572, Python 3.8+)
1016#ifndef MICROPY_PY_ASSIGN_EXPR
Jim Mussared01374d92021-08-14 01:43:15 +10001017#define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George17839502020-06-16 21:42:44 +10001018#endif
1019
Paul Sokolovsky63644012017-10-21 12:13:44 +03001020// Non-standard .pend_throw() method for generators, allowing for
1021// Future-like behavior with respect to exception handling: an
1022// exception set with .pend_throw() will activate on the next call
1023// to generator's .send() or .__next__(). (This is useful to implement
1024// async schedulers.)
1025#ifndef MICROPY_PY_GENERATOR_PEND_THROW
Jim Mussared01374d92021-08-14 01:43:15 +10001026#define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky63644012017-10-21 12:13:44 +03001027#endif
1028
Paul Sokolovskya1b442b2016-07-22 00:46:24 +03001029// Issue a warning when comparing str and bytes objects
Paul Sokolovsky707cae72016-07-22 00:34:34 +03001030#ifndef MICROPY_PY_STR_BYTES_CMP_WARN
1031#define MICROPY_PY_STR_BYTES_CMP_WARN (0)
1032#endif
1033
Jim Mussared28aaab92021-07-13 18:01:12 +10001034// Add bytes.hex and bytes.fromhex
1035#ifndef MICROPY_PY_BUILTINS_BYTES_HEX
1036#define MICROPY_PY_BUILTINS_BYTES_HEX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1037#endif
1038
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +03001039// Whether str object is proper unicode
1040#ifndef MICROPY_PY_BUILTINS_STR_UNICODE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001041#define MICROPY_PY_BUILTINS_STR_UNICODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George8546ce12014-06-28 10:29:22 +01001042#endif
Damien Georgeb3a50f02014-06-28 10:27:15 +01001043
tll68c28172017-06-24 08:38:32 +08001044// Whether to check for valid UTF-8 when converting bytes to str
1045#ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
1046#define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
1047#endif
1048
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +03001049// Whether str.center() method provided
1050#ifndef MICROPY_PY_BUILTINS_STR_CENTER
Jim Mussared0e236ee2021-09-15 23:18:23 +10001051#define MICROPY_PY_BUILTINS_STR_CENTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +03001052#endif
1053
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +03001054// Whether str.count() method provided
1055#ifndef MICROPY_PY_BUILTINS_STR_COUNT
Jim Mussared01374d92021-08-14 01:43:15 +10001056#define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +03001057#endif
1058
Paul Sokolovsky2da5d412018-08-15 15:17:41 +03001059// Whether str % (...) formatting operator provided
1060#ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
Jim Mussared01374d92021-08-14 01:43:15 +10001061#define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky2da5d412018-08-15 15:17:41 +03001062#endif
1063
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +03001064// Whether str.partition()/str.rpartition() method provided
1065#ifndef MICROPY_PY_BUILTINS_STR_PARTITION
Jim Mussared0e236ee2021-09-15 23:18:23 +10001066#define MICROPY_PY_BUILTINS_STR_PARTITION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +03001067#endif
1068
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +03001069// Whether str.splitlines() method provided
1070#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001071#define MICROPY_PY_BUILTINS_STR_SPLITLINES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +03001072#endif
1073
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001074// Whether to support bytearray object
1075#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
Jim Mussared01374d92021-08-14 01:43:15 +10001076#define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +03001077#endif
1078
Paul Sokolovskyfbb83352018-08-06 01:25:41 +03001079// Whether to support dict.fromkeys() class method
1080#ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
Jim Mussared01374d92021-08-14 01:43:15 +10001081#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskyfbb83352018-08-06 01:25:41 +03001082#endif
1083
Damien Georgedd4f4532014-10-23 13:34:35 +01001084// Whether to support memoryview object
1085#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
Jim Mussared0e236ee2021-09-15 23:18:23 +10001086#define MICROPY_PY_BUILTINS_MEMORYVIEW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgedd4f4532014-10-23 13:34:35 +01001087#endif
1088
stijn90fae912019-05-08 16:16:17 +02001089// Whether to support memoryview.itemsize attribute
1090#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001091#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn90fae912019-05-08 16:16:17 +02001092#endif
1093
Damien George3ebd4d02014-06-01 13:46:47 +01001094// Whether to support set object
1095#ifndef MICROPY_PY_BUILTINS_SET
Jim Mussared01374d92021-08-14 01:43:15 +10001096#define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George3ebd4d02014-06-01 13:46:47 +01001097#endif
1098
Damien Georgefb510b32014-06-01 13:32:54 +01001099// Whether to support slice subscript operators and slice object
1100#ifndef MICROPY_PY_BUILTINS_SLICE
Jim Mussared01374d92021-08-14 01:43:15 +10001101#define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001102#endif
1103
Tom Soulanilleaeb62f92015-09-11 14:31:32 -07001104// Whether to support slice attribute read access,
1105// i.e. slice.start, slice.stop, slice.step
1106#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001107#define MICROPY_PY_BUILTINS_SLICE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Tom Soulanilleaeb62f92015-09-11 14:31:32 -07001108#endif
1109
Nicko van Someren4c939552019-11-16 17:07:11 -07001110// Whether to support the .indices(len) method on slice objects
1111#ifndef MICROPY_PY_BUILTINS_SLICE_INDICES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001112#define MICROPY_PY_BUILTINS_SLICE_INDICES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Nicko van Someren4c939552019-11-16 17:07:11 -07001113#endif
1114
Damien Georgeee3fd462014-05-24 23:03:12 +01001115// Whether to support frozenset object
Damien Georgefb510b32014-06-01 13:32:54 +01001116#ifndef MICROPY_PY_BUILTINS_FROZENSET
Jim Mussared0e236ee2021-09-15 23:18:23 +10001117#define MICROPY_PY_BUILTINS_FROZENSET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001118#endif
1119
Damien Georgefb510b32014-06-01 13:32:54 +01001120// Whether to support property object
1121#ifndef MICROPY_PY_BUILTINS_PROPERTY
Jim Mussared01374d92021-08-14 01:43:15 +10001122#define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001123#endif
1124
Peter D. Grayb2a237d2015-03-06 14:48:14 -05001125// Whether to implement the start/stop/step attributes (readback) on
1126// the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
1127#ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
Jim Mussared01374d92021-08-14 01:43:15 +10001128#define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Peter D. Grayb2a237d2015-03-06 14:48:14 -05001129#endif
1130
Damien Georged77da832018-02-14 23:17:06 +11001131// Whether to support binary ops [only (in)equality is defined] between range
1132// objects. With this option disabled all range objects that are not exactly
1133// the same object will compare as not-equal. With it enabled the semantics
1134// match CPython and ranges are equal if they yield the same sequence of items.
1135#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001136#define MICROPY_PY_BUILTINS_RANGE_BINOP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien Georged77da832018-02-14 23:17:06 +11001137#endif
1138
stijn42863832019-01-03 15:19:42 +01001139// Support for callling next() with second argument
1140#ifndef MICROPY_PY_BUILTINS_NEXT2
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001141#define MICROPY_PY_BUILTINS_NEXT2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn42863832019-01-03 15:19:42 +01001142#endif
1143
Jan Klusacekb318ebf2018-01-09 22:47:35 +01001144// Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
1145#ifndef MICROPY_PY_BUILTINS_ROUND_INT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001146#define MICROPY_PY_BUILTINS_ROUND_INT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Jan Klusacekb318ebf2018-01-09 22:47:35 +01001147#endif
1148
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001149// Whether to support complete set of special methods for user
1150// classes, or only the most used ones. "Inplace" methods are
1151// controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
1152// "Reverse" methods are controlled by
1153// MICROPY_PY_REVERSE_SPECIAL_METHODS below.
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +02001154#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001155#define MICROPY_PY_ALL_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +02001156#endif
1157
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001158// Whether to support all inplace arithmetic operarion methods
1159// (__imul__, etc.)
1160#ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001161#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovsky0e80f342017-10-27 22:29:15 +03001162#endif
1163
1164// Whether to support reverse arithmetic operarion methods
1165// (__radd__, etc.). Additionally gated by
1166// MICROPY_PY_ALL_SPECIAL_METHODS.
Paul Sokolovskyeb84a832017-09-10 17:05:20 +03001167#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001168#define MICROPY_PY_REVERSE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyeb84a832017-09-10 17:05:20 +03001169#endif
1170
Damien Georgec9fc6202014-10-25 21:59:14 +01001171// Whether to support compile function
1172#ifndef MICROPY_PY_BUILTINS_COMPILE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001173#define MICROPY_PY_BUILTINS_COMPILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgec9fc6202014-10-25 21:59:14 +01001174#endif
1175
Paul Sokolovskye2d44e32015-04-06 23:50:37 +03001176// Whether to support enumerate function(type)
1177#ifndef MICROPY_PY_BUILTINS_ENUMERATE
Jim Mussared01374d92021-08-14 01:43:15 +10001178#define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskye2d44e32015-04-06 23:50:37 +03001179#endif
1180
Damien Georgedd5353a2015-12-18 12:35:44 +00001181// Whether to support eval and exec functions
1182// By default they are supported if the compiler is enabled
1183#ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
1184#define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
1185#endif
1186
Damien George2a3e2b92014-12-19 13:36:17 +00001187// Whether to support the Python 2 execfile function
1188#ifndef MICROPY_PY_BUILTINS_EXECFILE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001189#define MICROPY_PY_BUILTINS_EXECFILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George2a3e2b92014-12-19 13:36:17 +00001190#endif
1191
Paul Sokolovsky22ff3972015-08-20 01:01:56 +03001192// Whether to support filter function(type)
1193#ifndef MICROPY_PY_BUILTINS_FILTER
Jim Mussared01374d92021-08-14 01:43:15 +10001194#define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky22ff3972015-08-20 01:01:56 +03001195#endif
1196
Paul Sokolovsky282ca092015-04-07 00:16:51 +03001197// Whether to support reversed function(type)
1198#ifndef MICROPY_PY_BUILTINS_REVERSED
Jim Mussared01374d92021-08-14 01:43:15 +10001199#define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovsky282ca092015-04-07 00:16:51 +03001200#endif
1201
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +03001202// Whether to define "NotImplemented" special constant
1203#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
Jim Mussared0e236ee2021-09-15 23:18:23 +10001204#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +03001205#endif
1206
Damien Georgebc763022017-06-01 15:32:23 +10001207// Whether to provide the built-in input() function. The implementation of this
Damien George136369d2021-07-09 14:19:15 +10001208// uses shared/readline, so can only be enabled if the port uses this readline.
Damien Georgebc763022017-06-01 15:32:23 +10001209#ifndef MICROPY_PY_BUILTINS_INPUT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001210#define MICROPY_PY_BUILTINS_INPUT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgebc763022017-06-01 15:32:23 +10001211#endif
1212
pohmelie354e6882015-12-07 15:35:48 +03001213// Whether to support min/max functions
1214#ifndef MICROPY_PY_BUILTINS_MIN_MAX
Jim Mussared01374d92021-08-14 01:43:15 +10001215#define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
pohmelie354e6882015-12-07 15:35:48 +03001216#endif
1217
Damien Georgea19b5a02017-02-03 12:35:48 +11001218// Support for calls to pow() with 3 integer arguments
1219#ifndef MICROPY_PY_BUILTINS_POW3
Jim Mussared0e236ee2021-09-15 23:18:23 +10001220#define MICROPY_PY_BUILTINS_POW3 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgea19b5a02017-02-03 12:35:48 +11001221#endif
1222
Damien George9f04dfb2017-01-21 23:17:51 +11001223// Whether to provide the help function
1224#ifndef MICROPY_PY_BUILTINS_HELP
Jim Mussared0e236ee2021-09-15 23:18:23 +10001225#define MICROPY_PY_BUILTINS_HELP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George9f04dfb2017-01-21 23:17:51 +11001226#endif
1227
1228// Use this to configure the help text shown for help(). It should be a
1229// variable with the type "const char*". A sensible default is provided.
1230#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
1231#define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
1232#endif
1233
Damien Georgef5172af2017-01-22 12:12:54 +11001234// Add the ability to list the available modules when executing help('modules')
1235#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001236#define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgef5172af2017-01-22 12:12:54 +11001237#endif
1238
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001239// Whether to set __file__ for imported modules
1240#ifndef MICROPY_PY___FILE__
Jim Mussared01374d92021-08-14 01:43:15 +10001241#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001242#endif
1243
Damien George89deec02015-01-09 20:12:54 +00001244// Whether to provide mem-info related functions in micropython module
1245#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
Jim Mussared0e236ee2021-09-15 23:18:23 +10001246#define MICROPY_PY_MICROPYTHON_MEM_INFO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George89deec02015-01-09 20:12:54 +00001247#endif
1248
Damien George7e2a4882018-02-20 18:30:22 +11001249// Whether to provide "micropython.stack_use" function
1250#ifndef MICROPY_PY_MICROPYTHON_STACK_USE
1251#define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
1252#endif
1253
Andrew Leech86bfabe2019-06-28 16:35:51 +10001254// Whether to provide the "micropython.heap_locked" function
1255#ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001256#define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Andrew Leech86bfabe2019-06-28 16:35:51 +10001257#endif
1258
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001259// Whether to provide "array" module. Note that large chunk of the
1260// underlying code is shared with "bytearray" builtin type, so to
1261// get real savings, it should be disabled too.
1262#ifndef MICROPY_PY_ARRAY
Jim Mussared01374d92021-08-14 01:43:15 +10001263#define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001264#endif
1265
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001266// Whether to support slice assignments for array (and bytearray).
1267// This is rarely used, but adds ~0.5K of code.
1268#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
Jim Mussared0e236ee2021-09-15 23:18:23 +10001269#define MICROPY_PY_ARRAY_SLICE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001270#endif
1271
Damien George5aa311d2015-04-21 14:14:24 +00001272// Whether to support attrtuple type (MicroPython extension)
1273// It provides space-efficient tuples with attribute access
1274#ifndef MICROPY_PY_ATTRTUPLE
Jim Mussared01374d92021-08-14 01:43:15 +10001275#define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien George5aa311d2015-04-21 14:14:24 +00001276#endif
1277
Damien Georgeee3fd462014-05-24 23:03:12 +01001278// Whether to provide "collections" module
1279#ifndef MICROPY_PY_COLLECTIONS
Jim Mussared01374d92021-08-14 01:43:15 +10001280#define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001281#endif
1282
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001283// Whether to provide "collections.deque" type
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001284#ifndef MICROPY_PY_COLLECTIONS_DEQUE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001285#define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001286#endif
1287
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001288// Whether to provide "collections.OrderedDict" type
1289#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
Jim Mussared0e236ee2021-09-15 23:18:23 +10001290#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001291#endif
1292
stijn79ed58f2017-11-06 12:21:53 +01001293// Whether to provide the _asdict function for namedtuple
1294#ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001295#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
stijn79ed58f2017-11-06 12:21:53 +01001296#endif
1297
Damien Georgeee3fd462014-05-24 23:03:12 +01001298// Whether to provide "math" module
1299#ifndef MICROPY_PY_MATH
Jim Mussared01374d92021-08-14 01:43:15 +10001300#define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001301#endif
1302
stijndd696722019-11-20 13:38:33 +01001303// Whether to provide all math module constants (Python 3.5+), or just pi and e.
1304#ifndef MICROPY_PY_MATH_CONSTANTS
1305#define MICROPY_PY_MATH_CONSTANTS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1306#endif
1307
Damien George5cbeace2015-02-22 14:48:18 +00001308// Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
1309#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Jim Mussared0e236ee2021-09-15 23:18:23 +10001310#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George5cbeace2015-02-22 14:48:18 +00001311#endif
1312
Christopher Swenson8c656752018-08-27 10:32:21 +10001313// Whether to provide math.factorial function
1314#ifndef MICROPY_PY_MATH_FACTORIAL
Jim Mussared0e236ee2021-09-15 23:18:23 +10001315#define MICROPY_PY_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Christopher Swenson8c656752018-08-27 10:32:21 +10001316#endif
1317
stijnaf5c9982019-07-02 10:28:44 +02001318// Whether to provide math.isclose function
1319#ifndef MICROPY_PY_MATH_ISCLOSE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001320#define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
stijnaf5c9982019-07-02 10:28:44 +02001321#endif
1322
stijn81db22f2020-05-17 12:29:25 +02001323// Whether to provide fix for atan2 Inf handling.
1324#ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN
1325#define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0)
1326#endif
1327
1328// Whether to provide fix for fmod Inf handling.
1329#ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN
1330#define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0)
1331#endif
1332
1333// Whether to provide fix for modf negative zero handling.
1334#ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO
1335#define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0)
1336#endif
1337
stijn2e54d9d2020-09-08 15:22:34 +02001338// Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN.
1339#ifndef MICROPY_PY_MATH_POW_FIX_NAN
1340#define MICROPY_PY_MATH_POW_FIX_NAN (0)
1341#endif
1342
Damien Georgeee3fd462014-05-24 23:03:12 +01001343// Whether to provide "cmath" module
1344#ifndef MICROPY_PY_CMATH
Jim Mussared0e236ee2021-09-15 23:18:23 +10001345#define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001346#endif
1347
Laurens Valkf724d902022-11-29 10:38:57 +01001348// Whether to provide "micropython" module
1349#ifndef MICROPY_PY_MICROPYTHON
Laurens Valk632d43e2022-11-29 12:31:09 +01001350#define MICROPY_PY_MICROPYTHON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Laurens Valkf724d902022-11-29 10:38:57 +01001351#endif
1352
Damien Georgeee3fd462014-05-24 23:03:12 +01001353// Whether to provide "gc" module
1354#ifndef MICROPY_PY_GC
Jim Mussared01374d92021-08-14 01:43:15 +10001355#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001356#endif
1357
Paul Sokolovsky755a55f2014-06-05 22:48:02 +03001358// Whether to return number of collected objects from gc.collect()
1359#ifndef MICROPY_PY_GC_COLLECT_RETVAL
1360#define MICROPY_PY_GC_COLLECT_RETVAL (0)
1361#endif
1362
Damien Georgeee3fd462014-05-24 23:03:12 +01001363// Whether to provide "io" module
1364#ifndef MICROPY_PY_IO
Jim Mussared01374d92021-08-14 01:43:15 +10001365#define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001366#endif
1367
Damien Georgeaf0932a2018-06-04 15:54:26 +10001368// Whether to provide "io.IOBase" class to support user streams
1369#ifndef MICROPY_PY_IO_IOBASE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001370#define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgeaf0932a2018-06-04 15:54:26 +10001371#endif
1372
Damien Georgeee3fd462014-05-24 23:03:12 +01001373// Whether to provide "io.BytesIO" class
1374#ifndef MICROPY_PY_IO_BYTESIO
1375#define MICROPY_PY_IO_BYTESIO (1)
1376#endif
1377
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001378// Whether to provide "io.BufferedWriter" class
1379#ifndef MICROPY_PY_IO_BUFFEREDWRITER
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001380#define MICROPY_PY_IO_BUFFEREDWRITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001381#endif
1382
Damien Georgeee3fd462014-05-24 23:03:12 +01001383// Whether to provide "struct" module
1384#ifndef MICROPY_PY_STRUCT
Jim Mussared01374d92021-08-14 01:43:15 +10001385#define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001386#endif
1387
1388// Whether to provide "sys" module
1389#ifndef MICROPY_PY_SYS
Jim Mussared01374d92021-08-14 01:43:15 +10001390#define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Damien Georgeee3fd462014-05-24 23:03:12 +01001391#endif
1392
Damien Georgede43b502021-12-17 23:35:32 +11001393// Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init()
1394#ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS
Damien Georgefe9ffff2021-12-19 08:55:40 +11001395#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS)
Damien Georgede43b502021-12-17 23:35:32 +11001396#endif
1397
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001398// Whether to provide "sys.maxsize" constant
1399#ifndef MICROPY_PY_SYS_MAXSIZE
Jim Mussared0e236ee2021-09-15 23:18:23 +10001400#define MICROPY_PY_SYS_MAXSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001401#endif
1402
Paul Sokolovsky1a1d11f2015-12-05 00:09:10 +02001403// Whether to provide "sys.modules" dictionary
1404#ifndef MICROPY_PY_SYS_MODULES
1405#define MICROPY_PY_SYS_MODULES (1)
1406#endif
1407
Paul Sokolovsky8b85d142015-04-25 03:17:41 +03001408// Whether to provide "sys.exc_info" function
1409// Avoid enabling this, this function is Python2 heritage
1410#ifndef MICROPY_PY_SYS_EXC_INFO
1411#define MICROPY_PY_SYS_EXC_INFO (0)
1412#endif
1413
Jim Mussared0e8dfaf2022-10-07 02:13:58 +11001414// Whether to provide "sys.executable", which is the absolute path to the
1415// micropython binary
1416// Intended for use on the "OS" ports (e.g. Unix)
1417#ifndef MICROPY_PY_SYS_EXECUTABLE
1418#define MICROPY_PY_SYS_EXECUTABLE (0)
1419#endif
1420
Damien Georgeee3fd462014-05-24 23:03:12 +01001421// Whether to provide "sys.exit" function
1422#ifndef MICROPY_PY_SYS_EXIT
Paul Sokolovsky403c9302016-12-14 21:10:22 +03001423#define MICROPY_PY_SYS_EXIT (1)
Damien Georgeee3fd462014-05-24 23:03:12 +01001424#endif
1425
Milan Rossacb364702019-08-05 15:06:41 +02001426// Whether to provide "sys.atexit" function (MicroPython extension)
1427#ifndef MICROPY_PY_SYS_ATEXIT
1428#define MICROPY_PY_SYS_ATEXIT (0)
1429#endif
1430
Jim Mussared5e509752023-06-05 16:52:29 +10001431// Whether to provide the "sys.path" attribute (which forces module delegation
1432// and mutable sys attributes to be enabled).
1433// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in
1434// mp_init to an empty list. Otherwise the port must initialise it using
1435// `mp_sys_path = mp_obj_new_list(...)`.
1436#ifndef MICROPY_PY_SYS_PATH
1437#define MICROPY_PY_SYS_PATH (1)
1438#endif
1439
1440// Whether to provide the "sys.argv" attribute.
1441// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in
1442// mp_init to an empty list. Otherwise the port must initialise it using
1443// `mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), ...);`
1444#ifndef MICROPY_PY_SYS_ARGV
1445#define MICROPY_PY_SYS_ARGV (1)
1446#endif
1447
Damien Georgeac229312021-07-27 00:43:35 +10001448// Whether to provide sys.{ps1,ps2} mutable attributes, to control REPL prompts
1449#ifndef MICROPY_PY_SYS_PS1_PS2
1450#define MICROPY_PY_SYS_PS1_PS2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1451#endif
1452
Milan Rossa310b3d12019-08-14 16:09:36 +02001453// Whether to provide "sys.settrace" function
1454#ifndef MICROPY_PY_SYS_SETTRACE
1455#define MICROPY_PY_SYS_SETTRACE (0)
1456#endif
1457
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001458// Whether to provide "sys.getsizeof" function
1459#ifndef MICROPY_PY_SYS_GETSIZEOF
Jim Mussared3e5b1be2022-08-16 01:41:03 +10001460#define MICROPY_PY_SYS_GETSIZEOF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001461#endif
1462
Damien Georgeee3fd462014-05-24 23:03:12 +01001463// Whether to provide sys.{stdin,stdout,stderr} objects
1464#ifndef MICROPY_PY_SYS_STDFILES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001465#define MICROPY_PY_SYS_STDFILES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3bb8bd82014-04-14 21:20:30 +01001466#endif
1467
Damien George3c4b5d42015-05-13 23:49:21 +01001468// Whether to provide sys.{stdin,stdout,stderr}.buffer object
1469// This is implemented per-port
1470#ifndef MICROPY_PY_SYS_STDIO_BUFFER
Jim Mussared0e236ee2021-09-15 23:18:23 +10001471#define MICROPY_PY_SYS_STDIO_BUFFER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George3c4b5d42015-05-13 23:49:21 +01001472#endif
Paul Sokolovsky82158472014-06-28 03:03:47 +03001473
Damien Georgecac939d2021-07-27 00:41:27 +10001474// Whether to provide sys.tracebacklimit mutable attribute
1475#ifndef MICROPY_PY_SYS_TRACEBACKLIMIT
1476#define MICROPY_PY_SYS_TRACEBACKLIMIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
1477#endif
1478
Damien Georgebc181552021-07-27 00:39:04 +10001479// Whether the sys module supports attribute delegation
1480// This is enabled automatically when needed by other features
1481#ifndef MICROPY_PY_SYS_ATTR_DELEGATION
Jim Mussared5e509752023-06-05 16:52:29 +10001482#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 +10001483#endif
1484
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001485// Whether to provide "errno" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001486#ifndef MICROPY_PY_ERRNO
1487#define MICROPY_PY_ERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George596a3fe2016-05-10 10:54:25 +01001488#endif
1489
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001490// Whether to provide the errno.errorcode dict
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001491#ifndef MICROPY_PY_ERRNO_ERRORCODE
1492#define MICROPY_PY_ERRNO_ERRORCODE (1)
Damien Georgef5634062017-02-22 12:53:42 +11001493#endif
1494
Damien Georgeef710282023-08-01 12:39:39 +10001495// Whether to provide "select" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001496#ifndef MICROPY_PY_SELECT
1497#define MICROPY_PY_SELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky8f5bc3f2016-11-20 23:49:45 +03001498#endif
1499
Damien Georgeef710282023-08-01 12:39:39 +10001500// Whether to enable POSIX optimisations in the "select" module (requires system poll)
1501#ifndef MICROPY_PY_SELECT_POSIX_OPTIMISATIONS
1502#define MICROPY_PY_SELECT_POSIX_OPTIMISATIONS (0)
1503#endif
1504
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001505// Whether to enable the select() function in the "select" module (baremetal
David Lechner87585042021-07-06 18:08:18 -05001506// implementation). This is present for compatibility but can be disabled to
1507// save space.
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001508#ifndef MICROPY_PY_SELECT_SELECT
1509#define MICROPY_PY_SELECT_SELECT (1)
David Lechner87585042021-07-06 18:08:18 -05001510#endif
1511
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001512// Whether to provide the "time" module
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001513#ifndef MICROPY_PY_TIME
1514#define MICROPY_PY_TIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES)
Damien George99555532023-03-10 12:16:00 +11001515#endif
1516
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001517// Whether to provide time.gmtime/localtime/mktime functions
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001518#ifndef MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME
1519#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (0)
Damien George99555532023-03-10 12:16:00 +11001520#endif
1521
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001522// Whether to provide time.time/time_ns functions
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001523#ifndef MICROPY_PY_TIME_TIME_TIME_NS
1524#define MICROPY_PY_TIME_TIME_TIME_NS (0)
Paul Sokolovskya9728442016-10-14 20:13:02 +03001525#endif
1526
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001527// Period of values returned by time.ticks_ms(), ticks_us(), ticks_cpu()
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001528// functions. Should be power of two. All functions above use the same
1529// period, so if underlying hardware/API has different periods, the
1530// minimum of them should be used. The value below is the maximum value
1531// this parameter can take (corresponding to 30 bit tick values on 32-bit
1532// system).
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001533#ifndef MICROPY_PY_TIME_TICKS_PERIOD
1534#define MICROPY_PY_TIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001535#endif
1536
Damien George27cc0772016-04-22 22:52:33 +00001537// Whether to provide "_thread" module
1538#ifndef MICROPY_PY_THREAD
1539#define MICROPY_PY_THREAD (0)
1540#endif
1541
Damien George4cec63a2016-05-26 10:42:53 +00001542// Whether to make the VM/runtime thread-safe using a global lock
1543// If not enabled then thread safety must be provided at the Python level
1544#ifndef MICROPY_PY_THREAD_GIL
1545#define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1546#endif
1547
Damien Georgef6c22a02017-02-06 10:50:43 +11001548// Number of VM jump-loops to do before releasing the GIL.
1549// Set this to 0 to disable the divisor.
1550#ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1551#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1552#endif
1553
Paul Sokolovsky82158472014-06-28 03:03:47 +03001554// Extended modules
Paul Sokolovsky510296f2014-08-08 22:51:40 +03001555
Jim Mussared2fbc08c2023-06-08 15:51:50 +10001556#ifndef MICROPY_PY_ASYNCIO
1557#define MICROPY_PY_ASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgebc009fd2020-03-12 16:46:20 +11001558#endif
1559
Paul Sokolovsky82158472014-06-28 03:03:47 +03001560#ifndef MICROPY_PY_UCTYPES
Jim Mussared0e236ee2021-09-15 23:18:23 +10001561#define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovsky82158472014-06-28 03:03:47 +03001562#endif
1563
Paul Sokolovsky38151f32018-10-06 23:34:58 +03001564// Whether to provide SHORT, INT, LONG, etc. types in addition to
1565// exact-bitness types like INT16, INT32, etc.
1566#ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
1567#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
1568#endif
1569
Jim Mussared35339242023-06-26 13:52:10 +10001570// Whether to provide "deflate" module (decompression-only by default)
1571#ifndef MICROPY_PY_DEFLATE
1572#define MICROPY_PY_DEFLATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1573#endif
1574
1575// Whether to provide compression support in "deflate" module
1576#ifndef MICROPY_PY_DEFLATE_COMPRESS
1577#define MICROPY_PY_DEFLATE_COMPRESS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES)
1578#endif
1579
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001580#ifndef MICROPY_PY_JSON
1581#define MICROPY_PY_JSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George612045f2014-09-17 22:56:34 +01001582#endif
1583
Peter Zügerffc854f2021-02-03 09:24:25 +01001584// Whether to support the "separators" argument to dump, dumps
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001585#ifndef MICROPY_PY_JSON_SEPARATORS
1586#define MICROPY_PY_JSON_SEPARATORS (1)
Peter Zügerffc854f2021-02-03 09:24:25 +01001587#endif
1588
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001589#ifndef MICROPY_PY_OS
1590#define MICROPY_PY_OS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George926b5542022-03-03 17:59:30 +11001591#endif
1592
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001593#ifndef MICROPY_PY_OS_STATVFS
1594#define MICROPY_PY_OS_STATVFS (MICROPY_PY_OS)
Damien George0149cd62022-03-09 12:45:06 +11001595#endif
1596
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001597#ifndef MICROPY_PY_RE
1598#define MICROPY_PY_RE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyc71e0452014-09-12 18:48:07 +03001599#endif
1600
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001601#ifndef MICROPY_PY_RE_DEBUG
1602#define MICROPY_PY_RE_DEBUG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George7d851a22019-08-17 23:50:19 +10001603#endif
1604
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001605#ifndef MICROPY_PY_RE_MATCH_GROUPS
1606#define MICROPY_PY_RE_MATCH_GROUPS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George1f864602018-05-24 13:07:42 +10001607#endif
1608
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001609#ifndef MICROPY_PY_RE_MATCH_SPAN_START_END
1610#define MICROPY_PY_RE_MATCH_SPAN_START_END (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING)
Damien George1e9b8712018-05-24 13:08:15 +10001611#endif
1612
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001613#ifndef MICROPY_PY_RE_SUB
1614#define MICROPY_PY_RE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgee30a5fc2018-05-24 13:08:51 +10001615#endif
1616
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001617#ifndef MICROPY_PY_HEAPQ
1618#define MICROPY_PY_HEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgef5d69792014-10-22 17:37:18 +00001619#endif
1620
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001621#ifndef MICROPY_PY_HASHLIB
1622#define MICROPY_PY_HASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyf4b19c82014-11-22 01:19:13 +02001623#endif
1624
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001625#ifndef MICROPY_PY_HASHLIB_MD5
1626#define MICROPY_PY_HASHLIB_MD5 (0)
Paul Sokolovsky5fe37302018-08-19 11:58:22 +03001627#endif
1628
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001629#ifndef MICROPY_PY_HASHLIB_SHA1
1630#define MICROPY_PY_HASHLIB_SHA1 (0)
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001631#endif
1632
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001633#ifndef MICROPY_PY_HASHLIB_SHA256
1634#define MICROPY_PY_HASHLIB_SHA256 (1)
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001635#endif
1636
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001637#ifndef MICROPY_PY_CRYPTOLIB
1638#define MICROPY_PY_CRYPTOLIB (0)
Paul Sokolovsky567bc2d2018-01-07 15:13:56 +02001639#endif
1640
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001641// Depends on MICROPY_PY_CRYPTOLIB
1642#ifndef MICROPY_PY_CRYPTOLIB_CTR
1643#define MICROPY_PY_CRYPTOLIB_CTR (0)
Yonatan Goldschmidtef984362019-04-23 12:39:05 +03001644#endif
1645
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001646#ifndef MICROPY_PY_CRYPTOLIB_CONSTS
1647#define MICROPY_PY_CRYPTOLIB_CONSTS (0)
Yonatan Goldschmidt473fe452018-06-15 17:07:47 +03001648#endif
1649
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001650#ifndef MICROPY_PY_BINASCII
1651#define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskybfdc2052014-11-29 06:19:30 +02001652#endif
1653
Jim Mussared35339242023-06-26 13:52:10 +10001654// Depends on MICROPY_PY_DEFLATE
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001655#ifndef MICROPY_PY_BINASCII_CRC32
1656#define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskyc4283672016-08-24 18:28:43 +03001657#endif
1658
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001659#ifndef MICROPY_PY_RANDOM
1660#define MICROPY_PY_RANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Paul Sokolovskya58a91e2016-01-17 12:10:28 +02001661#endif
1662
Damien Georgea53af6c2016-01-22 16:19:32 +00001663// Whether to include: randrange, randint, choice, random, uniform
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001664#ifndef MICROPY_PY_RANDOM_EXTRA_FUNCS
1665#define MICROPY_PY_RANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien Georgea53af6c2016-01-22 16:19:32 +00001666#endif
1667
Paul Sokolovsky01162182015-05-03 20:25:40 +03001668#ifndef MICROPY_PY_MACHINE
1669#define MICROPY_PY_MACHINE (0)
1670#endif
1671
Jim Mussared870000f2021-08-10 01:09:04 +10001672// Whether to include: bitstream
1673#ifndef MICROPY_PY_MACHINE_BITSTREAM
1674#define MICROPY_PY_MACHINE_BITSTREAM (0)
1675#endif
1676
Damien George33168082016-05-31 14:25:19 +01001677// Whether to include: time_pulse_us
1678#ifndef MICROPY_PY_MACHINE_PULSE
1679#define MICROPY_PY_MACHINE_PULSE (0)
1680#endif
1681
Damien Georged0837122016-04-12 13:42:35 +01001682#ifndef MICROPY_PY_MACHINE_I2C
1683#define MICROPY_PY_MACHINE_I2C (0)
1684#endif
1685
Damien George4a1ae992022-06-01 11:57:20 +10001686// Whether the low-level I2C transfer function supports a separate write as the first transfer
1687#ifndef MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1
1688#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (0)
1689#endif
1690
Damien George122d9012021-09-02 12:37:00 +10001691// Whether to provide the "machine.SoftI2C" class
1692#ifndef MICROPY_PY_MACHINE_SOFTI2C
1693#define MICROPY_PY_MACHINE_SOFTI2C (0)
1694#endif
1695
Damien George0823c1b2016-09-01 15:07:20 +10001696#ifndef MICROPY_PY_MACHINE_SPI
1697#define MICROPY_PY_MACHINE_SPI (0)
1698#endif
1699
Damien Georgeafe06342021-09-02 12:39:28 +10001700// Whether to provide the "machine.SoftSPI" class
1701#ifndef MICROPY_PY_MACHINE_SOFTSPI
1702#define MICROPY_PY_MACHINE_SOFTSPI (0)
1703#endif
1704
Damien Georgecd35b8a2022-10-27 14:32:43 +11001705// Whether to provide the "machine.Timer" class
1706#ifndef MICROPY_PY_MACHINE_TIMER
1707#define MICROPY_PY_MACHINE_TIMER (0)
1708#endif
1709
Damien Georgeaab005c2022-04-04 23:07:35 +10001710// The default backlog value for socket.listen(backlog)
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001711#ifndef MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT
1712#define MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT (2)
Damien Georgeaab005c2022-04-04 23:07:35 +10001713#endif
1714
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001715#ifndef MICROPY_PY_SSL
1716#define MICROPY_PY_SSL (0)
Damien George772058a2022-01-07 23:59:17 +11001717#endif
1718
Jim Mussared7f5d5c72022-08-18 14:49:57 +10001719// Whether to add finaliser code to ssl objects
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001720#ifndef MICROPY_PY_SSL_FINALISER
1721#define MICROPY_PY_SSL_FINALISER (0)
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001722#endif
1723
Jim Mussaredf5f9edf2022-08-18 15:01:26 +10001724#ifndef MICROPY_PY_WEBSOCKET
1725#define MICROPY_PY_WEBSOCKET (0)
Paul Sokolovsky24342dd2016-03-24 19:14:12 +02001726#endif
1727
Damien George53ad6812016-04-08 11:08:37 +01001728#ifndef MICROPY_PY_FRAMEBUF
Jim Mussared0e236ee2021-09-15 23:18:23 +10001729#define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
Damien George53ad6812016-04-08 11:08:37 +01001730#endif
1731
Paul Sokolovsky737bd9c2016-07-02 14:57:42 +03001732#ifndef MICROPY_PY_BTREE
1733#define MICROPY_PY_BTREE (0)
1734#endif
1735
Damien Georged41f6dd2021-09-02 12:39:50 +10001736// Whether to provide the low-level "_onewire" module
1737#ifndef MICROPY_PY_ONEWIRE
1738#define MICROPY_PY_ONEWIRE (0)
1739#endif
1740
Jim Mussared975a6872023-07-21 13:39:36 +10001741// Whether to provide the "platform" module
1742#ifndef MICROPY_PY_PLATFORM
1743#define MICROPY_PY_PLATFORM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1744#endif
1745
Damien George58ebde42014-05-21 20:32:59 +01001746/*****************************************************************************/
1747/* Hooks for a port to add builtins */
1748
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001749// Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001750#ifndef MICROPY_PORT_BUILTINS
1751#define MICROPY_PORT_BUILTINS
Paul Sokolovsky910843e2014-02-14 12:02:34 +02001752#endif
Damien Georgecaac5422014-03-25 14:18:18 +00001753
stijn22cf0942022-01-05 16:04:58 +01001754// Additional builtin function definitions for extension by command-line, boards or variants.
1755// See modbuiltins.c:mp_module_builtins_globals_table for format.
1756#ifndef MICROPY_PORT_EXTRA_BUILTINS
1757#define MICROPY_PORT_EXTRA_BUILTINS
1758#endif
1759
Damien George57e99eb2014-04-10 22:42:11 +01001760// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
Damien George58ebde42014-05-21 20:32:59 +01001761#ifndef MICROPY_PORT_CONSTANTS
1762#define MICROPY_PORT_CONSTANTS
Damien George57e99eb2014-04-10 22:42:11 +01001763#endif
1764
Damien George136f6752014-01-07 14:54:15 +00001765/*****************************************************************************/
Damien George8fb5c8f2020-02-07 12:07:50 +11001766/* Hooks for a port to wrap functions with attributes */
1767
Damien George84125682021-09-24 12:49:51 +10001768#ifndef MICROPY_WRAP_MP_BINARY_OP
1769#define MICROPY_WRAP_MP_BINARY_OP(f) f
1770#endif
1771
1772#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE
1773#define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f
1774#endif
1775
1776#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL
1777#define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f
1778#endif
1779
1780#ifndef MICROPY_WRAP_MP_LOAD_NAME
1781#define MICROPY_WRAP_MP_LOAD_NAME(f) f
1782#endif
1783
1784#ifndef MICROPY_WRAP_MP_MAP_LOOKUP
1785#define MICROPY_WRAP_MP_MAP_LOOKUP(f) f
1786#endif
1787
1788#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE
1789#define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f
1790#endif
1791
Damien George7cbf8262021-04-28 10:52:19 +10001792#ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION
1793#define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f
1794#endif
1795
Damien Georgee9e9c762021-04-28 10:57:34 +10001796#ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT
1797#define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f
Damien George8fb5c8f2020-02-07 12:07:50 +11001798#endif
1799
Damien George544c3082020-04-23 16:18:14 +10001800#ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE
1801#define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f
1802#endif
1803
Damien Georged54208a2022-12-16 17:31:21 +11001804#ifndef MICROPY_WRAP_MP_SCHED_VM_ABORT
1805#define MICROPY_WRAP_MP_SCHED_VM_ABORT(f) f
1806#endif
1807
Damien George8fb5c8f2020-02-07 12:07:50 +11001808/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +00001809/* Miscellaneous settings */
1810
Damien George28631532015-02-08 13:42:00 +00001811// All uPy objects in ROM must be aligned on at least a 4 byte boundary
1812// so that the small-int/qstr/pointer distinction can be made. For machines
1813// that don't do this (eg 16-bit CPU), define the following macro to something
1814// like __attribute__((aligned(4))).
1815#ifndef MICROPY_OBJ_BASE_ALIGNMENT
1816#define MICROPY_OBJ_BASE_ALIGNMENT
1817#endif
1818
Damien George40047822022-04-21 16:30:23 +10001819// String used for the banner, and sys.version additional information
1820#ifndef MICROPY_BANNER_NAME_AND_VERSION
1821#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE
1822#endif
1823
Damien George402df832022-04-26 17:28:39 +10001824// String used for the second part of the banner, and sys.implementation._machine
1825#ifndef MICROPY_BANNER_MACHINE
1826#ifdef MICROPY_HW_BOARD_NAME
1827#define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME
1828#else
1829#define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version"
1830#endif
1831#endif
1832
Dave Hylands5b7fd202014-07-01 23:46:53 -07001833// On embedded platforms, these will typically enable/disable irqs.
1834#ifndef MICROPY_BEGIN_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001835#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001836#endif
1837#ifndef MICROPY_END_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001838#define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001839#endif
1840
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +02001841// Allow to override static modifier for global objects, e.g. to use with
1842// object code analysis tools which don't support static symbols.
1843#ifndef STATIC
1844#define STATIC static
1845#endif
1846
Damien Georgead4656b2021-02-04 16:39:09 +11001847// Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
1848#ifndef MP_BYTES_PER_OBJ_WORD
1849#define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
Damien George4c307bf2017-04-01 11:39:38 +11001850#endif
1851
Damien George7e956fa2021-02-04 15:32:59 +11001852// Number of bits in a byte
1853#ifndef MP_BITS_PER_BYTE
1854#define MP_BITS_PER_BYTE (8)
Yonatan Goldschmidt1c849d62019-12-01 01:10:12 +02001855#endif
Damien George40f3c022014-07-03 13:25:24 +01001856// mp_int_t value with most significant bit set
Damien Georgec8911902021-02-04 16:39:46 +11001857#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 +02001858
Damien Georgea9bcd512014-10-06 13:44:59 +00001859// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1860// defined and that they are the opposite of each other.
1861#if defined(MP_ENDIANNESS_LITTLE)
1862#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1863#elif defined(MP_ENDIANNESS_BIG)
1864#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1865#else
Damien George69661f32020-02-27 15:36:53 +11001866// Endianness not defined by port so try to autodetect it.
Damien Georgea9bcd512014-10-06 13:44:59 +00001867 #if defined(__BYTE_ORDER__)
1868 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1869 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001870 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Damien Georgea9bcd512014-10-06 13:44:59 +00001871 #define MP_ENDIANNESS_LITTLE (0)
1872 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001873 #else
Damien George4e4772b2015-05-30 23:12:30 +01001874 #include <endian.h>
1875 #if defined(__BYTE_ORDER)
1876 #if __BYTE_ORDER == __LITTLE_ENDIAN
1877 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001878 #elif __BYTE_ORDER == __BIG_ENDIAN
Damien George4e4772b2015-05-30 23:12:30 +01001879 #define MP_ENDIANNESS_LITTLE (0)
1880 #endif
Damien George4e4772b2015-05-30 23:12:30 +01001881 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001882 #endif
Damien George96303762018-05-07 13:36:52 +10001883 #ifndef MP_ENDIANNESS_LITTLE
1884 #error endianness not defined and cannot detect it
1885 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001886 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
Andrew Schellercc837372014-04-14 02:39:56 +01001887#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +03001888
Damien George3c658a42014-08-24 16:28:17 +01001889// Make a pointer to RAM callable (eg set lower bit for Thumb code)
1890// (This scheme won't work if we want to mix Thumb and normal ARM code.)
1891#ifndef MICROPY_MAKE_POINTER_CALLABLE
1892#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
1893#endif
1894
Damien George7f9d1d62015-04-09 23:56:15 +01001895// If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
Damien George2127e9a2015-01-14 00:11:09 +00001896// must be somehow reachable for marking by the GC, since the native code
1897// generators store pointers to GC managed memory in the code.
Fabian Vogtb7235b82014-09-03 16:59:33 +02001898#ifndef MP_PLAT_ALLOC_EXEC
Damien George4dea9222015-04-09 15:29:54 +00001899#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 +02001900#endif
1901
1902#ifndef MP_PLAT_FREE_EXEC
1903#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
1904#endif
1905
Angus Gratton519c24d2023-08-02 16:49:44 +10001906// Allocating new heap area at runtime requires port to be able to allocate from system heap
1907#if MICROPY_GC_SPLIT_HEAP_AUTO
1908#ifndef MP_PLAT_ALLOC_HEAP
1909#define MP_PLAT_ALLOC_HEAP(size) malloc(size)
1910#endif
1911#ifndef MP_PLAT_FREE_HEAP
1912#define MP_PLAT_FREE_HEAP(ptr) free(ptr)
1913#endif
1914#endif
1915
Damien George7f9d1d62015-04-09 23:56:15 +01001916// This macro is used to do all output (except when MICROPY_PY_IO is defined)
1917#ifndef MP_PLAT_PRINT_STRN
Damien George4300c7d2015-10-15 00:05:55 +01001918#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
Damien George7f9d1d62015-04-09 23:56:15 +01001919#endif
1920
Paul Sokolovsky722e5622014-09-06 19:17:23 +03001921#ifndef MP_SSIZE_MAX
1922#define MP_SSIZE_MAX SSIZE_MAX
1923#endif
1924
Damien George40f3c022014-07-03 13:25:24 +01001925// printf format spec to use for mp_int_t and friends
Damien George136f6752014-01-07 14:54:15 +00001926#ifndef INT_FMT
stijn3baf6b52015-11-20 15:59:06 +01001927#if defined(__LP64__)
Damien George40f3c022014-07-03 13:25:24 +01001928// Archs where mp_int_t == long, long != int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001929#define UINT_FMT "%lu"
1930#define INT_FMT "%ld"
stijn3baf6b52015-11-20 15:59:06 +01001931#elif defined(_WIN64)
stijn0a4eb4d2015-12-18 10:20:33 +01001932#define UINT_FMT "%llu"
1933#define INT_FMT "%lld"
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001934#else
Damien George40f3c022014-07-03 13:25:24 +01001935// Archs where mp_int_t == int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001936#define UINT_FMT "%u"
1937#define INT_FMT "%d"
1938#endif
stijn84fa3312020-04-16 09:13:57 +02001939#endif // INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +03001940
1941// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +02001942#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +03001943#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +02001944#endif
mux5c8db482014-06-21 17:24:55 +02001945
1946// Modifier for weak functions
1947#ifndef MP_WEAK
1948#define MP_WEAK __attribute__((weak))
1949#endif
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001950
Paul Sokolovsky0f5bf1a2016-06-15 23:52:00 +03001951// Modifier for functions which should be never inlined
1952#ifndef MP_NOINLINE
1953#define MP_NOINLINE __attribute__((noinline))
1954#endif
1955
Paul Sokolovsky1bc29112016-08-07 22:36:05 +03001956// Modifier for functions which should be always inlined
1957#ifndef MP_ALWAYSINLINE
1958#define MP_ALWAYSINLINE __attribute__((always_inline))
1959#endif
1960
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001961// Condition is likely to be true, to help branch prediction
1962#ifndef MP_LIKELY
1963#define MP_LIKELY(x) __builtin_expect((x), 1)
1964#endif
1965
1966// Condition is likely to be false, to help branch prediction
1967#ifndef MP_UNLIKELY
1968#define MP_UNLIKELY(x) __builtin_expect((x), 0)
1969#endif
Damien George9ddbe292014-12-29 01:02:19 +00001970
Damien George0c80cb32019-08-19 15:50:02 +10001971// To annotate that code is unreachable
1972#ifndef MP_UNREACHABLE
1973#if defined(__GNUC__)
1974#define MP_UNREACHABLE __builtin_unreachable();
1975#else
1976#define MP_UNREACHABLE for (;;);
1977#endif
1978#endif
1979
Emil Renner Berthingccd92332019-11-28 12:47:21 +01001980// Explicitly annotate switch case fall throughs
1981#if defined(__GNUC__) && __GNUC__ >= 7
1982#define MP_FALLTHROUGH __attribute__((fallthrough));
1983#else
1984#define MP_FALLTHROUGH
1985#endif
1986
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02001987#ifndef MP_HTOBE16
1988#if MP_ENDIANNESS_LITTLE
Damien Georgefeb25772020-03-20 21:47:07 +11001989#define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))
Damien George69661f32020-02-27 15:36:53 +11001990#define MP_BE16TOH(x) MP_HTOBE16(x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02001991#else
Damien George69661f32020-02-27 15:36:53 +11001992#define MP_HTOBE16(x) (x)
1993#define MP_BE16TOH(x) (x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02001994#endif
1995#endif
1996
1997#ifndef MP_HTOBE32
1998#if MP_ENDIANNESS_LITTLE
Damien Georgefeb25772020-03-20 21:47:07 +11001999#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 +11002000#define MP_BE32TOH(x) MP_HTOBE32(x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002001#else
Damien George69661f32020-02-27 15:36:53 +11002002#define MP_HTOBE32(x) (x)
2003#define MP_BE32TOH(x) (x)
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02002004#endif
2005#endif
2006
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002007// Warning categories are by default implemented as strings, though
2008// hook is left for a port to define them as something else.
2009#if MICROPY_WARNINGS_CATEGORY
Damien George69661f32020-02-27 15:36:53 +11002010#ifndef MP_WARN_CAT
2011#define MP_WARN_CAT(x) #x
2012#endif
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002013#else
Damien George69661f32020-02-27 15:36:53 +11002014#undef MP_WARN_CAT
2015#define MP_WARN_CAT(x) (NULL)
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03002016#endif
2017
Alexander Steffen299bc622017-06-29 23:14:58 +02002018#endif // MICROPY_INCLUDED_PY_MPCONFIG_H