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 14 |
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 | // Note: enabling this will use the gcc-specific extensions of ranged designated |
488 | // initialisers and addresses of labels, which are not part of the C99 standard. |
489 | #ifndef MICROPY_OPT_COMPUTED_GOTO |
490 | #define MICROPY_OPT_COMPUTED_GOTO (0) |
491 | #endif |
492 | |
493 | // Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR, |
494 | // STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and |
495 | // uses a bit of extra code ROM, but greatly improves lookup speed. |
496 | #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE |
497 | #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) |
498 | #endif |
499 | |
500 | // Whether to use fast versions of bitwise operations (and, or, xor) when the |
501 | // arguments are both positive. Increases Thumb2 code size by about 250 bytes. |
502 | #ifndef MICROPY_OPT_MPZ_BITWISE |
503 | #define MICROPY_OPT_MPZ_BITWISE (0) |
504 | #endif |
505 | |
506 | |
507 | // Whether math.factorial is large, fast and recursive (1) or small and slow (0). |
508 | #ifndef MICROPY_OPT_MATH_FACTORIAL |
509 | #define MICROPY_OPT_MATH_FACTORIAL (0) |
510 | #endif |
511 | |
512 | /*****************************************************************************/ |
513 | /* Python internal features */ |
514 | |
515 | // Whether to enable import of external modules |
516 | // When disabled, only importing of built-in modules is supported |
517 | // When enabled, a port must implement mp_import_stat (among other things) |
518 | #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT |
519 | #define MICROPY_ENABLE_EXTERNAL_IMPORT (1) |
520 | #endif |
521 | |
522 | // Whether to use the POSIX reader for importing files |
523 | #ifndef MICROPY_READER_POSIX |
524 | #define MICROPY_READER_POSIX (0) |
525 | #endif |
526 | |
527 | // Whether to use the VFS reader for importing files |
528 | #ifndef MICROPY_READER_VFS |
529 | #define MICROPY_READER_VFS (0) |
530 | #endif |
531 | |
532 | // Whether any readers have been defined |
533 | #ifndef MICROPY_HAS_FILE_READER |
534 | #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS) |
535 | #endif |
536 | |
537 | // Hook for the VM at the start of the opcode loop (can contain variable |
538 | // definitions usable by the other hook functions) |
539 | #ifndef MICROPY_VM_HOOK_INIT |
540 | #define MICROPY_VM_HOOK_INIT |
541 | #endif |
542 | |
543 | // Hook for the VM during the opcode loop (but only after jump opcodes) |
544 | #ifndef MICROPY_VM_HOOK_LOOP |
545 | #define MICROPY_VM_HOOK_LOOP |
546 | #endif |
547 | |
548 | // Hook for the VM just before return opcode is finished being interpreted |
549 | #ifndef MICROPY_VM_HOOK_RETURN |
550 | #define MICROPY_VM_HOOK_RETURN |
551 | #endif |
552 | |
553 | // Whether to include the garbage collector |
554 | #ifndef MICROPY_ENABLE_GC |
555 | #define MICROPY_ENABLE_GC (0) |
556 | #endif |
557 | |
558 | // Whether to enable finalisers in the garbage collector (ie call __del__) |
559 | #ifndef MICROPY_ENABLE_FINALISER |
560 | #define MICROPY_ENABLE_FINALISER (0) |
561 | #endif |
562 | |
563 | // Whether to enable a separate allocator for the Python stack. |
564 | // If enabled then the code must call mp_pystack_init before mp_init. |
565 | #ifndef MICROPY_ENABLE_PYSTACK |
566 | #define MICROPY_ENABLE_PYSTACK (0) |
567 | #endif |
568 | |
569 | // Number of bytes that memory returned by mp_pystack_alloc will be aligned by. |
570 | #ifndef MICROPY_PYSTACK_ALIGN |
571 | #define MICROPY_PYSTACK_ALIGN (8) |
572 | #endif |
573 | |
574 | // Whether to check C stack usage. C stack used for calling Python functions, |
575 | // etc. Not checking means segfault on overflow. |
576 | #ifndef MICROPY_STACK_CHECK |
577 | #define MICROPY_STACK_CHECK (0) |
578 | #endif |
579 | |
580 | // Whether to have an emergency exception buffer |
581 | #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
582 | #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) |
583 | #endif |
584 | #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF |
585 | #ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE |
586 | #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation |
587 | #endif |
588 | #endif |
589 | |
590 | // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function |
591 | #ifndef MICROPY_KBD_EXCEPTION |
592 | #define MICROPY_KBD_EXCEPTION (0) |
593 | #endif |
594 | |
595 | // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt |
596 | // handler) - if supported by a particular port. |
597 | #ifndef MICROPY_ASYNC_KBD_INTR |
598 | #define MICROPY_ASYNC_KBD_INTR (0) |
599 | #endif |
600 | |
601 | // Whether to include REPL helper function |
602 | #ifndef MICROPY_HELPER_REPL |
603 | #define MICROPY_HELPER_REPL (0) |
604 | #endif |
605 | |
606 | // Allow enabling debug prints after each REPL line |
607 | #ifndef MICROPY_REPL_INFO |
608 | #define MICROPY_REPL_INFO (0) |
609 | #endif |
610 | |
611 | // Whether to include emacs-style readline behavior in REPL |
612 | #ifndef MICROPY_REPL_EMACS_KEYS |
613 | #define MICROPY_REPL_EMACS_KEYS (0) |
614 | #endif |
615 | |
616 | // Whether to include emacs-style word movement/kill readline behavior in REPL. |
617 | // This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word |
618 | // and backward-kill-word, respectively. |
619 | #ifndef MICROPY_REPL_EMACS_WORDS_MOVE |
620 | #define MICROPY_REPL_EMACS_WORDS_MOVE (0) |
621 | #endif |
622 | |
623 | // Whether to include extra convenience keys for word movement/kill in readline REPL. |
624 | // This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word |
625 | // respectively. Ctrl+Delete is not implemented because it's a very different escape sequence. |
626 | // Depends on MICROPY_REPL_EMACS_WORDS_MOVE. |
627 | #ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE |
628 | #define (0) |
629 | #endif |
630 | |
631 | // Whether to implement auto-indent in REPL |
632 | #ifndef MICROPY_REPL_AUTO_INDENT |
633 | #define MICROPY_REPL_AUTO_INDENT (0) |
634 | #endif |
635 | |
636 | // Whether port requires event-driven REPL functions |
637 | #ifndef MICROPY_REPL_EVENT_DRIVEN |
638 | #define MICROPY_REPL_EVENT_DRIVEN (0) |
639 | #endif |
640 | |
641 | // Whether to include lexer helper function for unix |
642 | #ifndef MICROPY_HELPER_LEXER_UNIX |
643 | #define MICROPY_HELPER_LEXER_UNIX (0) |
644 | #endif |
645 | |
646 | // Long int implementation |
647 | #define MICROPY_LONGINT_IMPL_NONE (0) |
648 | #define MICROPY_LONGINT_IMPL_LONGLONG (1) |
649 | #define MICROPY_LONGINT_IMPL_MPZ (2) |
650 | |
651 | #ifndef MICROPY_LONGINT_IMPL |
652 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) |
653 | #endif |
654 | |
655 | #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |
656 | typedef long long mp_longint_impl_t; |
657 | #endif |
658 | |
659 | // Whether to include information in the byte code to determine source |
660 | // line number (increases RAM usage, but doesn't slow byte code execution) |
661 | #ifndef MICROPY_ENABLE_SOURCE_LINE |
662 | #define MICROPY_ENABLE_SOURCE_LINE (0) |
663 | #endif |
664 | |
665 | // Whether to include doc strings (increases RAM usage) |
666 | #ifndef MICROPY_ENABLE_DOC_STRING |
667 | #define MICROPY_ENABLE_DOC_STRING (0) |
668 | #endif |
669 | |
670 | // Exception messages are short static strings |
671 | #define MICROPY_ERROR_REPORTING_TERSE (1) |
672 | // Exception messages provide basic error details |
673 | #define MICROPY_ERROR_REPORTING_NORMAL (2) |
674 | // Exception messages provide full info, e.g. object names |
675 | #define MICROPY_ERROR_REPORTING_DETAILED (3) |
676 | |
677 | #ifndef MICROPY_ERROR_REPORTING |
678 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) |
679 | #endif |
680 | |
681 | // Whether issue warnings during compiling/execution |
682 | #ifndef MICROPY_WARNINGS |
683 | #define MICROPY_WARNINGS (0) |
684 | #endif |
685 | |
686 | // Whether to support warning categories |
687 | #ifndef MICROPY_WARNINGS_CATEGORY |
688 | #define MICROPY_WARNINGS_CATEGORY (0) |
689 | #endif |
690 | |
691 | // This macro is used when printing runtime warnings and errors |
692 | #ifndef MICROPY_ERROR_PRINTER |
693 | #define MICROPY_ERROR_PRINTER (&mp_plat_print) |
694 | #endif |
695 | |
696 | // Float and complex implementation |
697 | #define MICROPY_FLOAT_IMPL_NONE (0) |
698 | #define MICROPY_FLOAT_IMPL_FLOAT (1) |
699 | #define MICROPY_FLOAT_IMPL_DOUBLE (2) |
700 | |
701 | #ifndef MICROPY_FLOAT_IMPL |
702 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) |
703 | #endif |
704 | |
705 | #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT |
706 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
707 | #define MICROPY_FLOAT_CONST(x) x##F |
708 | #define MICROPY_FLOAT_C_FUN(fun) fun##f |
709 | typedef float mp_float_t; |
710 | #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE |
711 | #define MICROPY_PY_BUILTINS_FLOAT (1) |
712 | #define MICROPY_FLOAT_CONST(x) x |
713 | #define MICROPY_FLOAT_C_FUN(fun) fun |
714 | typedef double mp_float_t; |
715 | #else |
716 | #define MICROPY_PY_BUILTINS_FLOAT (0) |
717 | #endif |
718 | |
719 | #ifndef MICROPY_PY_BUILTINS_COMPLEX |
720 | #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) |
721 | #endif |
722 | |
723 | // Whether to provide a high-quality hash for float and complex numbers. |
724 | // Otherwise the default is a very simple but correct hashing function. |
725 | #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH |
726 | #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0) |
727 | #endif |
728 | |
729 | // Enable features which improve CPython compatibility |
730 | // but may lead to more code size/memory usage. |
731 | // TODO: Originally intended as generic category to not |
732 | // add bunch of once-off options. May need refactoring later |
733 | #ifndef MICROPY_CPYTHON_COMPAT |
734 | #define MICROPY_CPYTHON_COMPAT (1) |
735 | #endif |
736 | |
737 | // Perform full checks as done by CPython. Disabling this |
738 | // may produce incorrect results, if incorrect data is fed, |
739 | // but should not lead to MicroPython crashes or similar |
740 | // grave issues (in other words, only user app should be, |
741 | // affected, not system). |
742 | #ifndef MICROPY_FULL_CHECKS |
743 | #define MICROPY_FULL_CHECKS (1) |
744 | #endif |
745 | |
746 | // Whether POSIX-semantics non-blocking streams are supported |
747 | #ifndef MICROPY_STREAMS_NON_BLOCK |
748 | #define MICROPY_STREAMS_NON_BLOCK (0) |
749 | #endif |
750 | |
751 | // Whether to provide stream functions with POSIX-like signatures |
752 | // (useful for porting existing libraries to MicroPython). |
753 | #ifndef MICROPY_STREAMS_POSIX_API |
754 | #define MICROPY_STREAMS_POSIX_API (0) |
755 | #endif |
756 | |
757 | // Whether to call __init__ when importing builtin modules for the first time |
758 | #ifndef MICROPY_MODULE_BUILTIN_INIT |
759 | #define MICROPY_MODULE_BUILTIN_INIT (0) |
760 | #endif |
761 | |
762 | // Whether to support module-level __getattr__ (see PEP 562) |
763 | #ifndef MICROPY_MODULE_GETATTR |
764 | #define MICROPY_MODULE_GETATTR (1) |
765 | #endif |
766 | |
767 | // Whether module weak links are supported |
768 | #ifndef MICROPY_MODULE_WEAK_LINKS |
769 | #define MICROPY_MODULE_WEAK_LINKS (0) |
770 | #endif |
771 | |
772 | // Whether frozen modules are supported in the form of strings |
773 | #ifndef MICROPY_MODULE_FROZEN_STR |
774 | #define MICROPY_MODULE_FROZEN_STR (0) |
775 | #endif |
776 | |
777 | // Whether frozen modules are supported in the form of .mpy files |
778 | #ifndef MICROPY_MODULE_FROZEN_MPY |
779 | #define MICROPY_MODULE_FROZEN_MPY (0) |
780 | #endif |
781 | |
782 | // Convenience macro for whether frozen modules are supported |
783 | #ifndef MICROPY_MODULE_FROZEN |
784 | #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY) |
785 | #endif |
786 | |
787 | // Whether you can override builtins in the builtins module |
788 | #ifndef MICROPY_CAN_OVERRIDE_BUILTINS |
789 | #define MICROPY_CAN_OVERRIDE_BUILTINS (0) |
790 | #endif |
791 | |
792 | // Whether to check that the "self" argument of a builtin method has the |
793 | // correct type. Such an explicit check is only needed if a builtin |
794 | // method escapes to Python land without a first argument, eg |
795 | // list.append([], 1). Without this check such calls will have undefined |
796 | // behaviour (usually segfault) if the first argument is the wrong type. |
797 | #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG |
798 | #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1) |
799 | #endif |
800 | |
801 | // Whether to use internally defined errno's (otherwise system provided ones) |
802 | #ifndef MICROPY_USE_INTERNAL_ERRNO |
803 | #define MICROPY_USE_INTERNAL_ERRNO (0) |
804 | #endif |
805 | |
806 | // Whether to use internally defined *printf() functions (otherwise external ones) |
807 | #ifndef MICROPY_USE_INTERNAL_PRINTF |
808 | #define MICROPY_USE_INTERNAL_PRINTF (1) |
809 | #endif |
810 | |
811 | // Support for internal scheduler |
812 | #ifndef MICROPY_ENABLE_SCHEDULER |
813 | #define MICROPY_ENABLE_SCHEDULER (0) |
814 | #endif |
815 | |
816 | // Maximum number of entries in the scheduler |
817 | #ifndef MICROPY_SCHEDULER_DEPTH |
818 | #define MICROPY_SCHEDULER_DEPTH (4) |
819 | #endif |
820 | |
821 | // Support for generic VFS sub-system |
822 | #ifndef MICROPY_VFS |
823 | #define MICROPY_VFS (0) |
824 | #endif |
825 | |
826 | // Support for VFS POSIX component, to mount a POSIX filesystem within VFS |
827 | #ifndef MICROPY_VFS |
828 | #define MICROPY_VFS_POSIX (0) |
829 | #endif |
830 | |
831 | // Support for VFS FAT component, to mount a FAT filesystem within VFS |
832 | #ifndef MICROPY_VFS |
833 | #define MICROPY_VFS_FAT (0) |
834 | #endif |
835 | |
836 | /*****************************************************************************/ |
837 | /* Fine control over Python builtins, classes, modules, etc */ |
838 | |
839 | // Whether to support multiple inheritance of Python classes. Multiple |
840 | // inheritance makes some C functions inherently recursive, and adds a bit of |
841 | // code overhead. |
842 | #ifndef MICROPY_MULTIPLE_INHERITANCE |
843 | #define MICROPY_MULTIPLE_INHERITANCE (1) |
844 | #endif |
845 | |
846 | // Whether to implement attributes on functions |
847 | #ifndef MICROPY_PY_FUNCTION_ATTRS |
848 | #define MICROPY_PY_FUNCTION_ATTRS (0) |
849 | #endif |
850 | |
851 | // Whether to support the descriptors __get__, __set__, __delete__ |
852 | // This costs some code size and makes load/store/delete of instance |
853 | // attributes slower for the classes that use this feature |
854 | #ifndef MICROPY_PY_DESCRIPTORS |
855 | #define MICROPY_PY_DESCRIPTORS (0) |
856 | #endif |
857 | |
858 | // Whether to support class __delattr__ and __setattr__ methods |
859 | // This costs some code size and makes store/delete of instance |
860 | // attributes slower for the classes that use this feature |
861 | #ifndef MICROPY_PY_DELATTR_SETATTR |
862 | #define MICROPY_PY_DELATTR_SETATTR (0) |
863 | #endif |
864 | |
865 | // Support for async/await/async for/async with |
866 | #ifndef MICROPY_PY_ASYNC_AWAIT |
867 | #define MICROPY_PY_ASYNC_AWAIT (1) |
868 | #endif |
869 | |
870 | // Support for assignment expressions with := (see PEP 572, Python 3.8+) |
871 | #ifndef MICROPY_PY_ASSIGN_EXPR |
872 | #define MICROPY_PY_ASSIGN_EXPR (1) |
873 | #endif |
874 | |
875 | // Non-standard .pend_throw() method for generators, allowing for |
876 | // Future-like behavior with respect to exception handling: an |
877 | // exception set with .pend_throw() will activate on the next call |
878 | // to generator's .send() or .__next__(). (This is useful to implement |
879 | // async schedulers.) |
880 | #ifndef MICROPY_PY_GENERATOR_PEND_THROW |
881 | #define MICROPY_PY_GENERATOR_PEND_THROW (1) |
882 | #endif |
883 | |
884 | // Issue a warning when comparing str and bytes objects |
885 | #ifndef MICROPY_PY_STR_BYTES_CMP_WARN |
886 | #define MICROPY_PY_STR_BYTES_CMP_WARN (0) |
887 | #endif |
888 | |
889 | // Whether str object is proper unicode |
890 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE |
891 | #define MICROPY_PY_BUILTINS_STR_UNICODE (0) |
892 | #endif |
893 | |
894 | // Whether to check for valid UTF-8 when converting bytes to str |
895 | #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK |
896 | #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE) |
897 | #endif |
898 | |
899 | // Whether str.center() method provided |
900 | #ifndef MICROPY_PY_BUILTINS_STR_CENTER |
901 | #define MICROPY_PY_BUILTINS_STR_CENTER (0) |
902 | #endif |
903 | |
904 | // Whether str.count() method provided |
905 | #ifndef MICROPY_PY_BUILTINS_STR_COUNT |
906 | #define MICROPY_PY_BUILTINS_STR_COUNT (1) |
907 | #endif |
908 | |
909 | // Whether str % (...) formatting operator provided |
910 | #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO |
911 | #define MICROPY_PY_BUILTINS_STR_OP_MODULO (1) |
912 | #endif |
913 | |
914 | // Whether str.partition()/str.rpartition() method provided |
915 | #ifndef MICROPY_PY_BUILTINS_STR_PARTITION |
916 | #define MICROPY_PY_BUILTINS_STR_PARTITION (0) |
917 | #endif |
918 | |
919 | // Whether str.splitlines() method provided |
920 | #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES |
921 | #define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) |
922 | #endif |
923 | |
924 | // Whether to support bytearray object |
925 | #ifndef MICROPY_PY_BUILTINS_BYTEARRAY |
926 | #define MICROPY_PY_BUILTINS_BYTEARRAY (1) |
927 | #endif |
928 | |
929 | // Whether to support dict.fromkeys() class method |
930 | #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS |
931 | #define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1) |
932 | #endif |
933 | |
934 | // Whether to support memoryview object |
935 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW |
936 | #define MICROPY_PY_BUILTINS_MEMORYVIEW (0) |
937 | #endif |
938 | |
939 | // Whether to support memoryview.itemsize attribute |
940 | #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE |
941 | #define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0) |
942 | #endif |
943 | |
944 | // Whether to support set object |
945 | #ifndef MICROPY_PY_BUILTINS_SET |
946 | #define MICROPY_PY_BUILTINS_SET (1) |
947 | #endif |
948 | |
949 | // Whether to support slice subscript operators and slice object |
950 | #ifndef MICROPY_PY_BUILTINS_SLICE |
951 | #define MICROPY_PY_BUILTINS_SLICE (1) |
952 | #endif |
953 | |
954 | // Whether to support slice attribute read access, |
955 | // i.e. slice.start, slice.stop, slice.step |
956 | #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS |
957 | #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0) |
958 | #endif |
959 | |
960 | // Whether to support the .indices(len) method on slice objects |
961 | #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES |
962 | #define MICROPY_PY_BUILTINS_SLICE_INDICES (0) |
963 | #endif |
964 | |
965 | // Whether to support frozenset object |
966 | #ifndef MICROPY_PY_BUILTINS_FROZENSET |
967 | #define MICROPY_PY_BUILTINS_FROZENSET (0) |
968 | #endif |
969 | |
970 | // Whether to support property object |
971 | #ifndef MICROPY_PY_BUILTINS_PROPERTY |
972 | #define MICROPY_PY_BUILTINS_PROPERTY (1) |
973 | #endif |
974 | |
975 | // Whether to implement the start/stop/step attributes (readback) on |
976 | // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). |
977 | #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS |
978 | #define MICROPY_PY_BUILTINS_RANGE_ATTRS (1) |
979 | #endif |
980 | |
981 | // Whether to support binary ops [only (in)equality is defined] between range |
982 | // objects. With this option disabled all range objects that are not exactly |
983 | // the same object will compare as not-equal. With it enabled the semantics |
984 | // match CPython and ranges are equal if they yield the same sequence of items. |
985 | #ifndef MICROPY_PY_BUILTINS_RANGE_BINOP |
986 | #define MICROPY_PY_BUILTINS_RANGE_BINOP (0) |
987 | #endif |
988 | |
989 | // Support for callling next() with second argument |
990 | #ifndef MICROPY_PY_BUILTINS_NEXT2 |
991 | #define MICROPY_PY_BUILTINS_NEXT2 (0) |
992 | #endif |
993 | |
994 | // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120 |
995 | #ifndef MICROPY_PY_BUILTINS_ROUND_INT |
996 | #define MICROPY_PY_BUILTINS_ROUND_INT (0) |
997 | #endif |
998 | |
999 | // Whether to support complete set of special methods for user |
1000 | // classes, or only the most used ones. "Inplace" methods are |
1001 | // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below. |
1002 | // "Reverse" methods are controlled by |
1003 | // MICROPY_PY_REVERSE_SPECIAL_METHODS below. |
1004 | #ifndef MICROPY_PY_ALL_SPECIAL_METHODS |
1005 | #define MICROPY_PY_ALL_SPECIAL_METHODS (0) |
1006 | #endif |
1007 | |
1008 | // Whether to support all inplace arithmetic operarion methods |
1009 | // (__imul__, etc.) |
1010 | #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS |
1011 | #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0) |
1012 | #endif |
1013 | |
1014 | // Whether to support reverse arithmetic operarion methods |
1015 | // (__radd__, etc.). Additionally gated by |
1016 | // MICROPY_PY_ALL_SPECIAL_METHODS. |
1017 | #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS |
1018 | #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) |
1019 | #endif |
1020 | |
1021 | // Whether to support compile function |
1022 | #ifndef MICROPY_PY_BUILTINS_COMPILE |
1023 | #define MICROPY_PY_BUILTINS_COMPILE (0) |
1024 | #endif |
1025 | |
1026 | // Whether to support enumerate function(type) |
1027 | #ifndef MICROPY_PY_BUILTINS_ENUMERATE |
1028 | #define MICROPY_PY_BUILTINS_ENUMERATE (1) |
1029 | #endif |
1030 | |
1031 | // Whether to support eval and exec functions |
1032 | // By default they are supported if the compiler is enabled |
1033 | #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC |
1034 | #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER) |
1035 | #endif |
1036 | |
1037 | // Whether to support the Python 2 execfile function |
1038 | #ifndef MICROPY_PY_BUILTINS_EXECFILE |
1039 | #define MICROPY_PY_BUILTINS_EXECFILE (0) |
1040 | #endif |
1041 | |
1042 | // Whether to support filter function(type) |
1043 | #ifndef MICROPY_PY_BUILTINS_FILTER |
1044 | #define MICROPY_PY_BUILTINS_FILTER (1) |
1045 | #endif |
1046 | |
1047 | // Whether to support reversed function(type) |
1048 | #ifndef MICROPY_PY_BUILTINS_REVERSED |
1049 | #define MICROPY_PY_BUILTINS_REVERSED (1) |
1050 | #endif |
1051 | |
1052 | // Whether to define "NotImplemented" special constant |
1053 | #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED |
1054 | #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) |
1055 | #endif |
1056 | |
1057 | // Whether to provide the built-in input() function. The implementation of this |
1058 | // uses mp-readline, so can only be enabled if the port uses this readline. |
1059 | #ifndef MICROPY_PY_BUILTINS_INPUT |
1060 | #define MICROPY_PY_BUILTINS_INPUT (0) |
1061 | #endif |
1062 | |
1063 | // Whether to support min/max functions |
1064 | #ifndef MICROPY_PY_BUILTINS_MIN_MAX |
1065 | #define MICROPY_PY_BUILTINS_MIN_MAX (1) |
1066 | #endif |
1067 | |
1068 | // Support for calls to pow() with 3 integer arguments |
1069 | #ifndef MICROPY_PY_BUILTINS_POW3 |
1070 | #define MICROPY_PY_BUILTINS_POW3 (0) |
1071 | #endif |
1072 | |
1073 | // Whether to provide the help function |
1074 | #ifndef MICROPY_PY_BUILTINS_HELP |
1075 | #define MICROPY_PY_BUILTINS_HELP (0) |
1076 | #endif |
1077 | |
1078 | // Use this to configure the help text shown for help(). It should be a |
1079 | // variable with the type "const char*". A sensible default is provided. |
1080 | #ifndef MICROPY_PY_BUILTINS_HELP_TEXT |
1081 | #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text |
1082 | #endif |
1083 | |
1084 | // Add the ability to list the available modules when executing help('modules') |
1085 | #ifndef MICROPY_PY_BUILTINS_HELP_MODULES |
1086 | #define MICROPY_PY_BUILTINS_HELP_MODULES (0) |
1087 | #endif |
1088 | |
1089 | // Whether to set __file__ for imported modules |
1090 | #ifndef MICROPY_PY___FILE__ |
1091 | #define MICROPY_PY___FILE__ (1) |
1092 | #endif |
1093 | |
1094 | // Whether to provide mem-info related functions in micropython module |
1095 | #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO |
1096 | #define MICROPY_PY_MICROPYTHON_MEM_INFO (0) |
1097 | #endif |
1098 | |
1099 | // Whether to provide "micropython.stack_use" function |
1100 | #ifndef MICROPY_PY_MICROPYTHON_STACK_USE |
1101 | #define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO) |
1102 | #endif |
1103 | |
1104 | // Whether to provide the "micropython.heap_locked" function |
1105 | #ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED |
1106 | #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (0) |
1107 | #endif |
1108 | |
1109 | // Whether to provide "array" module. Note that large chunk of the |
1110 | // underlying code is shared with "bytearray" builtin type, so to |
1111 | // get real savings, it should be disabled too. |
1112 | #ifndef MICROPY_PY_ARRAY |
1113 | #define MICROPY_PY_ARRAY (1) |
1114 | #endif |
1115 | |
1116 | // Whether to support slice assignments for array (and bytearray). |
1117 | // This is rarely used, but adds ~0.5K of code. |
1118 | #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN |
1119 | #define MICROPY_PY_ARRAY_SLICE_ASSIGN (0) |
1120 | #endif |
1121 | |
1122 | // Whether to support attrtuple type (MicroPython extension) |
1123 | // It provides space-efficient tuples with attribute access |
1124 | #ifndef MICROPY_PY_ATTRTUPLE |
1125 | #define MICROPY_PY_ATTRTUPLE (1) |
1126 | #endif |
1127 | |
1128 | // Whether to provide "collections" module |
1129 | #ifndef MICROPY_PY_COLLECTIONS |
1130 | #define MICROPY_PY_COLLECTIONS (1) |
1131 | #endif |
1132 | |
1133 | // Whether to provide "ucollections.deque" type |
1134 | #ifndef MICROPY_PY_COLLECTIONS_DEQUE |
1135 | #define MICROPY_PY_COLLECTIONS_DEQUE (0) |
1136 | #endif |
1137 | |
1138 | // Whether to provide "collections.OrderedDict" type |
1139 | #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT |
1140 | #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) |
1141 | #endif |
1142 | |
1143 | // Whether to provide the _asdict function for namedtuple |
1144 | #ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT |
1145 | #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0) |
1146 | #endif |
1147 | |
1148 | // Whether to provide "math" module |
1149 | #ifndef MICROPY_PY_MATH |
1150 | #define MICROPY_PY_MATH (1) |
1151 | #endif |
1152 | |
1153 | // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} |
1154 | #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS |
1155 | #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) |
1156 | #endif |
1157 | |
1158 | // Whether to provide math.factorial function |
1159 | #ifndef MICROPY_PY_MATH_FACTORIAL |
1160 | #define MICROPY_PY_MATH_FACTORIAL (0) |
1161 | #endif |
1162 | |
1163 | // Whether to provide math.isclose function |
1164 | #ifndef MICROPY_PY_MATH_ISCLOSE |
1165 | #define MICROPY_PY_MATH_ISCLOSE (0) |
1166 | #endif |
1167 | |
1168 | // Whether to provide fix for atan2 Inf handling. |
1169 | #ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN |
1170 | #define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0) |
1171 | #endif |
1172 | |
1173 | // Whether to provide fix for fmod Inf handling. |
1174 | #ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN |
1175 | #define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0) |
1176 | #endif |
1177 | |
1178 | // Whether to provide fix for modf negative zero handling. |
1179 | #ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO |
1180 | #define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0) |
1181 | #endif |
1182 | |
1183 | // Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN. |
1184 | #ifndef MICROPY_PY_MATH_POW_FIX_NAN |
1185 | #define MICROPY_PY_MATH_POW_FIX_NAN (0) |
1186 | #endif |
1187 | |
1188 | // Whether to provide "cmath" module |
1189 | #ifndef MICROPY_PY_CMATH |
1190 | #define MICROPY_PY_CMATH (0) |
1191 | #endif |
1192 | |
1193 | // Whether to provide "gc" module |
1194 | #ifndef MICROPY_PY_GC |
1195 | #define MICROPY_PY_GC (1) |
1196 | #endif |
1197 | |
1198 | // Whether to return number of collected objects from gc.collect() |
1199 | #ifndef MICROPY_PY_GC_COLLECT_RETVAL |
1200 | #define MICROPY_PY_GC_COLLECT_RETVAL (0) |
1201 | #endif |
1202 | |
1203 | // Whether to provide "io" module |
1204 | #ifndef MICROPY_PY_IO |
1205 | #define MICROPY_PY_IO (1) |
1206 | #endif |
1207 | |
1208 | // Whether to provide "io.IOBase" class to support user streams |
1209 | #ifndef MICROPY_PY_IO_IOBASE |
1210 | #define MICROPY_PY_IO_IOBASE (0) |
1211 | #endif |
1212 | |
1213 | // Whether to provide "uio.resource_stream()" function with |
1214 | // the semantics of CPython's pkg_resources.resource_stream() |
1215 | // (allows to access binary resources in frozen source packages). |
1216 | // Note that the same functionality can be achieved in "pure |
1217 | // Python" by prepocessing binary resources into Python source |
1218 | // and bytecode-freezing it (with a simple helper module available |
1219 | // e.g. in micropython-lib). |
1220 | #ifndef MICROPY_PY_IO_RESOURCE_STREAM |
1221 | #define MICROPY_PY_IO_RESOURCE_STREAM (0) |
1222 | #endif |
1223 | |
1224 | // Whether to provide "io.FileIO" class |
1225 | #ifndef MICROPY_PY_IO_FILEIO |
1226 | #define MICROPY_PY_IO_FILEIO (0) |
1227 | #endif |
1228 | |
1229 | // Whether to provide "io.BytesIO" class |
1230 | #ifndef MICROPY_PY_IO_BYTESIO |
1231 | #define MICROPY_PY_IO_BYTESIO (1) |
1232 | #endif |
1233 | |
1234 | // Whether to provide "io.BufferedWriter" class |
1235 | #ifndef MICROPY_PY_IO_BUFFEREDWRITER |
1236 | #define MICROPY_PY_IO_BUFFEREDWRITER (0) |
1237 | #endif |
1238 | |
1239 | // Whether to provide "struct" module |
1240 | #ifndef MICROPY_PY_STRUCT |
1241 | #define MICROPY_PY_STRUCT (1) |
1242 | #endif |
1243 | |
1244 | // Whether to provide "sys" module |
1245 | #ifndef MICROPY_PY_SYS |
1246 | #define MICROPY_PY_SYS (1) |
1247 | #endif |
1248 | |
1249 | // Whether to provide "sys.maxsize" constant |
1250 | #ifndef MICROPY_PY_SYS_MAXSIZE |
1251 | #define MICROPY_PY_SYS_MAXSIZE (0) |
1252 | #endif |
1253 | |
1254 | // Whether to provide "sys.modules" dictionary |
1255 | #ifndef MICROPY_PY_SYS_MODULES |
1256 | #define MICROPY_PY_SYS_MODULES (1) |
1257 | #endif |
1258 | |
1259 | // Whether to provide "sys.exc_info" function |
1260 | // Avoid enabling this, this function is Python2 heritage |
1261 | #ifndef MICROPY_PY_SYS_EXC_INFO |
1262 | #define MICROPY_PY_SYS_EXC_INFO (0) |
1263 | #endif |
1264 | |
1265 | // Whether to provide "sys.exit" function |
1266 | #ifndef MICROPY_PY_SYS_EXIT |
1267 | #define MICROPY_PY_SYS_EXIT (1) |
1268 | #endif |
1269 | |
1270 | // Whether to provide "sys.atexit" function (MicroPython extension) |
1271 | #ifndef MICROPY_PY_SYS_ATEXIT |
1272 | #define MICROPY_PY_SYS_ATEXIT (0) |
1273 | #endif |
1274 | |
1275 | // Whether to provide "sys.settrace" function |
1276 | #ifndef MICROPY_PY_SYS_SETTRACE |
1277 | #define MICROPY_PY_SYS_SETTRACE (0) |
1278 | #endif |
1279 | |
1280 | // Whether to provide "sys.getsizeof" function |
1281 | #ifndef MICROPY_PY_SYS_GETSIZEOF |
1282 | #define MICROPY_PY_SYS_GETSIZEOF (0) |
1283 | #endif |
1284 | |
1285 | // Whether to provide sys.{stdin,stdout,stderr} objects |
1286 | #ifndef MICROPY_PY_SYS_STDFILES |
1287 | #define MICROPY_PY_SYS_STDFILES (0) |
1288 | #endif |
1289 | |
1290 | // Whether to provide sys.{stdin,stdout,stderr}.buffer object |
1291 | // This is implemented per-port |
1292 | #ifndef MICROPY_PY_SYS_STDIO_BUFFER |
1293 | #define MICROPY_PY_SYS_STDIO_BUFFER (0) |
1294 | #endif |
1295 | |
1296 | // Whether to provide "uerrno" module |
1297 | #ifndef MICROPY_PY_UERRNO |
1298 | #define MICROPY_PY_UERRNO (0) |
1299 | #endif |
1300 | |
1301 | // Whether to provide the uerrno.errorcode dict |
1302 | #ifndef MICROPY_PY_UERRNO_ERRORCODE |
1303 | #define MICROPY_PY_UERRNO_ERRORCODE (1) |
1304 | #endif |
1305 | |
1306 | // Whether to provide "uselect" module (baremetal implementation) |
1307 | #ifndef MICROPY_PY_USELECT |
1308 | #define MICROPY_PY_USELECT (0) |
1309 | #endif |
1310 | |
1311 | // Whether to provide "utime" module functions implementation |
1312 | // in terms of mp_hal_* functions. |
1313 | #ifndef MICROPY_PY_UTIME_MP_HAL |
1314 | #define MICROPY_PY_UTIME_MP_HAL (0) |
1315 | #endif |
1316 | |
1317 | // Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu() |
1318 | // functions. Should be power of two. All functions above use the same |
1319 | // period, so if underlying hardware/API has different periods, the |
1320 | // minimum of them should be used. The value below is the maximum value |
1321 | // this parameter can take (corresponding to 30 bit tick values on 32-bit |
1322 | // system). |
1323 | #ifndef MICROPY_PY_UTIME_TICKS_PERIOD |
1324 | #define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1) |
1325 | #endif |
1326 | |
1327 | // Whether to provide "_thread" module |
1328 | #ifndef MICROPY_PY_THREAD |
1329 | #define MICROPY_PY_THREAD (0) |
1330 | #endif |
1331 | |
1332 | // Whether to make the VM/runtime thread-safe using a global lock |
1333 | // If not enabled then thread safety must be provided at the Python level |
1334 | #ifndef MICROPY_PY_THREAD_GIL |
1335 | #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD) |
1336 | #endif |
1337 | |
1338 | // Number of VM jump-loops to do before releasing the GIL. |
1339 | // Set this to 0 to disable the divisor. |
1340 | #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR |
1341 | #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32) |
1342 | #endif |
1343 | |
1344 | // Extended modules |
1345 | |
1346 | #ifndef MICROPY_PY_UASYNCIO |
1347 | #define MICROPY_PY_UASYNCIO (0) |
1348 | #endif |
1349 | |
1350 | #ifndef MICROPY_PY_UCTYPES |
1351 | #define MICROPY_PY_UCTYPES (0) |
1352 | #endif |
1353 | |
1354 | // Whether to provide SHORT, INT, LONG, etc. types in addition to |
1355 | // exact-bitness types like INT16, INT32, etc. |
1356 | #ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES |
1357 | #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1) |
1358 | #endif |
1359 | |
1360 | #ifndef MICROPY_PY_UZLIB |
1361 | #define MICROPY_PY_UZLIB (0) |
1362 | #endif |
1363 | |
1364 | #ifndef MICROPY_PY_UJSON |
1365 | #define MICROPY_PY_UJSON (0) |
1366 | #endif |
1367 | |
1368 | #ifndef MICROPY_PY_URE |
1369 | #define MICROPY_PY_URE (0) |
1370 | #endif |
1371 | |
1372 | #ifndef MICROPY_PY_URE_DEBUG |
1373 | #define MICROPY_PY_URE_DEBUG (0) |
1374 | #endif |
1375 | |
1376 | #ifndef MICROPY_PY_URE_MATCH_GROUPS |
1377 | #define MICROPY_PY_URE_MATCH_GROUPS (0) |
1378 | #endif |
1379 | |
1380 | #ifndef MICROPY_PY_URE_MATCH_SPAN_START_END |
1381 | #define MICROPY_PY_URE_MATCH_SPAN_START_END (0) |
1382 | #endif |
1383 | |
1384 | #ifndef MICROPY_PY_URE_SUB |
1385 | #define MICROPY_PY_URE_SUB (0) |
1386 | #endif |
1387 | |
1388 | #ifndef MICROPY_PY_UHEAPQ |
1389 | #define MICROPY_PY_UHEAPQ (0) |
1390 | #endif |
1391 | |
1392 | // Optimized heap queue for relative timestamps |
1393 | #ifndef MICROPY_PY_UTIMEQ |
1394 | #define MICROPY_PY_UTIMEQ (0) |
1395 | #endif |
1396 | |
1397 | #ifndef MICROPY_PY_UHASHLIB |
1398 | #define MICROPY_PY_UHASHLIB (0) |
1399 | #endif |
1400 | |
1401 | #ifndef MICROPY_PY_UHASHLIB_MD5 |
1402 | #define MICROPY_PY_UHASHLIB_MD5 (0) |
1403 | #endif |
1404 | |
1405 | #ifndef MICROPY_PY_UHASHLIB_SHA1 |
1406 | #define MICROPY_PY_UHASHLIB_SHA1 (0) |
1407 | #endif |
1408 | |
1409 | #ifndef MICROPY_PY_UHASHLIB_SHA256 |
1410 | #define MICROPY_PY_UHASHLIB_SHA256 (1) |
1411 | #endif |
1412 | |
1413 | #ifndef MICROPY_PY_UCRYPTOLIB |
1414 | #define MICROPY_PY_UCRYPTOLIB (0) |
1415 | #endif |
1416 | |
1417 | // Depends on MICROPY_PY_UCRYPTOLIB |
1418 | #ifndef MICROPY_PY_UCRYPTOLIB_CTR |
1419 | #define MICROPY_PY_UCRYPTOLIB_CTR (0) |
1420 | #endif |
1421 | |
1422 | #ifndef MICROPY_PY_UCRYPTOLIB_CONSTS |
1423 | #define MICROPY_PY_UCRYPTOLIB_CONSTS (0) |
1424 | #endif |
1425 | |
1426 | #ifndef MICROPY_PY_UBINASCII |
1427 | #define MICROPY_PY_UBINASCII (0) |
1428 | #endif |
1429 | |
1430 | // Depends on MICROPY_PY_UZLIB |
1431 | #ifndef MICROPY_PY_UBINASCII_CRC32 |
1432 | #define MICROPY_PY_UBINASCII_CRC32 (0) |
1433 | #endif |
1434 | |
1435 | #ifndef MICROPY_PY_URANDOM |
1436 | #define MICROPY_PY_URANDOM (0) |
1437 | #endif |
1438 | |
1439 | // Whether to include: randrange, randint, choice, random, uniform |
1440 | #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS |
1441 | #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) |
1442 | #endif |
1443 | |
1444 | #ifndef MICROPY_PY_MACHINE |
1445 | #define MICROPY_PY_MACHINE (0) |
1446 | #endif |
1447 | |
1448 | // Whether to include: time_pulse_us |
1449 | #ifndef MICROPY_PY_MACHINE_PULSE |
1450 | #define MICROPY_PY_MACHINE_PULSE (0) |
1451 | #endif |
1452 | |
1453 | #ifndef MICROPY_PY_MACHINE_I2C |
1454 | #define MICROPY_PY_MACHINE_I2C (0) |
1455 | #endif |
1456 | |
1457 | #ifndef MICROPY_PY_MACHINE_SPI |
1458 | #define MICROPY_PY_MACHINE_SPI (0) |
1459 | #endif |
1460 | |
1461 | #ifndef MICROPY_PY_USSL |
1462 | #define MICROPY_PY_USSL (0) |
1463 | // Whether to add finaliser code to ussl objects |
1464 | #define MICROPY_PY_USSL_FINALISER (0) |
1465 | #endif |
1466 | |
1467 | #ifndef MICROPY_PY_UWEBSOCKET |
1468 | #define MICROPY_PY_UWEBSOCKET (0) |
1469 | #endif |
1470 | |
1471 | #ifndef MICROPY_PY_FRAMEBUF |
1472 | #define MICROPY_PY_FRAMEBUF (0) |
1473 | #endif |
1474 | |
1475 | #ifndef MICROPY_PY_BTREE |
1476 | #define MICROPY_PY_BTREE (0) |
1477 | #endif |
1478 | |
1479 | /*****************************************************************************/ |
1480 | /* Hooks for a port to add builtins */ |
1481 | |
1482 | // Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format. |
1483 | #ifndef MICROPY_PORT_BUILTINS |
1484 | #define MICROPY_PORT_BUILTINS |
1485 | #endif |
1486 | |
1487 | // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format. |
1488 | #ifndef MICROPY_PORT_BUILTIN_MODULES |
1489 | #define MICROPY_PORT_BUILTIN_MODULES |
1490 | #endif |
1491 | |
1492 | // Additional constant definitions for the compiler - see compile.c:mp_constants_table. |
1493 | #ifndef MICROPY_PORT_CONSTANTS |
1494 | #define MICROPY_PORT_CONSTANTS |
1495 | #endif |
1496 | |
1497 | // Any root pointers for GC scanning - see mpstate.c |
1498 | #ifndef MICROPY_PORT_ROOT_POINTERS |
1499 | #define MICROPY_PORT_ROOT_POINTERS |
1500 | #endif |
1501 | |
1502 | /*****************************************************************************/ |
1503 | /* Hooks for a port to wrap functions with attributes */ |
1504 | |
1505 | #ifndef MICROPY_WRAP_MP_KEYBOARD_INTERRUPT |
1506 | #define MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(f) f |
1507 | #endif |
1508 | |
1509 | #ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE |
1510 | #define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f |
1511 | #endif |
1512 | |
1513 | /*****************************************************************************/ |
1514 | /* Miscellaneous settings */ |
1515 | |
1516 | // All uPy objects in ROM must be aligned on at least a 4 byte boundary |
1517 | // so that the small-int/qstr/pointer distinction can be made. For machines |
1518 | // that don't do this (eg 16-bit CPU), define the following macro to something |
1519 | // like __attribute__((aligned(4))). |
1520 | #ifndef MICROPY_OBJ_BASE_ALIGNMENT |
1521 | #define MICROPY_OBJ_BASE_ALIGNMENT |
1522 | #endif |
1523 | |
1524 | // On embedded platforms, these will typically enable/disable irqs. |
1525 | #ifndef MICROPY_BEGIN_ATOMIC_SECTION |
1526 | #define MICROPY_BEGIN_ATOMIC_SECTION() (0) |
1527 | #endif |
1528 | #ifndef MICROPY_END_ATOMIC_SECTION |
1529 | #define MICROPY_END_ATOMIC_SECTION(state) (void)(state) |
1530 | #endif |
1531 | |
1532 | // Allow to override static modifier for global objects, e.g. to use with |
1533 | // object code analysis tools which don't support static symbols. |
1534 | #ifndef STATIC |
1535 | #define STATIC static |
1536 | #endif |
1537 | |
1538 | // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t |
1539 | #ifndef MP_BYTES_PER_OBJ_WORD |
1540 | #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t)) |
1541 | #endif |
1542 | |
1543 | // Number of bits in a byte |
1544 | #ifndef MP_BITS_PER_BYTE |
1545 | #define MP_BITS_PER_BYTE (8) |
1546 | #endif |
1547 | // mp_int_t value with most significant bit set |
1548 | #define MP_OBJ_WORD_MSBIT_HIGH (((mp_uint_t)1) << (MP_BYTES_PER_OBJ_WORD * MP_BITS_PER_BYTE - 1)) |
1549 | |
1550 | // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are |
1551 | // defined and that they are the opposite of each other. |
1552 | #if defined(MP_ENDIANNESS_LITTLE) |
1553 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
1554 | #elif defined(MP_ENDIANNESS_BIG) |
1555 | #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG) |
1556 | #else |
1557 | // Endianness not defined by port so try to autodetect it. |
1558 | #if defined(__BYTE_ORDER__) |
1559 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
1560 | #define MP_ENDIANNESS_LITTLE (1) |
1561 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
1562 | #define MP_ENDIANNESS_LITTLE (0) |
1563 | #endif |
1564 | #else |
1565 | #include <endian.h> |
1566 | #if defined(__BYTE_ORDER) |
1567 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
1568 | #define MP_ENDIANNESS_LITTLE (1) |
1569 | #elif __BYTE_ORDER == __BIG_ENDIAN |
1570 | #define MP_ENDIANNESS_LITTLE (0) |
1571 | #endif |
1572 | #endif |
1573 | #endif |
1574 | #ifndef MP_ENDIANNESS_LITTLE |
1575 | #error endianness not defined and cannot detect it |
1576 | #endif |
1577 | #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE) |
1578 | #endif |
1579 | |
1580 | // Make a pointer to RAM callable (eg set lower bit for Thumb code) |
1581 | // (This scheme won't work if we want to mix Thumb and normal ARM code.) |
1582 | #ifndef MICROPY_MAKE_POINTER_CALLABLE |
1583 | #define MICROPY_MAKE_POINTER_CALLABLE(p) (p) |
1584 | #endif |
1585 | |
1586 | // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them |
1587 | // must be somehow reachable for marking by the GC, since the native code |
1588 | // generators store pointers to GC managed memory in the code. |
1589 | #ifndef MP_PLAT_ALLOC_EXEC |
1590 | #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0) |
1591 | #endif |
1592 | |
1593 | #ifndef MP_PLAT_FREE_EXEC |
1594 | #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size) |
1595 | #endif |
1596 | |
1597 | // This macro is used to do all output (except when MICROPY_PY_IO is defined) |
1598 | #ifndef MP_PLAT_PRINT_STRN |
1599 | #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) |
1600 | #endif |
1601 | |
1602 | #ifndef MP_SSIZE_MAX |
1603 | #define MP_SSIZE_MAX SSIZE_MAX |
1604 | #endif |
1605 | |
1606 | // printf format spec to use for mp_int_t and friends |
1607 | #ifndef INT_FMT |
1608 | #if defined(__LP64__) |
1609 | // Archs where mp_int_t == long, long != int |
1610 | #define UINT_FMT "%lu" |
1611 | #define INT_FMT "%ld" |
1612 | #elif defined(_WIN64) |
1613 | #define UINT_FMT "%llu" |
1614 | #define INT_FMT "%lld" |
1615 | #else |
1616 | // Archs where mp_int_t == int |
1617 | #define UINT_FMT "%u" |
1618 | #define INT_FMT "%d" |
1619 | #endif |
1620 | #endif // INT_FMT |
1621 | |
1622 | // Modifier for function which doesn't return |
1623 | #ifndef NORETURN |
1624 | #define NORETURN __attribute__((noreturn)) |
1625 | #endif |
1626 | |
1627 | // Modifier for weak functions |
1628 | #ifndef MP_WEAK |
1629 | #define MP_WEAK __attribute__((weak)) |
1630 | #endif |
1631 | |
1632 | // Modifier for functions which should be never inlined |
1633 | #ifndef MP_NOINLINE |
1634 | #define MP_NOINLINE __attribute__((noinline)) |
1635 | #endif |
1636 | |
1637 | // Modifier for functions which should be always inlined |
1638 | #ifndef MP_ALWAYSINLINE |
1639 | #define MP_ALWAYSINLINE __attribute__((always_inline)) |
1640 | #endif |
1641 | |
1642 | // Condition is likely to be true, to help branch prediction |
1643 | #ifndef MP_LIKELY |
1644 | #define MP_LIKELY(x) __builtin_expect((x), 1) |
1645 | #endif |
1646 | |
1647 | // Condition is likely to be false, to help branch prediction |
1648 | #ifndef MP_UNLIKELY |
1649 | #define MP_UNLIKELY(x) __builtin_expect((x), 0) |
1650 | #endif |
1651 | |
1652 | // To annotate that code is unreachable |
1653 | #ifndef MP_UNREACHABLE |
1654 | #if defined(__GNUC__) |
1655 | #define MP_UNREACHABLE __builtin_unreachable(); |
1656 | #else |
1657 | #define MP_UNREACHABLE for (;;); |
1658 | #endif |
1659 | #endif |
1660 | |
1661 | // Explicitly annotate switch case fall throughs |
1662 | #if defined(__GNUC__) && __GNUC__ >= 7 |
1663 | #define MP_FALLTHROUGH __attribute__((fallthrough)); |
1664 | #else |
1665 | #define MP_FALLTHROUGH |
1666 | #endif |
1667 | |
1668 | #ifndef MP_HTOBE16 |
1669 | #if MP_ENDIANNESS_LITTLE |
1670 | #define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))) |
1671 | #define MP_BE16TOH(x) MP_HTOBE16(x) |
1672 | #else |
1673 | #define MP_HTOBE16(x) (x) |
1674 | #define MP_BE16TOH(x) (x) |
1675 | #endif |
1676 | #endif |
1677 | |
1678 | #ifndef MP_HTOBE32 |
1679 | #if MP_ENDIANNESS_LITTLE |
1680 | #define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff))) |
1681 | #define MP_BE32TOH(x) MP_HTOBE32(x) |
1682 | #else |
1683 | #define MP_HTOBE32(x) (x) |
1684 | #define MP_BE32TOH(x) (x) |
1685 | #endif |
1686 | #endif |
1687 | |
1688 | // Warning categories are by default implemented as strings, though |
1689 | // hook is left for a port to define them as something else. |
1690 | #if MICROPY_WARNINGS_CATEGORY |
1691 | #ifndef MP_WARN_CAT |
1692 | #define MP_WARN_CAT(x) #x |
1693 | #endif |
1694 | #else |
1695 | #undef MP_WARN_CAT |
1696 | #define MP_WARN_CAT(x) (NULL) |
1697 | #endif |
1698 | |
1699 | // Feature dependency check. |
1700 | #if MICROPY_PY_SYS_SETTRACE |
1701 | #if !MICROPY_PERSISTENT_CODE_SAVE |
1702 | #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_PERSISTENT_CODE_SAVE to be enabled" |
1703 | #endif |
1704 | #if MICROPY_COMP_CONST |
1705 | #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_COMP_CONST to be disabled" |
1706 | #endif |
1707 | #endif |
1708 | |
1709 | #endif // MICROPY_INCLUDED_PY_MPCONFIG_H |
1710 | |