blob: 57dec3cf266b13fea4b2add48c4cf9b96d3d0e63 [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 George6f75c4f2019-05-29 16:38:10 +100031#define MICROPY_VERSION_MINOR 11
Damien George3e25d612019-01-26 00:56:48 +110032#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
Jun Wub152bbd2019-05-06 00:31:11 -0700332// Convenience definition for whether any native or inline assembler emitter is enabled
333#define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)
334
Damien George136f6752014-01-07 14:54:15 +0000335/*****************************************************************************/
Damien George58ebde42014-05-21 20:32:59 +0100336/* Compiler configuration */
337
Damien Georgedd5353a2015-12-18 12:35:44 +0000338// Whether to include the compiler
339#ifndef MICROPY_ENABLE_COMPILER
340#define MICROPY_ENABLE_COMPILER (1)
341#endif
342
Damien Georgeea235202016-02-11 22:30:53 +0000343// Whether the compiler is dynamically configurable (ie at runtime)
Damien Georgea4f1d822019-05-29 21:17:29 +1000344// This will disable the ability to execute native/viper code
Damien Georgeea235202016-02-11 22:30:53 +0000345#ifndef MICROPY_DYNAMIC_COMPILER
346#define MICROPY_DYNAMIC_COMPILER (0)
347#endif
348
349// Configure dynamic compiler macros
350#if MICROPY_DYNAMIC_COMPILER
351#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
352#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
353#else
354#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
355#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
356#endif
357
Damien George64f2b212015-10-08 14:58:15 +0100358// Whether to enable constant folding; eg 1+2 rewritten as 3
359#ifndef MICROPY_COMP_CONST_FOLDING
360#define MICROPY_COMP_CONST_FOLDING (1)
361#endif
362
Damien George07796932019-02-27 00:10:04 +1100363// Whether to enable optimisations for constant literals, eg OrderedDict
364#ifndef MICROPY_COMP_CONST_LITERAL
365#define MICROPY_COMP_CONST_LITERAL (1)
366#endif
367
Damien Georgeddd1e182015-01-10 14:07:24 +0000368// Whether to enable lookup of constants in modules; eg module.CONST
369#ifndef MICROPY_COMP_MODULE_CONST
370#define MICROPY_COMP_MODULE_CONST (0)
371#endif
372
Damien George58ebde42014-05-21 20:32:59 +0100373// Whether to enable constant optimisation; id = const(value)
374#ifndef MICROPY_COMP_CONST
375#define MICROPY_COMP_CONST (1)
376#endif
377
Damien George42e0c592015-03-14 13:11:35 +0000378// Whether to enable optimisation of: a, b = c, d
379// Costs 124 bytes (Thumb2)
380#ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
381#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
382#endif
383
384// Whether to enable optimisation of: a, b, c = d, e, f
Damien George253f2bd2018-02-04 13:35:21 +1100385// Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
Damien George42e0c592015-03-14 13:11:35 +0000386#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
387#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
388#endif
389
Damien Georgeae54fbf2017-04-22 14:58:01 +1000390// Whether to enable optimisation of: return a if b else c
391// Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
392#ifndef MICROPY_COMP_RETURN_IF_EXPR
393#define MICROPY_COMP_RETURN_IF_EXPR (0)
394#endif
395
Damien George58ebde42014-05-21 20:32:59 +0100396/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +0000397/* Internal debugging stuff */
398
399// Whether to collect memory allocation stats
400#ifndef MICROPY_MEM_STATS
401#define MICROPY_MEM_STATS (0)
402#endif
403
Damien Georgeda2d2b62018-08-02 14:04:44 +1000404// The mp_print_t printer used for debugging output
405#ifndef MICROPY_DEBUG_PRINTER
406#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
407#endif
408
Damien Georgecbd2f742014-01-19 11:48:48 +0000409// Whether to build functions that print debugging info:
Damien George3417bc22014-05-10 10:36:38 +0100410// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000411// mp_parse_node_print
412#ifndef MICROPY_DEBUG_PRINTERS
413#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000414#endif
415
Stefan Naumannace9fb52017-07-24 18:55:14 +0200416// Whether to enable all debugging outputs (it will be extremely verbose)
417#ifndef MICROPY_DEBUG_VERBOSE
418#define MICROPY_DEBUG_VERBOSE (0)
419#endif
420
Damien George02cc2882019-03-08 15:48:20 +1100421// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
422#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
423#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
424#endif
425
Damien George6d199342019-01-04 17:09:41 +1100426// Whether to enable a simple VM stack overflow check
427#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
428#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
429#endif
430
Damien George136f6752014-01-07 14:54:15 +0000431/*****************************************************************************/
Damien Georgeee3fd462014-05-24 23:03:12 +0100432/* Optimisations */
433
434// Whether to use computed gotos in the VM, or a switch
435// Computed gotos are roughly 10% faster, and increase VM code size by a little
Damien George44f0a4d2017-09-18 23:53:33 +1000436// Note: enabling this will use the gcc-specific extensions of ranged designated
437// initialisers and addresses of labels, which are not part of the C99 standard.
Damien Georgeee3fd462014-05-24 23:03:12 +0100438#ifndef MICROPY_OPT_COMPUTED_GOTO
439#define MICROPY_OPT_COMPUTED_GOTO (0)
440#endif
441
Damien George7ee91cf2015-01-06 12:51:39 +0000442// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
443// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
444// uses a bit of extra code ROM, but greatly improves lookup speed.
445#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
446#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
447#endif
448
Doug Currie2e2e15c2016-01-30 22:35:58 -0500449// Whether to use fast versions of bitwise operations (and, or, xor) when the
450// arguments are both positive. Increases Thumb2 code size by about 250 bytes.
451#ifndef MICROPY_OPT_MPZ_BITWISE
452#define MICROPY_OPT_MPZ_BITWISE (0)
453#endif
454
Christopher Swenson8c656752018-08-27 10:32:21 +1000455
456// Whether math.factorial is large, fast and recursive (1) or small and slow (0).
457#ifndef MICROPY_OPT_MATH_FACTORIAL
458#define MICROPY_OPT_MATH_FACTORIAL (0)
459#endif
460
Damien Georgeee3fd462014-05-24 23:03:12 +0100461/*****************************************************************************/
462/* Python internal features */
Damien George136f6752014-01-07 14:54:15 +0000463
Damien George20993682018-02-20 18:00:44 +1100464// Whether to enable import of external modules
465// When disabled, only importing of built-in modules is supported
466// When enabled, a port must implement mp_import_stat (among other things)
467#ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
468#define MICROPY_ENABLE_EXTERNAL_IMPORT (1)
469#endif
470
Damien George6b239c22016-11-16 16:04:57 +1100471// Whether to use the POSIX reader for importing files
472#ifndef MICROPY_READER_POSIX
473#define MICROPY_READER_POSIX (0)
474#endif
475
Damien Georgedcb9ea72017-01-27 15:10:09 +1100476// Whether to use the VFS reader for importing files
477#ifndef MICROPY_READER_VFS
478#define MICROPY_READER_VFS (0)
479#endif
480
Sean Burtone33bc592018-12-13 12:10:35 +0000481// Whether any readers have been defined
482#ifndef MICROPY_HAS_FILE_READER
483#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
484#endif
485
Damien George40d84302016-02-15 22:46:21 +0000486// Hook for the VM at the start of the opcode loop (can contain variable
487// definitions usable by the other hook functions)
488#ifndef MICROPY_VM_HOOK_INIT
489#define MICROPY_VM_HOOK_INIT
490#endif
491
492// Hook for the VM during the opcode loop (but only after jump opcodes)
493#ifndef MICROPY_VM_HOOK_LOOP
494#define MICROPY_VM_HOOK_LOOP
495#endif
496
497// Hook for the VM just before return opcode is finished being interpreted
498#ifndef MICROPY_VM_HOOK_RETURN
499#define MICROPY_VM_HOOK_RETURN
500#endif
501
Damien Georged3ebe482014-01-07 15:20:33 +0000502// Whether to include the garbage collector
503#ifndef MICROPY_ENABLE_GC
504#define MICROPY_ENABLE_GC (0)
505#endif
506
Damien George12bab722014-04-05 20:35:48 +0100507// Whether to enable finalisers in the garbage collector (ie call __del__)
Damien George7860c2a2014-11-05 21:16:41 +0000508#ifndef MICROPY_ENABLE_FINALISER
509#define MICROPY_ENABLE_FINALISER (0)
Damien George12bab722014-04-05 20:35:48 +0100510#endif
511
Damien George02d830c2017-11-26 23:28:40 +1100512// Whether to enable a separate allocator for the Python stack.
513// If enabled then the code must call mp_pystack_init before mp_init.
514#ifndef MICROPY_ENABLE_PYSTACK
515#define MICROPY_ENABLE_PYSTACK (0)
516#endif
517
518// Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
519#ifndef MICROPY_PYSTACK_ALIGN
520#define MICROPY_PYSTACK_ALIGN (8)
521#endif
522
Paul Sokolovsky23668692014-06-25 03:03:34 +0300523// Whether to check C stack usage. C stack used for calling Python functions,
524// etc. Not checking means segfault on overflow.
525#ifndef MICROPY_STACK_CHECK
Damien George4a5895c2015-01-09 00:10:55 +0000526#define MICROPY_STACK_CHECK (0)
Paul Sokolovsky23668692014-06-25 03:03:34 +0300527#endif
528
Dave Hylands5b7fd202014-07-01 23:46:53 -0700529// Whether to have an emergency exception buffer
530#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
531#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
532#endif
533#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
534# ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
535# define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
536# endif
537#endif
538
Damien Georgebbb4b982017-04-10 17:19:36 +1000539// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
Damien George7f1da0a2016-12-15 13:00:19 +1100540#ifndef MICROPY_KBD_EXCEPTION
541#define MICROPY_KBD_EXCEPTION (0)
542#endif
543
Paul Sokolovsky1c9210b2015-12-23 00:06:37 +0200544// Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
545// handler) - if supported by a particular port.
546#ifndef MICROPY_ASYNC_KBD_INTR
547#define MICROPY_ASYNC_KBD_INTR (0)
548#endif
549
Damien George136f6752014-01-07 14:54:15 +0000550// Whether to include REPL helper function
Damien George58ebde42014-05-21 20:32:59 +0100551#ifndef MICROPY_HELPER_REPL
552#define MICROPY_HELPER_REPL (0)
Damien George136f6752014-01-07 14:54:15 +0000553#endif
554
Tom Soulanille7d588b02015-07-09 16:32:36 -0700555// Whether to include emacs-style readline behavior in REPL
556#ifndef MICROPY_REPL_EMACS_KEYS
Damien Georged8a7f8b2015-07-26 15:49:13 +0100557#define MICROPY_REPL_EMACS_KEYS (0)
Tom Soulanille7d588b02015-07-09 16:32:36 -0700558#endif
559
Damien George0af73012015-08-20 10:34:16 +0100560// Whether to implement auto-indent in REPL
561#ifndef MICROPY_REPL_AUTO_INDENT
562#define MICROPY_REPL_AUTO_INDENT (0)
563#endif
564
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200565// Whether port requires event-driven REPL functions
566#ifndef MICROPY_REPL_EVENT_DRIVEN
567#define MICROPY_REPL_EVENT_DRIVEN (0)
568#endif
569
Damien Georged3ebe482014-01-07 15:20:33 +0000570// Whether to include lexer helper function for unix
Damien George58ebde42014-05-21 20:32:59 +0100571#ifndef MICROPY_HELPER_LEXER_UNIX
572#define MICROPY_HELPER_LEXER_UNIX (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000573#endif
574
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200575// Long int implementation
576#define MICROPY_LONGINT_IMPL_NONE (0)
577#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000578#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200579
580#ifndef MICROPY_LONGINT_IMPL
581#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
582#endif
583
584#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
585typedef long long mp_longint_impl_t;
586#endif
587
Damien George62ad1892014-01-29 21:51:51 +0000588// Whether to include information in the byte code to determine source
589// line number (increases RAM usage, but doesn't slow byte code execution)
590#ifndef MICROPY_ENABLE_SOURCE_LINE
591#define MICROPY_ENABLE_SOURCE_LINE (0)
592#endif
593
Damien George1463c1f2014-04-25 23:52:57 +0100594// Whether to include doc strings (increases RAM usage)
595#ifndef MICROPY_ENABLE_DOC_STRING
596#define MICROPY_ENABLE_DOC_STRING (0)
597#endif
598
Damien George1e9a92f2014-11-06 17:36:16 +0000599// Exception messages are short static strings
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300600#define MICROPY_ERROR_REPORTING_TERSE (1)
601// Exception messages provide basic error details
602#define MICROPY_ERROR_REPORTING_NORMAL (2)
603// Exception messages provide full info, e.g. object names
604#define MICROPY_ERROR_REPORTING_DETAILED (3)
605
606#ifndef MICROPY_ERROR_REPORTING
607#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
608#endif
609
Paul Sokolovsky8a8c1fc2015-01-01 09:29:28 +0200610// Whether issue warnings during compiling/execution
611#ifndef MICROPY_WARNINGS
612#define MICROPY_WARNINGS (0)
613#endif
614
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +0300615// Whether to support warning categories
616#ifndef MICROPY_WARNINGS_CATEGORY
617#define MICROPY_WARNINGS_CATEGORY (0)
618#endif
619
David Lechner62849b72017-09-24 20:15:48 -0500620// This macro is used when printing runtime warnings and errors
621#ifndef MICROPY_ERROR_PRINTER
622#define MICROPY_ERROR_PRINTER (&mp_plat_print)
623#endif
624
Damien George0c36da02014-03-08 15:24:39 +0000625// Float and complex implementation
626#define MICROPY_FLOAT_IMPL_NONE (0)
627#define MICROPY_FLOAT_IMPL_FLOAT (1)
628#define MICROPY_FLOAT_IMPL_DOUBLE (2)
629
630#ifndef MICROPY_FLOAT_IMPL
631#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
632#endif
633
634#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
Damien Georgefb510b32014-06-01 13:32:54 +0100635#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100636#define MICROPY_FLOAT_CONST(x) x##F
Damien George0c36da02014-03-08 15:24:39 +0000637#define MICROPY_FLOAT_C_FUN(fun) fun##f
638typedef float mp_float_t;
639#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
Damien Georgefb510b32014-06-01 13:32:54 +0100640#define MICROPY_PY_BUILTINS_FLOAT (1)
Damien George561844f2016-11-03 12:33:01 +1100641#define MICROPY_FLOAT_CONST(x) x
Damien George0c36da02014-03-08 15:24:39 +0000642#define MICROPY_FLOAT_C_FUN(fun) fun
643typedef double mp_float_t;
644#else
Damien Georgefb510b32014-06-01 13:32:54 +0100645#define MICROPY_PY_BUILTINS_FLOAT (0)
Damien George136f6752014-01-07 14:54:15 +0000646#endif
647
Paul Sokolovsky3b6f7b92014-06-20 01:48:35 +0300648#ifndef MICROPY_PY_BUILTINS_COMPLEX
649#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
650#endif
651
Damien Georgea73501b2017-04-06 17:27:33 +1000652// Whether to provide a high-quality hash for float and complex numbers.
653// Otherwise the default is a very simple but correct hashing function.
654#ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
655#define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
656#endif
657
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200658// Enable features which improve CPython compatibility
659// but may lead to more code size/memory usage.
660// TODO: Originally intended as generic category to not
661// add bunch of once-off options. May need refactoring later
662#ifndef MICROPY_CPYTHON_COMPAT
663#define MICROPY_CPYTHON_COMPAT (1)
664#endif
665
Paul Sokolovsky9a973972017-04-02 21:20:07 +0300666// Perform full checks as done by CPython. Disabling this
667// may produce incorrect results, if incorrect data is fed,
668// but should not lead to MicroPython crashes or similar
669// grave issues (in other words, only user app should be,
670// affected, not system).
671#ifndef MICROPY_FULL_CHECKS
672#define MICROPY_FULL_CHECKS (1)
673#endif
674
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300675// Whether POSIX-semantics non-blocking streams are supported
676#ifndef MICROPY_STREAMS_NON_BLOCK
677#define MICROPY_STREAMS_NON_BLOCK (0)
678#endif
679
Paul Sokolovsky61e77a42016-07-30 20:05:56 +0300680// Whether to provide stream functions with POSIX-like signatures
681// (useful for porting existing libraries to MicroPython).
682#ifndef MICROPY_STREAMS_POSIX_API
683#define MICROPY_STREAMS_POSIX_API (0)
684#endif
685
Damien George3c9c3682015-09-15 14:56:13 +0100686// Whether to call __init__ when importing builtin modules for the first time
687#ifndef MICROPY_MODULE_BUILTIN_INIT
688#define MICROPY_MODULE_BUILTIN_INIT (0)
689#endif
690
Paul m. p. P454cca62018-10-22 18:34:29 +0200691// Whether to support module-level __getattr__ (see PEP 562)
692#ifndef MICROPY_MODULE_GETATTR
693#define MICROPY_MODULE_GETATTR (0)
694#endif
695
Damien Georgec14a8162014-10-12 11:46:04 +0100696// Whether module weak links are supported
697#ifndef MICROPY_MODULE_WEAK_LINKS
698#define MICROPY_MODULE_WEAK_LINKS (0)
699#endif
700
Damien George0a2e9652016-01-31 22:24:16 +0000701// Whether frozen modules are supported in the form of strings
702#ifndef MICROPY_MODULE_FROZEN_STR
703#define MICROPY_MODULE_FROZEN_STR (0)
704#endif
705
706// Whether frozen modules are supported in the form of .mpy files
707#ifndef MICROPY_MODULE_FROZEN_MPY
708#define MICROPY_MODULE_FROZEN_MPY (0)
709#endif
710
711// Convenience macro for whether frozen modules are supported
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200712#ifndef MICROPY_MODULE_FROZEN
Damien George0a2e9652016-01-31 22:24:16 +0000713#define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200714#endif
715
Damien George78d702c2014-12-09 16:19:48 +0000716// Whether you can override builtins in the builtins module
717#ifndef MICROPY_CAN_OVERRIDE_BUILTINS
718#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
719#endif
720
Damien George06593fb2015-06-19 12:49:10 +0000721// Whether to check that the "self" argument of a builtin method has the
722// correct type. Such an explicit check is only needed if a builtin
723// method escapes to Python land without a first argument, eg
724// list.append([], 1). Without this check such calls will have undefined
725// behaviour (usually segfault) if the first argument is the wrong type.
726#ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
727#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
728#endif
729
Damien George3f56fd62016-05-10 10:54:06 +0100730// Whether to use internally defined errno's (otherwise system provided ones)
731#ifndef MICROPY_USE_INTERNAL_ERRNO
732#define MICROPY_USE_INTERNAL_ERRNO (0)
733#endif
734
Delio Brignolie2ac8bb2016-08-21 11:33:37 +0200735// Whether to use internally defined *printf() functions (otherwise external ones)
736#ifndef MICROPY_USE_INTERNAL_PRINTF
737#define MICROPY_USE_INTERNAL_PRINTF (1)
738#endif
739
Damien George6e74d242017-02-16 18:05:06 +1100740// Support for internal scheduler
741#ifndef MICROPY_ENABLE_SCHEDULER
742#define MICROPY_ENABLE_SCHEDULER (0)
743#endif
744
745// Maximum number of entries in the scheduler
746#ifndef MICROPY_SCHEDULER_DEPTH
747#define MICROPY_SCHEDULER_DEPTH (4)
748#endif
749
Damien Georgedcb9ea72017-01-27 15:10:09 +1100750// Support for generic VFS sub-system
751#ifndef MICROPY_VFS
752#define MICROPY_VFS (0)
753#endif
754
Damien George8d82b0e2018-06-06 13:11:33 +1000755// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
756#ifndef MICROPY_VFS
757#define MICROPY_VFS_POSIX (0)
758#endif
759
Damien Georgea8b9e712018-06-06 14:31:29 +1000760// Support for VFS FAT component, to mount a FAT filesystem within VFS
761#ifndef MICROPY_VFS
762#define MICROPY_VFS_FAT (0)
763#endif
764
Damien Georgeee3fd462014-05-24 23:03:12 +0100765/*****************************************************************************/
766/* Fine control over Python builtins, classes, modules, etc */
767
Damien Georgeda154fd2017-04-01 23:52:24 +1100768// Whether to support multiple inheritance of Python classes. Multiple
769// inheritance makes some C functions inherently recursive, and adds a bit of
770// code overhead.
771#ifndef MICROPY_MULTIPLE_INHERITANCE
772#define MICROPY_MULTIPLE_INHERITANCE (1)
773#endif
774
stijn3cc17c62015-02-14 18:44:31 +0100775// Whether to implement attributes on functions
776#ifndef MICROPY_PY_FUNCTION_ATTRS
777#define MICROPY_PY_FUNCTION_ATTRS (0)
778#endif
779
Damien George36c10522018-05-25 17:09:54 +1000780// Whether to support the descriptors __get__, __set__, __delete__
781// This costs some code size and makes load/store/delete of instance
782// attributes slower for the classes that use this feature
stijn28fa84b2015-02-14 18:43:54 +0100783#ifndef MICROPY_PY_DESCRIPTORS
784#define MICROPY_PY_DESCRIPTORS (0)
785#endif
786
dmazzella18e65692017-01-03 11:00:12 +0100787// Whether to support class __delattr__ and __setattr__ methods
Damien George36c10522018-05-25 17:09:54 +1000788// This costs some code size and makes store/delete of instance
789// attributes slower for the classes that use this feature
dmazzella18e65692017-01-03 11:00:12 +0100790#ifndef MICROPY_PY_DELATTR_SETATTR
791#define MICROPY_PY_DELATTR_SETATTR (0)
792#endif
793
pohmelie81ebba72016-01-27 23:23:11 +0300794// Support for async/await/async for/async with
795#ifndef MICROPY_PY_ASYNC_AWAIT
796#define MICROPY_PY_ASYNC_AWAIT (1)
797#endif
798
Paul Sokolovsky63644012017-10-21 12:13:44 +0300799// Non-standard .pend_throw() method for generators, allowing for
800// Future-like behavior with respect to exception handling: an
801// exception set with .pend_throw() will activate on the next call
802// to generator's .send() or .__next__(). (This is useful to implement
803// async schedulers.)
804#ifndef MICROPY_PY_GENERATOR_PEND_THROW
805#define MICROPY_PY_GENERATOR_PEND_THROW (1)
806#endif
807
Paul Sokolovskya1b442b2016-07-22 00:46:24 +0300808// Issue a warning when comparing str and bytes objects
Paul Sokolovsky707cae72016-07-22 00:34:34 +0300809#ifndef MICROPY_PY_STR_BYTES_CMP_WARN
810#define MICROPY_PY_STR_BYTES_CMP_WARN (0)
811#endif
812
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +0300813// Whether str object is proper unicode
814#ifndef MICROPY_PY_BUILTINS_STR_UNICODE
815#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
Damien George8546ce12014-06-28 10:29:22 +0100816#endif
Damien Georgeb3a50f02014-06-28 10:27:15 +0100817
tll68c28172017-06-24 08:38:32 +0800818// Whether to check for valid UTF-8 when converting bytes to str
819#ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
820#define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
821#endif
822
Paul Sokolovsky1b5abfc2016-05-22 00:13:44 +0300823// Whether str.center() method provided
824#ifndef MICROPY_PY_BUILTINS_STR_CENTER
825#define MICROPY_PY_BUILTINS_STR_CENTER (0)
826#endif
827
Paul Sokolovsky5a91fce2018-08-05 23:56:19 +0300828// Whether str.count() method provided
829#ifndef MICROPY_PY_BUILTINS_STR_COUNT
830#define MICROPY_PY_BUILTINS_STR_COUNT (1)
831#endif
832
Paul Sokolovsky2da5d412018-08-15 15:17:41 +0300833// Whether str % (...) formatting operator provided
834#ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
835#define MICROPY_PY_BUILTINS_STR_OP_MODULO (1)
836#endif
837
Paul Sokolovsky56eb25f2016-08-07 06:46:55 +0300838// Whether str.partition()/str.rpartition() method provided
839#ifndef MICROPY_PY_BUILTINS_STR_PARTITION
840#define MICROPY_PY_BUILTINS_STR_PARTITION (0)
841#endif
842
Paul Sokolovskyac2f7a72015-04-04 00:09:23 +0300843// Whether str.splitlines() method provided
844#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
845#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
846#endif
847
Paul Sokolovskycb78f862014-06-27 20:39:09 +0300848// Whether to support bytearray object
849#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
850#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
Paul Sokolovsky12bc13e2014-06-13 01:05:19 +0300851#endif
852
Paul Sokolovskyfbb83352018-08-06 01:25:41 +0300853// Whether to support dict.fromkeys() class method
854#ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
855#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
856#endif
857
Damien Georgedd4f4532014-10-23 13:34:35 +0100858// Whether to support memoryview object
859#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
860#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
861#endif
862
stijn90fae912019-05-08 16:16:17 +0200863// Whether to support memoryview.itemsize attribute
864#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
865#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0)
866#endif
867
Damien George3ebd4d02014-06-01 13:46:47 +0100868// Whether to support set object
869#ifndef MICROPY_PY_BUILTINS_SET
870#define MICROPY_PY_BUILTINS_SET (1)
871#endif
872
Damien Georgefb510b32014-06-01 13:32:54 +0100873// Whether to support slice subscript operators and slice object
874#ifndef MICROPY_PY_BUILTINS_SLICE
875#define MICROPY_PY_BUILTINS_SLICE (1)
Damien Georgeee3fd462014-05-24 23:03:12 +0100876#endif
877
Tom Soulanilleaeb62f92015-09-11 14:31:32 -0700878// Whether to support slice attribute read access,
879// i.e. slice.start, slice.stop, slice.step
880#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
881#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
882#endif
883
Damien Georgeee3fd462014-05-24 23:03:12 +0100884// Whether to support frozenset object
Damien Georgefb510b32014-06-01 13:32:54 +0100885#ifndef MICROPY_PY_BUILTINS_FROZENSET
886#define MICROPY_PY_BUILTINS_FROZENSET (0)
Damien Georgeee3fd462014-05-24 23:03:12 +0100887#endif
888
Damien Georgefb510b32014-06-01 13:32:54 +0100889// Whether to support property object
890#ifndef MICROPY_PY_BUILTINS_PROPERTY
891#define MICROPY_PY_BUILTINS_PROPERTY (1)
Damien Georgeee3fd462014-05-24 23:03:12 +0100892#endif
893
Peter D. Grayb2a237d2015-03-06 14:48:14 -0500894// Whether to implement the start/stop/step attributes (readback) on
895// the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
896#ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
897#define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
898#endif
899
Damien Georged77da832018-02-14 23:17:06 +1100900// Whether to support binary ops [only (in)equality is defined] between range
901// objects. With this option disabled all range objects that are not exactly
902// the same object will compare as not-equal. With it enabled the semantics
903// match CPython and ranges are equal if they yield the same sequence of items.
904#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
905#define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
906#endif
907
stijn42863832019-01-03 15:19:42 +0100908// Support for callling next() with second argument
909#ifndef MICROPY_PY_BUILTINS_NEXT2
910#define MICROPY_PY_BUILTINS_NEXT2 (0)
911#endif
912
Jan Klusacekb318ebf2018-01-09 22:47:35 +0100913// Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
914#ifndef MICROPY_PY_BUILTINS_ROUND_INT
915#define MICROPY_PY_BUILTINS_ROUND_INT (0)
916#endif
917
Daniel Campora077812b2015-06-29 22:45:39 +0200918// Whether to support timeout exceptions (like socket.timeout)
919#ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR
920#define MICROPY_PY_BUILTINS_TIMEOUTERROR (0)
921#endif
922
Paul Sokolovsky0e80f342017-10-27 22:29:15 +0300923// Whether to support complete set of special methods for user
924// classes, or only the most used ones. "Inplace" methods are
925// controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
926// "Reverse" methods are controlled by
927// MICROPY_PY_REVERSE_SPECIAL_METHODS below.
Paul Sokolovsky98c4bc32015-01-30 01:42:49 +0200928#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
929#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
930#endif
931
Paul Sokolovsky0e80f342017-10-27 22:29:15 +0300932// Whether to support all inplace arithmetic operarion methods
933// (__imul__, etc.)
934#ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
935#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
936#endif
937
938// Whether to support reverse arithmetic operarion methods
939// (__radd__, etc.). Additionally gated by
940// MICROPY_PY_ALL_SPECIAL_METHODS.
Paul Sokolovskyeb84a832017-09-10 17:05:20 +0300941#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
942#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
943#endif
944
Damien Georgec9fc6202014-10-25 21:59:14 +0100945// Whether to support compile function
946#ifndef MICROPY_PY_BUILTINS_COMPILE
947#define MICROPY_PY_BUILTINS_COMPILE (0)
948#endif
949
Paul Sokolovskye2d44e32015-04-06 23:50:37 +0300950// Whether to support enumerate function(type)
951#ifndef MICROPY_PY_BUILTINS_ENUMERATE
952#define MICROPY_PY_BUILTINS_ENUMERATE (1)
953#endif
954
Damien Georgedd5353a2015-12-18 12:35:44 +0000955// Whether to support eval and exec functions
956// By default they are supported if the compiler is enabled
957#ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
958#define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
959#endif
960
Damien George2a3e2b92014-12-19 13:36:17 +0000961// Whether to support the Python 2 execfile function
962#ifndef MICROPY_PY_BUILTINS_EXECFILE
963#define MICROPY_PY_BUILTINS_EXECFILE (0)
964#endif
965
Paul Sokolovsky22ff3972015-08-20 01:01:56 +0300966// Whether to support filter function(type)
967#ifndef MICROPY_PY_BUILTINS_FILTER
968#define MICROPY_PY_BUILTINS_FILTER (1)
969#endif
970
Paul Sokolovsky282ca092015-04-07 00:16:51 +0300971// Whether to support reversed function(type)
972#ifndef MICROPY_PY_BUILTINS_REVERSED
973#define MICROPY_PY_BUILTINS_REVERSED (1)
974#endif
975
Paul Sokolovsky5ab5ac52015-05-04 19:45:53 +0300976// Whether to define "NotImplemented" special constant
977#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
978#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
979#endif
980
Damien Georgebc763022017-06-01 15:32:23 +1000981// Whether to provide the built-in input() function. The implementation of this
982// uses mp-readline, so can only be enabled if the port uses this readline.
983#ifndef MICROPY_PY_BUILTINS_INPUT
984#define MICROPY_PY_BUILTINS_INPUT (0)
985#endif
986
pohmelie354e6882015-12-07 15:35:48 +0300987// Whether to support min/max functions
988#ifndef MICROPY_PY_BUILTINS_MIN_MAX
989#define MICROPY_PY_BUILTINS_MIN_MAX (1)
990#endif
991
Damien Georgea19b5a02017-02-03 12:35:48 +1100992// Support for calls to pow() with 3 integer arguments
993#ifndef MICROPY_PY_BUILTINS_POW3
994#define MICROPY_PY_BUILTINS_POW3 (0)
995#endif
996
Damien George9f04dfb2017-01-21 23:17:51 +1100997// Whether to provide the help function
998#ifndef MICROPY_PY_BUILTINS_HELP
999#define MICROPY_PY_BUILTINS_HELP (0)
1000#endif
1001
1002// Use this to configure the help text shown for help(). It should be a
1003// variable with the type "const char*". A sensible default is provided.
1004#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
1005#define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
1006#endif
1007
Damien Georgef5172af2017-01-22 12:12:54 +11001008// Add the ability to list the available modules when executing help('modules')
1009#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
1010#define MICROPY_PY_BUILTINS_HELP_MODULES (0)
1011#endif
1012
Paul Sokolovskyd0f5e612014-07-25 11:00:15 +03001013// Whether to set __file__ for imported modules
1014#ifndef MICROPY_PY___FILE__
1015#define MICROPY_PY___FILE__ (1)
1016#endif
1017
Damien George89deec02015-01-09 20:12:54 +00001018// Whether to provide mem-info related functions in micropython module
1019#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
1020#define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
1021#endif
1022
Damien George7e2a4882018-02-20 18:30:22 +11001023// Whether to provide "micropython.stack_use" function
1024#ifndef MICROPY_PY_MICROPYTHON_STACK_USE
1025#define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
1026#endif
1027
Paul Sokolovskycb78f862014-06-27 20:39:09 +03001028// Whether to provide "array" module. Note that large chunk of the
1029// underlying code is shared with "bytearray" builtin type, so to
1030// get real savings, it should be disabled too.
1031#ifndef MICROPY_PY_ARRAY
1032#define MICROPY_PY_ARRAY (1)
1033#endif
1034
Paul Sokolovskycefcbb22015-02-27 22:16:05 +02001035// Whether to support slice assignments for array (and bytearray).
1036// This is rarely used, but adds ~0.5K of code.
1037#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
1038#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
1039#endif
1040
Damien George5aa311d2015-04-21 14:14:24 +00001041// Whether to support attrtuple type (MicroPython extension)
1042// It provides space-efficient tuples with attribute access
1043#ifndef MICROPY_PY_ATTRTUPLE
1044#define MICROPY_PY_ATTRTUPLE (1)
1045#endif
1046
Damien Georgeee3fd462014-05-24 23:03:12 +01001047// Whether to provide "collections" module
1048#ifndef MICROPY_PY_COLLECTIONS
1049#define MICROPY_PY_COLLECTIONS (1)
1050#endif
1051
Paul Sokolovsky970eedc2018-02-06 00:06:42 +02001052// Whether to provide "ucollections.deque" type
1053#ifndef MICROPY_PY_COLLECTIONS_DEQUE
1054#define MICROPY_PY_COLLECTIONS_DEQUE (0)
1055#endif
1056
Paul Sokolovsky0ef01d02015-03-18 01:25:04 +02001057// Whether to provide "collections.OrderedDict" type
1058#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
1059#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
1060#endif
1061
stijn79ed58f2017-11-06 12:21:53 +01001062// Whether to provide the _asdict function for namedtuple
1063#ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
1064#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0)
1065#endif
1066
Damien Georgeee3fd462014-05-24 23:03:12 +01001067// Whether to provide "math" module
1068#ifndef MICROPY_PY_MATH
1069#define MICROPY_PY_MATH (1)
1070#endif
1071
Damien George5cbeace2015-02-22 14:48:18 +00001072// Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
1073#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
1074#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
1075#endif
1076
Christopher Swenson8c656752018-08-27 10:32:21 +10001077// Whether to provide math.factorial function
1078#ifndef MICROPY_PY_MATH_FACTORIAL
1079#define MICROPY_PY_MATH_FACTORIAL (0)
1080#endif
1081
stijnaf5c9982019-07-02 10:28:44 +02001082// Whether to provide math.isclose function
1083#ifndef MICROPY_PY_MATH_ISCLOSE
1084#define MICROPY_PY_MATH_ISCLOSE (0)
1085#endif
1086
Damien Georgeee3fd462014-05-24 23:03:12 +01001087// Whether to provide "cmath" module
1088#ifndef MICROPY_PY_CMATH
1089#define MICROPY_PY_CMATH (0)
1090#endif
1091
1092// Whether to provide "gc" module
1093#ifndef MICROPY_PY_GC
1094#define MICROPY_PY_GC (1)
1095#endif
1096
Paul Sokolovsky755a55f2014-06-05 22:48:02 +03001097// Whether to return number of collected objects from gc.collect()
1098#ifndef MICROPY_PY_GC_COLLECT_RETVAL
1099#define MICROPY_PY_GC_COLLECT_RETVAL (0)
1100#endif
1101
Damien Georgeee3fd462014-05-24 23:03:12 +01001102// Whether to provide "io" module
1103#ifndef MICROPY_PY_IO
1104#define MICROPY_PY_IO (1)
1105#endif
1106
Damien Georgeaf0932a2018-06-04 15:54:26 +10001107// Whether to provide "io.IOBase" class to support user streams
1108#ifndef MICROPY_PY_IO_IOBASE
1109#define MICROPY_PY_IO_IOBASE (0)
1110#endif
1111
Paul Sokolovskyd7da2db2017-05-03 01:47:08 +03001112// Whether to provide "uio.resource_stream()" function with
1113// the semantics of CPython's pkg_resources.resource_stream()
Paul Sokolovskye7fc7652017-12-10 02:15:43 +02001114// (allows to access binary resources in frozen source packages).
1115// Note that the same functionality can be achieved in "pure
1116// Python" by prepocessing binary resources into Python source
1117// and bytecode-freezing it (with a simple helper module available
1118// e.g. in micropython-lib).
Paul Sokolovskyd7da2db2017-05-03 01:47:08 +03001119#ifndef MICROPY_PY_IO_RESOURCE_STREAM
1120#define MICROPY_PY_IO_RESOURCE_STREAM (0)
1121#endif
1122
Damien Georgeee3fd462014-05-24 23:03:12 +01001123// Whether to provide "io.FileIO" class
1124#ifndef MICROPY_PY_IO_FILEIO
1125#define MICROPY_PY_IO_FILEIO (0)
1126#endif
1127
1128// Whether to provide "io.BytesIO" class
1129#ifndef MICROPY_PY_IO_BYTESIO
1130#define MICROPY_PY_IO_BYTESIO (1)
1131#endif
1132
Paul Sokolovsky5d93dfb2016-03-25 01:10:49 +02001133// Whether to provide "io.BufferedWriter" class
1134#ifndef MICROPY_PY_IO_BUFFEREDWRITER
1135#define MICROPY_PY_IO_BUFFEREDWRITER (0)
1136#endif
1137
Damien Georgeee3fd462014-05-24 23:03:12 +01001138// Whether to provide "struct" module
1139#ifndef MICROPY_PY_STRUCT
1140#define MICROPY_PY_STRUCT (1)
1141#endif
1142
1143// Whether to provide "sys" module
1144#ifndef MICROPY_PY_SYS
1145#define MICROPY_PY_SYS (1)
1146#endif
1147
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +03001148// Whether to provide "sys.maxsize" constant
1149#ifndef MICROPY_PY_SYS_MAXSIZE
1150#define MICROPY_PY_SYS_MAXSIZE (0)
1151#endif
1152
Paul Sokolovsky1a1d11f2015-12-05 00:09:10 +02001153// Whether to provide "sys.modules" dictionary
1154#ifndef MICROPY_PY_SYS_MODULES
1155#define MICROPY_PY_SYS_MODULES (1)
1156#endif
1157
Paul Sokolovsky8b85d142015-04-25 03:17:41 +03001158// Whether to provide "sys.exc_info" function
1159// Avoid enabling this, this function is Python2 heritage
1160#ifndef MICROPY_PY_SYS_EXC_INFO
1161#define MICROPY_PY_SYS_EXC_INFO (0)
1162#endif
1163
Damien Georgeee3fd462014-05-24 23:03:12 +01001164// Whether to provide "sys.exit" function
1165#ifndef MICROPY_PY_SYS_EXIT
Paul Sokolovsky403c9302016-12-14 21:10:22 +03001166#define MICROPY_PY_SYS_EXIT (1)
Damien Georgeee3fd462014-05-24 23:03:12 +01001167#endif
1168
Milan Rossacb364702019-08-05 15:06:41 +02001169// Whether to provide "sys.atexit" function (MicroPython extension)
1170#ifndef MICROPY_PY_SYS_ATEXIT
1171#define MICROPY_PY_SYS_ATEXIT (0)
1172#endif
1173
Paul Sokolovskybfc20922017-08-11 09:42:39 +03001174// Whether to provide "sys.getsizeof" function
1175#ifndef MICROPY_PY_SYS_GETSIZEOF
1176#define MICROPY_PY_SYS_GETSIZEOF (0)
1177#endif
1178
Damien Georgeee3fd462014-05-24 23:03:12 +01001179// Whether to provide sys.{stdin,stdout,stderr} objects
1180#ifndef MICROPY_PY_SYS_STDFILES
1181#define MICROPY_PY_SYS_STDFILES (0)
Damien George3bb8bd82014-04-14 21:20:30 +01001182#endif
1183
Damien George3c4b5d42015-05-13 23:49:21 +01001184// Whether to provide sys.{stdin,stdout,stderr}.buffer object
1185// This is implemented per-port
1186#ifndef MICROPY_PY_SYS_STDIO_BUFFER
1187#define MICROPY_PY_SYS_STDIO_BUFFER (0)
1188#endif
Paul Sokolovsky82158472014-06-28 03:03:47 +03001189
Damien George596a3fe2016-05-10 10:54:25 +01001190// Whether to provide "uerrno" module
1191#ifndef MICROPY_PY_UERRNO
1192#define MICROPY_PY_UERRNO (0)
1193#endif
1194
Damien Georgef5634062017-02-22 12:53:42 +11001195// Whether to provide the uerrno.errorcode dict
1196#ifndef MICROPY_PY_UERRNO_ERRORCODE
1197#define MICROPY_PY_UERRNO_ERRORCODE (1)
1198#endif
1199
Paul Sokolovsky8f5bc3f2016-11-20 23:49:45 +03001200// Whether to provide "uselect" module (baremetal implementation)
1201#ifndef MICROPY_PY_USELECT
1202#define MICROPY_PY_USELECT (0)
1203#endif
1204
Paul Sokolovskya9728442016-10-14 20:13:02 +03001205// Whether to provide "utime" module functions implementation
1206// in terms of mp_hal_* functions.
1207#ifndef MICROPY_PY_UTIME_MP_HAL
1208#define MICROPY_PY_UTIME_MP_HAL (0)
1209#endif
1210
Paul Sokolovsky76146b32016-10-30 03:02:07 +03001211// Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
1212// functions. Should be power of two. All functions above use the same
1213// period, so if underlying hardware/API has different periods, the
1214// minimum of them should be used. The value below is the maximum value
1215// this parameter can take (corresponding to 30 bit tick values on 32-bit
1216// system).
1217#ifndef MICROPY_PY_UTIME_TICKS_PERIOD
1218#define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
1219#endif
1220
Damien George27cc0772016-04-22 22:52:33 +00001221// Whether to provide "_thread" module
1222#ifndef MICROPY_PY_THREAD
1223#define MICROPY_PY_THREAD (0)
1224#endif
1225
Damien George4cec63a2016-05-26 10:42:53 +00001226// Whether to make the VM/runtime thread-safe using a global lock
1227// If not enabled then thread safety must be provided at the Python level
1228#ifndef MICROPY_PY_THREAD_GIL
1229#define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1230#endif
1231
Damien Georgef6c22a02017-02-06 10:50:43 +11001232// Number of VM jump-loops to do before releasing the GIL.
1233// Set this to 0 to disable the divisor.
1234#ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1235#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1236#endif
1237
Paul Sokolovsky82158472014-06-28 03:03:47 +03001238// Extended modules
Paul Sokolovsky510296f2014-08-08 22:51:40 +03001239
Paul Sokolovsky82158472014-06-28 03:03:47 +03001240#ifndef MICROPY_PY_UCTYPES
1241#define MICROPY_PY_UCTYPES (0)
1242#endif
1243
Paul Sokolovsky38151f32018-10-06 23:34:58 +03001244// Whether to provide SHORT, INT, LONG, etc. types in addition to
1245// exact-bitness types like INT16, INT32, etc.
1246#ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
1247#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
1248#endif
1249
Paul Sokolovsky34162872014-10-12 08:16:34 -07001250#ifndef MICROPY_PY_UZLIB
1251#define MICROPY_PY_UZLIB (0)
1252#endif
1253
Damien George612045f2014-09-17 22:56:34 +01001254#ifndef MICROPY_PY_UJSON
1255#define MICROPY_PY_UJSON (0)
1256#endif
1257
Paul Sokolovskyc71e0452014-09-12 18:48:07 +03001258#ifndef MICROPY_PY_URE
1259#define MICROPY_PY_URE (0)
1260#endif
1261
Damien George7d851a22019-08-17 23:50:19 +10001262#ifndef MICROPY_PY_URE_DEBUG
1263#define MICROPY_PY_URE_DEBUG (0)
1264#endif
1265
Damien George1f864602018-05-24 13:07:42 +10001266#ifndef MICROPY_PY_URE_MATCH_GROUPS
1267#define MICROPY_PY_URE_MATCH_GROUPS (0)
1268#endif
1269
Damien George1e9b8712018-05-24 13:08:15 +10001270#ifndef MICROPY_PY_URE_MATCH_SPAN_START_END
1271#define MICROPY_PY_URE_MATCH_SPAN_START_END (0)
1272#endif
1273
Damien Georgee30a5fc2018-05-24 13:08:51 +10001274#ifndef MICROPY_PY_URE_SUB
1275#define MICROPY_PY_URE_SUB (0)
1276#endif
1277
Damien Georgef5d69792014-10-22 17:37:18 +00001278#ifndef MICROPY_PY_UHEAPQ
1279#define MICROPY_PY_UHEAPQ (0)
1280#endif
1281
Paul Sokolovskyd02f6a92016-12-22 00:29:32 +03001282// Optimized heap queue for relative timestamps
1283#ifndef MICROPY_PY_UTIMEQ
1284#define MICROPY_PY_UTIMEQ (0)
1285#endif
1286
Paul Sokolovskyf4b19c82014-11-22 01:19:13 +02001287#ifndef MICROPY_PY_UHASHLIB
1288#define MICROPY_PY_UHASHLIB (0)
1289#endif
1290
Paul Sokolovsky5fe37302018-08-19 11:58:22 +03001291#ifndef MICROPY_PY_UHASHLIB_MD5
1292#define MICROPY_PY_UHASHLIB_MD5 (0)
1293#endif
1294
Yonatan Goldschmidt66303542018-06-09 02:48:29 +03001295#ifndef MICROPY_PY_UHASHLIB_SHA1
1296#define MICROPY_PY_UHASHLIB_SHA1 (0)
1297#endif
1298
1299#ifndef MICROPY_PY_UHASHLIB_SHA256
1300#define MICROPY_PY_UHASHLIB_SHA256 (1)
1301#endif
1302
Paul Sokolovsky567bc2d2018-01-07 15:13:56 +02001303#ifndef MICROPY_PY_UCRYPTOLIB
1304#define MICROPY_PY_UCRYPTOLIB (0)
1305#endif
1306
Yonatan Goldschmidtef984362019-04-23 12:39:05 +03001307// Depends on MICROPY_PY_UCRYPTOLIB
1308#ifndef MICROPY_PY_UCRYPTOLIB_CTR
1309#define MICROPY_PY_UCRYPTOLIB_CTR (0)
1310#endif
1311
Yonatan Goldschmidt473fe452018-06-15 17:07:47 +03001312#ifndef MICROPY_PY_UCRYPTOLIB_CONSTS
1313#define MICROPY_PY_UCRYPTOLIB_CONSTS (0)
1314#endif
1315
Paul Sokolovskybfdc2052014-11-29 06:19:30 +02001316#ifndef MICROPY_PY_UBINASCII
1317#define MICROPY_PY_UBINASCII (0)
1318#endif
1319
Paul Sokolovskyc4283672016-08-24 18:28:43 +03001320// Depends on MICROPY_PY_UZLIB
1321#ifndef MICROPY_PY_UBINASCII_CRC32
1322#define MICROPY_PY_UBINASCII_CRC32 (0)
1323#endif
1324
Paul Sokolovskya58a91e2016-01-17 12:10:28 +02001325#ifndef MICROPY_PY_URANDOM
1326#define MICROPY_PY_URANDOM (0)
1327#endif
1328
Damien Georgea53af6c2016-01-22 16:19:32 +00001329// Whether to include: randrange, randint, choice, random, uniform
1330#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
1331#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
1332#endif
1333
Paul Sokolovsky01162182015-05-03 20:25:40 +03001334#ifndef MICROPY_PY_MACHINE
1335#define MICROPY_PY_MACHINE (0)
1336#endif
1337
Damien George33168082016-05-31 14:25:19 +01001338// Whether to include: time_pulse_us
1339#ifndef MICROPY_PY_MACHINE_PULSE
1340#define MICROPY_PY_MACHINE_PULSE (0)
1341#endif
1342
Damien Georged0837122016-04-12 13:42:35 +01001343#ifndef MICROPY_PY_MACHINE_I2C
1344#define MICROPY_PY_MACHINE_I2C (0)
1345#endif
1346
Damien George0823c1b2016-09-01 15:07:20 +10001347#ifndef MICROPY_PY_MACHINE_SPI
1348#define MICROPY_PY_MACHINE_SPI (0)
1349#endif
1350
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001351#ifndef MICROPY_PY_USSL
1352#define MICROPY_PY_USSL (0)
Eric Poulsen74ec52d2017-10-26 21:17:35 -07001353// Whether to add finaliser code to ussl objects
1354#define MICROPY_PY_USSL_FINALISER (0)
Paul Sokolovskyaaa88672015-10-06 18:10:00 +03001355#endif
1356
Yonatan Goldschmidtbc4f8b42019-02-10 22:35:18 +02001357#ifndef MICROPY_PY_UWEBSOCKET
1358#define MICROPY_PY_UWEBSOCKET (0)
Paul Sokolovsky24342dd2016-03-24 19:14:12 +02001359#endif
1360
Damien George53ad6812016-04-08 11:08:37 +01001361#ifndef MICROPY_PY_FRAMEBUF
1362#define MICROPY_PY_FRAMEBUF (0)
1363#endif
1364
Paul Sokolovsky737bd9c2016-07-02 14:57:42 +03001365#ifndef MICROPY_PY_BTREE
1366#define MICROPY_PY_BTREE (0)
1367#endif
1368
Damien George58ebde42014-05-21 20:32:59 +01001369/*****************************************************************************/
1370/* Hooks for a port to add builtins */
1371
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001372// Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001373#ifndef MICROPY_PORT_BUILTINS
1374#define MICROPY_PORT_BUILTINS
Paul Sokolovsky910843e2014-02-14 12:02:34 +02001375#endif
Damien Georgecaac5422014-03-25 14:18:18 +00001376
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001377// Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format.
Damien George58ebde42014-05-21 20:32:59 +01001378#ifndef MICROPY_PORT_BUILTIN_MODULES
1379#define MICROPY_PORT_BUILTIN_MODULES
Damien Georgecaac5422014-03-25 14:18:18 +00001380#endif
1381
Yonatan Goldschmidt343401c2019-02-03 21:24:16 +02001382// Any module weak links - see objmodule.c:mp_builtin_module_weak_links_table.
Damien Georgec14a8162014-10-12 11:46:04 +01001383#ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1384#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1385#endif
1386
Damien George57e99eb2014-04-10 22:42:11 +01001387// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
Damien George58ebde42014-05-21 20:32:59 +01001388#ifndef MICROPY_PORT_CONSTANTS
1389#define MICROPY_PORT_CONSTANTS
Damien George57e99eb2014-04-10 22:42:11 +01001390#endif
1391
Damien Georgeb4b10fd2015-01-01 23:30:53 +00001392// Any root pointers for GC scanning - see mpstate.c
1393#ifndef MICROPY_PORT_ROOT_POINTERS
1394#define MICROPY_PORT_ROOT_POINTERS
1395#endif
1396
Damien George136f6752014-01-07 14:54:15 +00001397/*****************************************************************************/
1398/* Miscellaneous settings */
1399
Damien George28631532015-02-08 13:42:00 +00001400// All uPy objects in ROM must be aligned on at least a 4 byte boundary
1401// so that the small-int/qstr/pointer distinction can be made. For machines
1402// that don't do this (eg 16-bit CPU), define the following macro to something
1403// like __attribute__((aligned(4))).
1404#ifndef MICROPY_OBJ_BASE_ALIGNMENT
1405#define MICROPY_OBJ_BASE_ALIGNMENT
1406#endif
1407
Dave Hylands5b7fd202014-07-01 23:46:53 -07001408// On embedded platforms, these will typically enable/disable irqs.
1409#ifndef MICROPY_BEGIN_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001410#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001411#endif
1412#ifndef MICROPY_END_ATOMIC_SECTION
Damien George4859edb2014-10-15 17:33:24 +00001413#define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
Dave Hylands5b7fd202014-07-01 23:46:53 -07001414#endif
1415
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +02001416// Allow to override static modifier for global objects, e.g. to use with
1417// object code analysis tools which don't support static symbols.
1418#ifndef STATIC
1419#define STATIC static
1420#endif
1421
Damien George4c307bf2017-04-01 11:39:38 +11001422// Number of bytes in a word
1423#ifndef BYTES_PER_WORD
1424#define BYTES_PER_WORD (sizeof(mp_uint_t))
1425#endif
1426
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +02001427#define BITS_PER_BYTE (8)
1428#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
Damien George40f3c022014-07-03 13:25:24 +01001429// mp_int_t value with most significant bit set
1430#define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +02001431
Damien Georgea9bcd512014-10-06 13:44:59 +00001432// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1433// defined and that they are the opposite of each other.
1434#if defined(MP_ENDIANNESS_LITTLE)
1435#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1436#elif defined(MP_ENDIANNESS_BIG)
1437#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1438#else
Damien George96303762018-05-07 13:36:52 +10001439 // Endianness not defined by port so try to autodetect it.
Damien Georgea9bcd512014-10-06 13:44:59 +00001440 #if defined(__BYTE_ORDER__)
1441 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1442 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001443 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Damien Georgea9bcd512014-10-06 13:44:59 +00001444 #define MP_ENDIANNESS_LITTLE (0)
1445 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001446 #else
Damien George4e4772b2015-05-30 23:12:30 +01001447 #include <endian.h>
1448 #if defined(__BYTE_ORDER)
1449 #if __BYTE_ORDER == __LITTLE_ENDIAN
1450 #define MP_ENDIANNESS_LITTLE (1)
Damien George96303762018-05-07 13:36:52 +10001451 #elif __BYTE_ORDER == __BIG_ENDIAN
Damien George4e4772b2015-05-30 23:12:30 +01001452 #define MP_ENDIANNESS_LITTLE (0)
1453 #endif
Damien George4e4772b2015-05-30 23:12:30 +01001454 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001455 #endif
Damien George96303762018-05-07 13:36:52 +10001456 #ifndef MP_ENDIANNESS_LITTLE
1457 #error endianness not defined and cannot detect it
1458 #endif
Damien Georgea9bcd512014-10-06 13:44:59 +00001459 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
Andrew Schellercc837372014-04-14 02:39:56 +01001460#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +03001461
Damien George3c658a42014-08-24 16:28:17 +01001462// Make a pointer to RAM callable (eg set lower bit for Thumb code)
1463// (This scheme won't work if we want to mix Thumb and normal ARM code.)
1464#ifndef MICROPY_MAKE_POINTER_CALLABLE
1465#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
1466#endif
1467
Damien George7f9d1d62015-04-09 23:56:15 +01001468// If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
Damien George2127e9a2015-01-14 00:11:09 +00001469// must be somehow reachable for marking by the GC, since the native code
1470// generators store pointers to GC managed memory in the code.
Fabian Vogtb7235b82014-09-03 16:59:33 +02001471#ifndef MP_PLAT_ALLOC_EXEC
Damien George4dea9222015-04-09 15:29:54 +00001472#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 +02001473#endif
1474
1475#ifndef MP_PLAT_FREE_EXEC
1476#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
1477#endif
1478
Damien George7f9d1d62015-04-09 23:56:15 +01001479// This macro is used to do all output (except when MICROPY_PY_IO is defined)
1480#ifndef MP_PLAT_PRINT_STRN
Damien George4300c7d2015-10-15 00:05:55 +01001481#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
Damien George7f9d1d62015-04-09 23:56:15 +01001482#endif
1483
Paul Sokolovsky722e5622014-09-06 19:17:23 +03001484#ifndef MP_SSIZE_MAX
1485#define MP_SSIZE_MAX SSIZE_MAX
1486#endif
1487
Damien George40f3c022014-07-03 13:25:24 +01001488// printf format spec to use for mp_int_t and friends
Damien George136f6752014-01-07 14:54:15 +00001489#ifndef INT_FMT
stijn3baf6b52015-11-20 15:59:06 +01001490#if defined(__LP64__)
Damien George40f3c022014-07-03 13:25:24 +01001491// Archs where mp_int_t == long, long != int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001492#define UINT_FMT "%lu"
1493#define INT_FMT "%ld"
stijn3baf6b52015-11-20 15:59:06 +01001494#elif defined(_WIN64)
stijn0a4eb4d2015-12-18 10:20:33 +01001495#define UINT_FMT "%llu"
1496#define INT_FMT "%lld"
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001497#else
Damien George40f3c022014-07-03 13:25:24 +01001498// Archs where mp_int_t == int
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +02001499#define UINT_FMT "%u"
1500#define INT_FMT "%d"
1501#endif
1502#endif //INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +03001503
1504// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +02001505#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +03001506#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +02001507#endif
mux5c8db482014-06-21 17:24:55 +02001508
1509// Modifier for weak functions
1510#ifndef MP_WEAK
1511#define MP_WEAK __attribute__((weak))
1512#endif
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001513
Paul Sokolovsky0f5bf1a2016-06-15 23:52:00 +03001514// Modifier for functions which should be never inlined
1515#ifndef MP_NOINLINE
1516#define MP_NOINLINE __attribute__((noinline))
1517#endif
1518
Paul Sokolovsky1bc29112016-08-07 22:36:05 +03001519// Modifier for functions which should be always inlined
1520#ifndef MP_ALWAYSINLINE
1521#define MP_ALWAYSINLINE __attribute__((always_inline))
1522#endif
1523
Paul Sokolovsky361909e2014-12-29 00:51:06 +02001524// Condition is likely to be true, to help branch prediction
1525#ifndef MP_LIKELY
1526#define MP_LIKELY(x) __builtin_expect((x), 1)
1527#endif
1528
1529// Condition is likely to be false, to help branch prediction
1530#ifndef MP_UNLIKELY
1531#define MP_UNLIKELY(x) __builtin_expect((x), 0)
1532#endif
Damien George9ddbe292014-12-29 01:02:19 +00001533
Damien George0c80cb32019-08-19 15:50:02 +10001534// To annotate that code is unreachable
1535#ifndef MP_UNREACHABLE
1536#if defined(__GNUC__)
1537#define MP_UNREACHABLE __builtin_unreachable();
1538#else
1539#define MP_UNREACHABLE for (;;);
1540#endif
1541#endif
1542
Paul Sokolovsky1b146e92017-11-08 19:45:18 +02001543#ifndef MP_HTOBE16
1544#if MP_ENDIANNESS_LITTLE
1545# define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))
1546# define MP_BE16TOH(x) MP_HTOBE16(x)
1547#else
1548# define MP_HTOBE16(x) (x)
1549# define MP_BE16TOH(x) (x)
1550#endif
1551#endif
1552
1553#ifndef MP_HTOBE32
1554#if MP_ENDIANNESS_LITTLE
1555# define MP_HTOBE32(x) ((uint32_t)( (((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff) ))
1556# define MP_BE32TOH(x) MP_HTOBE32(x)
1557#else
1558# define MP_HTOBE32(x) (x)
1559# define MP_BE32TOH(x) (x)
1560#endif
1561#endif
1562
Paul Sokolovsky2f5d1132018-12-21 14:20:55 +03001563// Warning categories are by default implemented as strings, though
1564// hook is left for a port to define them as something else.
1565#if MICROPY_WARNINGS_CATEGORY
1566# ifndef MP_WARN_CAT
1567# define MP_WARN_CAT(x) #x
1568# endif
1569#else
1570# undef MP_WARN_CAT
1571# define MP_WARN_CAT(x) (NULL)
1572#endif
1573
Alexander Steffen299bc622017-06-29 23:14:58 +02001574#endif // MICROPY_INCLUDED_PY_MPCONFIG_H