1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2013, 2014 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 #ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
27 #define MICROPY_INCLUDED_PY_MPCONFIG_H
28 
29 // Current version of MicroPython
30 #define MICROPY_VERSION_MAJOR 1
31 #define MICROPY_VERSION_MINOR 17
32 #define MICROPY_VERSION_MICRO 0
33 
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 
46 // This file contains default configuration settings for MicroPython.
47 // You can override any of the options below using mpconfigport.h file
48 // located in a directory of your port.
49 
50 // mpconfigport.h is a file containing configuration settings for a
51 // particular port. mpconfigport.h is actually a default name for
52 // such config, and it can be overridden using MP_CONFIGFILE preprocessor
53 // 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
62 #include <mpconfigport.h>
63 #endif
64 
65 // Any options not explicitly set in mpconfigport.h will get default
66 // values below.
67 
68 /*****************************************************************************/
69 /* Object representation                                                     */
70 
71 // A MicroPython object is a machine word having the following form:
72 //  - xxxx...xxx1 : a small int, bits 1 and above are the value
73 //  - xxxx...x010 : a qstr, bits 3 and above are the value
74 //  - xxxx...x110 : an immediate object, bits 3 and above are the value
75 //  - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
76 #define MICROPY_OBJ_REPR_A (0)
77 
78 // A MicroPython object is a machine word having the following form:
79 //  - xxxx...xx01 : a small int, bits 2 and above are the value
80 //  - xxxx...x011 : a qstr, bits 3 and above are the value
81 //  - xxxx...x111 : an immediate object, bits 3 and above are the value
82 //  - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
83 #define MICROPY_OBJ_REPR_B (1)
84 
85 // A MicroPython object is a machine word having the following form (called R):
86 //  - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
87 //  - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value
88 //  - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value
89 //  - s1111111 10000000 00000000 00000010 +/- inf
90 //  - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
91 //  - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
92 //  - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
93 // Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
94 // This makes strs/immediates easier to encode/decode as they have zeros in the top 9 bits.
95 // This scheme only works with 32-bit word size and float enabled.
96 #define MICROPY_OBJ_REPR_C (2)
97 
98 // A MicroPython object is a 64-bit word having the following form (called R):
99 //  - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
100 //  - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
101 //  - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
102 //  - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
103 //  - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
104 //  - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object
105 //  - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
106 // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
107 // This makes pointers have all zeros in the top 32 bits.
108 // Small-ints and strs have 1 as LSB to make sure they don't look like pointers
109 // to the garbage collector.
110 #define MICROPY_OBJ_REPR_D (3)
111 
112 #ifndef MICROPY_OBJ_REPR
113 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
114 #endif
115 
116 // Whether to encode None/False/True as immediate objects instead of pointers to
117 // real objects.  Reduces code size by a decent amount without hurting
118 // performance, for all representations except D on some architectures.
119 #ifndef MICROPY_OBJ_IMMEDIATE_OBJS
120 #define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D)
121 #endif
122 
123 /*****************************************************************************/
124 /* Memory allocation policy                                                  */
125 
126 // Number of bytes in memory allocation/GC block. Any size allocated will be
127 // rounded up to be multiples of this.
128 #ifndef MICROPY_BYTES_PER_GC_BLOCK
129 #define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD)
130 #endif
131 
132 // Number of words allocated (in BSS) to the GC stack (minimum is 1)
133 #ifndef MICROPY_ALLOC_GC_STACK_SIZE
134 #define MICROPY_ALLOC_GC_STACK_SIZE (64)
135 #endif
136 
137 // The C-type to use for entries in the GC stack.  By default it allows the
138 // heap to be as large as the address space, but the bit-width of this type can
139 // be reduced to save memory when the heap is small enough.  The type must be
140 // big enough to index all blocks in the heap, which is set by
141 // heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK.
142 #ifndef MICROPY_GC_STACK_ENTRY_TYPE
143 #define MICROPY_GC_STACK_ENTRY_TYPE size_t
144 #endif
145 
146 // Be conservative and always clear to zero newly (re)allocated memory in the GC.
147 // This helps eliminate stray pointers that hold on to memory that's no longer
148 // used.  It decreases performance due to unnecessary memory clearing.
149 // A memory manager which always clears memory can set this to 0.
150 // TODO Do analysis to understand why some memory is not properly cleared and
151 // find a more efficient way to clear it.
152 #ifndef MICROPY_GC_CONSERVATIVE_CLEAR
153 #define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
154 #endif
155 
156 // Support automatic GC when reaching allocation threshold,
157 // configurable by gc.threshold().
158 #ifndef MICROPY_GC_ALLOC_THRESHOLD
159 #define MICROPY_GC_ALLOC_THRESHOLD (1)
160 #endif
161 
162 // Number of bytes to allocate initially when creating new chunks to store
163 // interned string data.  Smaller numbers lead to more chunks being needed
164 // and more wastage at the end of the chunk.  Larger numbers lead to wasted
165 // space at the end when no more strings need interning.
166 #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
167 #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
168 #endif
169 
170 // Initial amount for lexer indentation level
171 #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
172 #define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
173 #endif
174 
175 // Increment for lexer indentation level
176 #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
177 #define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
178 #endif
179 
180 // Initial amount for parse rule stack
181 #ifndef MICROPY_ALLOC_PARSE_RULE_INIT
182 #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
183 #endif
184 
185 // Increment for parse rule stack
186 #ifndef MICROPY_ALLOC_PARSE_RULE_INC
187 #define MICROPY_ALLOC_PARSE_RULE_INC (16)
188 #endif
189 
190 // Initial amount for parse result stack
191 #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
192 #define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
193 #endif
194 
195 // Increment for parse result stack
196 #ifndef MICROPY_ALLOC_PARSE_RESULT_INC
197 #define MICROPY_ALLOC_PARSE_RESULT_INC (16)
198 #endif
199 
200 // Strings this length or less will be interned by the parser
201 #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
202 #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
203 #endif
204 
205 // Number of bytes to allocate initially when creating new chunks to store
206 // parse nodes.  Small leads to fragmentation, large leads to excess use.
207 #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
208 #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
209 #endif
210 
211 // Initial amount for ids in a scope
212 #ifndef MICROPY_ALLOC_SCOPE_ID_INIT
213 #define MICROPY_ALLOC_SCOPE_ID_INIT (4)
214 #endif
215 
216 // Increment for ids in a scope
217 #ifndef MICROPY_ALLOC_SCOPE_ID_INC
218 #define MICROPY_ALLOC_SCOPE_ID_INC (6)
219 #endif
220 
221 // Maximum length of a path in the filesystem
222 // So we can allocate a buffer on the stack for path manipulation in import
223 #ifndef MICROPY_ALLOC_PATH_MAX
224 #define MICROPY_ALLOC_PATH_MAX (512)
225 #endif
226 
227 // Initial size of module dict
228 #ifndef MICROPY_MODULE_DICT_SIZE
229 #define MICROPY_MODULE_DICT_SIZE (1)
230 #endif
231 
232 // Initial size of sys.modules dict
233 #ifndef MICROPY_LOADED_MODULES_DICT_SIZE
234 #define MICROPY_LOADED_MODULES_DICT_SIZE (3)
235 #endif
236 
237 // Whether realloc/free should be passed allocated memory region size
238 // You must enable this if MICROPY_MEM_STATS is enabled
239 #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
240 #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
241 #endif
242 
243 // Number of bytes used to store qstr length
244 // Dictates hard limit on maximum Python identifier length, but 1 byte
245 // (limit of 255 bytes in an identifier) should be enough for everyone
246 #ifndef MICROPY_QSTR_BYTES_IN_LEN
247 #define MICROPY_QSTR_BYTES_IN_LEN (1)
248 #endif
249 
250 // Number of bytes used to store qstr hash
251 #ifndef MICROPY_QSTR_BYTES_IN_HASH
252 #define MICROPY_QSTR_BYTES_IN_HASH (2)
253 #endif
254 
255 // Avoid using C stack when making Python function calls. C stack still
256 // may be used if there's no free heap.
257 #ifndef MICROPY_STACKLESS
258 #define MICROPY_STACKLESS (0)
259 #endif
260 
261 // Never use C stack when making Python function calls. This may break
262 // testsuite as will subtly change which exception is thrown in case
263 // of too deep recursion and other similar cases.
264 #ifndef MICROPY_STACKLESS_STRICT
265 #define MICROPY_STACKLESS_STRICT (0)
266 #endif
267 
268 // Don't use alloca calls. As alloca() is not part of ANSI C, this
269 // workaround option is provided for compilers lacking this de-facto
270 // standard function. The way it works is allocating from heap, and
271 // relying on garbage collection to free it eventually. This is of
272 // course much less optimal than real alloca().
273 #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
274 #undef alloca
275 #define alloca(x) m_malloc(x)
276 #endif
277 
278 /*****************************************************************************/
279 /* MicroPython emitters                                                     */
280 
281 // Whether to support loading of persistent code
282 #ifndef MICROPY_PERSISTENT_CODE_LOAD
283 #define MICROPY_PERSISTENT_CODE_LOAD (0)
284 #endif
285 
286 // Whether to support saving of persistent code
287 #ifndef MICROPY_PERSISTENT_CODE_SAVE
288 #define MICROPY_PERSISTENT_CODE_SAVE (0)
289 #endif
290 
291 // Whether to support saving persistent code to a file via mp_raw_code_save_file
292 #ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE
293 #define MICROPY_PERSISTENT_CODE_SAVE_FILE (0)
294 #endif
295 
296 // Whether generated code can persist independently of the VM/runtime instance
297 // This is enabled automatically when needed by other features
298 #ifndef MICROPY_PERSISTENT_CODE
299 #define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
300 #endif
301 
302 // Whether to emit x64 native code
303 #ifndef MICROPY_EMIT_X64
304 #define MICROPY_EMIT_X64 (0)
305 #endif
306 
307 // Whether to emit x86 native code
308 #ifndef MICROPY_EMIT_X86
309 #define MICROPY_EMIT_X86 (0)
310 #endif
311 
312 // Whether to emit thumb native code
313 #ifndef MICROPY_EMIT_THUMB
314 #define MICROPY_EMIT_THUMB (0)
315 #endif
316 
317 // Whether to emit ARMv7-M instruction support in thumb native code
318 #ifndef MICROPY_EMIT_THUMB_ARMV7M
319 #define MICROPY_EMIT_THUMB_ARMV7M (1)
320 #endif
321 
322 // Whether to enable the thumb inline assembler
323 #ifndef MICROPY_EMIT_INLINE_THUMB
324 #define MICROPY_EMIT_INLINE_THUMB (0)
325 #endif
326 
327 // Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
328 #ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
329 #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
330 #endif
331 
332 // Whether to enable float support in the Thumb2 inline assembler
333 #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
334 #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
335 #endif
336 
337 // Whether to emit ARM native code
338 #ifndef MICROPY_EMIT_ARM
339 #define MICROPY_EMIT_ARM (0)
340 #endif
341 
342 // Whether to emit Xtensa native code
343 #ifndef MICROPY_EMIT_XTENSA
344 #define MICROPY_EMIT_XTENSA (0)
345 #endif
346 
347 // Whether to enable the Xtensa inline assembler
348 #ifndef MICROPY_EMIT_INLINE_XTENSA
349 #define MICROPY_EMIT_INLINE_XTENSA (0)
350 #endif
351 
352 // Whether to emit Xtensa-Windowed native code
353 #ifndef MICROPY_EMIT_XTENSAWIN
354 #define MICROPY_EMIT_XTENSAWIN (0)
355 #endif
356 
357 // Convenience definition for whether any native emitter is enabled
358 #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN)
359 
360 // Select prelude-as-bytes-object for certain emitters
361 #define MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ (MICROPY_EMIT_XTENSAWIN)
362 
363 // Convenience definition for whether any inline assembler emitter is enabled
364 #define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)
365 
366 // Convenience definition for whether any native or inline assembler emitter is enabled
367 #define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)
368 
369 // Whether native relocatable code loaded from .mpy files is explicitly tracked
370 // so that the GC cannot reclaim it.  Needed on architectures that allocate
371 // executable memory on the MicroPython heap and don't explicitly track this
372 // data some other way.
373 #ifndef MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE
374 #if !MICROPY_EMIT_MACHINE_CODE || defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC)
375 #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (0)
376 #else
377 #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (1)
378 #endif
379 #endif
380 
381 /*****************************************************************************/
382 /* Compiler configuration                                                    */
383 
384 // Whether to include the compiler
385 #ifndef MICROPY_ENABLE_COMPILER
386 #define MICROPY_ENABLE_COMPILER (1)
387 #endif
388 
389 // Whether the compiler is dynamically configurable (ie at runtime)
390 // This will disable the ability to execute native/viper code
391 #ifndef MICROPY_DYNAMIC_COMPILER
392 #define MICROPY_DYNAMIC_COMPILER (0)
393 #endif
394 
395 // Configure dynamic compiler macros
396 #if MICROPY_DYNAMIC_COMPILER
397 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
398 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
399 #else
400 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
401 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
402 #endif
403 
404 // Whether to enable constant folding; eg 1+2 rewritten as 3
405 #ifndef MICROPY_COMP_CONST_FOLDING
406 #define MICROPY_COMP_CONST_FOLDING (1)
407 #endif
408 
409 // Whether to enable optimisations for constant literals, eg OrderedDict
410 #ifndef MICROPY_COMP_CONST_LITERAL
411 #define MICROPY_COMP_CONST_LITERAL (1)
412 #endif
413 
414 // Whether to enable lookup of constants in modules; eg module.CONST
415 #ifndef MICROPY_COMP_MODULE_CONST
416 #define MICROPY_COMP_MODULE_CONST (0)
417 #endif
418 
419 // Whether to enable constant optimisation; id = const(value)
420 #ifndef MICROPY_COMP_CONST
421 #define MICROPY_COMP_CONST (1)
422 #endif
423 
424 // Whether to enable optimisation of: a, b = c, d
425 // Costs 124 bytes (Thumb2)
426 #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
427 #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
428 #endif
429 
430 // Whether to enable optimisation of: a, b, c = d, e, f
431 // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
432 #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
433 #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
434 #endif
435 
436 // Whether to enable optimisation of: return a if b else c
437 // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
438 #ifndef MICROPY_COMP_RETURN_IF_EXPR
439 #define MICROPY_COMP_RETURN_IF_EXPR (0)
440 #endif
441 
442 /*****************************************************************************/
443 /* Internal debugging stuff                                                  */
444 
445 // Whether to collect memory allocation stats
446 #ifndef MICROPY_MEM_STATS
447 #define MICROPY_MEM_STATS (0)
448 #endif
449 
450 // The mp_print_t printer used for debugging output
451 #ifndef MICROPY_DEBUG_PRINTER
452 #define MICROPY_DEBUG_PRINTER (&mp_plat_print)
453 #endif
454 
455 // Whether to build functions that print debugging info:
456 //   mp_bytecode_print
457 //   mp_parse_node_print
458 #ifndef MICROPY_DEBUG_PRINTERS
459 #define MICROPY_DEBUG_PRINTERS (0)
460 #endif
461 
462 // Whether to enable all debugging outputs (it will be extremely verbose)
463 #ifndef MICROPY_DEBUG_VERBOSE
464 #define MICROPY_DEBUG_VERBOSE (0)
465 #endif
466 
467 // Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
468 #ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
469 #define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
470 #endif
471 
472 // Whether to print parse rule names (rather than integers) in mp_parse_node_print
473 #ifndef MICROPY_DEBUG_PARSE_RULE_NAME
474 #define MICROPY_DEBUG_PARSE_RULE_NAME (0)
475 #endif
476 
477 // Whether to enable a simple VM stack overflow check
478 #ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
479 #define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
480 #endif
481 
482 /*****************************************************************************/
483 /* Optimisations                                                             */
484 
485 // Whether to use computed gotos in the VM, or a switch
486 // Computed gotos are roughly 10% faster, and increase VM code size by a little,
487 // e.g. ~1kiB on Cortex M4.
488 // Note: enabling this will use the gcc-specific extensions of ranged designated
489 // initialisers and addresses of labels, which are not part of the C99 standard.
490 #ifndef MICROPY_OPT_COMPUTED_GOTO
491 #define MICROPY_OPT_COMPUTED_GOTO (0)
492 #endif
493 
494 // Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
495 // STORE_ATTR bytecodes.  Uses 1 byte extra RAM for each of these opcodes and
496 // uses a bit of extra code ROM, but greatly improves lookup speed.
497 #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
498 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
499 #endif
500 
501 // Whether to use fast versions of bitwise operations (and, or, xor) when the
502 // arguments are both positive.  Increases Thumb2 code size by about 250 bytes.
503 #ifndef MICROPY_OPT_MPZ_BITWISE
504 #define MICROPY_OPT_MPZ_BITWISE (0)
505 #endif
506 
507 
508 // Whether math.factorial is large, fast and recursive (1) or small and slow (0).
509 #ifndef MICROPY_OPT_MATH_FACTORIAL
510 #define MICROPY_OPT_MATH_FACTORIAL (0)
511 #endif
512 
513 /*****************************************************************************/
514 /* Python internal features                                                  */
515 
516 // Whether to enable import of external modules
517 // When disabled, only importing of built-in modules is supported
518 // When enabled, a port must implement mp_import_stat (among other things)
519 #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
520 #define MICROPY_ENABLE_EXTERNAL_IMPORT (1)
521 #endif
522 
523 // Whether to use the POSIX reader for importing files
524 #ifndef MICROPY_READER_POSIX
525 #define MICROPY_READER_POSIX (0)
526 #endif
527 
528 // Whether to use the VFS reader for importing files
529 #ifndef MICROPY_READER_VFS
530 #define MICROPY_READER_VFS (0)
531 #endif
532 
533 // Whether any readers have been defined
534 #ifndef MICROPY_HAS_FILE_READER
535 #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
536 #endif
537 
538 // Hook for the VM at the start of the opcode loop (can contain variable
539 // definitions usable by the other hook functions)
540 #ifndef MICROPY_VM_HOOK_INIT
541 #define MICROPY_VM_HOOK_INIT
542 #endif
543 
544 // Hook for the VM during the opcode loop (but only after jump opcodes)
545 #ifndef MICROPY_VM_HOOK_LOOP
546 #define MICROPY_VM_HOOK_LOOP
547 #endif
548 
549 // Hook for the VM just before return opcode is finished being interpreted
550 #ifndef MICROPY_VM_HOOK_RETURN
551 #define MICROPY_VM_HOOK_RETURN
552 #endif
553 
554 // Hook for mp_sched_schedule when a function gets scheduled on sched_queue
555 // (this macro executes within an atomic section)
556 #ifndef MICROPY_SCHED_HOOK_SCHEDULED
557 #define MICROPY_SCHED_HOOK_SCHEDULED
558 #endif
559 
560 // Whether to include the garbage collector
561 #ifndef MICROPY_ENABLE_GC
562 #define MICROPY_ENABLE_GC (0)
563 #endif
564 
565 // Whether to enable finalisers in the garbage collector (ie call __del__)
566 #ifndef MICROPY_ENABLE_FINALISER
567 #define MICROPY_ENABLE_FINALISER (0)
568 #endif
569 
570 // Whether to enable a separate allocator for the Python stack.
571 // If enabled then the code must call mp_pystack_init before mp_init.
572 #ifndef MICROPY_ENABLE_PYSTACK
573 #define MICROPY_ENABLE_PYSTACK (0)
574 #endif
575 
576 // Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
577 #ifndef MICROPY_PYSTACK_ALIGN
578 #define MICROPY_PYSTACK_ALIGN (8)
579 #endif
580 
581 // Whether to check C stack usage. C stack used for calling Python functions,
582 // etc. Not checking means segfault on overflow.
583 #ifndef MICROPY_STACK_CHECK
584 #define MICROPY_STACK_CHECK (0)
585 #endif
586 
587 // Whether to have an emergency exception buffer
588 #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
589 #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
590 #endif
591 #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
592 #ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
593 #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)      // 0 - implies dynamic allocation
594 #endif
595 #endif
596 
597 // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
598 #ifndef MICROPY_KBD_EXCEPTION
599 #define MICROPY_KBD_EXCEPTION (0)
600 #endif
601 
602 // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
603 // handler) - if supported by a particular port.
604 #ifndef MICROPY_ASYNC_KBD_INTR
605 #define MICROPY_ASYNC_KBD_INTR (0)
606 #endif
607 
608 // Whether to include REPL helper function
609 #ifndef MICROPY_HELPER_REPL
610 #define MICROPY_HELPER_REPL (0)
611 #endif
612 
613 // Allow enabling debug prints after each REPL line
614 #ifndef MICROPY_REPL_INFO
615 #define MICROPY_REPL_INFO (0)
616 #endif
617 
618 // Whether to include emacs-style readline behavior in REPL
619 #ifndef MICROPY_REPL_EMACS_KEYS
620 #define MICROPY_REPL_EMACS_KEYS (0)
621 #endif
622 
623 // Whether to include emacs-style word movement/kill readline behavior in REPL.
624 // This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word
625 // and backward-kill-word, respectively.
626 #ifndef MICROPY_REPL_EMACS_WORDS_MOVE
627 #define MICROPY_REPL_EMACS_WORDS_MOVE (0)
628 #endif
629 
630 // Whether to include extra convenience keys for word movement/kill in readline REPL.
631 // This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word
632 // respectively. Ctrl+Delete is not implemented because it's a very different escape sequence.
633 // Depends on MICROPY_REPL_EMACS_WORDS_MOVE.
634 #ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
635 #define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (0)
636 #endif
637 
638 // Whether to implement auto-indent in REPL
639 #ifndef MICROPY_REPL_AUTO_INDENT
640 #define MICROPY_REPL_AUTO_INDENT (0)
641 #endif
642 
643 // Whether port requires event-driven REPL functions
644 #ifndef MICROPY_REPL_EVENT_DRIVEN
645 #define MICROPY_REPL_EVENT_DRIVEN (0)
646 #endif
647 
648 // Whether to include lexer helper function for unix
649 #ifndef MICROPY_HELPER_LEXER_UNIX
650 #define MICROPY_HELPER_LEXER_UNIX (0)
651 #endif
652 
653 // Long int implementation
654 #define MICROPY_LONGINT_IMPL_NONE (0)
655 #define MICROPY_LONGINT_IMPL_LONGLONG (1)
656 #define MICROPY_LONGINT_IMPL_MPZ (2)
657 
658 #ifndef MICROPY_LONGINT_IMPL
659 #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
660 #endif
661 
662 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
663 typedef long long mp_longint_impl_t;
664 #endif
665 
666 // Whether to include information in the byte code to determine source
667 // line number (increases RAM usage, but doesn't slow byte code execution)
668 #ifndef MICROPY_ENABLE_SOURCE_LINE
669 #define MICROPY_ENABLE_SOURCE_LINE (0)
670 #endif
671 
672 // Whether to include doc strings (increases RAM usage)
673 #ifndef MICROPY_ENABLE_DOC_STRING
674 #define MICROPY_ENABLE_DOC_STRING (0)
675 #endif
676 
677 // Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION)
678 #define MICROPY_ERROR_REPORTING_NONE     (0)
679 // Exception messages are short static strings
680 #define MICROPY_ERROR_REPORTING_TERSE    (1)
681 // Exception messages provide basic error details
682 #define MICROPY_ERROR_REPORTING_NORMAL   (2)
683 // Exception messages provide full info, e.g. object names
684 #define MICROPY_ERROR_REPORTING_DETAILED (3)
685 
686 #ifndef MICROPY_ERROR_REPORTING
687 #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
688 #endif
689 
690 // Whether issue warnings during compiling/execution
691 #ifndef MICROPY_WARNINGS
692 #define MICROPY_WARNINGS (0)
693 #endif
694 
695 // Whether to support warning categories
696 #ifndef MICROPY_WARNINGS_CATEGORY
697 #define MICROPY_WARNINGS_CATEGORY (0)
698 #endif
699 
700 // This macro is used when printing runtime warnings and errors
701 #ifndef MICROPY_ERROR_PRINTER
702 #define MICROPY_ERROR_PRINTER (&mp_plat_print)
703 #endif
704 
705 // Float and complex implementation
706 #define MICROPY_FLOAT_IMPL_NONE (0)
707 #define MICROPY_FLOAT_IMPL_FLOAT (1)
708 #define MICROPY_FLOAT_IMPL_DOUBLE (2)
709 
710 #ifndef MICROPY_FLOAT_IMPL
711 #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
712 #endif
713 
714 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
715 #define MICROPY_PY_BUILTINS_FLOAT (1)
716 #define MICROPY_FLOAT_CONST(x) x##F
717 #define MICROPY_FLOAT_C_FUN(fun) fun##f
718 typedef float mp_float_t;
719 #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
720 #define MICROPY_PY_BUILTINS_FLOAT (1)
721 #define MICROPY_FLOAT_CONST(x) x
722 #define MICROPY_FLOAT_C_FUN(fun) fun
723 typedef double mp_float_t;
724 #else
725 #define MICROPY_PY_BUILTINS_FLOAT (0)
726 #endif
727 
728 #ifndef MICROPY_PY_BUILTINS_COMPLEX
729 #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
730 #endif
731 
732 // Whether to provide a high-quality hash for float and complex numbers.
733 // Otherwise the default is a very simple but correct hashing function.
734 #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
735 #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
736 #endif
737 
738 // Enable features which improve CPython compatibility
739 // but may lead to more code size/memory usage.
740 // TODO: Originally intended as generic category to not
741 // add bunch of once-off options. May need refactoring later
742 #ifndef MICROPY_CPYTHON_COMPAT
743 #define MICROPY_CPYTHON_COMPAT (1)
744 #endif
745 
746 // Perform full checks as done by CPython. Disabling this
747 // may produce incorrect results, if incorrect data is fed,
748 // but should not lead to MicroPython crashes or similar
749 // grave issues (in other words, only user app should be,
750 // affected, not system).
751 #ifndef MICROPY_FULL_CHECKS
752 #define MICROPY_FULL_CHECKS (1)
753 #endif
754 
755 // Whether POSIX-semantics non-blocking streams are supported
756 #ifndef MICROPY_STREAMS_NON_BLOCK
757 #define MICROPY_STREAMS_NON_BLOCK (0)
758 #endif
759 
760 // Whether to provide stream functions with POSIX-like signatures
761 // (useful for porting existing libraries to MicroPython).
762 #ifndef MICROPY_STREAMS_POSIX_API
763 #define MICROPY_STREAMS_POSIX_API (0)
764 #endif
765 
766 // Whether to call __init__ when importing builtin modules for the first time
767 #ifndef MICROPY_MODULE_BUILTIN_INIT
768 #define MICROPY_MODULE_BUILTIN_INIT (0)
769 #endif
770 
771 // Whether to support module-level __getattr__ (see PEP 562)
772 #ifndef MICROPY_MODULE_GETATTR
773 #define MICROPY_MODULE_GETATTR (1)
774 #endif
775 
776 // Whether module weak links are supported
777 #ifndef MICROPY_MODULE_WEAK_LINKS
778 #define MICROPY_MODULE_WEAK_LINKS (0)
779 #endif
780 
781 // Whether frozen modules are supported in the form of strings
782 #ifndef MICROPY_MODULE_FROZEN_STR
783 #define MICROPY_MODULE_FROZEN_STR (0)
784 #endif
785 
786 // Whether frozen modules are supported in the form of .mpy files
787 #ifndef MICROPY_MODULE_FROZEN_MPY
788 #define MICROPY_MODULE_FROZEN_MPY (0)
789 #endif
790 
791 // Convenience macro for whether frozen modules are supported
792 #ifndef MICROPY_MODULE_FROZEN
793 #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
794 #endif
795 
796 // Whether you can override builtins in the builtins module
797 #ifndef MICROPY_CAN_OVERRIDE_BUILTINS
798 #define MICROPY_CAN_OVERRIDE_BUILTINS (0)
799 #endif
800 
801 // Whether to check that the "self" argument of a builtin method has the
802 // correct type.  Such an explicit check is only needed if a builtin
803 // method escapes to Python land without a first argument, eg
804 // list.append([], 1).  Without this check such calls will have undefined
805 // behaviour (usually segfault) if the first argument is the wrong type.
806 #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
807 #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
808 #endif
809 
810 // Whether to use internally defined errno's (otherwise system provided ones)
811 #ifndef MICROPY_USE_INTERNAL_ERRNO
812 #define MICROPY_USE_INTERNAL_ERRNO (0)
813 #endif
814 
815 // Whether to use internally defined *printf() functions (otherwise external ones)
816 #ifndef MICROPY_USE_INTERNAL_PRINTF
817 #define MICROPY_USE_INTERNAL_PRINTF (1)
818 #endif
819 
820 // Support for internal scheduler
821 #ifndef MICROPY_ENABLE_SCHEDULER
822 #define MICROPY_ENABLE_SCHEDULER (0)
823 #endif
824 
825 // Maximum number of entries in the scheduler
826 #ifndef MICROPY_SCHEDULER_DEPTH
827 #define MICROPY_SCHEDULER_DEPTH (4)
828 #endif
829 
830 // Support for generic VFS sub-system
831 #ifndef MICROPY_VFS
832 #define MICROPY_VFS (0)
833 #endif
834 
835 // Support for VFS POSIX component, to mount a POSIX filesystem within VFS
836 #ifndef MICROPY_VFS
837 #define MICROPY_VFS_POSIX (0)
838 #endif
839 
840 // Support for VFS FAT component, to mount a FAT filesystem within VFS
841 #ifndef MICROPY_VFS
842 #define MICROPY_VFS_FAT (0)
843 #endif
844 
845 /*****************************************************************************/
846 /* Fine control over Python builtins, classes, modules, etc                  */
847 
848 // Whether to support multiple inheritance of Python classes.  Multiple
849 // inheritance makes some C functions inherently recursive, and adds a bit of
850 // code overhead.
851 #ifndef MICROPY_MULTIPLE_INHERITANCE
852 #define MICROPY_MULTIPLE_INHERITANCE (1)
853 #endif
854 
855 // Whether to implement attributes on functions
856 #ifndef MICROPY_PY_FUNCTION_ATTRS
857 #define MICROPY_PY_FUNCTION_ATTRS (0)
858 #endif
859 
860 // Whether to support the descriptors __get__, __set__, __delete__
861 // This costs some code size and makes load/store/delete of instance
862 // attributes slower for the classes that use this feature
863 #ifndef MICROPY_PY_DESCRIPTORS
864 #define MICROPY_PY_DESCRIPTORS (0)
865 #endif
866 
867 // Whether to support class __delattr__ and __setattr__ methods
868 // This costs some code size and makes store/delete of instance
869 // attributes slower for the classes that use this feature
870 #ifndef MICROPY_PY_DELATTR_SETATTR
871 #define MICROPY_PY_DELATTR_SETATTR (0)
872 #endif
873 
874 // Support for async/await/async for/async with
875 #ifndef MICROPY_PY_ASYNC_AWAIT
876 #define MICROPY_PY_ASYNC_AWAIT (1)
877 #endif
878 
879 // Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+)
880 #ifndef MICROPY_PY_FSTRINGS
881 #define MICROPY_PY_FSTRINGS (0)
882 #endif
883 
884 // Support for assignment expressions with := (see PEP 572, Python 3.8+)
885 #ifndef MICROPY_PY_ASSIGN_EXPR
886 #define MICROPY_PY_ASSIGN_EXPR (1)
887 #endif
888 
889 // Non-standard .pend_throw() method for generators, allowing for
890 // Future-like behavior with respect to exception handling: an
891 // exception set with .pend_throw() will activate on the next call
892 // to generator's .send() or .__next__(). (This is useful to implement
893 // async schedulers.)
894 #ifndef MICROPY_PY_GENERATOR_PEND_THROW
895 #define MICROPY_PY_GENERATOR_PEND_THROW (1)
896 #endif
897 
898 // Issue a warning when comparing str and bytes objects
899 #ifndef MICROPY_PY_STR_BYTES_CMP_WARN
900 #define MICROPY_PY_STR_BYTES_CMP_WARN (0)
901 #endif
902 
903 // Whether str object is proper unicode
904 #ifndef MICROPY_PY_BUILTINS_STR_UNICODE
905 #define MICROPY_PY_BUILTINS_STR_UNICODE (0)
906 #endif
907 
908 // Whether to check for valid UTF-8 when converting bytes to str
909 #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
910 #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
911 #endif
912 
913 // Whether str.center() method provided
914 #ifndef MICROPY_PY_BUILTINS_STR_CENTER
915 #define MICROPY_PY_BUILTINS_STR_CENTER (0)
916 #endif
917 
918 // Whether str.count() method provided
919 #ifndef MICROPY_PY_BUILTINS_STR_COUNT
920 #define MICROPY_PY_BUILTINS_STR_COUNT (1)
921 #endif
922 
923 // Whether str % (...) formatting operator provided
924 #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
925 #define MICROPY_PY_BUILTINS_STR_OP_MODULO (1)
926 #endif
927 
928 // Whether str.partition()/str.rpartition() method provided
929 #ifndef MICROPY_PY_BUILTINS_STR_PARTITION
930 #define MICROPY_PY_BUILTINS_STR_PARTITION (0)
931 #endif
932 
933 // Whether str.splitlines() method provided
934 #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
935 #define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
936 #endif
937 
938 // Whether to support bytearray object
939 #ifndef MICROPY_PY_BUILTINS_BYTEARRAY
940 #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
941 #endif
942 
943 // Whether to support dict.fromkeys() class method
944 #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
945 #define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
946 #endif
947 
948 // Whether to support memoryview object
949 #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
950 #define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
951 #endif
952 
953 // Whether to support memoryview.itemsize attribute
954 #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
955 #define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0)
956 #endif
957 
958 // Whether to support set object
959 #ifndef MICROPY_PY_BUILTINS_SET
960 #define MICROPY_PY_BUILTINS_SET (1)
961 #endif
962 
963 // Whether to support slice subscript operators and slice object
964 #ifndef MICROPY_PY_BUILTINS_SLICE
965 #define MICROPY_PY_BUILTINS_SLICE (1)
966 #endif
967 
968 // Whether to support slice attribute read access,
969 // i.e. slice.start, slice.stop, slice.step
970 #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
971 #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
972 #endif
973 
974 // Whether to support the .indices(len) method on slice objects
975 #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES
976 #define MICROPY_PY_BUILTINS_SLICE_INDICES (0)
977 #endif
978 
979 // Whether to support frozenset object
980 #ifndef MICROPY_PY_BUILTINS_FROZENSET
981 #define MICROPY_PY_BUILTINS_FROZENSET (0)
982 #endif
983 
984 // Whether to support property object
985 #ifndef MICROPY_PY_BUILTINS_PROPERTY
986 #define MICROPY_PY_BUILTINS_PROPERTY (1)
987 #endif
988 
989 // Whether to implement the start/stop/step attributes (readback) on
990 // the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
991 #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
992 #define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
993 #endif
994 
995 // Whether to support binary ops [only (in)equality is defined] between range
996 // objects.  With this option disabled all range objects that are not exactly
997 // the same object will compare as not-equal.  With it enabled the semantics
998 // match CPython and ranges are equal if they yield the same sequence of items.
999 #ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
1000 #define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
1001 #endif
1002 
1003 // Support for callling next() with second argument
1004 #ifndef MICROPY_PY_BUILTINS_NEXT2
1005 #define MICROPY_PY_BUILTINS_NEXT2 (0)
1006 #endif
1007 
1008 // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
1009 #ifndef MICROPY_PY_BUILTINS_ROUND_INT
1010 #define MICROPY_PY_BUILTINS_ROUND_INT (0)
1011 #endif
1012 
1013 // Whether to support complete set of special methods for user
1014 // classes, or only the most used ones. "Inplace" methods are
1015 // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
1016 // "Reverse" methods are controlled by
1017 // MICROPY_PY_REVERSE_SPECIAL_METHODS below.
1018 #ifndef MICROPY_PY_ALL_SPECIAL_METHODS
1019 #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
1020 #endif
1021 
1022 // Whether to support all inplace arithmetic operarion methods
1023 // (__imul__, etc.)
1024 #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
1025 #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
1026 #endif
1027 
1028 // Whether to support reverse arithmetic operarion methods
1029 // (__radd__, etc.). Additionally gated by
1030 // MICROPY_PY_ALL_SPECIAL_METHODS.
1031 #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
1032 #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
1033 #endif
1034 
1035 // Whether to support compile function
1036 #ifndef MICROPY_PY_BUILTINS_COMPILE
1037 #define MICROPY_PY_BUILTINS_COMPILE (0)
1038 #endif
1039 
1040 // Whether to support enumerate function(type)
1041 #ifndef MICROPY_PY_BUILTINS_ENUMERATE
1042 #define MICROPY_PY_BUILTINS_ENUMERATE (1)
1043 #endif
1044 
1045 // Whether to support eval and exec functions
1046 // By default they are supported if the compiler is enabled
1047 #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
1048 #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
1049 #endif
1050 
1051 // Whether to support the Python 2 execfile function
1052 #ifndef MICROPY_PY_BUILTINS_EXECFILE
1053 #define MICROPY_PY_BUILTINS_EXECFILE (0)
1054 #endif
1055 
1056 // Whether to support filter function(type)
1057 #ifndef MICROPY_PY_BUILTINS_FILTER
1058 #define MICROPY_PY_BUILTINS_FILTER (1)
1059 #endif
1060 
1061 // Whether to support reversed function(type)
1062 #ifndef MICROPY_PY_BUILTINS_REVERSED
1063 #define MICROPY_PY_BUILTINS_REVERSED (1)
1064 #endif
1065 
1066 // Whether to define "NotImplemented" special constant
1067 #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
1068 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
1069 #endif
1070 
1071 // Whether to provide the built-in input() function. The implementation of this
1072 // uses shared/readline, so can only be enabled if the port uses this readline.
1073 #ifndef MICROPY_PY_BUILTINS_INPUT
1074 #define MICROPY_PY_BUILTINS_INPUT (0)
1075 #endif
1076 
1077 // Whether to support min/max functions
1078 #ifndef MICROPY_PY_BUILTINS_MIN_MAX
1079 #define MICROPY_PY_BUILTINS_MIN_MAX (1)
1080 #endif
1081 
1082 // Support for calls to pow() with 3 integer arguments
1083 #ifndef MICROPY_PY_BUILTINS_POW3
1084 #define MICROPY_PY_BUILTINS_POW3 (0)
1085 #endif
1086 
1087 // Whether to provide the help function
1088 #ifndef MICROPY_PY_BUILTINS_HELP
1089 #define MICROPY_PY_BUILTINS_HELP (0)
1090 #endif
1091 
1092 // Use this to configure the help text shown for help().  It should be a
1093 // variable with the type "const char*".  A sensible default is provided.
1094 #ifndef MICROPY_PY_BUILTINS_HELP_TEXT
1095 #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
1096 #endif
1097 
1098 // Add the ability to list the available modules when executing help('modules')
1099 #ifndef MICROPY_PY_BUILTINS_HELP_MODULES
1100 #define MICROPY_PY_BUILTINS_HELP_MODULES (0)
1101 #endif
1102 
1103 // Whether to set __file__ for imported modules
1104 #ifndef MICROPY_PY___FILE__
1105 #define MICROPY_PY___FILE__ (1)
1106 #endif
1107 
1108 // Whether to provide mem-info related functions in micropython module
1109 #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
1110 #define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
1111 #endif
1112 
1113 // Whether to provide "micropython.stack_use" function
1114 #ifndef MICROPY_PY_MICROPYTHON_STACK_USE
1115 #define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
1116 #endif
1117 
1118 // Whether to provide the "micropython.heap_locked" function
1119 #ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED
1120 #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (0)
1121 #endif
1122 
1123 // Whether to provide "array" module. Note that large chunk of the
1124 // underlying code is shared with "bytearray" builtin type, so to
1125 // get real savings, it should be disabled too.
1126 #ifndef MICROPY_PY_ARRAY
1127 #define MICROPY_PY_ARRAY (1)
1128 #endif
1129 
1130 // Whether to support slice assignments for array (and bytearray).
1131 // This is rarely used, but adds ~0.5K of code.
1132 #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
1133 #define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
1134 #endif
1135 
1136 // Whether to support attrtuple type (MicroPython extension)
1137 // It provides space-efficient tuples with attribute access
1138 #ifndef MICROPY_PY_ATTRTUPLE
1139 #define MICROPY_PY_ATTRTUPLE (1)
1140 #endif
1141 
1142 // Whether to provide "collections" module
1143 #ifndef MICROPY_PY_COLLECTIONS
1144 #define MICROPY_PY_COLLECTIONS (1)
1145 #endif
1146 
1147 // Whether to provide "ucollections.deque" type
1148 #ifndef MICROPY_PY_COLLECTIONS_DEQUE
1149 #define MICROPY_PY_COLLECTIONS_DEQUE (0)
1150 #endif
1151 
1152 // Whether to provide "collections.OrderedDict" type
1153 #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
1154 #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
1155 #endif
1156 
1157 // Whether to provide the _asdict function for namedtuple
1158 #ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
1159 #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0)
1160 #endif
1161 
1162 // Whether to provide "math" module
1163 #ifndef MICROPY_PY_MATH
1164 #define MICROPY_PY_MATH (1)
1165 #endif
1166 
1167 // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
1168 #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
1169 #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
1170 #endif
1171 
1172 // Whether to provide math.factorial function
1173 #ifndef MICROPY_PY_MATH_FACTORIAL
1174 #define MICROPY_PY_MATH_FACTORIAL (0)
1175 #endif
1176 
1177 // Whether to provide math.isclose function
1178 #ifndef MICROPY_PY_MATH_ISCLOSE
1179 #define MICROPY_PY_MATH_ISCLOSE (0)
1180 #endif
1181 
1182 // Whether to provide fix for atan2 Inf handling.
1183 #ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN
1184 #define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0)
1185 #endif
1186 
1187 // Whether to provide fix for fmod Inf handling.
1188 #ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN
1189 #define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0)
1190 #endif
1191 
1192 // Whether to provide fix for modf negative zero handling.
1193 #ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO
1194 #define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0)
1195 #endif
1196 
1197 // Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN.
1198 #ifndef MICROPY_PY_MATH_POW_FIX_NAN
1199 #define MICROPY_PY_MATH_POW_FIX_NAN (0)
1200 #endif
1201 
1202 // Whether to provide "cmath" module
1203 #ifndef MICROPY_PY_CMATH
1204 #define MICROPY_PY_CMATH (0)
1205 #endif
1206 
1207 // Whether to provide "gc" module
1208 #ifndef MICROPY_PY_GC
1209 #define MICROPY_PY_GC (1)
1210 #endif
1211 
1212 // Whether to return number of collected objects from gc.collect()
1213 #ifndef MICROPY_PY_GC_COLLECT_RETVAL
1214 #define MICROPY_PY_GC_COLLECT_RETVAL (0)
1215 #endif
1216 
1217 // Whether to provide "io" module
1218 #ifndef MICROPY_PY_IO
1219 #define MICROPY_PY_IO (1)
1220 #endif
1221 
1222 // Whether to provide "io.IOBase" class to support user streams
1223 #ifndef MICROPY_PY_IO_IOBASE
1224 #define MICROPY_PY_IO_IOBASE (0)
1225 #endif
1226 
1227 // Whether to provide "uio.resource_stream()" function with
1228 // the semantics of CPython's pkg_resources.resource_stream()
1229 // (allows to access binary resources in frozen source packages).
1230 // Note that the same functionality can be achieved in "pure
1231 // Python" by prepocessing binary resources into Python source
1232 // and bytecode-freezing it (with a simple helper module available
1233 // e.g. in micropython-lib).
1234 #ifndef MICROPY_PY_IO_RESOURCE_STREAM
1235 #define MICROPY_PY_IO_RESOURCE_STREAM (0)
1236 #endif
1237 
1238 // Whether to provide "io.FileIO" class
1239 #ifndef MICROPY_PY_IO_FILEIO
1240 #define MICROPY_PY_IO_FILEIO (0)
1241 #endif
1242 
1243 // Whether to provide "io.BytesIO" class
1244 #ifndef MICROPY_PY_IO_BYTESIO
1245 #define MICROPY_PY_IO_BYTESIO (1)
1246 #endif
1247 
1248 // Whether to provide "io.BufferedWriter" class
1249 #ifndef MICROPY_PY_IO_BUFFEREDWRITER
1250 #define MICROPY_PY_IO_BUFFEREDWRITER (0)
1251 #endif
1252 
1253 // Whether to provide "struct" module
1254 #ifndef MICROPY_PY_STRUCT
1255 #define MICROPY_PY_STRUCT (1)
1256 #endif
1257 
1258 // Whether to provide "sys" module
1259 #ifndef MICROPY_PY_SYS
1260 #define MICROPY_PY_SYS (1)
1261 #endif
1262 
1263 // Whether to provide "sys.maxsize" constant
1264 #ifndef MICROPY_PY_SYS_MAXSIZE
1265 #define MICROPY_PY_SYS_MAXSIZE (0)
1266 #endif
1267 
1268 // Whether to provide "sys.modules" dictionary
1269 #ifndef MICROPY_PY_SYS_MODULES
1270 #define MICROPY_PY_SYS_MODULES (1)
1271 #endif
1272 
1273 // Whether to provide "sys.exc_info" function
1274 // Avoid enabling this, this function is Python2 heritage
1275 #ifndef MICROPY_PY_SYS_EXC_INFO
1276 #define MICROPY_PY_SYS_EXC_INFO (0)
1277 #endif
1278 
1279 // Whether to provide "sys.exit" function
1280 #ifndef MICROPY_PY_SYS_EXIT
1281 #define MICROPY_PY_SYS_EXIT (1)
1282 #endif
1283 
1284 // Whether to provide "sys.atexit" function (MicroPython extension)
1285 #ifndef MICROPY_PY_SYS_ATEXIT
1286 #define MICROPY_PY_SYS_ATEXIT (0)
1287 #endif
1288 
1289 // Whether to provide "sys.settrace" function
1290 #ifndef MICROPY_PY_SYS_SETTRACE
1291 #define MICROPY_PY_SYS_SETTRACE (0)
1292 #endif
1293 
1294 // Whether to provide "sys.getsizeof" function
1295 #ifndef MICROPY_PY_SYS_GETSIZEOF
1296 #define MICROPY_PY_SYS_GETSIZEOF (0)
1297 #endif
1298 
1299 // Whether to provide sys.{stdin,stdout,stderr} objects
1300 #ifndef MICROPY_PY_SYS_STDFILES
1301 #define MICROPY_PY_SYS_STDFILES (0)
1302 #endif
1303 
1304 // Whether to provide sys.{stdin,stdout,stderr}.buffer object
1305 // This is implemented per-port
1306 #ifndef MICROPY_PY_SYS_STDIO_BUFFER
1307 #define MICROPY_PY_SYS_STDIO_BUFFER (0)
1308 #endif
1309 
1310 // Whether to provide "uerrno" module
1311 #ifndef MICROPY_PY_UERRNO
1312 #define MICROPY_PY_UERRNO (0)
1313 #endif
1314 
1315 // Whether to provide the uerrno.errorcode dict
1316 #ifndef MICROPY_PY_UERRNO_ERRORCODE
1317 #define MICROPY_PY_UERRNO_ERRORCODE (1)
1318 #endif
1319 
1320 // Whether to provide "uselect" module (baremetal implementation)
1321 #ifndef MICROPY_PY_USELECT
1322 #define MICROPY_PY_USELECT (0)
1323 #endif
1324 
1325 // Whether to enable the select() function in the "uselect" module (baremetal
1326 // implementation). This is present for compatibility but can be disabled to
1327 // save space.
1328 #ifndef MICROPY_PY_USELECT_SELECT
1329 #define MICROPY_PY_USELECT_SELECT (1)
1330 #endif
1331 
1332 // Whether to provide "utime" module functions implementation
1333 // in terms of mp_hal_* functions.
1334 #ifndef MICROPY_PY_UTIME_MP_HAL
1335 #define MICROPY_PY_UTIME_MP_HAL (0)
1336 #endif
1337 
1338 // Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
1339 // functions. Should be power of two. All functions above use the same
1340 // period, so if underlying hardware/API has different periods, the
1341 // minimum of them should be used. The value below is the maximum value
1342 // this parameter can take (corresponding to 30 bit tick values on 32-bit
1343 // system).
1344 #ifndef MICROPY_PY_UTIME_TICKS_PERIOD
1345 #define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
1346 #endif
1347 
1348 // Whether to provide "_thread" module
1349 #ifndef MICROPY_PY_THREAD
1350 #define MICROPY_PY_THREAD (0)
1351 #endif
1352 
1353 // Whether to make the VM/runtime thread-safe using a global lock
1354 // If not enabled then thread safety must be provided at the Python level
1355 #ifndef MICROPY_PY_THREAD_GIL
1356 #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1357 #endif
1358 
1359 // Number of VM jump-loops to do before releasing the GIL.
1360 // Set this to 0 to disable the divisor.
1361 #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1362 #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1363 #endif
1364 
1365 // Extended modules
1366 
1367 #ifndef MICROPY_PY_UASYNCIO
1368 #define MICROPY_PY_UASYNCIO (0)
1369 #endif
1370 
1371 #ifndef MICROPY_PY_UCTYPES
1372 #define MICROPY_PY_UCTYPES (0)
1373 #endif
1374 
1375 // Whether to provide SHORT, INT, LONG, etc. types in addition to
1376 // exact-bitness types like INT16, INT32, etc.
1377 #ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
1378 #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
1379 #endif
1380 
1381 #ifndef MICROPY_PY_UZLIB
1382 #define MICROPY_PY_UZLIB (0)
1383 #endif
1384 
1385 #ifndef MICROPY_PY_UJSON
1386 #define MICROPY_PY_UJSON (0)
1387 #endif
1388 
1389 // Whether to support the "separators" argument to dump, dumps
1390 #ifndef MICROPY_PY_UJSON_SEPARATORS
1391 #define MICROPY_PY_UJSON_SEPARATORS (1)
1392 #endif
1393 
1394 #ifndef MICROPY_PY_URE
1395 #define MICROPY_PY_URE (0)
1396 #endif
1397 
1398 #ifndef MICROPY_PY_URE_DEBUG
1399 #define MICROPY_PY_URE_DEBUG (0)
1400 #endif
1401 
1402 #ifndef MICROPY_PY_URE_MATCH_GROUPS
1403 #define MICROPY_PY_URE_MATCH_GROUPS (0)
1404 #endif
1405 
1406 #ifndef MICROPY_PY_URE_MATCH_SPAN_START_END
1407 #define MICROPY_PY_URE_MATCH_SPAN_START_END (0)
1408 #endif
1409 
1410 #ifndef MICROPY_PY_URE_SUB
1411 #define MICROPY_PY_URE_SUB (0)
1412 #endif
1413 
1414 #ifndef MICROPY_PY_UHEAPQ
1415 #define MICROPY_PY_UHEAPQ (0)
1416 #endif
1417 
1418 // Optimized heap queue for relative timestamps
1419 #ifndef MICROPY_PY_UTIMEQ
1420 #define MICROPY_PY_UTIMEQ (0)
1421 #endif
1422 
1423 #ifndef MICROPY_PY_UHASHLIB
1424 #define MICROPY_PY_UHASHLIB (0)
1425 #endif
1426 
1427 #ifndef MICROPY_PY_UHASHLIB_MD5
1428 #define MICROPY_PY_UHASHLIB_MD5 (0)
1429 #endif
1430 
1431 #ifndef MICROPY_PY_UHASHLIB_SHA1
1432 #define MICROPY_PY_UHASHLIB_SHA1  (0)
1433 #endif
1434 
1435 #ifndef MICROPY_PY_UHASHLIB_SHA256
1436 #define MICROPY_PY_UHASHLIB_SHA256 (1)
1437 #endif
1438 
1439 #ifndef MICROPY_PY_UCRYPTOLIB
1440 #define MICROPY_PY_UCRYPTOLIB (0)
1441 #endif
1442 
1443 // Depends on MICROPY_PY_UCRYPTOLIB
1444 #ifndef MICROPY_PY_UCRYPTOLIB_CTR
1445 #define MICROPY_PY_UCRYPTOLIB_CTR (0)
1446 #endif
1447 
1448 #ifndef MICROPY_PY_UCRYPTOLIB_CONSTS
1449 #define MICROPY_PY_UCRYPTOLIB_CONSTS (0)
1450 #endif
1451 
1452 #ifndef MICROPY_PY_UBINASCII
1453 #define MICROPY_PY_UBINASCII (0)
1454 #endif
1455 
1456 // Depends on MICROPY_PY_UZLIB
1457 #ifndef MICROPY_PY_UBINASCII_CRC32
1458 #define MICROPY_PY_UBINASCII_CRC32 (0)
1459 #endif
1460 
1461 #ifndef MICROPY_PY_URANDOM
1462 #define MICROPY_PY_URANDOM (0)
1463 #endif
1464 
1465 // Whether to include: randrange, randint, choice, random, uniform
1466 #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
1467 #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
1468 #endif
1469 
1470 #ifndef MICROPY_PY_MACHINE
1471 #define MICROPY_PY_MACHINE (0)
1472 #endif
1473 
1474 // Whether to include: bitstream
1475 #ifndef MICROPY_PY_MACHINE_BITSTREAM
1476 #define MICROPY_PY_MACHINE_BITSTREAM (0)
1477 #endif
1478 
1479 // Whether to include: time_pulse_us
1480 #ifndef MICROPY_PY_MACHINE_PULSE
1481 #define MICROPY_PY_MACHINE_PULSE (0)
1482 #endif
1483 
1484 #ifndef MICROPY_PY_MACHINE_I2C
1485 #define MICROPY_PY_MACHINE_I2C (0)
1486 #endif
1487 
1488 #ifndef MICROPY_PY_MACHINE_SPI
1489 #define MICROPY_PY_MACHINE_SPI (0)
1490 #endif
1491 
1492 #ifndef MICROPY_PY_USSL
1493 #define MICROPY_PY_USSL (0)
1494 // Whether to add finaliser code to ussl objects
1495 #define MICROPY_PY_USSL_FINALISER (0)
1496 #endif
1497 
1498 #ifndef MICROPY_PY_UWEBSOCKET
1499 #define MICROPY_PY_UWEBSOCKET (0)
1500 #endif
1501 
1502 #ifndef MICROPY_PY_FRAMEBUF
1503 #define MICROPY_PY_FRAMEBUF (0)
1504 #endif
1505 
1506 #ifndef MICROPY_PY_BTREE
1507 #define MICROPY_PY_BTREE (0)
1508 #endif
1509 
1510 /*****************************************************************************/
1511 /* Hooks for a port to add builtins                                          */
1512 
1513 // Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
1514 #ifndef MICROPY_PORT_BUILTINS
1515 #define MICROPY_PORT_BUILTINS
1516 #endif
1517 
1518 // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format.
1519 #ifndef MICROPY_PORT_BUILTIN_MODULES
1520 #define MICROPY_PORT_BUILTIN_MODULES
1521 #endif
1522 
1523 // Additional constant definitions for the compiler - see compile.c:mp_constants_table.
1524 #ifndef MICROPY_PORT_CONSTANTS
1525 #define MICROPY_PORT_CONSTANTS
1526 #endif
1527 
1528 // Any root pointers for GC scanning - see mpstate.c
1529 #ifndef MICROPY_PORT_ROOT_POINTERS
1530 #define MICROPY_PORT_ROOT_POINTERS
1531 #endif
1532 
1533 /*****************************************************************************/
1534 /* Hooks for a port to wrap functions with attributes                        */
1535 
1536 #ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION
1537 #define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f
1538 #endif
1539 
1540 #ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT
1541 #define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f
1542 #endif
1543 
1544 #ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE
1545 #define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f
1546 #endif
1547 
1548 /*****************************************************************************/
1549 /* Miscellaneous settings                                                    */
1550 
1551 // All uPy objects in ROM must be aligned on at least a 4 byte boundary
1552 // so that the small-int/qstr/pointer distinction can be made.  For machines
1553 // that don't do this (eg 16-bit CPU), define the following macro to something
1554 // like __attribute__((aligned(4))).
1555 #ifndef MICROPY_OBJ_BASE_ALIGNMENT
1556 #define MICROPY_OBJ_BASE_ALIGNMENT
1557 #endif
1558 
1559 // On embedded platforms, these will typically enable/disable irqs.
1560 #ifndef MICROPY_BEGIN_ATOMIC_SECTION
1561 #define MICROPY_BEGIN_ATOMIC_SECTION() (0)
1562 #endif
1563 #ifndef MICROPY_END_ATOMIC_SECTION
1564 #define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
1565 #endif
1566 
1567 // Allow to override static modifier for global objects, e.g. to use with
1568 // object code analysis tools which don't support static symbols.
1569 #ifndef STATIC
1570 #define STATIC static
1571 #endif
1572 
1573 // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
1574 #ifndef MP_BYTES_PER_OBJ_WORD
1575 #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
1576 #endif
1577 
1578 // Number of bits in a byte
1579 #ifndef MP_BITS_PER_BYTE
1580 #define MP_BITS_PER_BYTE (8)
1581 #endif
1582 // mp_int_t value with most significant bit set
1583 #define MP_OBJ_WORD_MSBIT_HIGH (((mp_uint_t)1) << (MP_BYTES_PER_OBJ_WORD * MP_BITS_PER_BYTE - 1))
1584 
1585 // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1586 // defined and that they are the opposite of each other.
1587 #if defined(MP_ENDIANNESS_LITTLE)
1588 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1589 #elif defined(MP_ENDIANNESS_BIG)
1590 #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1591 #else
1592 // Endianness not defined by port so try to autodetect it.
1593   #if defined(__BYTE_ORDER__)
1594     #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1595       #define MP_ENDIANNESS_LITTLE (1)
1596     #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1597       #define MP_ENDIANNESS_LITTLE (0)
1598     #endif
1599   #else
1600     #include <endian.h>
1601       #if defined(__BYTE_ORDER)
1602         #if __BYTE_ORDER == __LITTLE_ENDIAN
1603           #define MP_ENDIANNESS_LITTLE (1)
1604         #elif __BYTE_ORDER == __BIG_ENDIAN
1605           #define MP_ENDIANNESS_LITTLE (0)
1606         #endif
1607       #endif
1608   #endif
1609   #ifndef MP_ENDIANNESS_LITTLE
1610     #error endianness not defined and cannot detect it
1611   #endif
1612   #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1613 #endif
1614 
1615 // Make a pointer to RAM callable (eg set lower bit for Thumb code)
1616 // (This scheme won't work if we want to mix Thumb and normal ARM code.)
1617 #ifndef MICROPY_MAKE_POINTER_CALLABLE
1618 #define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
1619 #endif
1620 
1621 // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
1622 // must be somehow reachable for marking by the GC, since the native code
1623 // generators store pointers to GC managed memory in the code.
1624 #ifndef MP_PLAT_ALLOC_EXEC
1625 #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
1626 #endif
1627 
1628 #ifndef MP_PLAT_FREE_EXEC
1629 #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
1630 #endif
1631 
1632 // This macro is used to do all output (except when MICROPY_PY_IO is defined)
1633 #ifndef MP_PLAT_PRINT_STRN
1634 #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
1635 #endif
1636 
1637 #ifndef MP_SSIZE_MAX
1638 #define MP_SSIZE_MAX SSIZE_MAX
1639 #endif
1640 
1641 // printf format spec to use for mp_int_t and friends
1642 #ifndef INT_FMT
1643 #if defined(__LP64__)
1644 // Archs where mp_int_t == long, long != int
1645 #define UINT_FMT "%lu"
1646 #define INT_FMT "%ld"
1647 #elif defined(_WIN64)
1648 #define UINT_FMT "%llu"
1649 #define INT_FMT "%lld"
1650 #else
1651 // Archs where mp_int_t == int
1652 #define UINT_FMT "%u"
1653 #define INT_FMT "%d"
1654 #endif
1655 #endif // INT_FMT
1656 
1657 // Modifier for function which doesn't return
1658 #ifndef NORETURN
1659 #define NORETURN __attribute__((noreturn))
1660 #endif
1661 
1662 // Modifier for weak functions
1663 #ifndef MP_WEAK
1664 #define MP_WEAK __attribute__((weak))
1665 #endif
1666 
1667 // Modifier for functions which should be never inlined
1668 #ifndef MP_NOINLINE
1669 #define MP_NOINLINE __attribute__((noinline))
1670 #endif
1671 
1672 // Modifier for functions which should be always inlined
1673 #ifndef MP_ALWAYSINLINE
1674 #define MP_ALWAYSINLINE __attribute__((always_inline))
1675 #endif
1676 
1677 // Condition is likely to be true, to help branch prediction
1678 #ifndef MP_LIKELY
1679 #define MP_LIKELY(x) __builtin_expect((x), 1)
1680 #endif
1681 
1682 // Condition is likely to be false, to help branch prediction
1683 #ifndef MP_UNLIKELY
1684 #define MP_UNLIKELY(x) __builtin_expect((x), 0)
1685 #endif
1686 
1687 // To annotate that code is unreachable
1688 #ifndef MP_UNREACHABLE
1689 #if defined(__GNUC__)
1690 #define MP_UNREACHABLE __builtin_unreachable();
1691 #else
1692 #define MP_UNREACHABLE for (;;);
1693 #endif
1694 #endif
1695 
1696 // Explicitly annotate switch case fall throughs
1697 #if defined(__GNUC__) && __GNUC__ >= 7
1698 #define MP_FALLTHROUGH __attribute__((fallthrough));
1699 #else
1700 #define MP_FALLTHROUGH
1701 #endif
1702 
1703 #ifndef MP_HTOBE16
1704 #if MP_ENDIANNESS_LITTLE
1705 #define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))
1706 #define MP_BE16TOH(x) MP_HTOBE16(x)
1707 #else
1708 #define MP_HTOBE16(x) (x)
1709 #define MP_BE16TOH(x) (x)
1710 #endif
1711 #endif
1712 
1713 #ifndef MP_HTOBE32
1714 #if MP_ENDIANNESS_LITTLE
1715 #define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff)))
1716 #define MP_BE32TOH(x) MP_HTOBE32(x)
1717 #else
1718 #define MP_HTOBE32(x) (x)
1719 #define MP_BE32TOH(x) (x)
1720 #endif
1721 #endif
1722 
1723 // Warning categories are by default implemented as strings, though
1724 // hook is left for a port to define them as something else.
1725 #if MICROPY_WARNINGS_CATEGORY
1726 #ifndef MP_WARN_CAT
1727 #define MP_WARN_CAT(x) #x
1728 #endif
1729 #else
1730 #undef MP_WARN_CAT
1731 #define MP_WARN_CAT(x) (NULL)
1732 #endif
1733 
1734 // Feature dependency check.
1735 #if MICROPY_PY_SYS_SETTRACE
1736 #if !MICROPY_PERSISTENT_CODE_SAVE
1737 #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_PERSISTENT_CODE_SAVE to be enabled"
1738 #endif
1739 #if MICROPY_COMP_CONST
1740 #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_COMP_CONST to be disabled"
1741 #endif
1742 #endif
1743 
1744 #endif // MICROPY_INCLUDED_PY_MPCONFIG_H
1745