Numworks Epsilon  1.4.1
Graphing Calculator Operating System
mpconfig.h
Go to the documentation of this file.
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 // This file contains default configuration settings for MicroPython.
30 // You can override any of the options below using mpconfigport.h file
31 // located in a directory of your port.
32 
33 // mpconfigport.h is a file containing configuration settings for a
34 // particular port. mpconfigport.h is actually a default name for
35 // such config, and it can be overridden using MP_CONFIGFILE preprocessor
36 // define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
37 // argument to make when using standard MicroPython makefiles).
38 // This is useful to have more than one config per port, for example,
39 // release vs debug configs, etc. Note that if you switch from one config
40 // to another, you must rebuild from scratch using "-B" switch to make.
41 
42 #ifdef MP_CONFIGFILE
43 #include MP_CONFIGFILE
44 #else
45 #include <mpconfigport.h>
46 #endif
47 
48 // Any options not explicitly set in mpconfigport.h will get default
49 // values below.
50 
51 /*****************************************************************************/
52 /* Object representation */
53 
54 // A MicroPython object is a machine word having the following form:
55 // - xxxx...xxx1 : a small int, bits 1 and above are the value
56 // - xxxx...xx10 : a qstr, bits 2 and above are the value
57 // - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
58 #define MICROPY_OBJ_REPR_A (0)
59 
60 // A MicroPython object is a machine word having the following form:
61 // - xxxx...xx01 : a small int, bits 2 and above are the value
62 // - xxxx...xx11 : a qstr, bits 2 and above are the value
63 // - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
64 #define MICROPY_OBJ_REPR_B (1)
65 
66 // A MicroPython object is a machine word having the following form (called R):
67 // - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
68 // - 01111111 1qqqqqqq qqqqqqqq qqqqq110 str with 20-bit qstr value
69 // - s1111111 10000000 00000000 00000010 +/- inf
70 // - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
71 // - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
72 // - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
73 // Str and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
74 // This makes strs easier to encode/decode as they have zeros in the top 9 bits.
75 // This scheme only works with 32-bit word size and float enabled.
76 #define MICROPY_OBJ_REPR_C (2)
77 
78 // A MicroPython object is a 64-bit word having the following form (called R):
79 // - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
80 // - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
81 // - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
82 // - 01111111 11111101 00000000 00000000 iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
83 // - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
84 // - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
85 // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
86 // This makes pointers have all zeros in the top 32 bits.
87 // Small-ints and strs have 1 as LSB to make sure they don't look like pointers
88 // to the garbage collector.
89 #define MICROPY_OBJ_REPR_D (3)
90 
91 #ifndef MICROPY_OBJ_REPR
92 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
93 #endif
94 
95 /*****************************************************************************/
96 /* Memory allocation policy */
97 
98 // Number of bytes in memory allocation/GC block. Any size allocated will be
99 // rounded up to be multiples of this.
100 #ifndef MICROPY_BYTES_PER_GC_BLOCK
101 #define MICROPY_BYTES_PER_GC_BLOCK (4 * BYTES_PER_WORD)
102 #endif
103 
104 // Number of words allocated (in BSS) to the GC stack (minimum is 1)
105 #ifndef MICROPY_ALLOC_GC_STACK_SIZE
106 #define MICROPY_ALLOC_GC_STACK_SIZE (64)
107 #endif
108 
109 // Be conservative and always clear to zero newly (re)allocated memory in the GC.
110 // This helps eliminate stray pointers that hold on to memory that's no longer
111 // used. It decreases performance due to unnecessary memory clearing.
112 // A memory manager which always clears memory can set this to 0.
113 // TODO Do analysis to understand why some memory is not properly cleared and
114 // find a more efficient way to clear it.
115 #ifndef MICROPY_GC_CONSERVATIVE_CLEAR
116 #define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
117 #endif
118 
119 // Support automatic GC when reaching allocation threshold,
120 // configurable by gc.threshold().
121 #ifndef MICROPY_GC_ALLOC_THRESHOLD
122 #define MICROPY_GC_ALLOC_THRESHOLD (1)
123 #endif
124 
125 // Number of bytes to allocate initially when creating new chunks to store
126 // interned string data. Smaller numbers lead to more chunks being needed
127 // and more wastage at the end of the chunk. Larger numbers lead to wasted
128 // space at the end when no more strings need interning.
129 #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
130 #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
131 #endif
132 
133 // Initial amount for lexer indentation level
134 #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
135 #define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
136 #endif
137 
138 // Increment for lexer indentation level
139 #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
140 #define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
141 #endif
142 
143 // Initial amount for parse rule stack
144 #ifndef MICROPY_ALLOC_PARSE_RULE_INIT
145 #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
146 #endif
147 
148 // Increment for parse rule stack
149 #ifndef MICROPY_ALLOC_PARSE_RULE_INC
150 #define MICROPY_ALLOC_PARSE_RULE_INC (16)
151 #endif
152 
153 // Initial amount for parse result stack
154 #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
155 #define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
156 #endif
157 
158 // Increment for parse result stack
159 #ifndef MICROPY_ALLOC_PARSE_RESULT_INC
160 #define MICROPY_ALLOC_PARSE_RESULT_INC (16)
161 #endif
162 
163 // Strings this length or less will be interned by the parser
164 #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
165 #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
166 #endif
167 
168 // Number of bytes to allocate initially when creating new chunks to store
169 // parse nodes. Small leads to fragmentation, large leads to excess use.
170 #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
171 #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
172 #endif
173 
174 // Initial amount for ids in a scope
175 #ifndef MICROPY_ALLOC_SCOPE_ID_INIT
176 #define MICROPY_ALLOC_SCOPE_ID_INIT (4)
177 #endif
178 
179 // Increment for ids in a scope
180 #ifndef MICROPY_ALLOC_SCOPE_ID_INC
181 #define MICROPY_ALLOC_SCOPE_ID_INC (6)
182 #endif
183 
184 // Maximum length of a path in the filesystem
185 // So we can allocate a buffer on the stack for path manipulation in import
186 #ifndef MICROPY_ALLOC_PATH_MAX
187 #define MICROPY_ALLOC_PATH_MAX (512)
188 #endif
189 
190 // Initial size of module dict
191 #ifndef MICROPY_MODULE_DICT_SIZE
192 #define MICROPY_MODULE_DICT_SIZE (1)
193 #endif
194 
195 // Whether realloc/free should be passed allocated memory region size
196 // You must enable this if MICROPY_MEM_STATS is enabled
197 #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
198 #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
199 #endif
200 
201 // Number of bytes used to store qstr length
202 // Dictates hard limit on maximum Python identifier length, but 1 byte
203 // (limit of 255 bytes in an identifier) should be enough for everyone
204 #ifndef MICROPY_QSTR_BYTES_IN_LEN
205 #define MICROPY_QSTR_BYTES_IN_LEN (1)
206 #endif
207 
208 // Number of bytes used to store qstr hash
209 #ifndef MICROPY_QSTR_BYTES_IN_HASH
210 #define MICROPY_QSTR_BYTES_IN_HASH (2)
211 #endif
212 
213 // Avoid using C stack when making Python function calls. C stack still
214 // may be used if there's no free heap.
215 #ifndef MICROPY_STACKLESS
216 #define MICROPY_STACKLESS (0)
217 #endif
218 
219 // Never use C stack when making Python function calls. This may break
220 // testsuite as will subtly change which exception is thrown in case
221 // of too deep recursion and other similar cases.
222 #ifndef MICROPY_STACKLESS_STRICT
223 #define MICROPY_STACKLESS_STRICT (0)
224 #endif
225 
226 // Don't use alloca calls. As alloca() is not part of ANSI C, this
227 // workaround option is provided for compilers lacking this de-facto
228 // standard function. The way it works is allocating from heap, and
229 // relying on garbage collection to free it eventually. This is of
230 // course much less optimal than real alloca().
231 #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
232 #undef alloca
233 #define alloca(x) m_malloc(x)
234 #endif
235 
236 /*****************************************************************************/
237 /* MicroPython emitters */
238 
239 // Whether to support loading of persistent code
240 #ifndef MICROPY_PERSISTENT_CODE_LOAD
241 #define MICROPY_PERSISTENT_CODE_LOAD (0)
242 #endif
243 
244 // Whether to support saving of persistent code
245 #ifndef MICROPY_PERSISTENT_CODE_SAVE
246 #define MICROPY_PERSISTENT_CODE_SAVE (0)
247 #endif
248 
249 // Whether generated code can persist independently of the VM/runtime instance
250 // This is enabled automatically when needed by other features
251 #ifndef MICROPY_PERSISTENT_CODE
252 #define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
253 #endif
254 
255 // Whether to emit x64 native code
256 #ifndef MICROPY_EMIT_X64
257 #define MICROPY_EMIT_X64 (0)
258 #endif
259 
260 // Whether to emit x86 native code
261 #ifndef MICROPY_EMIT_X86
262 #define MICROPY_EMIT_X86 (0)
263 #endif
264 
265 // Whether to emit thumb native code
266 #ifndef MICROPY_EMIT_THUMB
267 #define MICROPY_EMIT_THUMB (0)
268 #endif
269 
270 // Whether to enable the thumb inline assembler
271 #ifndef MICROPY_EMIT_INLINE_THUMB
272 #define MICROPY_EMIT_INLINE_THUMB (0)
273 #endif
274 
275 // Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
276 #ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
277 #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
278 #endif
279 
280 // Whether to enable float support in the Thumb2 inline assembler
281 #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
282 #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
283 #endif
284 
285 // Whether to emit ARM native code
286 #ifndef MICROPY_EMIT_ARM
287 #define MICROPY_EMIT_ARM (0)
288 #endif
289 
290 // Whether to emit Xtensa native code
291 #ifndef MICROPY_EMIT_XTENSA
292 #define MICROPY_EMIT_XTENSA (0)
293 #endif
294 
295 // Whether to enable the Xtensa inline assembler
296 #ifndef MICROPY_EMIT_INLINE_XTENSA
297 #define MICROPY_EMIT_INLINE_XTENSA (0)
298 #endif
299 
300 // Convenience definition for whether any native emitter is enabled
301 #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA)
302 
303 // Convenience definition for whether any inline assembler emitter is enabled
304 #define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)
305 
306 /*****************************************************************************/
307 /* Compiler configuration */
308 
309 // Whether to include the compiler
310 #ifndef MICROPY_ENABLE_COMPILER
311 #define MICROPY_ENABLE_COMPILER (1)
312 #endif
313 
314 // Whether the compiler is dynamically configurable (ie at runtime)
315 #ifndef MICROPY_DYNAMIC_COMPILER
316 #define MICROPY_DYNAMIC_COMPILER (0)
317 #endif
318 
319 // Configure dynamic compiler macros
320 #if MICROPY_DYNAMIC_COMPILER
321 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
322 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
323 #else
324 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
325 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
326 #endif
327 
328 // Whether to enable constant folding; eg 1+2 rewritten as 3
329 #ifndef MICROPY_COMP_CONST_FOLDING
330 #define MICROPY_COMP_CONST_FOLDING (1)
331 #endif
332 
333 // Whether to enable lookup of constants in modules; eg module.CONST
334 #ifndef MICROPY_COMP_MODULE_CONST
335 #define MICROPY_COMP_MODULE_CONST (0)
336 #endif
337 
338 // Whether to enable constant optimisation; id = const(value)
339 #ifndef MICROPY_COMP_CONST
340 #define MICROPY_COMP_CONST (1)
341 #endif
342 
343 // Whether to enable optimisation of: a, b = c, d
344 // Costs 124 bytes (Thumb2)
345 #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
346 #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
347 #endif
348 
349 // Whether to enable optimisation of: a, b, c = d, e, f
350 // Cost 156 bytes (Thumb2)
351 #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
352 #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
353 #endif
354 
355 // Whether to enable optimisation of: return a if b else c
356 // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
357 #ifndef MICROPY_COMP_RETURN_IF_EXPR
358 #define MICROPY_COMP_RETURN_IF_EXPR (0)
359 #endif
360 
361 /*****************************************************************************/
362 /* Internal debugging stuff */
363 
364 // Whether to collect memory allocation stats
365 #ifndef MICROPY_MEM_STATS
366 #define MICROPY_MEM_STATS (0)
367 #endif
368 
369 // Whether to build functions that print debugging info:
370 // mp_bytecode_print
371 // mp_parse_node_print
372 #ifndef MICROPY_DEBUG_PRINTERS
373 #define MICROPY_DEBUG_PRINTERS (0)
374 #endif
375 
376 // Whether to enable all debugging outputs (it will be extremely verbose)
377 #ifndef MICROPY_DEBUG_VERBOSE
378 #define MICROPY_DEBUG_VERBOSE (0)
379 #endif
380 
381 /*****************************************************************************/
382 /* Optimisations */
383 
384 // Whether to use computed gotos in the VM, or a switch
385 // Computed gotos are roughly 10% faster, and increase VM code size by a little
386 // Note: enabling this will use the gcc-specific extensions of ranged designated
387 // initialisers and addresses of labels, which are not part of the C99 standard.
388 #ifndef MICROPY_OPT_COMPUTED_GOTO
389 #define MICROPY_OPT_COMPUTED_GOTO (0)
390 #endif
391 
392 // Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
393 // STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
394 // uses a bit of extra code ROM, but greatly improves lookup speed.
395 #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
396 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
397 #endif
398 
399 // Whether to use fast versions of bitwise operations (and, or, xor) when the
400 // arguments are both positive. Increases Thumb2 code size by about 250 bytes.
401 #ifndef MICROPY_OPT_MPZ_BITWISE
402 #define MICROPY_OPT_MPZ_BITWISE (0)
403 #endif
404 
405 /*****************************************************************************/
406 /* Python internal features */
407 
408 // Whether to use the POSIX reader for importing files
409 #ifndef MICROPY_READER_POSIX
410 #define MICROPY_READER_POSIX (0)
411 #endif
412 
413 // Whether to use the VFS reader for importing files
414 #ifndef MICROPY_READER_VFS
415 #define MICROPY_READER_VFS (0)
416 #endif
417 
418 // Hook for the VM at the start of the opcode loop (can contain variable
419 // definitions usable by the other hook functions)
420 #ifndef MICROPY_VM_HOOK_INIT
421 #define MICROPY_VM_HOOK_INIT
422 #endif
423 
424 // Hook for the VM during the opcode loop (but only after jump opcodes)
425 #ifndef MICROPY_VM_HOOK_LOOP
426 #define MICROPY_VM_HOOK_LOOP
427 #endif
428 
429 // Hook for the VM just before return opcode is finished being interpreted
430 #ifndef MICROPY_VM_HOOK_RETURN
431 #define MICROPY_VM_HOOK_RETURN
432 #endif
433 
434 // Whether to include the garbage collector
435 #ifndef MICROPY_ENABLE_GC
436 #define MICROPY_ENABLE_GC (0)
437 #endif
438 
439 // Whether to enable finalisers in the garbage collector (ie call __del__)
440 #ifndef MICROPY_ENABLE_FINALISER
441 #define MICROPY_ENABLE_FINALISER (0)
442 #endif
443 
444 // Whether to check C stack usage. C stack used for calling Python functions,
445 // etc. Not checking means segfault on overflow.
446 #ifndef MICROPY_STACK_CHECK
447 #define MICROPY_STACK_CHECK (0)
448 #endif
449 
450 // Whether to have an emergency exception buffer
451 #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
452 #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
453 #endif
454 #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
455 # ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
456 # define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
457 # endif
458 #endif
459 
460 // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
461 #ifndef MICROPY_KBD_EXCEPTION
462 #define MICROPY_KBD_EXCEPTION (0)
463 #endif
464 
465 // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
466 // handler) - if supported by a particular port.
467 #ifndef MICROPY_ASYNC_KBD_INTR
468 #define MICROPY_ASYNC_KBD_INTR (0)
469 #endif
470 
471 // Whether to include REPL helper function
472 #ifndef MICROPY_HELPER_REPL
473 #define MICROPY_HELPER_REPL (0)
474 #endif
475 
476 // Whether to include emacs-style readline behavior in REPL
477 #ifndef MICROPY_REPL_EMACS_KEYS
478 #define MICROPY_REPL_EMACS_KEYS (0)
479 #endif
480 
481 // Whether to implement auto-indent in REPL
482 #ifndef MICROPY_REPL_AUTO_INDENT
483 #define MICROPY_REPL_AUTO_INDENT (0)
484 #endif
485 
486 // Whether port requires event-driven REPL functions
487 #ifndef MICROPY_REPL_EVENT_DRIVEN
488 #define MICROPY_REPL_EVENT_DRIVEN (0)
489 #endif
490 
491 // Whether to include lexer helper function for unix
492 #ifndef MICROPY_HELPER_LEXER_UNIX
493 #define MICROPY_HELPER_LEXER_UNIX (0)
494 #endif
495 
496 // Long int implementation
497 #define MICROPY_LONGINT_IMPL_NONE (0)
498 #define MICROPY_LONGINT_IMPL_LONGLONG (1)
499 #define MICROPY_LONGINT_IMPL_MPZ (2)
500 
501 #ifndef MICROPY_LONGINT_IMPL
502 #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
503 #endif
504 
505 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
506 typedef long long mp_longint_impl_t;
507 #endif
508 
509 // Whether to include information in the byte code to determine source
510 // line number (increases RAM usage, but doesn't slow byte code execution)
511 #ifndef MICROPY_ENABLE_SOURCE_LINE
512 #define MICROPY_ENABLE_SOURCE_LINE (0)
513 #endif
514 
515 // Whether to include doc strings (increases RAM usage)
516 #ifndef MICROPY_ENABLE_DOC_STRING
517 #define MICROPY_ENABLE_DOC_STRING (0)
518 #endif
519 
520 // Exception messages are short static strings
521 #define MICROPY_ERROR_REPORTING_TERSE (1)
522 // Exception messages provide basic error details
523 #define MICROPY_ERROR_REPORTING_NORMAL (2)
524 // Exception messages provide full info, e.g. object names
525 #define MICROPY_ERROR_REPORTING_DETAILED (3)
526 
527 #ifndef MICROPY_ERROR_REPORTING
528 #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
529 #endif
530 
531 // Whether issue warnings during compiling/execution
532 #ifndef MICROPY_WARNINGS
533 #define MICROPY_WARNINGS (0)
534 #endif
535 
536 // This macro is used when printing runtime warnings and errors
537 #ifndef MICROPY_ERROR_PRINTER
538 #define MICROPY_ERROR_PRINTER (&mp_plat_print)
539 #endif
540 
541 // Float and complex implementation
542 #define MICROPY_FLOAT_IMPL_NONE (0)
543 #define MICROPY_FLOAT_IMPL_FLOAT (1)
544 #define MICROPY_FLOAT_IMPL_DOUBLE (2)
545 
546 #ifndef MICROPY_FLOAT_IMPL
547 #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
548 #endif
549 
550 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
551 #define MICROPY_PY_BUILTINS_FLOAT (1)
552 #define MICROPY_FLOAT_CONST(x) x##F
553 #define MICROPY_FLOAT_C_FUN(fun) fun##f
554 typedef float mp_float_t;
555 #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
556 #define MICROPY_PY_BUILTINS_FLOAT (1)
557 #define MICROPY_FLOAT_CONST(x) x
558 #define MICROPY_FLOAT_C_FUN(fun) fun
559 typedef double mp_float_t;
560 #else
561 #define MICROPY_PY_BUILTINS_FLOAT (0)
562 #endif
563 
564 #ifndef MICROPY_PY_BUILTINS_COMPLEX
565 #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
566 #endif
567 
568 // Whether to provide a high-quality hash for float and complex numbers.
569 // Otherwise the default is a very simple but correct hashing function.
570 #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
571 #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
572 #endif
573 
574 // Enable features which improve CPython compatibility
575 // but may lead to more code size/memory usage.
576 // TODO: Originally intended as generic category to not
577 // add bunch of once-off options. May need refactoring later
578 #ifndef MICROPY_CPYTHON_COMPAT
579 #define MICROPY_CPYTHON_COMPAT (1)
580 #endif
581 
582 // Perform full checks as done by CPython. Disabling this
583 // may produce incorrect results, if incorrect data is fed,
584 // but should not lead to MicroPython crashes or similar
585 // grave issues (in other words, only user app should be,
586 // affected, not system).
587 #ifndef MICROPY_FULL_CHECKS
588 #define MICROPY_FULL_CHECKS (1)
589 #endif
590 
591 // Whether POSIX-semantics non-blocking streams are supported
592 #ifndef MICROPY_STREAMS_NON_BLOCK
593 #define MICROPY_STREAMS_NON_BLOCK (0)
594 #endif
595 
596 // Whether to provide stream functions with POSIX-like signatures
597 // (useful for porting existing libraries to MicroPython).
598 #ifndef MICROPY_STREAMS_POSIX_API
599 #define MICROPY_STREAMS_POSIX_API (0)
600 #endif
601 
602 // Whether to call __init__ when importing builtin modules for the first time
603 #ifndef MICROPY_MODULE_BUILTIN_INIT
604 #define MICROPY_MODULE_BUILTIN_INIT (0)
605 #endif
606 
607 // Whether module weak links are supported
608 #ifndef MICROPY_MODULE_WEAK_LINKS
609 #define MICROPY_MODULE_WEAK_LINKS (0)
610 #endif
611 
612 // Whether frozen modules are supported in the form of strings
613 #ifndef MICROPY_MODULE_FROZEN_STR
614 #define MICROPY_MODULE_FROZEN_STR (0)
615 #endif
616 
617 // Whether frozen modules are supported in the form of .mpy files
618 #ifndef MICROPY_MODULE_FROZEN_MPY
619 #define MICROPY_MODULE_FROZEN_MPY (0)
620 #endif
621 
622 // Convenience macro for whether frozen modules are supported
623 #ifndef MICROPY_MODULE_FROZEN
624 #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
625 #endif
626 
627 // Whether you can override builtins in the builtins module
628 #ifndef MICROPY_CAN_OVERRIDE_BUILTINS
629 #define MICROPY_CAN_OVERRIDE_BUILTINS (0)
630 #endif
631 
632 // Whether to check that the "self" argument of a builtin method has the
633 // correct type. Such an explicit check is only needed if a builtin
634 // method escapes to Python land without a first argument, eg
635 // list.append([], 1). Without this check such calls will have undefined
636 // behaviour (usually segfault) if the first argument is the wrong type.
637 #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
638 #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
639 #endif
640 
641 // Whether to use internally defined errno's (otherwise system provided ones)
642 #ifndef MICROPY_USE_INTERNAL_ERRNO
643 #define MICROPY_USE_INTERNAL_ERRNO (0)
644 #endif
645 
646 // Whether to use internally defined *printf() functions (otherwise external ones)
647 #ifndef MICROPY_USE_INTERNAL_PRINTF
648 #define MICROPY_USE_INTERNAL_PRINTF (1)
649 #endif
650 
651 // Support for internal scheduler
652 #ifndef MICROPY_ENABLE_SCHEDULER
653 #define MICROPY_ENABLE_SCHEDULER (0)
654 #endif
655 
656 // Maximum number of entries in the scheduler
657 #ifndef MICROPY_SCHEDULER_DEPTH
658 #define MICROPY_SCHEDULER_DEPTH (4)
659 #endif
660 
661 // Support for generic VFS sub-system
662 #ifndef MICROPY_VFS
663 #define MICROPY_VFS (0)
664 #endif
665 
666 /*****************************************************************************/
667 /* Fine control over Python builtins, classes, modules, etc */
668 
669 // Whether to implement attributes on functions
670 #ifndef MICROPY_PY_FUNCTION_ATTRS
671 #define MICROPY_PY_FUNCTION_ATTRS (0)
672 #endif
673 
674 // Whether to support descriptors (__get__ and __set__)
675 // This costs some code size and makes all load attrs and store attrs slow
676 #ifndef MICROPY_PY_DESCRIPTORS
677 #define MICROPY_PY_DESCRIPTORS (0)
678 #endif
679 
680 // Whether to support class __delattr__ and __setattr__ methods
681 // This costs some code size and makes all del attrs and store attrs slow
682 #ifndef MICROPY_PY_DELATTR_SETATTR
683 #define MICROPY_PY_DELATTR_SETATTR (0)
684 #endif
685 
686 // Support for async/await/async for/async with
687 #ifndef MICROPY_PY_ASYNC_AWAIT
688 #define MICROPY_PY_ASYNC_AWAIT (1)
689 #endif
690 
691 // Issue a warning when comparing str and bytes objects
692 #ifndef MICROPY_PY_STR_BYTES_CMP_WARN
693 #define MICROPY_PY_STR_BYTES_CMP_WARN (0)
694 #endif
695 
696 // Whether str object is proper unicode
697 #ifndef MICROPY_PY_BUILTINS_STR_UNICODE
698 #define MICROPY_PY_BUILTINS_STR_UNICODE (0)
699 #endif
700 
701 // Whether to check for valid UTF-8 when converting bytes to str
702 #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
703 #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
704 #endif
705 
706 // Whether str.center() method provided
707 #ifndef MICROPY_PY_BUILTINS_STR_CENTER
708 #define MICROPY_PY_BUILTINS_STR_CENTER (0)
709 #endif
710 
711 // Whether str.partition()/str.rpartition() method provided
712 #ifndef MICROPY_PY_BUILTINS_STR_PARTITION
713 #define MICROPY_PY_BUILTINS_STR_PARTITION (0)
714 #endif
715 
716 // Whether str.splitlines() method provided
717 #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
718 #define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
719 #endif
720 
721 // Whether to support bytearray object
722 #ifndef MICROPY_PY_BUILTINS_BYTEARRAY
723 #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
724 #endif
725 
726 // Whether to support memoryview object
727 #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
728 #define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
729 #endif
730 
731 // Whether to support set object
732 #ifndef MICROPY_PY_BUILTINS_SET
733 #define MICROPY_PY_BUILTINS_SET (1)
734 #endif
735 
736 // Whether to support slice subscript operators and slice object
737 #ifndef MICROPY_PY_BUILTINS_SLICE
738 #define MICROPY_PY_BUILTINS_SLICE (1)
739 #endif
740 
741 // Whether to support slice attribute read access,
742 // i.e. slice.start, slice.stop, slice.step
743 #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
744 #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
745 #endif
746 
747 // Whether to support frozenset object
748 #ifndef MICROPY_PY_BUILTINS_FROZENSET
749 #define MICROPY_PY_BUILTINS_FROZENSET (0)
750 #endif
751 
752 // Whether to support property object
753 #ifndef MICROPY_PY_BUILTINS_PROPERTY
754 #define MICROPY_PY_BUILTINS_PROPERTY (1)
755 #endif
756 
757 // Whether to implement the start/stop/step attributes (readback) on
758 // the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
759 #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
760 #define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
761 #endif
762 
763 // Whether to support timeout exceptions (like socket.timeout)
764 #ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR
765 #define MICROPY_PY_BUILTINS_TIMEOUTERROR (0)
766 #endif
767 
768 // Whether to support complete set of special methods for user
769 // classes, or only the most used ones. "Inplace" methods are
770 // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
771 // "Reverse" methods are controlled by
772 // MICROPY_PY_REVERSE_SPECIAL_METHODS below.
773 #ifndef MICROPY_PY_ALL_SPECIAL_METHODS
774 #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
775 #endif
776 
777 // Whether to support all inplace arithmetic operarion methods
778 // (__imul__, etc.)
779 #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
780 #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
781 #endif
782 
783 // Whether to support reverse arithmetic operarion methods
784 // (__radd__, etc.). Additionally gated by
785 // MICROPY_PY_ALL_SPECIAL_METHODS.
786 #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
787 #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
788 #endif
789 
790 // Whether to support compile function
791 #ifndef MICROPY_PY_BUILTINS_COMPILE
792 #define MICROPY_PY_BUILTINS_COMPILE (0)
793 #endif
794 
795 // Whether to support enumerate function(type)
796 #ifndef MICROPY_PY_BUILTINS_ENUMERATE
797 #define MICROPY_PY_BUILTINS_ENUMERATE (1)
798 #endif
799 
800 // Whether to support eval and exec functions
801 // By default they are supported if the compiler is enabled
802 #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
803 #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
804 #endif
805 
806 // Whether to support the Python 2 execfile function
807 #ifndef MICROPY_PY_BUILTINS_EXECFILE
808 #define MICROPY_PY_BUILTINS_EXECFILE (0)
809 #endif
810 
811 // Whether to support filter function(type)
812 #ifndef MICROPY_PY_BUILTINS_FILTER
813 #define MICROPY_PY_BUILTINS_FILTER (1)
814 #endif
815 
816 // Whether to support reversed function(type)
817 #ifndef MICROPY_PY_BUILTINS_REVERSED
818 #define MICROPY_PY_BUILTINS_REVERSED (1)
819 #endif
820 
821 // Whether to define "NotImplemented" special constant
822 #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
823 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
824 #endif
825 
826 // Whether to provide the built-in input() function. The implementation of this
827 // uses mp-readline, so can only be enabled if the port uses this readline.
828 #ifndef MICROPY_PY_BUILTINS_INPUT
829 #define MICROPY_PY_BUILTINS_INPUT (0)
830 #endif
831 
832 // Whether to support min/max functions
833 #ifndef MICROPY_PY_BUILTINS_MIN_MAX
834 #define MICROPY_PY_BUILTINS_MIN_MAX (1)
835 #endif
836 
837 // Support for calls to pow() with 3 integer arguments
838 #ifndef MICROPY_PY_BUILTINS_POW3
839 #define MICROPY_PY_BUILTINS_POW3 (0)
840 #endif
841 
842 // Whether to provide the help function
843 #ifndef MICROPY_PY_BUILTINS_HELP
844 #define MICROPY_PY_BUILTINS_HELP (0)
845 #endif
846 
847 // Use this to configure the help text shown for help(). It should be a
848 // variable with the type "const char*". A sensible default is provided.
849 #ifndef MICROPY_PY_BUILTINS_HELP_TEXT
850 #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
851 #endif
852 
853 // Add the ability to list the available modules when executing help('modules')
854 #ifndef MICROPY_PY_BUILTINS_HELP_MODULES
855 #define MICROPY_PY_BUILTINS_HELP_MODULES (0)
856 #endif
857 
858 // Whether to set __file__ for imported modules
859 #ifndef MICROPY_PY___FILE__
860 #define MICROPY_PY___FILE__ (1)
861 #endif
862 
863 // Whether to provide mem-info related functions in micropython module
864 #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
865 #define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
866 #endif
867 
868 // Whether to provide "array" module. Note that large chunk of the
869 // underlying code is shared with "bytearray" builtin type, so to
870 // get real savings, it should be disabled too.
871 #ifndef MICROPY_PY_ARRAY
872 #define MICROPY_PY_ARRAY (1)
873 #endif
874 
875 // Whether to support slice assignments for array (and bytearray).
876 // This is rarely used, but adds ~0.5K of code.
877 #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
878 #define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
879 #endif
880 
881 // Whether to support attrtuple type (MicroPython extension)
882 // It provides space-efficient tuples with attribute access
883 #ifndef MICROPY_PY_ATTRTUPLE
884 #define MICROPY_PY_ATTRTUPLE (1)
885 #endif
886 
887 // Whether to provide "collections" module
888 #ifndef MICROPY_PY_COLLECTIONS
889 #define MICROPY_PY_COLLECTIONS (1)
890 #endif
891 
892 // Whether to provide "collections.OrderedDict" type
893 #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
894 #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
895 #endif
896 
897 // Whether to provide "math" module
898 #ifndef MICROPY_PY_MATH
899 #define MICROPY_PY_MATH (1)
900 #endif
901 
902 // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
903 #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
904 #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
905 #endif
906 
907 // Whether to provide "cmath" module
908 #ifndef MICROPY_PY_CMATH
909 #define MICROPY_PY_CMATH (0)
910 #endif
911 
912 // Whether to provide "gc" module
913 #ifndef MICROPY_PY_GC
914 #define MICROPY_PY_GC (1)
915 #endif
916 
917 // Whether to return number of collected objects from gc.collect()
918 #ifndef MICROPY_PY_GC_COLLECT_RETVAL
919 #define MICROPY_PY_GC_COLLECT_RETVAL (0)
920 #endif
921 
922 // Whether to provide "io" module
923 #ifndef MICROPY_PY_IO
924 #define MICROPY_PY_IO (1)
925 #endif
926 
927 // Whether to provide "uio.resource_stream()" function with
928 // the semantics of CPython's pkg_resources.resource_stream()
929 // (allows to access resources in frozen packages).
930 #ifndef MICROPY_PY_IO_RESOURCE_STREAM
931 #define MICROPY_PY_IO_RESOURCE_STREAM (0)
932 #endif
933 
934 // Whether to provide "io.FileIO" class
935 #ifndef MICROPY_PY_IO_FILEIO
936 #define MICROPY_PY_IO_FILEIO (0)
937 #endif
938 
939 // Whether to provide "io.BytesIO" class
940 #ifndef MICROPY_PY_IO_BYTESIO
941 #define MICROPY_PY_IO_BYTESIO (1)
942 #endif
943 
944 // Whether to provide "io.BufferedWriter" class
945 #ifndef MICROPY_PY_IO_BUFFEREDWRITER
946 #define MICROPY_PY_IO_BUFFEREDWRITER (0)
947 #endif
948 
949 // Whether to provide "struct" module
950 #ifndef MICROPY_PY_STRUCT
951 #define MICROPY_PY_STRUCT (1)
952 #endif
953 
954 // Whether to provide "sys" module
955 #ifndef MICROPY_PY_SYS
956 #define MICROPY_PY_SYS (1)
957 #endif
958 
959 // Whether to provide "sys.maxsize" constant
960 #ifndef MICROPY_PY_SYS_MAXSIZE
961 #define MICROPY_PY_SYS_MAXSIZE (0)
962 #endif
963 
964 // Whether to provide "sys.modules" dictionary
965 #ifndef MICROPY_PY_SYS_MODULES
966 #define MICROPY_PY_SYS_MODULES (1)
967 #endif
968 
969 // Whether to provide "sys.exc_info" function
970 // Avoid enabling this, this function is Python2 heritage
971 #ifndef MICROPY_PY_SYS_EXC_INFO
972 #define MICROPY_PY_SYS_EXC_INFO (0)
973 #endif
974 
975 // Whether to provide "sys.exit" function
976 #ifndef MICROPY_PY_SYS_EXIT
977 #define MICROPY_PY_SYS_EXIT (1)
978 #endif
979 
980 // Whether to provide "sys.getsizeof" function
981 #ifndef MICROPY_PY_SYS_GETSIZEOF
982 #define MICROPY_PY_SYS_GETSIZEOF (0)
983 #endif
984 
985 // Whether to provide sys.{stdin,stdout,stderr} objects
986 #ifndef MICROPY_PY_SYS_STDFILES
987 #define MICROPY_PY_SYS_STDFILES (0)
988 #endif
989 
990 // Whether to provide sys.{stdin,stdout,stderr}.buffer object
991 // This is implemented per-port
992 #ifndef MICROPY_PY_SYS_STDIO_BUFFER
993 #define MICROPY_PY_SYS_STDIO_BUFFER (0)
994 #endif
995 
996 // Whether to provide "uerrno" module
997 #ifndef MICROPY_PY_UERRNO
998 #define MICROPY_PY_UERRNO (0)
999 #endif
1000 
1001 // Whether to provide the uerrno.errorcode dict
1002 #ifndef MICROPY_PY_UERRNO_ERRORCODE
1003 #define MICROPY_PY_UERRNO_ERRORCODE (1)
1004 #endif
1005 
1006 // Whether to provide "uselect" module (baremetal implementation)
1007 #ifndef MICROPY_PY_USELECT
1008 #define MICROPY_PY_USELECT (0)
1009 #endif
1010 
1011 // Whether to provide "utime" module functions implementation
1012 // in terms of mp_hal_* functions.
1013 #ifndef MICROPY_PY_UTIME_MP_HAL
1014 #define MICROPY_PY_UTIME_MP_HAL (0)
1015 #endif
1016 
1017 // Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
1018 // functions. Should be power of two. All functions above use the same
1019 // period, so if underlying hardware/API has different periods, the
1020 // minimum of them should be used. The value below is the maximum value
1021 // this parameter can take (corresponding to 30 bit tick values on 32-bit
1022 // system).
1023 #ifndef MICROPY_PY_UTIME_TICKS_PERIOD
1024 #define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
1025 #endif
1026 
1027 // Whether to provide "_thread" module
1028 #ifndef MICROPY_PY_THREAD
1029 #define MICROPY_PY_THREAD (0)
1030 #endif
1031 
1032 // Whether to make the VM/runtime thread-safe using a global lock
1033 // If not enabled then thread safety must be provided at the Python level
1034 #ifndef MICROPY_PY_THREAD_GIL
1035 #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
1036 #endif
1037 
1038 // Number of VM jump-loops to do before releasing the GIL.
1039 // Set this to 0 to disable the divisor.
1040 #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
1041 #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
1042 #endif
1043 
1044 // Extended modules
1045 
1046 #ifndef MICROPY_PY_UCTYPES
1047 #define MICROPY_PY_UCTYPES (0)
1048 #endif
1049 
1050 #ifndef MICROPY_PY_UZLIB
1051 #define MICROPY_PY_UZLIB (0)
1052 #endif
1053 
1054 #ifndef MICROPY_PY_UJSON
1055 #define MICROPY_PY_UJSON (0)
1056 #endif
1057 
1058 #ifndef MICROPY_PY_URE
1059 #define MICROPY_PY_URE (0)
1060 #endif
1061 
1062 #ifndef MICROPY_PY_UHEAPQ
1063 #define MICROPY_PY_UHEAPQ (0)
1064 #endif
1065 
1066 // Optimized heap queue for relative timestamps
1067 #ifndef MICROPY_PY_UTIMEQ
1068 #define MICROPY_PY_UTIMEQ (0)
1069 #endif
1070 
1071 #ifndef MICROPY_PY_UHASHLIB
1072 #define MICROPY_PY_UHASHLIB (0)
1073 #endif
1074 
1075 #ifndef MICROPY_PY_UBINASCII
1076 #define MICROPY_PY_UBINASCII (0)
1077 #endif
1078 
1079 // Depends on MICROPY_PY_UZLIB
1080 #ifndef MICROPY_PY_UBINASCII_CRC32
1081 #define MICROPY_PY_UBINASCII_CRC32 (0)
1082 #endif
1083 
1084 #ifndef MICROPY_PY_URANDOM
1085 #define MICROPY_PY_URANDOM (0)
1086 #endif
1087 
1088 // Whether to include: randrange, randint, choice, random, uniform
1089 #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
1090 #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
1091 #endif
1092 
1093 #ifndef MICROPY_PY_MACHINE
1094 #define MICROPY_PY_MACHINE (0)
1095 #endif
1096 
1097 // Whether to include: time_pulse_us
1098 #ifndef MICROPY_PY_MACHINE_PULSE
1099 #define MICROPY_PY_MACHINE_PULSE (0)
1100 #endif
1101 
1102 #ifndef MICROPY_PY_MACHINE_I2C
1103 #define MICROPY_PY_MACHINE_I2C (0)
1104 #endif
1105 
1106 #ifndef MICROPY_PY_MACHINE_SPI
1107 #define MICROPY_PY_MACHINE_SPI (0)
1108 #endif
1109 
1110 #ifndef MICROPY_PY_USSL
1111 #define MICROPY_PY_USSL (0)
1112 // Whether to add finaliser code to ussl objects
1113 #define MICROPY_PY_USSL_FINALISER (0)
1114 #endif
1115 
1116 #ifndef MICROPY_PY_WEBSOCKET
1117 #define MICROPY_PY_WEBSOCKET (0)
1118 #endif
1119 
1120 #ifndef MICROPY_PY_FRAMEBUF
1121 #define MICROPY_PY_FRAMEBUF (0)
1122 #endif
1123 
1124 #ifndef MICROPY_PY_BTREE
1125 #define MICROPY_PY_BTREE (0)
1126 #endif
1127 
1128 /*****************************************************************************/
1129 /* Hooks for a port to add builtins */
1130 
1131 // Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
1132 #ifndef MICROPY_PORT_BUILTINS
1133 #define MICROPY_PORT_BUILTINS
1134 #endif
1135 
1136 // Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
1137 #ifndef MICROPY_PORT_BUILTIN_MODULES
1138 #define MICROPY_PORT_BUILTIN_MODULES
1139 #endif
1140 
1141 // Any module weak links - see builtintables.c:mp_builtin_module_weak_links_table.
1142 #ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1143 #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
1144 #endif
1145 
1146 // Additional constant definitions for the compiler - see compile.c:mp_constants_table.
1147 #ifndef MICROPY_PORT_CONSTANTS
1148 #define MICROPY_PORT_CONSTANTS
1149 #endif
1150 
1151 // Any root pointers for GC scanning - see mpstate.c
1152 #ifndef MICROPY_PORT_ROOT_POINTERS
1153 #define MICROPY_PORT_ROOT_POINTERS
1154 #endif
1155 
1156 /*****************************************************************************/
1157 /* Miscellaneous settings */
1158 
1159 // All uPy objects in ROM must be aligned on at least a 4 byte boundary
1160 // so that the small-int/qstr/pointer distinction can be made. For machines
1161 // that don't do this (eg 16-bit CPU), define the following macro to something
1162 // like __attribute__((aligned(4))).
1163 #ifndef MICROPY_OBJ_BASE_ALIGNMENT
1164 #define MICROPY_OBJ_BASE_ALIGNMENT
1165 #endif
1166 
1167 // On embedded platforms, these will typically enable/disable irqs.
1168 #ifndef MICROPY_BEGIN_ATOMIC_SECTION
1169 #define MICROPY_BEGIN_ATOMIC_SECTION() (0)
1170 #endif
1171 #ifndef MICROPY_END_ATOMIC_SECTION
1172 #define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
1173 #endif
1174 
1175 // Allow to override static modifier for global objects, e.g. to use with
1176 // object code analysis tools which don't support static symbols.
1177 #ifndef STATIC
1178 #define STATIC static
1179 #endif
1180 
1181 // Number of bytes in a word
1182 #ifndef BYTES_PER_WORD
1183 #define BYTES_PER_WORD (sizeof(mp_uint_t))
1184 #endif
1185 
1186 #define BITS_PER_BYTE (8)
1187 #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
1188 // mp_int_t value with most significant bit set
1189 #define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
1190 
1191 // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
1192 // defined and that they are the opposite of each other.
1193 #if defined(MP_ENDIANNESS_LITTLE)
1194 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1195 #elif defined(MP_ENDIANNESS_BIG)
1196 #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
1197 #else
1198  // Endiannes not defined by port so try to autodetect it.
1199  #if defined(__BYTE_ORDER__)
1200  #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1201  #define MP_ENDIANNESS_LITTLE (1)
1202  #else
1203  #define MP_ENDIANNESS_LITTLE (0)
1204  #endif
1205  #elif defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN)
1206  #define MP_ENDIANNESS_LITTLE (1)
1207  #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined (_BIG_ENDIAN)
1208  #define MP_ENDIANNESS_LITTLE (0)
1209  #else
1210  #include <endian.h>
1211  #if defined(__BYTE_ORDER)
1212  #if __BYTE_ORDER == __LITTLE_ENDIAN
1213  #define MP_ENDIANNESS_LITTLE (1)
1214  #else
1215  #define MP_ENDIANNESS_LITTLE (0)
1216  #endif
1217  #else
1218  #error endianness not defined and cannot detect it
1219  #endif
1220  #endif
1221  #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
1222 #endif
1223 
1224 // Make a pointer to RAM callable (eg set lower bit for Thumb code)
1225 // (This scheme won't work if we want to mix Thumb and normal ARM code.)
1226 #ifndef MICROPY_MAKE_POINTER_CALLABLE
1227 #define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
1228 #endif
1229 
1230 // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
1231 // must be somehow reachable for marking by the GC, since the native code
1232 // generators store pointers to GC managed memory in the code.
1233 #ifndef MP_PLAT_ALLOC_EXEC
1234 #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
1235 #endif
1236 
1237 #ifndef MP_PLAT_FREE_EXEC
1238 #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
1239 #endif
1240 
1241 // This macro is used to do all output (except when MICROPY_PY_IO is defined)
1242 #ifndef MP_PLAT_PRINT_STRN
1243 #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
1244 #endif
1245 
1246 #ifndef MP_SSIZE_MAX
1247 #define MP_SSIZE_MAX SSIZE_MAX
1248 #endif
1249 
1250 // printf format spec to use for mp_int_t and friends
1251 #ifndef INT_FMT
1252 #if defined(__LP64__)
1253 // Archs where mp_int_t == long, long != int
1254 #define UINT_FMT "%lu"
1255 #define INT_FMT "%ld"
1256 #elif defined(_WIN64)
1257 #define UINT_FMT "%llu"
1258 #define INT_FMT "%lld"
1259 #else
1260 // Archs where mp_int_t == int
1261 #define UINT_FMT "%u"
1262 #define INT_FMT "%d"
1263 #endif
1264 #endif //INT_FMT
1265 
1266 // Modifier for function which doesn't return
1267 #ifndef NORETURN
1268 #define NORETURN __attribute__((noreturn))
1269 #endif
1270 
1271 // Modifier for weak functions
1272 #ifndef MP_WEAK
1273 #define MP_WEAK __attribute__((weak))
1274 #endif
1275 
1276 // Modifier for functions which should be never inlined
1277 #ifndef MP_NOINLINE
1278 #define MP_NOINLINE __attribute__((noinline))
1279 #endif
1280 
1281 // Modifier for functions which should be always inlined
1282 #ifndef MP_ALWAYSINLINE
1283 #define MP_ALWAYSINLINE __attribute__((always_inline))
1284 #endif
1285 
1286 // Condition is likely to be true, to help branch prediction
1287 #ifndef MP_LIKELY
1288 #define MP_LIKELY(x) __builtin_expect((x), 1)
1289 #endif
1290 
1291 // Condition is likely to be false, to help branch prediction
1292 #ifndef MP_UNLIKELY
1293 #define MP_UNLIKELY(x) __builtin_expect((x), 0)
1294 #endif
1295 
1296 #endif // MICROPY_INCLUDED_PY_MPCONFIG_H