blob: 2d857d8f6dbedd04de73c120d9b539f003b4428e [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 George3e25d612019-01-26 00:56:48 +110031#define MICROPY_VERSION_MINOR 10
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 \
37 | MICROPY_VERSION_MINOR << 8 \
38 | MICROPY_VERSION_MICRO)
39
40// String version
41#define MICROPY_VERSION_STRING \
42 MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \
43 MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \
44 MP_STRINGIFY(MICROPY_VERSION_MICRO)
45
Paul 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
59#ifdef MP_CONFIGFILE
60#include MP_CONFIGFILE
61#else
Damien George8340c482014-06-12 19:50:17 +010062#include <mpconfigport.h>
Paul Sokolovskyb1422de2014-10-29 04:08:49 +020063#endif
Paul Sokolovskyb372bfc2014-01-03 17:15:53 +020064
Damien George136f6752014-01-07 14:54:15 +000065// Any options not explicitly set in mpconfigport.h will get default
66// values below.
67
68/*****************************************************************************/
Damien George567184e2015-03-29 14:05:46 +010069/* Object representation */
70
Damien Georgec408ed92017-06-26 12:29:20 +100071// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +010072// - xxxx...xxx1 : a small int, bits 1 and above are the value
73// - xxxx...xx10 : a qstr, bits 2 and above are the value
74// - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
75#define MICROPY_OBJ_REPR_A (0)
76
Damien Georgec408ed92017-06-26 12:29:20 +100077// A MicroPython object is a machine word having the following form:
Damien George567184e2015-03-29 14:05:46 +010078// - xxxx...xx01 : a small int, bits 2 and above are the value
79// - xxxx...xx11 : a qstr, bits 2 and above are the value
80// - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
81#define MICROPY_OBJ_REPR_B (1)
82
Damien George8b8d1892015-11-06 23:25:10 +000083// A MicroPython object is a machine word having the following form (called R):
Damien George183edef2015-10-17 23:20:57 +010084// - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
Damien George8b8d1892015-11-06 23:25:10 +000085// - 01111111 1qqqqqqq qqqqqqqq qqqqq110 str with 20-bit qstr value
Damien George183edef2015-10-17 23:20:57 +010086// - s1111111 10000000 00000000 00000010 +/- inf
87// - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
88// - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
89// - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
Damien George8b8d1892015-11-06 23:25:10 +000090// Str and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
91// This makes strs easier to encode/decode as they have zeros in the top 9 bits.
Damien George183edef2015-10-17 23:20:57 +010092// This scheme only works with 32-bit word size and float enabled.
93#define MICROPY_OBJ_REPR_C (2)
94
Damien Georgeb8cfb0d2015-11-27 17:09:11 +000095// A MicroPython object is a 64-bit word having the following form (called R):
96// - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
97// - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
98// - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
Damien George2759bec2017-12-11 22:39:12 +110099// - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
Damien Georgeb8cfb0d2015-11-27 17:09:11 +0000100// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
101// - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
102// Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
103// This makes pointers have all zeros in the top 32 bits.
104// Small-ints and strs have 1 as LSB to make sure they don't look like pointers
105// to the garbage collector.
106#define MICROPY_OBJ_REPR_D (3)
107
Damien George567184e2015-03-29 14:05:46 +0100108#ifndef MICROPY_OBJ_REPR
109#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
110#endif
111
112/*****************************************************************************/
Damien George66e18f02014-05-05 13:19:03 +0100113/* Memory allocation policy */
114
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200115// Number of bytes in memory allocation/GC block. Any size allocated will be
116// rounded up to be multiples of this.
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200117#ifndef MICROPY_BYTES_PER_GC_BLOCK
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200118#define MICROPY_BYTES_PER_GC_BLOCK (4 * BYTES_PER_WORD)
Paul Sokolovskyb4eccfd2015-12-03 01:57:50 +0200119#endif
Paul Sokolovsky75feece2015-12-03 01:40:52 +0200120
Damien Georgefd40a9c2015-01-01 22:04:46 +0000121// Number of words allocated (in BSS) to the GC stack (minimum is 1)
122#ifndef MICROPY_ALLOC_GC_STACK_SIZE
123#define MICROPY_ALLOC_GC_STACK_SIZE (64)
124#endif
125
Ayke van Laethem31cf5282018-02-23 18:59:31 +0100126// The C-type to use for entries in the GC stack. By default it allows the
127// heap to be as large as the address space, but the bit-width of this type can
128// be reduced to save memory when the heap is small enough. The type must be
129// big enough to index all blocks in the heap, which is set by
130// heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK.
131#ifndef MICROPY_GC_STACK_ENTRY_TYPE
132#define MICROPY_GC_STACK_ENTRY_TYPE size_t
133#endif
134
Damien George5ffe1d82016-08-26 15:35:26 +1000135// Be conservative and always clear to zero newly (re)allocated memory in the GC.
136// This helps eliminate stray pointers that hold on to memory that's no longer
137// used. It decreases performance due to unnecessary memory clearing.
Colin Hogben828df542016-10-31 14:52:11 +0000138// A memory manager which always clears memory can set this to 0.
Damien George5ffe1d82016-08-26 15:35:26 +1000139// TODO Do analysis to understand why some memory is not properly cleared and
140// find a more efficient way to clear it.
141#ifndef MICROPY_GC_CONSERVATIVE_CLEAR
Colin Hogben828df542016-10-31 14:52:11 +0000142#define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
Damien George5ffe1d82016-08-26 15:35:26 +1000143#endif
144
Paul Sokolovsky93e353e2016-07-21 00:37:30 +0300145// Support automatic GC when reaching allocation threshold,
146// configurable by gc.threshold().
147#ifndef MICROPY_GC_ALLOC_THRESHOLD
148#define MICROPY_GC_ALLOC_THRESHOLD (1)
149#endif
150
Damien Georgeade9a052015-06-13 21:53:22 +0100151// Number of bytes to allocate initially when creating new chunks to store
152// interned string data. Smaller numbers lead to more chunks being needed
153// and more wastage at the end of the chunk. Larger numbers lead to wasted
154// space at the end when no more strings need interning.
155#ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
156#define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
157#endif
158
Damien Georgee1199ec2014-05-10 17:48:01 +0100159// Initial amount for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100160#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
161#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
Damien Georgee1199ec2014-05-10 17:48:01 +0100162#endif
163
164// Increment for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +0100165#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
166#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
Damien Georgee1199ec2014-05-10 17:48:01 +0100167#endif
168
Damien George66e18f02014-05-05 13:19:03 +0100169// Initial amount for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100170#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
171#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
Damien George66e18f02014-05-05 13:19:03 +0100172#endif
173
174// Increment for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +0100175#ifndef MICROPY_ALLOC_PARSE_RULE_INC
176#define MICROPY_ALLOC_PARSE_RULE_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100177#endif
178
179// Initial amount for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100180#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
181#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
Damien George66e18f02014-05-05 13:19:03 +0100182#endif
183
184// Increment for parse result stack
Damien George58ebde42014-05-21 20:32:59 +0100185#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
186#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
Damien George66e18f02014-05-05 13:19:03 +0100187#endif
188
Damien George5042bce2014-05-25 22:06:06 +0100189// Strings this length or less will be interned by the parser
190#ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
191#define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
192#endif
193
Damien George58e0f4a2015-09-23 10:50:43 +0100194// Number of bytes to allocate initially when creating new chunks to store
195// parse nodes. Small leads to fragmentation, large leads to excess use.
196#ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
197#define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
198#endif
199
Damien George66e18f02014-05-05 13:19:03 +0100200// Initial amount for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100201#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
202#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
Damien George66e18f02014-05-05 13:19:03 +0100203#endif
204
205// Increment for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +0100206#ifndef MICROPY_ALLOC_SCOPE_ID_INC
207#define MICROPY_ALLOC_SCOPE_ID_INC (6)
208#endif
209
210// Maximum length of a path in the filesystem
211// So we can allocate a buffer on the stack for path manipulation in import
212#ifndef MICROPY_ALLOC_PATH_MAX
213#define MICROPY_ALLOC_PATH_MAX (512)
Damien George66e18f02014-05-05 13:19:03 +0100214#endif
215
Paul Sokolovsky346aacf2014-11-05 00:27:15 +0200216// Initial size of module dict
217#ifndef MICROPY_MODULE_DICT_SIZE
218#define MICROPY_MODULE_DICT_SIZE (1)
219#endif
220
Damien Georged8914522015-02-27 09:54:12 +0000221// Whether realloc/free should be passed allocated memory region size
222// You must enable this if MICROPY_MEM_STATS is enabled
223#ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
224#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
225#endif
226
Damien George95836f82015-01-11 22:27:30 +0000227// Number of bytes used to store qstr length
228// Dictates hard limit on maximum Python identifier length, but 1 byte
229// (limit of 255 bytes in an identifier) should be enough for everyone
230#ifndef MICROPY_QSTR_BYTES_IN_LEN
231#define MICROPY_QSTR_BYTES_IN_LEN (1)
232#endif
233
Damien Georgec3bd9412015-07-20 11:03:13 +0000234// Number of bytes used to store qstr hash
235#ifndef MICROPY_QSTR_BYTES_IN_HASH
236#define MICROPY_QSTR_BYTES_IN_HASH (2)
237#endif
238
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200239// Avoid using C stack when making Python function calls. C stack still
240// may be used if there's no free heap.
Paul Sokolovsky20397572015-03-28 01:14:44 +0200241#ifndef MICROPY_STACKLESS
242#define MICROPY_STACKLESS (0)
243#endif
244
Paul Sokolovsky7f1c9812015-03-28 01:14:45 +0200245// Never use C stack when making Python function calls. This may break
246// testsuite as will subtly change which exception is thrown in case
247// of too deep recursion and other similar cases.
248#ifndef MICROPY_STACKLESS_STRICT
249#define MICROPY_STACKLESS_STRICT (0)
250#endif
251
Paul Sokolovskyf32020e2015-11-25 23:22:31 +0200252// Don't use alloca calls. As alloca() is not part of ANSI C, this
253// workaround option is provided for compilers lacking this de-facto
254// standard function. The way it works is allocating from heap, and
255// relying on garbage collection to free it eventually. This is of
256// course much less optimal than real alloca().
257#if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
258#undef alloca
259#define alloca(x) m_malloc(x)
260#endif
261
Damien George66e18f02014-05-05 13:19:03 +0100262/*****************************************************************************/
Damien Georgec408ed92017-06-26 12:29:20 +1000263/* MicroPython emitters */
Damien George136f6752014-01-07 14:54:15 +0000264
Damien Georged8c834c2015-11-02 21:55:42 +0000265// Whether to support loading of persistent code
266#ifndef MICROPY_PERSISTENT_CODE_LOAD
267#define MICROPY_PERSISTENT_CODE_LOAD (0)
268#endif
269
270// Whether to support saving of persistent code
271#ifndef MICROPY_PERSISTENT_CODE_SAVE
272#define MICROPY_PERSISTENT_CODE_SAVE (0)
273#endif
274
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000275// Whether generated code can persist independently of the VM/runtime instance
Damien Georged8c834c2015-11-02 21:55:42 +0000276// This is enabled automatically when needed by other features
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000277#ifndef MICROPY_PERSISTENT_CODE
Damien George0a2e9652016-01-31 22:24:16 +0000278#define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
Damien Georgec8e9c0d2015-11-02 17:27:18 +0000279#endif
280
Damien George136f6752014-01-07 14:54:15 +0000281// Whether to emit x64 native code
282#ifndef MICROPY_EMIT_X64
283#define MICROPY_EMIT_X64 (0)
284#endif
285
Damien Georgec90f59e2014-09-06 23:06:36 +0100286// Whether to emit x86 native code
287#ifndef MICROPY_EMIT_X86
288#define MICROPY_EMIT_X86 (0)
289#endif
290
Damien George136f6752014-01-07 14:54:15 +0000291// Whether to emit thumb native code
292#ifndef MICROPY_EMIT_THUMB
293#define MICROPY_EMIT_THUMB (0)
294#endif
295
296// Whether to enable the thumb inline assembler
297#ifndef MICROPY_EMIT_INLINE_THUMB
298#define MICROPY_EMIT_INLINE_THUMB (0)
299#endif
300
Damien Georgee8135412015-10-16 22:08:57 +0100301// Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
302#ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
303#define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
304#endif
305
=50089722015-04-14 13:14:57 +0100306// Whether to enable float support in the Thumb2 inline assembler
307#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
308#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
309#endif
310
Fabian Vogtfe3d16e2014-08-16 22:55:53 +0200311// Whether to emit ARM native code
312#ifndef MICROPY_EMIT_ARM
313#define MICROPY_EMIT_ARM (0)
314#endif
315
Damien George8e5aced2016-12-09 16:39:39 +1100316// Whether to emit Xtensa native code
317#ifndef MICROPY_EMIT_XTENSA
318#define MICROPY_EMIT_XTENSA (0)
319#endif
320
Damien Georgef76b1bf2016-12-09 17:03:33 +1100321// Whether to enable the Xtensa inline assembler
322#ifndef MICROPY_EMIT_INLINE_XTENSA
323#define MICROPY_EMIT_INLINE_XTENSA (0)
324#endif
325
Damien George2ac4af62014-08-15 16:45:41 +0100326// Convenience definition for whether any native emitter is enabled
Damien George8e5aced2016-12-09 16:39:39 +1100327#define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA)
Damien George2ac4af62014-08-15 16:45:41 +0100328
Damien Georgead297a12016-12-09 13:17:49 +1100329// Convenience definition for whether any inline assembler emitter is enabled
Damien Georgef76b1bf2016-12-09 17:03:33 +1100330#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)
Damien Georgead297a12016-12-09 13:17:49 +1100331
Damien George136f6752014-01-07 14:54:15 +0000332/*****************************************************************************/
Damien George58ebde42014-05-21 20:32:59 +0100333/* Compiler configuration */
334
Damien Georgedd5353a2015-12-18 12:35:44 +0000335// Whether to include the compiler
336#ifndef MICROPY_ENABLE_COMPILER
337#define MICROPY_ENABLE_COMPILER (1)
338#endif
339
Damien Georgeea235202016-02-11 22:30:53 +0000340// Whether the compiler is dynamically configurable (ie at runtime)
341#ifndef MICROPY_DYNAMIC_COMPILER
342#define MICROPY_DYNAMIC_COMPILER (0)
343#endif
344
345// Configure dynamic compiler macros
346#if MICROPY_DYNAMIC_COMPILER
347#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
348#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
349#else
350#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
351#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
352#endif
353
Damien George64f2b212015-10-08 14:58:15 +0100354// Whether to enable constant folding; eg 1+2 rewritten as 3
355#ifndef MICROPY_COMP_CONST_FOLDING
356#define MICROPY_COMP_CONST_FOLDING (1)
357#endif
358
Damien George07796932019-02-27 00:10:04 +1100359// Whether to enable optimisations for constant literals, eg OrderedDict
360#ifndef MICROPY_COMP_CONST_LITERAL
361#define MICROPY_COMP_CONST_LITERAL (1)
362#endif
363
Damien Georgeddd1e182015-01-10 14:07:24 +0000364// Whether to enable lookup of constants in modules; eg module.CONST
365#ifndef MICROPY_COMP_MODULE_CONST
366#define MICROPY_COMP_MODULE_CONST (0)
367#endif
368
Damien George58ebde42014-05-21 20:32:59 +0100369// Whether to enable constant optimisation; id = const(value)
370#ifndef MICROPY_COMP_CONST
371#define MICROPY_COMP_CONST (1)
372#endif
373
Damien George42e0c592015-03-14 13:11:35 +0000374// Whether to enable optimisation of: a, b = c, d
375// Costs 124 bytes (Thumb2)
376#ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
377#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
378#endif
379
380// Whether to enable optimisation of: a, b, c = d, e, f
Damien George253f2bd2018-02-04 13:35:21 +1100381// Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
Damien George42e0c592015-03-14 13:11:35 +0000382#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
383#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
384#endif
385
Damien Georgeae54fbf2017-04-22 14:58:01 +1000386// Whether to enable optimisation of: return a if b else c
387// Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
388#ifndef MICROPY_COMP_RETURN_IF_EXPR
389#define MICROPY_COMP_RETURN_IF_EXPR (0)
390#endif
391
Damien George58ebde42014-05-21 20:32:59 +0100392/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +0000393/* Internal debugging stuff */
394
395// Whether to collect memory allocation stats
396#ifndef MICROPY_MEM_STATS
397#define MICROPY_MEM_STATS (0)
398#endif
399
Damien Georgeda2d2b62018-08-02 14:04:44 +1000400// The mp_print_t printer used for debugging output
401#ifndef MICROPY_DEBUG_PRINTER
402#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
403#endif
404
Damien Georgecbd2f742014-01-19 11:48:48 +0000405// Whether to build functions that print debugging info:
Damien George3417bc22014-05-10 10:36:38 +0100406// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000407// mp_parse_node_print
408#ifndef MICROPY_DEBUG_PRINTERS
409#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000410#endif
411
Stefan Naumannace9fb52017-07-24 18:55:14 +0200412// Whether to enable all debugging outputs (it will be extremely verbose)
413#ifndef MICROPY_DEBUG_VERBOSE
414#define MICROPY_DEBUG_VERBOSE (0)
415#endif
416
Damien George02cc2882019-03-08 15:48:20 +1100417// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
418#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
419#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
420#endif
421
Damien George6d199342019-01-04 17:09:41 +1100422// Whether to enable a simple VM stack overflow check
423#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
424#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
425#endif
426
Damien George136f6752014-01-07 14:54:15 +0000427/*****************************************************************************/
Damien Georgeee3fd462014-05-24 23:03:12 +0100428/* Optimisations */
429
430// Whether to use computed gotos in the VM, or a switch
431// Computed gotos are roughly 10% faster, and increase VM code size by a little
Damien George44f0a4d2017-09-18 23:53:33 +1000432// Note: enabling this will use the gcc-specific extensions of ranged designated
433// initialisers and addresses of labels, which are not part of the C99 standard.
Damien Georgeee3fd462014-05-24 23:03:12 +0100434#ifndef MICROPY_OPT_COMPUTED_GOTO
435#define MICROPY_OPT_COMPUTED_GOTO (0)
436#endif
437
Damien George7ee91cf2015-01-06 12:51:39 +0000438// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
439// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
440// uses a bit of extra code ROM, but greatly improves lookup speed.
441#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
442#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
443#endif
444
Doug Currie2e2e15c2016-01-30 22:35:58 -0500445// Whether to use fast versions of bitwise operations (and, or, xor) when the
446// arguments are both positive. Increases Thumb2 code size by about 250 bytes.
447#ifndef MICROPY_OPT_MPZ_BITWISE
448#define MICROPY_OPT_MPZ_BITWISE (0)
449#endif
450
Christopher Swenson8c656752018-08-27 10:32:21 +1000451
452// Whether math.factorial is large, fast and recursive (1) or small and slow (0).
453#ifndef MICROPY_OPT_MATH_FACTORIAL
454#define MICROPY_OPT_MATH_FACTORIAL (0)
455#endif
456
Damien Georgeee3fd462014-05-24 23:03:12 +0100457/*****************************************************************************/
458/* Python internal features */
Damien George136f6752014-01-07 14:54:15 +0000459
Damien George20993682018-02-20 18:00:44 +1100460// Whether to enable import of external modules
461// When disabled, only importing of built-in modules is supported
462// When enabled, a port must implement mp_import_stat (among other things)
463#ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
464#define MICROPY_ENABLE_EXTERNAL_IMPORT (1)
465#endif
466
Damien George6b239c22016-11-16 16:04:57 +1100467// Whether to use the POSIX reader for importing files
468#ifndef MICROPY_READER_POSIX
469#define MICROPY_READER_POSIX (0)
470#endif
471
Damien Georgedcb9ea72017-01-27 15:10:09 +1100472// Whether to use the VFS reader for importing files
473#ifndef MICROPY_READER_VFS
474#define MICROPY_READER_VFS (0)
475#endif
476
Sean Burtone33bc592018-12-13 12:10:35 +0000477// Whether any readers have been defined
478#ifndef MICROPY_HAS_FILE_READER
479#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
480#endif
481
Damien George40d84302016-02-15 22:46:21 +0000482// Hook for the VM at the start of the opcode loop (can contain variable
483// definitions usable by the other hook functions)
484#ifndef MICROPY_VM_HOOK_INIT
485#define MICROPY_VM_HOOK_INIT
486#endif
487
488// Hook for the VM during the opcode loop (but only after jump opcodes)
489#ifndef MICROPY_VM_HOOK_LOOP
490#define MICROPY_VM_HOOK_LOOP
491#endif
492
493// Hook for the VM just before return opcode is finished being interpreted
494#ifndef MICROPY_VM_HOOK_RETURN
495#define MICROPY_VM_HOOK_RETURN
496#endif
497
Damien Georged3ebe482014-01-07 15:20:33 +0000498// Whether to include the garbage collector
499#ifndef MICROPY_ENABLE_GC
500#define MICROPY_ENABLE_GC (0)
501#endif
502
Damien George12bab722014-04-05 20:35:48 +0100503// Whether to enable finalisers in the garbage collector (ie call __del__)
Damien George7860c2a2014-11-05 21:16:41 +0000504#ifndef MICROPY_ENABLE_FINALISER
505#define MICROPY_ENABLE_FINALISER (0)
Damien George12bab722014-04-05 20:35:48 +0100506#endif
507
Damien George02d830c2017-11-26 23:28:40 +1100508// Whether to enable a separate allocator for the Python stack.
509// If enabled then the code must call mp_pystack_init before mp_init.
510#ifndef MICROPY_ENABLE_PYSTACK
511#define MICROPY_ENABLE_PYSTACK (0)
512#endif
513
514// Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
515#ifndef MICROPY_PYSTACK_ALIGN
516#define MICROPY_PYSTACK_ALIGN (8)
517#endif
518
Paul Sokolovsky23668692014-06-25 03:03:34 +0300519// Whether to check C stack usage. C stack used for calling Python functions,
520// etc. Not checking means segfault on overflow.
521#ifndef MICROPY_STACK_CHECK
Damien George4a5895c2015-01-09 00:10:55 +0000522#define MICROPY_STACK_CHECK (0)
Paul Sokolovsky23668692014-06-25 03:03:34 +0300523#endif
524
Dave Hylands5b7fd202014-07-01 23:46:53 -0700525// Whether to have an emergency exception buffer
526#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
527#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
528#endif
529#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
530# ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
531# define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
532# endif
533#endif
534
Damien Georgebbb4b982017-04-10 17:19:36 +1000535// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
Damien George7f1da0a2016-12-15 13:00:19 +1100536#ifndef MICROPY_KBD_EXCEPTION
537#define MICROPY_KBD_EXCEPTION (0)
538#endif
539
Paul Sokolovsky1c9210b2015-12-23 00:06:37 +0200540// Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
541// handler) - if supported by a particular port.
542#ifndef MICROPY_ASYNC_KBD_INTR
543#define MICROPY_ASYNC_KBD_INTR (0)
544#endif
545
Damien George136f6752014-01-07 14:54:15 +0000546// Whether to include REPL helper function
Damien George58ebde42014-05-21 20:32:59 +0100547#ifndef MICROPY_HELPER_REPL
548#define MICROPY_HELPER_REPL (0)
Damien George136f6752014-01-07 14:54:15 +0000549#endif
550
Tom Soulanille7d588b02015-07-09 16:32:36 -0700551// Whether to include emacs-style readline behavior in REPL
552#ifndef MICROPY_REPL_EMACS_KEYS
Damien Georged8a7f8b2015-07-26 15:49:13 +0100553#define MICROPY_REPL_EMACS_KEYS (0)
Tom Soulanille7d588b02015-07-09 16:32:36 -0700554#endif
555
Damien George0af73012015-08-20 10:34:16 +0100556// Whether to implement auto-indent in REPL
557#ifndef MICROPY_REPL_AUTO_INDENT
558#define MICROPY_REPL_AUTO_INDENT (0)
559#endif
560
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200561// Whether port requires event-driven REPL functions
562#ifndef MICROPY_REPL_EVENT_DRIVEN
563#define MICROPY_REPL_EVENT_DRIVEN (0)
564#endif
565
Damien Georged3ebe482014-01-07 15:20:33 +0000566// Whether to include lexer helper function for unix
Damien George58ebde42014-05-21 20:32:59 +0100567#ifndef MICROPY_HELPER_LEXER_UNIX
568#define MICROPY_HELPER_LEXER_UNIX (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000569#endif
570
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200571// Long int implementation
572#define MICROPY_LONGINT_IMPL_NONE (0)
573#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000574#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200575
576#ifndef MICROPY_LONGINT_IMPL
577#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
578#endif
579
580#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
581typedef long long mp_longint_impl_t;
582#endif
583
Damien George62ad1892014-01-29 21:51:51 +0000584// Whether to include information in the byte code to determine source
585// line number (increases RAM usage, but doesn't slow byte code execution)
586#ifndef MICROPY_ENABLE_SOURCE_LINE
587#define MICROPY_ENABLE_SOURCE_LINE (0)
588#endif
589
Damien George1463c1f2014-04-25 23:52:57 +0100590// Whether to include doc strings (increases RAM usage)
591#ifndef MICROPY_ENABLE_DOC_STRING
592#define MICROPY_ENABLE_DOC_STRING (0)
593#endif
594
Damien George1e9a92f2014-11-06 17:36:16 +0000595// Exception messages are short static strings
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300596#define MICROPY_ERROR_REPORTING_TERSE (1)
597// Exception messages provide basic error details
598#define MICROPY_ERROR_REPORTING_NORMAL (2)
599// Exception messages provide full info, e.g. object names
600#define MICROPY_ERROR_REPORTING_DETAILED (3)
601
602#ifndef MICROPY_ERROR_REPORTING
603#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
604#endif
605
Paul Sokolovsky8a8c1fc2015-01-01 09:29:28 +0200606// Whether issue warnings during compiling/execution
607#ifndef MICROPY_WARNINGS
608#define MICROPY_WARNINGS (0)
609#endif
610
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +0300611// Whether to support warning categories
612#ifndef MICROPY_WARNINGS_CATEGORY
613#define MICROPY_WARNINGS_CATEGORY (0)
614#endif
615
David Lechner62849b72017-09-24 20:15:48 -0500616// This macro is used when printing runtime warnings and errors
617#ifndef MICROPY_ERROR_PRINTER
618#define MICROPY_ERROR_PRINTER (&mp_plat_print)
619#endif
620
Damien George0c36da02014-03-08 15:24:39 +0000621// Float and complex implementation
622#define MICROPY_FLOAT_IMPL_NONE (0)
623#define MICROPY_FLOAT_IMPL_FLOAT (1)
624#define MICROPY_FLOAT_IMPL_DOUBLE (2)
625
626#ifndef MICROPY_FLOAT_IMPL
627#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
628#endif
629
630#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
Damien Georgefb510b32014-06-01 13:32:54 +0100631#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100632#define MICROPY_FLOAT_CONST(x) x##F
Damien George0c36da02014-03-08 15:24:39 +0000633#define MICROPY_FLOAT_C_FUN(fun) fun##f
634typedef float mp_float_t;
635#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
Damien Georgefb510b32014-06-01 13:32:54 +0100636#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100637#define MICROPY_FLOAT_CONST(x) x
Damien George0c36da02014-03-08 15:24:39 +0000638#define MICROPY_FLOAT_C_FUN(fun) fun
639typedef double mp_float_t;
640#else
Damien Georgefb510b32014-06-01 13:32:54 +0100641#define MICROPY_PY_BUILTINS_FLOAT (0)
Damien George136f6752014-01-07 14:54:15 +0000642#endif
643
Paul Sokolovsky3b6f7b92014-06-20 01:48:35 +0300644#ifndef MICROPY_PY_BUILTINS_COMPLEX
645#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
646#endif
647
Damien Georgea73501b2017-04-06 17:27:33 +1000648// Whether to provide a high-quality hash for float and complex numbers.
649// Otherwise the default is a very simple but correct hashing function.
650#ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
651#define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
652#endif
653
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200654// Enable features which improve CPython compatibility
655// but may lead to more code size/memory usage.
656// TODO: Originally intended as generic category to not
657// add bunch of once-off options. May need refactoring later
658#ifndef MICROPY_CPYTHON_COMPAT
659#define MICROPY_CPYTHON_COMPAT (1)
660#endif
661
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300662// Perform full checks as done by CPython. Disabling this
663// may produce incorrect results, if incorrect data is fed,
664// but should not lead to MicroPython crashes or similar
665// grave issues (in other words, only user app should be,
666// affected, not system).
667#ifndef MICROPY_FULL_CHECKS
668#define MICROPY_FULL_CHECKS (1)
669#endif
670
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300671// Whether POSIX-semantics non-blocking streams are supported
672#ifndef MICROPY_STREAMS_NON_BLOCK
673#define MICROPY_STREAMS_NON_BLOCK (0)
674#endif
675
Paul Sokolovsky61e77a42016-07-30 20:05:56 +0300676// Whether to provide stream functions with POSIX-like signatures
677// (useful for porting existing libraries to MicroPython).
678#ifndef MICROPY_STREAMS_POSIX_API
679#define MICROPY_STREAMS_POSIX_API (0)
680#endif
681
Damien George3c9c3682015-09-15 14:56:13 +0100682// Whether to call __init__ when importing builtin modules for the first time
683#ifndef MICROPY_MODULE_BUILTIN_INIT
684#define MICROPY_MODULE_BUILTIN_INIT (0)
685#endif
686
Paul m. p. P454cca62018-10-22 18:34:29 +0200687// Whether to support module-level __getattr__ (see PEP 562)
688#ifndef MICROPY_MODULE_GETATTR
689#define MICROPY_MODULE_GETATTR (0)
690#endif
691
Damien Georgec14a8162014-10-12 11:46:04 +0100692// Whether module weak links are supported
693#ifndef MICROPY_MODULE_WEAK_LINKS
694#define MICROPY_MODULE_WEAK_LINKS (0)
695#endif
696
Damien George0a2e9652016-01-31 22:24:16 +0000697// Whether frozen modules are supported in the form of strings
698#ifndef MICROPY_MODULE_FROZEN_STR
699#define MICROPY_MODULE_FROZEN_STR (0)
700#endif
701
702// Whether frozen modules are supported in the form of .mpy files
703#ifndef MICROPY_MODULE_FROZEN_MPY
704#define MICROPY_MODULE_FROZEN_MPY (0)
705#endif
706
707// Convenience macro for whether frozen modules are supported
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200708#ifndef MICROPY_MODULE_FROZEN
Damien George0a2e9652016-01-31 22:24:16 +0000709#define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200710#endif
711
Damien George78d702c2014-12-09 16:19:48 +0000712// Whether you can override builtins in the builtins module
713#ifndef MICROPY_CAN_OVERRIDE_BUILTINS
714#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
715#endif
716
Damien George06593fb2015-06-19 12:49:10 +0000717// Whether to check that the "self" argument of a builtin method has the
718// correct type. Such an explicit check is only needed if a builtin
719// method escapes to Python land without a first argument, eg
720// list.append([], 1). Without this check such calls will have undefined
721// behaviour (usually segfault) if the first argument is the wrong type.
722#ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
723#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
724#endif
725
Damien George3f56fd62016-05-10 10:54:06 +0100726// Whether to use internally defined errno's (otherwise system provided ones)
727#ifndef MICROPY_USE_INTERNAL_ERRNO
728#define MICROPY_USE_INTERNAL_ERRNO (0)
729#endif
730
Delio Brignolie2ac8bb2016-08-21 11:33:37 +0200731// Whether to use internally defined *printf() functions (otherwise external ones)
732#ifndef MICROPY_USE_INTERNAL_PRINTF
733#define MICROPY_USE_INTERNAL_PRINTF (1)
734#endif
735
Damien George6e74d242017-02-16 18:05:06 +1100736// Support for internal scheduler
737#ifndef MICROPY_ENABLE_SCHEDULER
738#define MICROPY_ENABLE_SCHEDULER (0)
739#endif
740
741// Maximum number of entries in the scheduler
742#ifndef MICROPY_SCHEDULER_DEPTH
743#define MICROPY_SCHEDULER_DEPTH (4)
744#endif
745
Damien Georgedcb9ea72017-01-27 15:10:09 +1100746// Support for generic VFS sub-system
747#ifndef MICROPY_VFS
748#define MICROPY_VFS (0)
749#endif
750
Damien George8d82b0e2018-06-06 13:11:33 +1000751// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
752#ifndef MICROPY_VFS
753#define MICROPY_VFS_POSIX (0)
754#endif
755
Damien Georgea8b9e712018-06-06 14:31:29 +1000756// Support for VFS FAT component, to mount a FAT filesystem within VFS
757#ifndef MICROPY_VFS
758#define MICROPY_VFS_FAT (0)
759#endif
760
Damien Georgeee3fd462014-05-24 23:03:12 +0100761/*****************************************************************************/
762/* Fine control over Python builtins, classes, modules, etc */
763
Damien Georgeda154fd2017-04-01 23:52:24 +1100764// Whether to support multiple inheritance of Python classes. Multiple
765// inheritance makes some C functions inherently recursive, and adds a bit of
766// code overhead.
767#ifndef MICROPY_MULTIPLE_INHERITANCE
768#define MICROPY_MULTIPLE_INHERITANCE (1)
769#endif
770
stijn3cc17c62015-02-14 18:44:31 +0100771// Whether to implement attributes on functions
772#ifndef MICROPY_PY_FUNCTION_ATTRS
773#define MICROPY_PY_FUNCTION_ATTRS (0)
774#endif
775
Damien George36c10522018-05-25 17:09:54 +1000776// Whether to support the descriptors __get__, __set__, __delete__
777// This costs some code size and makes load/store/delete of instance
778// attributes slower for the classes that use this feature
stijn28fa84b2015-02-14 18:43:54 +0100779#ifndef MICROPY_PY_DESCRIPTORS
780#define MICROPY_PY_DESCRIPTORS (0)
781#endif
782
dmazzella18e65692017-01-03 11:00:12 +0100783// Whether to support class __delattr__ and __setattr__ methods
Damien George36c10522018-05-25 17:09:54 +1000784// This costs some code size and makes store/delete of instance
785// attributes slower for the classes that use this feature
dmazzella18e65692017-01-03 11:00:12 +0100786#ifndef MICROPY_PY_DELATTR_SETATTR
787#define MICROPY_PY_DELATTR_SETATTR (0)
788#endif
789
pohmelie81ebba72016-01-27 23:23:11 +0300790// Support for async/await/async for/async with
791#ifndef MICROPY_PY_ASYNC_AWAIT
792#define MICROPY_PY_ASYNC_AWAIT (1)
793#endif
794
Paul Sokolovsky63644012017-10-21 12:13:44 +0300795// Non-standard .pend_throw() method for generators, allowing for
796// Future-like behavior with respect to exception handling: an
797// exception set with .pend_throw() will activate on the next call
798// to generator's .send() or .__next__(). (This is useful to implement
799// async schedulers.)
800#ifndef MICROPY_PY_GENERATOR_PEND_THROW
801#define MICROPY_PY_GENERATOR_PEND_THROW (1)
802#endif
803
Paul Sokolovskya1b442b2016-07-22 00:46:24 +0300804// Issue a warning when comparing str and bytes objects
Paul Sokolovsky707cae72016-07-22 00:34:34 +0300805#ifndef MICROPY_PY_STR_BYTES_CMP_WARN
806#define MICROPY_PY_STR_BYTES_CMP_WARN (0)
807#endif
808
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +0300809// Whether str object is proper unicode
810#ifndef MICROPY_PY_BUILTINS_STR_UNICODE
811#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
Damien George8546ce12014-06-28 10:29:22 +0100812#endif
Damien Georgeb3a50f02014-06-28 10:27:15 +0100813
tll68c28172017-06-24 08:38:32 +0800814// Whether to check for valid UTF-8 when converting bytes to str
815#ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
816#define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
817#endif
818
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +0300819// Whether str.center() method provided
820#ifndef MICROPY_PY_BUILTINS_STR_CENTER
821#define MICROPY_PY_BUILTINS_STR_CENTER (0)
822#endif
823
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +0300824// Whether str.count() method provided
825#ifndef MICROPY_PY_BUILTINS_STR_COUNT
826#define MICROPY_PY_BUILTINS_STR_COUNT (1)
827#endif
828
Paul Sokolovsky2da5d412018-08-15 15:17:41 +0300829// Whether str % (...) formatting operator provided
830#ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
831#define MICROPY_PY_BUILTINS_STR_OP_MODULO (1)
832#endif
833
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +0300834// Whether str.partition()/str.rpartition() method provided
835#ifndef MICROPY_PY_BUILTINS_STR_PARTITION
836#define MICROPY_PY_BUILTINS_STR_PARTITION (0)
837#endif
838
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +0300839// Whether str.splitlines() method provided
840#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
841#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
842#endif
843
Paul Sokolovskycb78f862014-06-27 20:39:09 +0300844// Whether to support bytearray object
845#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
846#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +0300847#endif
848
Paul Sokolovskyfbb83352018-08-06 01:25:41 +0300849// Whether to support dict.fromkeys() class method
850#ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
851#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
852#endif
853
Damien Georgedd4f4532014-10-23 13:34:35 +0100854// Whether to support memoryview object
855#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
856#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
857#endif
858
stijn90fae912019-05-08 16:16:17 +0200859// Whether to support memoryview.itemsize attribute
860#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
861#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0)
862#endif
863
Damien George3ebd4d02014-06-01 13:46:47 +0100864// Whether to support set object
865#ifndef MICROPY_PY_BUILTINS_SET
866#define MICROPY_PY_BUILTINS_SET (1)
867#endif
868
Damien Georgefb510b32014-06-01 13:32:54 +0100869// Whether to support slice subscript operators and slice object
870#ifndef MICROPY_PY_BUILTINS_SLICE
871#define MICROPY_PY_BUILTINS_SLICE (1)
Damien Georgeee3fd462014-05-24 23:03:12 +0100872#endif
873
Tom Soulanilleaeb62f92015-09-11 14:31:32 -0700874// Whether to support slice attribute read access,
875// i.e. slice.start, slice.stop, slice.step
876#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
877#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
878#endif
879
Damien Georgeee3fd462014-05-24 23:03:12 +0100880// Whether to support frozenset object
Damien Georgefb510b32014-06-01 13:32:54 +0100881#ifndef MICROPY_PY_BUILTINS_FROZENSET
882#define MICROPY_PY_BUILTINS_FROZENSET (0)
Damien Georgeee3fd462014-05-24 23:03:12 +0100883#endif
884
Damien Georgefb510b32014-06-01 13:32:54 +0100885// Whether to support property object
886#ifndef MICROPY_PY_BUILTINS_PROPERTY
887#define MICROPY_PY_BUILTINS_PROPERTY (1)
Damien Georgeee3fd462014-05-24 23:03:12 +0100888#endif
889
Peter D. Grayb2a237d2015-03-06 14:48:14 -0500890// Whether to implement the start/stop/step attributes (readback) on
891// the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
892#ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
893#define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
894#endif
895
Damien Georged77da832018-02-14 23:17:06 +1100896// Whether to support binary ops [only (in)equality is defined] between range
897// objects. With this option disabled all range objects that are not exactly
898// the same object will compare as not-equal. With it enabled the semantics
899// match CPython and ranges are equal if they yield the same sequence of items.
900#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
901#define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
902#endif
903
stijn42863832019-01-03 15:19:42 +0100904// Support for callling next() with second argument
905#ifndef MICROPY_PY_BUILTINS_NEXT2
906#define MICROPY_PY_BUILTINS_NEXT2 (0)
907#endif
908
Jan Klusacekb318ebf2018-01-09 22:47:35 +0100909// Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
910#ifndef MICROPY_PY_BUILTINS_ROUND_INT
911#define MICROPY_PY_BUILTINS_ROUND_INT (0)
912#endif
913
Daniel Campora077812b2015-06-29 22:45:39 +0200914// Whether to support timeout exceptions (like socket.timeout)
915#ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR
916#define MICROPY_PY_BUILTINS_TIMEOUTERROR (0)
917#endif
918
Paul Sokolovsky0e80f342017-10-27 22:29:15 +0300919// Whether to support complete set of special methods for user
920// classes, or only the most used ones. "Inplace" methods are
921// controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
922// "Reverse" methods are controlled by
923// MICROPY_PY_REVERSE_SPECIAL_METHODS below.
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +0200924#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
925#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
926#endif
927
Paul Sokolovsky0e80f342017-10-27 22:29:15 +0300928// Whether to support all inplace arithmetic operarion methods
929// (__imul__, etc.)
930#ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
931#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
932#endif
933
934// Whether to support reverse arithmetic operarion methods
935// (__radd__, etc.). Additionally gated by
936// MICROPY_PY_ALL_SPECIAL_METHODS.
Paul Sokolovskyeb84a832017-09-10 17:05:20 +0300937#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
938#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
939#endif
940
Damien Georgec9fc6202014-10-25 21:59:14 +0100941// Whether to support compile function
942#ifndef MICROPY_PY_BUILTINS_COMPILE
943#define MICROPY_PY_BUILTINS_COMPILE (0)
944#endif
945
Paul Sokolovskye2d44e32015-04-06 23:50:37 +0300946// Whether to support enumerate function(type)
947#ifndef MICROPY_PY_BUILTINS_ENUMERATE
948#define MICROPY_PY_BUILTINS_ENUMERATE (1)
949#endif
950
Damien Georgedd5353a2015-12-18 12:35:44 +0000951// Whether to support eval and exec functions
952// By default they are supported if the compiler is enabled
953#ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
954#define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
955#endif
956
Damien George2a3e2b92014-12-19 13:36:17 +0000957// Whether to support the Python 2 execfile function
958#ifndef MICROPY_PY_BUILTINS_EXECFILE
959#define MICROPY_PY_BUILTINS_EXECFILE (0)
960#endif
961
Paul Sokolovsky22ff3972015-08-20 01:01:56 +0300962// Whether to support filter function(type)
963#ifndef MICROPY_PY_BUILTINS_FILTER
964#define MICROPY_PY_BUILTINS_FILTER (1)
965#endif
966
Paul Sokolovsky282ca092015-04-07 00:16:51 +0300967// Whether to support reversed function(type)
968#ifndef MICROPY_PY_BUILTINS_REVERSED
969#define MICROPY_PY_BUILTINS_REVERSED (1)
970#endif
971
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +0300972// Whether to define "NotImplemented" special constant
973#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
974#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
975#endif
976
Damien Georgebc763022017-06-01 15:32:23 +1000977// Whether to provide the built-in input() function. The implementation of this
978// uses mp-readline, so can only be enabled if the port uses this readline.
979#ifndef MICROPY_PY_BUILTINS_INPUT
980#define MICROPY_PY_BUILTINS_INPUT (0)
981#endif
982
pohmelie354e6882015-12-07 15:35:48 +0300983// Whether to support min/max functions
984#ifndef MICROPY_PY_BUILTINS_MIN_MAX
985#define MICROPY_PY_BUILTINS_MIN_MAX (1)
986#endif
987
Damien Georgea19b5a02017-02-03 12:35:48 +1100988// Support for calls to pow() with 3 integer arguments
989#ifndef MICROPY_PY_BUILTINS_POW3
990#define MICROPY_PY_BUILTINS_POW3 (0)
991#endif
992
Damien George9f04dfb2017-01-21 23:17:51 +1100993// Whether to provide the help function
994#ifndef MICROPY_PY_BUILTINS_HELP
995#define MICROPY_PY_BUILTINS_HELP (0)
996#endif
997
998// Use this to configure the help text shown for help(). It should be a
999// variable with the type "const char*". A sensible default is provided.
1000#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
1001#define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
1002#endif
1003
Damien Georgef5172af2017-01-22 12:12:54 +11001004// Add the ability to list the available modules when executing help('modules')
1005#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
1006#define MICROPY_PY_BUILTINS_HELP_MODULES (0)
1007#endif
1008
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001009// Whether to set __file__ for imported modules
1010#ifndef MICROPY_PY___FILE__
1011#define MICROPY_PY___FILE__ (1)
1012#endif
1013
Damien George89deec02015-01-09 20:12:54 +00001014// Whether to provide mem-info related functions in micropython module
1015#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
1016#define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
1017#endif
1018
Damien George7e2a4882018-02-20 18:30:22 +11001019// Whether to provide "micropython.stack_use" function
1020#ifndef MICROPY_PY_MICROPYTHON_STACK_USE
1021#define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
1022#endif
1023
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001024// Whether to provide "array" module. Note that large chunk of the
1025// underlying code is shared with "bytearray" builtin type, so to
1026// get real savings, it should be disabled too.
1027#ifndef MICROPY_PY_ARRAY
1028#define MICROPY_PY_ARRAY (1)
1029#endif
1030
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001031// Whether to support slice assignments for array (and bytearray).
1032// This is rarely used, but adds ~0.5K of code.
1033#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
1034#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
1035#endif
1036
Damien George5aa311d2015-04-21 14:14:24 +00001037// Whether to support attrtuple type (MicroPython extension)
1038// It provides space-efficient tuples with attribute access
1039#ifndef MICROPY_PY_ATTRTUPLE
1040#define MICROPY_PY_ATTRTUPLE (1)
1041#endif
1042
Damien Georgeee3fd462014-05-24 23:03:12 +01001043// Whether to provide "collections" module
1044#ifndef MICROPY_PY_COLLECTIONS
1045#define MICROPY_PY_COLLECTIONS (1)
1046#endif
1047
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001048// Whether to provide "ucollections.deque" type
1049#ifndef MICROPY_PY_COLLECTIONS_DEQUE
1050#define MICROPY_PY_COLLECTIONS_DEQUE (0)
1051#endif
1052
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001053// Whether to provide "collections.OrderedDict" type
1054#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
1055#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
1056#endif
1057
stijn79ed58f2017-11-06 12:21:53 +01001058// Whether to provide the _asdict function for namedtuple
1059#ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
1060#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0)
1061#endif
1062
Damien Georgeee3fd462014-05-24 23:03:12 +01001063// Whether to provide "math" module
1064#ifndef MICROPY_PY_MATH
1065#define MICROPY_PY_MATH (1)
1066#endif
1067
Damien George5cbeace2015-02-22 14:48:18 +00001068// Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
1069#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
1070#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
1071#endif
1072
Christopher Swenson8c656752018-08-27 10:32:21 +10001073// Whether to provide math.factorial function
1074#ifndef MICROPY_PY_MATH_FACTORIAL
1075#define MICROPY_PY_MATH_FACTORIAL (0)
1076#endif
1077
Damien Georgeee3fd462014-05-24 23:03:12 +01001078// Whether to provide "cmath" module
1079#ifndef MICROPY_PY_CMATH
1080#define MICROPY_PY_CMATH (0)
1081#endif
1082
1083// Whether to provide "gc" module
1084#ifndef MICROPY_PY_GC
1085#define MICROPY_PY_GC (1)
1086#endif
1087
Paul Sokolovsky755a55f2014-06-05 22:48:02 +03001088// Whether to return number of collected objects from gc.collect()
1089#ifndef MICROPY_PY_GC_COLLECT_RETVAL
1090#define MICROPY_PY_GC_COLLECT_RETVAL (0)
1091#endif
1092
Damien Georgeee3fd462014-05-24 23:03:12 +01001093// Whether to provide "io" module
1094#ifndef MICROPY_PY_IO
1095#define MICROPY_PY_IO (1)
1096#endif
1097
Damien Georgeaf0932a2018-06-04 15:54:26 +10001098// Whether to provide "io.IOBase" class to support user streams
1099#ifndef MICROPY_PY_IO_IOBASE
1100#define MICROPY_PY_IO_IOBASE (0)
1101#endif
1102
Paul Sokolovskyd7da2db2017-05-03 01:47:08 +03001103// Whether to provide "uio.resource_stream()" function with
1104// the semantics of CPython's pkg_resources.resource_stream()
Paul Sokolovskye7fc7652017-12-10 02:15:43 +02001105// (allows to access binary resources in frozen source packages).
1106// Note that the same functionality can be achieved in "pure
1107// Python" by prepocessing binary resources into Python source
1108// and bytecode-freezing it (with a simple helper module available
1109// e.g. in micropython-lib).
Paul Sokolovskyd7da2db2017-05-03 01:47:08 +03001110#ifndef MICROPY_PY_IO_RESOURCE_STREAM
1111#define MICROPY_PY_IO_RESOURCE_STREAM (0)
1112#endif
1113
Damien Georgeee3fd462014-05-24 23:03:12 +01001114// Whether to provide "io.FileIO" class
1115#ifndef MICROPY_PY_IO_FILEIO
1116#define MICROPY_PY_IO_FILEIO (0)
1117#endif
1118
1119// Whether to provide "io.BytesIO" class
1120#ifndef MICROPY_PY_IO_BYTESIO
1121#define MICROPY_PY_IO_BYTESIO (1)
1122#endif
1123
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001124// Whether to provide "io.BufferedWriter" class
1125#ifndef MICROPY_PY_IO_BUFFEREDWRITER
1126#define MICROPY_PY_IO_BUFFEREDWRITER (0)
1127#endif
1128
Damien Georgeee3fd462014-05-24 23:03:12 +01001129// Whether to provide "struct" module
1130#ifndef MICROPY_PY_STRUCT
1131#define MICROPY_PY_STRUCT (1)
1132#endif
1133
1134// Whether to provide "sys" module
1135#ifndef MICROPY_PY_SYS
1136#define MICROPY_PY_SYS (1)
1137#endif
1138
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001139// Whether to provide "sys.maxsize" constant
1140#ifndef MICROPY_PY_SYS_MAXSIZE
1141#define MICROPY_PY_SYS_MAXSIZE (0)
1142#endif
1143
Paul Sokolovsky1a1d11f2015-12-05 00:09:10 +02001144// Whether to provide "sys.modules" dictionary
1145#ifndef MICROPY_PY_SYS_MODULES
1146#define MICROPY_PY_SYS_MODULES (1)
1147#endif
1148
Paul Sokolovsky8b85d142015-04-25 03:17:41 +03001149// Whether to provide "sys.exc_info" function
1150// Avoid enabling this, this function is Python2 heritage
1151#ifndef MICROPY_PY_SYS_EXC_INFO
1152#define MICROPY_PY_SYS_EXC_INFO (0)
1153#endif
1154
Damien Georgeee3fd462014-05-24 23:03:12 +01001155// Whether to provide "sys.exit" function
1156#ifndef MICROPY_PY_SYS_EXIT
Paul Sokolovsky403c9302016-12-14 21:10:22 +03001157#define MICROPY_PY_SYS_EXIT (1)
Damien Georgeee3fd462014-05-24 23:03:12 +01001158#endif
1159
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001160// Whether to provide "sys.getsizeof" function
1161#ifndef MICROPY_PY_SYS_GETSIZEOF
1162#define MICROPY_PY_SYS_GETSIZEOF (0)
1163#endif
1164
Damien Georgeee3fd462014-05-24 23:03:12 +01001165// Whether to provide sys.{stdin,stdout,stderr} objects
1166#ifndef MICROPY_PY_SYS_STDFILES
1167#define MICROPY_PY_SYS_STDFILES (0)
Damien George3bb8bd82014-04-14 21:20:30 +01001168#endif
1169
Damien George3c4b5d42015-05-13 23:49:21 +01001170// Whether to provide sys.{stdin,stdout,stderr}.buffer object
1171// This is implemented per-port
1172#ifndef MICROPY_PY_SYS_STDIO_BUFFER
1173#define MICROPY_PY_SYS_STDIO_BUFFER (0)
1174#endif
Paul Sokolovsky82158472014-06-28 03:03:47 +03001175
Damien George596a3fe2016-05-10 10:54:25 +01001176// Whether to provide "uerrno" module
1177#ifndef MICROPY_PY_UERRNO
1178#define MICROPY_PY_UERRNO (0)
1179#endif
1180
Damien Georgef5634062017-02-22 12:53:42 +11001181// Whether to provide the uerrno.errorcode dict
1182#ifndef MICROPY_PY_UERRNO_ERRORCODE
1183#define MICROPY_PY_UERRNO_ERRORCODE (1)
1184#endif
1185
Paul Sokolovsky8f5bc3f2016-11-20 23:49:45 +03001186// Whether to provide "uselect" module (baremetal implementation)
1187#ifndef MICROPY_PY_USELECT
1188#define MICROPY_PY_USELECT (0)
1189#endif
1190
Paul Sokolovskya9728442016-10-14 20:13:02 +03001191// Whether to provide "utime" module functions implementation
1192// in terms of mp_hal_* functions.
1193#ifndef MICROPY_PY_UTIME_MP_HAL
1194#define MICROPY_PY_UTIME_MP_HAL (0)
1195#endif
1196
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001197// Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
1198// functions. Should be power of two. All functions above use the same
1199// period, so if underlying hardware/API has different periods, the
1200// minimum of them should be used. The value below is the maximum value
1201// this parameter can take (corresponding to 30 bit tick values on 32-bit
1202// system).
1203#ifndef MICROPY_PY_UTIME_TICKS_PERIOD
1204#define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
1205#endif
1206
Damien George27cc0772016-04-22 22:52:33 +00001207// Whether to provide "_thread" module
1208#ifndef MICROPY_PY_THREAD
1209#define MICROPY_PY_THREAD (0)
1210#endif
1211
Damien George4cec63a2016-05-26 10:42:53 +00001212// Whether to make the VM/runtime thread-safe using a global lock
1213// If not enabled then thread safety must be provided at the Python level
1214#ifndef MICROPY_PY_THREAD_GIL
1215#define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1216#endif
1217
Damien Georgef6c22a02017-02-06 10:50:43 +11001218// Number of VM jump-loops to do before releasing the GIL.
1219// Set this to 0 to disable the divisor.
1220#ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1221#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1222#endif
1223
Paul Sokolovsky82158472014-06-28 03:03:47 +03001224// Extended modules
Paul Sokolovsky510296f2014-08-08 22:51:40 +03001225
Paul Sokolovsky82158472014-06-28 03:03:47 +03001226#ifndef MICROPY_PY_UCTYPES
1227#define MICROPY_PY_UCTYPES (0)
1228#endif
1229
Paul Sokolovsky38151f32018-10-06 23:34:58 +03001230// Whether to provide SHORT, INT, LONG, etc. types in addition to
1231// exact-bitness types like INT16, INT32, etc.
1232#ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
1233#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
1234#endif
1235
Paul Sokolovsky34162872014-10-12 08:16:34 -07001236#ifndef MICROPY_PY_UZLIB
1237#define MICROPY_PY_UZLIB (0)
1238#endif
1239
Damien George612045f2014-09-17 22:56:34 +01001240#ifndef MICROPY_PY_UJSON
1241#define MICROPY_PY_UJSON (0)
1242#endif
1243
Paul Sokolovskyc71e0452014-09-12 18:48:07 +03001244#ifndef MICROPY_PY_URE
1245#define MICROPY_PY_URE (0)
1246#endif
1247
Damien George1f864602018-05-24 13:07:42 +10001248#ifndef MICROPY_PY_URE_MATCH_GROUPS
1249#define MICROPY_PY_URE_MATCH_GROUPS (0)
1250#endif
1251
Damien George1e9b8712018-05-24 13:08:15 +10001252#ifndef MICROPY_PY_URE_MATCH_SPAN_START_END
1253#define MICROPY_PY_URE_MATCH_SPAN_START_END (0)
1254#endif
1255
Damien Georgee30a5fc2018-05-24 13:08:51 +10001256#ifndef MICROPY_PY_URE_SUB
1257#define MICROPY_PY_URE_SUB (0)
1258#endif
1259
Damien Georgef5d69792014-10-22 17:37:18 +00001260#ifndef MICROPY_PY_UHEAPQ
1261#define MICROPY_PY_UHEAPQ (0)
1262#endif
1263
Paul Sokolovskyd02f6a92016-12-22 00:29:32 +03001264// Optimized heap queue for relative timestamps
1265#ifndef MICROPY_PY_UTIMEQ
1266#define MICROPY_PY_UTIMEQ (0)
1267#endif
1268
Paul Sokolovskyf4b19c82014-11-22 01:19:13 +02001269#ifndef MICROPY_PY_UHASHLIB
1270#define MICROPY_PY_UHASHLIB (0)
1271#endif
1272
Paul Sokolovsky5fe37302018-08-19 11:58:22 +03001273#ifndef MICROPY_PY_UHASHLIB_MD5
1274#define MICROPY_PY_UHASHLIB_MD5 (0)
1275#endif
1276
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001277#ifndef MICROPY_PY_UHASHLIB_SHA1
1278#define MICROPY_PY_UHASHLIB_SHA1 (0)
1279#endif
1280
1281#ifndef MICROPY_PY_UHASHLIB_SHA256
1282#define MICROPY_PY_UHASHLIB_SHA256 (1)
1283#endif
1284
Paul Sokolovsky567bc2d2018-01-07 15:13:56 +02001285#ifndef MICROPY_PY_UCRYPTOLIB
1286#define MICROPY_PY_UCRYPTOLIB (0)
1287#endif
1288
Yonatan Goldschmidtef984362019-04-23 12:39:05 +03001289// Depends on MICROPY_PY_UCRYPTOLIB
1290#ifndef MICROPY_PY_UCRYPTOLIB_CTR
1291#define MICROPY_PY_UCRYPTOLIB_CTR (0)
1292#endif
1293
Yonatan Goldschmidt473fe452018-06-15 17:07:47 +03001294#ifndef MICROPY_PY_UCRYPTOLIB_CONSTS
1295#define MICROPY_PY_UCRYPTOLIB_CONSTS (0)
1296#endif
1297
Paul Sokolovskybfdc2052014-11-29 06:19:30 +02001298#ifndef MICROPY_PY_UBINASCII
1299#define MICROPY_PY_UBINASCII (0)
1300#endif
1301
Paul Sokolovskyc4283672016-08-24 18:28:43 +03001302// Depends on MICROPY_PY_UZLIB
1303#ifndef MICROPY_PY_UBINASCII_CRC32
1304#define MICROPY_PY_UBINASCII_CRC32 (0)
1305#endif
1306
Paul Sokolovskya58a91e2016-01-17 12:10:28 +02001307#ifndef MICROPY_PY_URANDOM
1308#define MICROPY_PY_URANDOM (0)
1309#endif
1310
Damien Georgea53af6c2016-01-22 16:19:32 +00001311// Whether to include: randrange, randint, choice, random, uniform
1312#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
1313#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
1314#endif
1315
Paul Sokolovsky01162182015-05-03 20:25:40 +03001316#ifndef MICROPY_PY_MACHINE
1317#define MICROPY_PY_MACHINE (0)
1318#endif
1319
Damien George33168082016-05-31 14:25:19 +01001320// Whether to include: time_pulse_us
1321#ifndef MICROPY_PY_MACHINE_PULSE
1322#define MICROPY_PY_MACHINE_PULSE (0)
1323#endif
1324
Damien Georged0837122016-04-12 13:42:35 +01001325#ifndef MICROPY_PY_MACHINE_I2C
1326#define MICROPY_PY_MACHINE_I2C (0)
1327#endif
1328
Damien George0823c1b2016-09-01 15:07:20 +10001329#ifndef MICROPY_PY_MACHINE_SPI
1330#define MICROPY_PY_MACHINE_SPI (0)
1331#endif
1332
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001333#ifndef MICROPY_PY_USSL
1334#define MICROPY_PY_USSL (0)
Eric Poulsen74ec52d2017-10-26 21:17:35 -07001335// Whether to add finaliser code to ussl objects
1336#define MICROPY_PY_USSL_FINALISER (0)
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001337#endif
1338
Yonatan Goldschmidtbc4f8b42019-02-10 22:35:18 +02001339#ifndef MICROPY_PY_UWEBSOCKET
1340#define MICROPY_PY_UWEBSOCKET (0)
Paul Sokolovsky24342dd2016-03-24 19:14:12 +02001341#endif
1342
Damien George53ad6812016-04-08 11:08:37 +01001343#ifndef MICROPY_PY_FRAMEBUF
1344#define MICROPY_PY_FRAMEBUF (0)
1345#endif
1346
Paul Sokolovsky737bd9c2016-07-02 14:57:42 +03001347#ifndef MICROPY_PY_BTREE
1348#define MICROPY_PY_BTREE (0)
1349#endif
1350
Damien George58ebde42014-05-21 20:32:59 +01001351/*****************************************************************************/
1352/* Hooks for a port to add builtins */
1353
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001354// Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001355#ifndef MICROPY_PORT_BUILTINS
1356#define MICROPY_PORT_BUILTINS
Paul Sokolovsky910843e2014-02-14 12:02:34 +02001357#endif
Damien Georgecaac5422014-03-25 14:18:18 +00001358
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001359// Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001360#ifndef MICROPY_PORT_BUILTIN_MODULES
1361#define MICROPY_PORT_BUILTIN_MODULES
Damien Georgecaac5422014-03-25 14:18:18 +00001362#endif
1363
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001364// Any module weak links - see objmodule.c:mp_builtin_module_weak_links_table.
Damien Georgec14a8162014-10-12 11:46:04 +01001365#ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1366#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1367#endif
1368
Damien George57e99eb2014-04-10 22:42:11 +01001369// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
Damien George58ebde42014-05-21 20:32:59 +01001370#ifndef MICROPY_PORT_CONSTANTS
1371#define MICROPY_PORT_CONSTANTS
Damien George57e99eb2014-04-10 22:42:11 +01001372#endif
1373
Damien Georgeb4b10fd2015-01-01 23:30:53 +00001374// Any root pointers for GC scanning - see mpstate.c
1375#ifndef MICROPY_PORT_ROOT_POINTERS
1376#define MICROPY_PORT_ROOT_POINTERS
1377#endif
1378
Damien George136f6752014-01-07 14:54:15 +00001379/*****************************************************************************/
1380/* Miscellaneous settings */
1381
Damien George28631532015-02-08 13:42:00 +00001382// All uPy objects in ROM must be aligned on at least a 4 byte boundary
1383// so that the small-int/qstr/pointer distinction can be made. For machines
1384// that don't do this (eg 16-bit CPU), define the following macro to something
1385// like __attribute__((aligned(4))).
1386#ifndef MICROPY_OBJ_BASE_ALIGNMENT
1387#define MICROPY_OBJ_BASE_ALIGNMENT
1388#endif
1389
Dave Hylands5b7fd202014-07-01 23:46:53 -07001390// On embedded platforms, these will typically enable/disable irqs.
1391#ifndef MICROPY_BEGIN_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001392#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001393#endif
1394#ifndef MICROPY_END_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001395#define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001396#endif
1397
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +02001398// Allow to override static modifier for global objects, e.g. to use with
1399// object code analysis tools which don't support static symbols.
1400#ifndef STATIC
1401#define STATIC static
1402#endif
1403
Damien George4c307bf2017-04-01 11:39:38 +11001404// Number of bytes in a word
1405#ifndef BYTES_PER_WORD
1406#define BYTES_PER_WORD (sizeof(mp_uint_t))
1407#endif
1408
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +02001409#define BITS_PER_BYTE (8)
1410#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
Damien George40f3c022014-07-03 13:25:24 +01001411// mp_int_t value with most significant bit set
1412#define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +02001413
Damien Georgea9bcd512014-10-06 13:44:59 +00001414// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1415// defined and that they are the opposite of each other.
1416#if defined(MP_ENDIANNESS_LITTLE)
1417#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1418#elif defined(MP_ENDIANNESS_BIG)
1419#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1420#else
Damien George96303762018-05-07 13:36:52 +10001421 // Endianness not defined by port so try to autodetect it.
Damien Georgea9bcd512014-10-06 13:44:59 +00001422 #if defined(__BYTE_ORDER__)
1423 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1424 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001425 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Damien Georgea9bcd512014-10-06 13:44:59 +00001426 #define MP_ENDIANNESS_LITTLE (0)
1427 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001428 #else
Damien George4e4772b2015-05-30 23:12:30 +01001429 #include <endian.h>
1430 #if defined(__BYTE_ORDER)
1431 #if __BYTE_ORDER == __LITTLE_ENDIAN
1432 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001433 #elif __BYTE_ORDER == __BIG_ENDIAN
Damien George4e4772b2015-05-30 23:12:30 +01001434 #define MP_ENDIANNESS_LITTLE (0)
1435 #endif
Damien George4e4772b2015-05-30 23:12:30 +01001436 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001437 #endif
Damien George96303762018-05-07 13:36:52 +10001438 #ifndef MP_ENDIANNESS_LITTLE
1439 #error endianness not defined and cannot detect it
1440 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001441 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
Andrew Schellercc837372014-04-14 02:39:56 +01001442#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +03001443
Damien George3c658a42014-08-24 16:28:17 +01001444// Make a pointer to RAM callable (eg set lower bit for Thumb code)
1445// (This scheme won't work if we want to mix Thumb and normal ARM code.)
1446#ifndef MICROPY_MAKE_POINTER_CALLABLE
1447#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
1448#endif
1449
Damien George7f9d1d62015-04-09 23:56:15 +01001450// If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
Damien George2127e9a2015-01-14 00:11:09 +00001451// must be somehow reachable for marking by the GC, since the native code
1452// generators store pointers to GC managed memory in the code.
Fabian Vogtb7235b82014-09-03 16:59:33 +02001453#ifndef MP_PLAT_ALLOC_EXEC
Damien George4dea9222015-04-09 15:29:54 +00001454#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 +02001455#endif
1456
1457#ifndef MP_PLAT_FREE_EXEC
1458#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
1459#endif
1460
Damien George7f9d1d62015-04-09 23:56:15 +01001461// This macro is used to do all output (except when MICROPY_PY_IO is defined)
1462#ifndef MP_PLAT_PRINT_STRN
Damien George4300c7d2015-10-15 00:05:55 +01001463#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
Damien George7f9d1d62015-04-09 23:56:15 +01001464#endif
1465
Paul Sokolovsky722e5622014-09-06 19:17:23 +03001466#ifndef MP_SSIZE_MAX
1467#define MP_SSIZE_MAX SSIZE_MAX
1468#endif
1469
Damien George40f3c022014-07-03 13:25:24 +01001470// printf format spec to use for mp_int_t and friends
Damien George136f6752014-01-07 14:54:15 +00001471#ifndef INT_FMT
stijn3baf6b52015-11-20 15:59:06 +01001472#if defined(__LP64__)
Damien George40f3c022014-07-03 13:25:24 +01001473// Archs where mp_int_t == long, long != int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001474#define UINT_FMT "%lu"
1475#define INT_FMT "%ld"
stijn3baf6b52015-11-20 15:59:06 +01001476#elif defined(_WIN64)
stijn0a4eb4d2015-12-18 10:20:33 +01001477#define UINT_FMT "%llu"
1478#define INT_FMT "%lld"
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001479#else
Damien George40f3c022014-07-03 13:25:24 +01001480// Archs where mp_int_t == int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001481#define UINT_FMT "%u"
1482#define INT_FMT "%d"
1483#endif
1484#endif //INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +03001485
1486// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +02001487#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +03001488#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +02001489#endif
mux5c8db482014-06-21 17:24:55 +02001490
1491// Modifier for weak functions
1492#ifndef MP_WEAK
1493#define MP_WEAK __attribute__((weak))
1494#endif
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001495
Paul Sokolovsky0f5bf1a2016-06-15 23:52:00 +03001496// Modifier for functions which should be never inlined
1497#ifndef MP_NOINLINE
1498#define MP_NOINLINE __attribute__((noinline))
1499#endif
1500
Paul Sokolovsky1bc29112016-08-07 22:36:05 +03001501// Modifier for functions which should be always inlined
1502#ifndef MP_ALWAYSINLINE
1503#define MP_ALWAYSINLINE __attribute__((always_inline))
1504#endif
1505
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001506// Condition is likely to be true, to help branch prediction
1507#ifndef MP_LIKELY
1508#define MP_LIKELY(x) __builtin_expect((x), 1)
1509#endif
1510
1511// Condition is likely to be false, to help branch prediction
1512#ifndef MP_UNLIKELY
1513#define MP_UNLIKELY(x) __builtin_expect((x), 0)
1514#endif
Damien George9ddbe292014-12-29 01:02:19 +00001515
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02001516#ifndef MP_HTOBE16
1517#if MP_ENDIANNESS_LITTLE
1518# define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))
1519# define MP_BE16TOH(x) MP_HTOBE16(x)
1520#else
1521# define MP_HTOBE16(x) (x)
1522# define MP_BE16TOH(x) (x)
1523#endif
1524#endif
1525
1526#ifndef MP_HTOBE32
1527#if MP_ENDIANNESS_LITTLE
1528# define MP_HTOBE32(x) ((uint32_t)( (((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff) ))
1529# define MP_BE32TOH(x) MP_HTOBE32(x)
1530#else
1531# define MP_HTOBE32(x) (x)
1532# define MP_BE32TOH(x) (x)
1533#endif
1534#endif
1535
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03001536// Warning categories are by default implemented as strings, though
1537// hook is left for a port to define them as something else.
1538#if MICROPY_WARNINGS_CATEGORY
1539# ifndef MP_WARN_CAT
1540# define MP_WARN_CAT(x) #x
1541# endif
1542#else
1543# undef MP_WARN_CAT
1544# define MP_WARN_CAT(x) (NULL)
1545#endif
1546
Alexander Steffen299bc622017-06-29 23:14:58 +02001547#endif // MICROPY_INCLUDED_PY_MPCONFIG_H