Port of MicroPython to the mbed platform. See micropython-repl for an interactive program.

Dependents:   micropython-repl

This a port of MicroPython to the mbed Classic platform.

This provides an interpreter running on the board's USB serial connection.

Getting Started

Import the micropython-repl program into your IDE workspace on developer.mbed.org. Compile and download to your board. Connect to the USB serial port in your usual manner. You should get a startup message similar to the following:

  MicroPython v1.7-155-gdddcdd8 on 2016-04-23; K64F with ARM
  Type "help()" for more information.
  >>>

Then you can start using micropython. For example:

  >>> from mbed import DigitalOut
  >>> from pins import LED1
  >>> led = DigitalOut(LED1)
  >>> led.write(1)

Requirements

You need approximately 100K of flash memory, so this will be no good for boards with smaller amounts of storage.

Caveats

This can be considered an alpha release of the port; things may not work; APIs may change in later releases. It is NOT an official part part the micropython project, so if anything doesn't work, blame me. If it does work, most of the credit is due to micropython.

  • Only a few of the mbed classes are available in micropython so far, and not all methods of those that are.
  • Only a few boards have their full range of pin names available; for others, only a few standard ones (USBTX, USBRX, LED1) are implemented.
  • The garbage collector is not yet implemented. The interpreter will gradually consume memory and then fail.
  • Exceptions from the mbed classes are not yet handled.
  • Asynchronous processing (e.g. events on inputs) is not supported.

Credits

  • Damien P. George and other contributors who created micropython.
  • Colin Hogben, author of this port.
Committer:
Colin Hogben
Date:
Wed Apr 27 22:11:29 2016 +0100
Revision:
10:33521d742af1
Parent:
2:c89e95946844
Update README and version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pythontech 0:5868e8752d44 1 /*
pythontech 0:5868e8752d44 2 * This file is part of the Micro Python project, http://micropython.org/
pythontech 0:5868e8752d44 3 *
pythontech 0:5868e8752d44 4 * The MIT License (MIT)
pythontech 0:5868e8752d44 5 *
pythontech 0:5868e8752d44 6 * Copyright (c) 2013, 2014 Damien P. George
pythontech 0:5868e8752d44 7 *
pythontech 0:5868e8752d44 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
pythontech 0:5868e8752d44 9 * of this software and associated documentation files (the "Software"), to deal
pythontech 0:5868e8752d44 10 * in the Software without restriction, including without limitation the rights
pythontech 0:5868e8752d44 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
pythontech 0:5868e8752d44 12 * copies of the Software, and to permit persons to whom the Software is
pythontech 0:5868e8752d44 13 * furnished to do so, subject to the following conditions:
pythontech 0:5868e8752d44 14 *
pythontech 0:5868e8752d44 15 * The above copyright notice and this permission notice shall be included in
pythontech 0:5868e8752d44 16 * all copies or substantial portions of the Software.
pythontech 0:5868e8752d44 17 *
pythontech 0:5868e8752d44 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
pythontech 0:5868e8752d44 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
pythontech 0:5868e8752d44 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
pythontech 0:5868e8752d44 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
pythontech 0:5868e8752d44 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pythontech 0:5868e8752d44 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
pythontech 0:5868e8752d44 24 * THE SOFTWARE.
pythontech 0:5868e8752d44 25 */
pythontech 0:5868e8752d44 26 #ifndef __MICROPY_INCLUDED_PY_MPCONFIG_H__
pythontech 0:5868e8752d44 27 #define __MICROPY_INCLUDED_PY_MPCONFIG_H__
pythontech 0:5868e8752d44 28
pythontech 0:5868e8752d44 29 // This file contains default configuration settings for MicroPython.
pythontech 0:5868e8752d44 30 // You can override any of the options below using mpconfigport.h file
pythontech 0:5868e8752d44 31 // located in a directory of your port.
pythontech 0:5868e8752d44 32
pythontech 0:5868e8752d44 33 // mpconfigport.h is a file containing configuration settings for a
pythontech 0:5868e8752d44 34 // particular port. mpconfigport.h is actually a default name for
pythontech 0:5868e8752d44 35 // such config, and it can be overriden using MP_CONFIGFILE preprocessor
pythontech 0:5868e8752d44 36 // define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
pythontech 0:5868e8752d44 37 // argument to make when using standard MicroPython makefiles).
pythontech 0:5868e8752d44 38 // This is useful to have more than one config per port, for example,
pythontech 0:5868e8752d44 39 // release vs debug configs, etc. Note that if you switch from one config
pythontech 0:5868e8752d44 40 // to another, you must rebuild from scratch using "-B" switch to make.
pythontech 0:5868e8752d44 41
pythontech 0:5868e8752d44 42 #ifdef MP_CONFIGFILE
pythontech 0:5868e8752d44 43 #include MP_CONFIGFILE
pythontech 0:5868e8752d44 44 #else
pythontech 0:5868e8752d44 45 #include <mpconfigport.h>
pythontech 0:5868e8752d44 46 #endif
pythontech 0:5868e8752d44 47
pythontech 0:5868e8752d44 48 // Any options not explicitly set in mpconfigport.h will get default
pythontech 0:5868e8752d44 49 // values below.
pythontech 0:5868e8752d44 50
pythontech 0:5868e8752d44 51 /*****************************************************************************/
pythontech 0:5868e8752d44 52 /* Object representation */
pythontech 0:5868e8752d44 53
pythontech 0:5868e8752d44 54 // A Micro Python object is a machine word having the following form:
pythontech 0:5868e8752d44 55 // - xxxx...xxx1 : a small int, bits 1 and above are the value
pythontech 0:5868e8752d44 56 // - xxxx...xx10 : a qstr, bits 2 and above are the value
pythontech 0:5868e8752d44 57 // - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
pythontech 0:5868e8752d44 58 #define MICROPY_OBJ_REPR_A (0)
pythontech 0:5868e8752d44 59
pythontech 0:5868e8752d44 60 // A Micro Python object is a machine word having the following form:
pythontech 0:5868e8752d44 61 // - xxxx...xx01 : a small int, bits 2 and above are the value
pythontech 0:5868e8752d44 62 // - xxxx...xx11 : a qstr, bits 2 and above are the value
pythontech 0:5868e8752d44 63 // - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
pythontech 0:5868e8752d44 64 #define MICROPY_OBJ_REPR_B (1)
pythontech 0:5868e8752d44 65
pythontech 0:5868e8752d44 66 // A MicroPython object is a machine word having the following form (called R):
pythontech 0:5868e8752d44 67 // - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
pythontech 0:5868e8752d44 68 // - 01111111 1qqqqqqq qqqqqqqq qqqqq110 str with 20-bit qstr value
pythontech 0:5868e8752d44 69 // - s1111111 10000000 00000000 00000010 +/- inf
pythontech 0:5868e8752d44 70 // - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
pythontech 0:5868e8752d44 71 // - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
pythontech 0:5868e8752d44 72 // - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
pythontech 0:5868e8752d44 73 // Str and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
pythontech 0:5868e8752d44 74 // This makes strs easier to encode/decode as they have zeros in the top 9 bits.
pythontech 0:5868e8752d44 75 // This scheme only works with 32-bit word size and float enabled.
pythontech 0:5868e8752d44 76
pythontech 0:5868e8752d44 77 #define MICROPY_OBJ_REPR_C (2)
pythontech 0:5868e8752d44 78
pythontech 0:5868e8752d44 79 // A MicroPython object is a 64-bit word having the following form (called R):
pythontech 0:5868e8752d44 80 // - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
pythontech 0:5868e8752d44 81 // - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
pythontech 0:5868e8752d44 82 // - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
pythontech 0:5868e8752d44 83 // - 01111111 11111101 00000000 00000000 iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
pythontech 0:5868e8752d44 84 // - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
pythontech 0:5868e8752d44 85 // - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
pythontech 0:5868e8752d44 86 // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
pythontech 0:5868e8752d44 87 // This makes pointers have all zeros in the top 32 bits.
pythontech 0:5868e8752d44 88 // Small-ints and strs have 1 as LSB to make sure they don't look like pointers
pythontech 0:5868e8752d44 89 // to the garbage collector.
pythontech 0:5868e8752d44 90 #define MICROPY_OBJ_REPR_D (3)
pythontech 0:5868e8752d44 91
pythontech 0:5868e8752d44 92 #ifndef MICROPY_OBJ_REPR
pythontech 0:5868e8752d44 93 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
pythontech 0:5868e8752d44 94 #endif
pythontech 0:5868e8752d44 95
pythontech 0:5868e8752d44 96 /*****************************************************************************/
pythontech 0:5868e8752d44 97 /* Memory allocation policy */
pythontech 0:5868e8752d44 98
pythontech 0:5868e8752d44 99 // Number of bytes in memory allocation/GC block. Any size allocated will be
pythontech 0:5868e8752d44 100 // rounded up to be multiples of this.
pythontech 0:5868e8752d44 101 #ifndef MICROPY_BYTES_PER_GC_BLOCK
pythontech 0:5868e8752d44 102 #define MICROPY_BYTES_PER_GC_BLOCK (4 * BYTES_PER_WORD)
pythontech 0:5868e8752d44 103 #endif
pythontech 0:5868e8752d44 104
pythontech 0:5868e8752d44 105 // Number of words allocated (in BSS) to the GC stack (minimum is 1)
pythontech 0:5868e8752d44 106 #ifndef MICROPY_ALLOC_GC_STACK_SIZE
pythontech 0:5868e8752d44 107 #define MICROPY_ALLOC_GC_STACK_SIZE (64)
pythontech 0:5868e8752d44 108 #endif
pythontech 0:5868e8752d44 109
pythontech 0:5868e8752d44 110 // Number of bytes to allocate initially when creating new chunks to store
pythontech 0:5868e8752d44 111 // interned string data. Smaller numbers lead to more chunks being needed
pythontech 0:5868e8752d44 112 // and more wastage at the end of the chunk. Larger numbers lead to wasted
pythontech 0:5868e8752d44 113 // space at the end when no more strings need interning.
pythontech 0:5868e8752d44 114 #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
pythontech 0:5868e8752d44 115 #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
pythontech 0:5868e8752d44 116 #endif
pythontech 0:5868e8752d44 117
pythontech 0:5868e8752d44 118 // Initial amount for lexer indentation level
pythontech 0:5868e8752d44 119 #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
pythontech 0:5868e8752d44 120 #define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
pythontech 0:5868e8752d44 121 #endif
pythontech 0:5868e8752d44 122
pythontech 0:5868e8752d44 123 // Increment for lexer indentation level
pythontech 0:5868e8752d44 124 #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
pythontech 0:5868e8752d44 125 #define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
pythontech 0:5868e8752d44 126 #endif
pythontech 0:5868e8752d44 127
pythontech 0:5868e8752d44 128 // Initial amount for parse rule stack
pythontech 0:5868e8752d44 129 #ifndef MICROPY_ALLOC_PARSE_RULE_INIT
pythontech 0:5868e8752d44 130 #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
pythontech 0:5868e8752d44 131 #endif
pythontech 0:5868e8752d44 132
pythontech 0:5868e8752d44 133 // Increment for parse rule stack
pythontech 0:5868e8752d44 134 #ifndef MICROPY_ALLOC_PARSE_RULE_INC
pythontech 0:5868e8752d44 135 #define MICROPY_ALLOC_PARSE_RULE_INC (16)
pythontech 0:5868e8752d44 136 #endif
pythontech 0:5868e8752d44 137
pythontech 0:5868e8752d44 138 // Initial amount for parse result stack
pythontech 0:5868e8752d44 139 #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
pythontech 0:5868e8752d44 140 #define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
pythontech 0:5868e8752d44 141 #endif
pythontech 0:5868e8752d44 142
pythontech 0:5868e8752d44 143 // Increment for parse result stack
pythontech 0:5868e8752d44 144 #ifndef MICROPY_ALLOC_PARSE_RESULT_INC
pythontech 0:5868e8752d44 145 #define MICROPY_ALLOC_PARSE_RESULT_INC (16)
pythontech 0:5868e8752d44 146 #endif
pythontech 0:5868e8752d44 147
pythontech 0:5868e8752d44 148 // Strings this length or less will be interned by the parser
pythontech 0:5868e8752d44 149 #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
pythontech 0:5868e8752d44 150 #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
pythontech 0:5868e8752d44 151 #endif
pythontech 0:5868e8752d44 152
pythontech 0:5868e8752d44 153 // Number of bytes to allocate initially when creating new chunks to store
pythontech 0:5868e8752d44 154 // parse nodes. Small leads to fragmentation, large leads to excess use.
pythontech 0:5868e8752d44 155 #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
pythontech 0:5868e8752d44 156 #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
pythontech 0:5868e8752d44 157 #endif
pythontech 0:5868e8752d44 158
pythontech 0:5868e8752d44 159 // Initial amount for ids in a scope
pythontech 0:5868e8752d44 160 #ifndef MICROPY_ALLOC_SCOPE_ID_INIT
pythontech 0:5868e8752d44 161 #define MICROPY_ALLOC_SCOPE_ID_INIT (4)
pythontech 0:5868e8752d44 162 #endif
pythontech 0:5868e8752d44 163
pythontech 0:5868e8752d44 164 // Increment for ids in a scope
pythontech 0:5868e8752d44 165 #ifndef MICROPY_ALLOC_SCOPE_ID_INC
pythontech 0:5868e8752d44 166 #define MICROPY_ALLOC_SCOPE_ID_INC (6)
pythontech 0:5868e8752d44 167 #endif
pythontech 0:5868e8752d44 168
pythontech 0:5868e8752d44 169 // Maximum length of a path in the filesystem
pythontech 0:5868e8752d44 170 // So we can allocate a buffer on the stack for path manipulation in import
pythontech 0:5868e8752d44 171 #ifndef MICROPY_ALLOC_PATH_MAX
pythontech 0:5868e8752d44 172 #define MICROPY_ALLOC_PATH_MAX (512)
pythontech 0:5868e8752d44 173 #endif
pythontech 0:5868e8752d44 174
pythontech 0:5868e8752d44 175 // Initial size of module dict
pythontech 0:5868e8752d44 176 #ifndef MICROPY_MODULE_DICT_SIZE
pythontech 0:5868e8752d44 177 #define MICROPY_MODULE_DICT_SIZE (1)
pythontech 0:5868e8752d44 178 #endif
pythontech 0:5868e8752d44 179
pythontech 0:5868e8752d44 180 // Whether realloc/free should be passed allocated memory region size
pythontech 0:5868e8752d44 181 // You must enable this if MICROPY_MEM_STATS is enabled
pythontech 0:5868e8752d44 182 #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
pythontech 0:5868e8752d44 183 #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
pythontech 0:5868e8752d44 184 #endif
pythontech 0:5868e8752d44 185
pythontech 0:5868e8752d44 186 // Number of bytes used to store qstr length
pythontech 0:5868e8752d44 187 // Dictates hard limit on maximum Python identifier length, but 1 byte
pythontech 0:5868e8752d44 188 // (limit of 255 bytes in an identifier) should be enough for everyone
pythontech 0:5868e8752d44 189 #ifndef MICROPY_QSTR_BYTES_IN_LEN
pythontech 0:5868e8752d44 190 #define MICROPY_QSTR_BYTES_IN_LEN (1)
pythontech 0:5868e8752d44 191 #endif
pythontech 0:5868e8752d44 192
pythontech 0:5868e8752d44 193 // Number of bytes used to store qstr hash
pythontech 0:5868e8752d44 194 #ifndef MICROPY_QSTR_BYTES_IN_HASH
pythontech 0:5868e8752d44 195 #define MICROPY_QSTR_BYTES_IN_HASH (2)
pythontech 0:5868e8752d44 196 #endif
pythontech 0:5868e8752d44 197
pythontech 0:5868e8752d44 198 // Avoid using C stack when making Python function calls. C stack still
pythontech 0:5868e8752d44 199 // may be used if there's no free heap.
pythontech 0:5868e8752d44 200 #ifndef MICROPY_STACKLESS
pythontech 0:5868e8752d44 201 #define MICROPY_STACKLESS (0)
pythontech 0:5868e8752d44 202 #endif
pythontech 0:5868e8752d44 203
pythontech 0:5868e8752d44 204 // Never use C stack when making Python function calls. This may break
pythontech 0:5868e8752d44 205 // testsuite as will subtly change which exception is thrown in case
pythontech 0:5868e8752d44 206 // of too deep recursion and other similar cases.
pythontech 0:5868e8752d44 207 #ifndef MICROPY_STACKLESS_STRICT
pythontech 0:5868e8752d44 208 #define MICROPY_STACKLESS_STRICT (0)
pythontech 0:5868e8752d44 209 #endif
pythontech 0:5868e8752d44 210
pythontech 0:5868e8752d44 211 // Don't use alloca calls. As alloca() is not part of ANSI C, this
pythontech 0:5868e8752d44 212 // workaround option is provided for compilers lacking this de-facto
pythontech 0:5868e8752d44 213 // standard function. The way it works is allocating from heap, and
pythontech 0:5868e8752d44 214 // relying on garbage collection to free it eventually. This is of
pythontech 0:5868e8752d44 215 // course much less optimal than real alloca().
pythontech 0:5868e8752d44 216 #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
pythontech 0:5868e8752d44 217 #undef alloca
pythontech 0:5868e8752d44 218 #define alloca(x) m_malloc(x)
pythontech 0:5868e8752d44 219 #endif
pythontech 0:5868e8752d44 220
pythontech 0:5868e8752d44 221 /*****************************************************************************/
pythontech 0:5868e8752d44 222 /* Micro Python emitters */
pythontech 0:5868e8752d44 223
pythontech 0:5868e8752d44 224 // Whether to support loading of persistent code
pythontech 0:5868e8752d44 225 #ifndef MICROPY_PERSISTENT_CODE_LOAD
pythontech 0:5868e8752d44 226 #define MICROPY_PERSISTENT_CODE_LOAD (0)
pythontech 0:5868e8752d44 227 #endif
pythontech 0:5868e8752d44 228
pythontech 0:5868e8752d44 229 // Whether to support saving of persistent code
pythontech 0:5868e8752d44 230 #ifndef MICROPY_PERSISTENT_CODE_SAVE
pythontech 0:5868e8752d44 231 #define MICROPY_PERSISTENT_CODE_SAVE (0)
pythontech 0:5868e8752d44 232 #endif
pythontech 0:5868e8752d44 233
pythontech 0:5868e8752d44 234 // Whether generated code can persist independently of the VM/runtime instance
pythontech 0:5868e8752d44 235 // This is enabled automatically when needed by other features
pythontech 0:5868e8752d44 236 #ifndef MICROPY_PERSISTENT_CODE
Colin Hogben 2:c89e95946844 237 #define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
pythontech 0:5868e8752d44 238 #endif
pythontech 0:5868e8752d44 239
pythontech 0:5868e8752d44 240 // Whether to emit x64 native code
pythontech 0:5868e8752d44 241 #ifndef MICROPY_EMIT_X64
pythontech 0:5868e8752d44 242 #define MICROPY_EMIT_X64 (0)
pythontech 0:5868e8752d44 243 #endif
pythontech 0:5868e8752d44 244
pythontech 0:5868e8752d44 245 // Whether to emit x86 native code
pythontech 0:5868e8752d44 246 #ifndef MICROPY_EMIT_X86
pythontech 0:5868e8752d44 247 #define MICROPY_EMIT_X86 (0)
pythontech 0:5868e8752d44 248 #endif
pythontech 0:5868e8752d44 249
pythontech 0:5868e8752d44 250 // Whether to emit thumb native code
pythontech 0:5868e8752d44 251 #ifndef MICROPY_EMIT_THUMB
pythontech 0:5868e8752d44 252 #define MICROPY_EMIT_THUMB (0)
pythontech 0:5868e8752d44 253 #endif
pythontech 0:5868e8752d44 254
pythontech 0:5868e8752d44 255 // Whether to enable the thumb inline assembler
pythontech 0:5868e8752d44 256 #ifndef MICROPY_EMIT_INLINE_THUMB
pythontech 0:5868e8752d44 257 #define MICROPY_EMIT_INLINE_THUMB (0)
pythontech 0:5868e8752d44 258 #endif
pythontech 0:5868e8752d44 259
pythontech 0:5868e8752d44 260 // Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
pythontech 0:5868e8752d44 261 #ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
pythontech 0:5868e8752d44 262 #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
pythontech 0:5868e8752d44 263 #endif
pythontech 0:5868e8752d44 264
pythontech 0:5868e8752d44 265 // Whether to enable float support in the Thumb2 inline assembler
pythontech 0:5868e8752d44 266 #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
pythontech 0:5868e8752d44 267 #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
pythontech 0:5868e8752d44 268 #endif
pythontech 0:5868e8752d44 269
pythontech 0:5868e8752d44 270 // Whether to emit ARM native code
pythontech 0:5868e8752d44 271 #ifndef MICROPY_EMIT_ARM
pythontech 0:5868e8752d44 272 #define MICROPY_EMIT_ARM (0)
pythontech 0:5868e8752d44 273 #endif
pythontech 0:5868e8752d44 274
pythontech 0:5868e8752d44 275 // Convenience definition for whether any native emitter is enabled
pythontech 0:5868e8752d44 276 #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM)
pythontech 0:5868e8752d44 277
pythontech 0:5868e8752d44 278 /*****************************************************************************/
pythontech 0:5868e8752d44 279 /* Compiler configuration */
pythontech 0:5868e8752d44 280
pythontech 0:5868e8752d44 281 // Whether to include the compiler
pythontech 0:5868e8752d44 282 #ifndef MICROPY_ENABLE_COMPILER
pythontech 0:5868e8752d44 283 #define MICROPY_ENABLE_COMPILER (1)
pythontech 0:5868e8752d44 284 #endif
pythontech 0:5868e8752d44 285
pythontech 0:5868e8752d44 286 // Whether the compiler is dynamically configurable (ie at runtime)
pythontech 0:5868e8752d44 287 #ifndef MICROPY_DYNAMIC_COMPILER
pythontech 0:5868e8752d44 288 #define MICROPY_DYNAMIC_COMPILER (0)
pythontech 0:5868e8752d44 289 #endif
pythontech 0:5868e8752d44 290
pythontech 0:5868e8752d44 291 // Configure dynamic compiler macros
pythontech 0:5868e8752d44 292 #if MICROPY_DYNAMIC_COMPILER
pythontech 0:5868e8752d44 293 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
pythontech 0:5868e8752d44 294 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
pythontech 0:5868e8752d44 295 #else
pythontech 0:5868e8752d44 296 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
pythontech 0:5868e8752d44 297 #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
pythontech 0:5868e8752d44 298 #endif
pythontech 0:5868e8752d44 299
pythontech 0:5868e8752d44 300 // Whether to enable constant folding; eg 1+2 rewritten as 3
pythontech 0:5868e8752d44 301 #ifndef MICROPY_COMP_CONST_FOLDING
pythontech 0:5868e8752d44 302 #define MICROPY_COMP_CONST_FOLDING (1)
pythontech 0:5868e8752d44 303 #endif
pythontech 0:5868e8752d44 304
pythontech 0:5868e8752d44 305 // Whether to enable lookup of constants in modules; eg module.CONST
pythontech 0:5868e8752d44 306 #ifndef MICROPY_COMP_MODULE_CONST
pythontech 0:5868e8752d44 307 #define MICROPY_COMP_MODULE_CONST (0)
pythontech 0:5868e8752d44 308 #endif
pythontech 0:5868e8752d44 309
pythontech 0:5868e8752d44 310 // Whether to enable constant optimisation; id = const(value)
pythontech 0:5868e8752d44 311 #ifndef MICROPY_COMP_CONST
pythontech 0:5868e8752d44 312 #define MICROPY_COMP_CONST (1)
pythontech 0:5868e8752d44 313 #endif
pythontech 0:5868e8752d44 314
pythontech 0:5868e8752d44 315 // Whether to enable optimisation of: a, b = c, d
pythontech 0:5868e8752d44 316 // Costs 124 bytes (Thumb2)
pythontech 0:5868e8752d44 317 #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
pythontech 0:5868e8752d44 318 #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
pythontech 0:5868e8752d44 319 #endif
pythontech 0:5868e8752d44 320
pythontech 0:5868e8752d44 321 // Whether to enable optimisation of: a, b, c = d, e, f
pythontech 0:5868e8752d44 322 // Cost 156 bytes (Thumb2)
pythontech 0:5868e8752d44 323 #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
pythontech 0:5868e8752d44 324 #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
pythontech 0:5868e8752d44 325 #endif
pythontech 0:5868e8752d44 326
pythontech 0:5868e8752d44 327 /*****************************************************************************/
pythontech 0:5868e8752d44 328 /* Internal debugging stuff */
pythontech 0:5868e8752d44 329
pythontech 0:5868e8752d44 330 // Whether to collect memory allocation stats
pythontech 0:5868e8752d44 331 #ifndef MICROPY_MEM_STATS
pythontech 0:5868e8752d44 332 #define MICROPY_MEM_STATS (0)
pythontech 0:5868e8752d44 333 #endif
pythontech 0:5868e8752d44 334
pythontech 0:5868e8752d44 335 // Whether to build functions that print debugging info:
pythontech 0:5868e8752d44 336 // mp_lexer_show_token
pythontech 0:5868e8752d44 337 // mp_bytecode_print
pythontech 0:5868e8752d44 338 // mp_parse_node_print
pythontech 0:5868e8752d44 339 #ifndef MICROPY_DEBUG_PRINTERS
pythontech 0:5868e8752d44 340 #define MICROPY_DEBUG_PRINTERS (0)
pythontech 0:5868e8752d44 341 #endif
pythontech 0:5868e8752d44 342
pythontech 0:5868e8752d44 343 /*****************************************************************************/
pythontech 0:5868e8752d44 344 /* Optimisations */
pythontech 0:5868e8752d44 345
pythontech 0:5868e8752d44 346 // Whether to use computed gotos in the VM, or a switch
pythontech 0:5868e8752d44 347 // Computed gotos are roughly 10% faster, and increase VM code size by a little
pythontech 0:5868e8752d44 348 #ifndef MICROPY_OPT_COMPUTED_GOTO
pythontech 0:5868e8752d44 349 #define MICROPY_OPT_COMPUTED_GOTO (0)
pythontech 0:5868e8752d44 350 #endif
pythontech 0:5868e8752d44 351
pythontech 0:5868e8752d44 352 // Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
pythontech 0:5868e8752d44 353 // STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
pythontech 0:5868e8752d44 354 // uses a bit of extra code ROM, but greatly improves lookup speed.
pythontech 0:5868e8752d44 355 #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
pythontech 0:5868e8752d44 356 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
pythontech 0:5868e8752d44 357 #endif
pythontech 0:5868e8752d44 358
pythontech 0:5868e8752d44 359 // Whether to use fast versions of bitwise operations (and, or, xor) when the
pythontech 0:5868e8752d44 360 // arguments are both positive. Increases Thumb2 code size by about 250 bytes.
pythontech 0:5868e8752d44 361 #ifndef MICROPY_OPT_MPZ_BITWISE
pythontech 0:5868e8752d44 362 #define MICROPY_OPT_MPZ_BITWISE (0)
pythontech 0:5868e8752d44 363 #endif
pythontech 0:5868e8752d44 364
pythontech 0:5868e8752d44 365 /*****************************************************************************/
pythontech 0:5868e8752d44 366 /* Python internal features */
pythontech 0:5868e8752d44 367
pythontech 0:5868e8752d44 368 // Hook for the VM at the start of the opcode loop (can contain variable
pythontech 0:5868e8752d44 369 // definitions usable by the other hook functions)
pythontech 0:5868e8752d44 370 #ifndef MICROPY_VM_HOOK_INIT
pythontech 0:5868e8752d44 371 #define MICROPY_VM_HOOK_INIT
pythontech 0:5868e8752d44 372 #endif
pythontech 0:5868e8752d44 373
pythontech 0:5868e8752d44 374 // Hook for the VM during the opcode loop (but only after jump opcodes)
pythontech 0:5868e8752d44 375 #ifndef MICROPY_VM_HOOK_LOOP
pythontech 0:5868e8752d44 376 #define MICROPY_VM_HOOK_LOOP
pythontech 0:5868e8752d44 377 #endif
pythontech 0:5868e8752d44 378
pythontech 0:5868e8752d44 379 // Hook for the VM just before return opcode is finished being interpreted
pythontech 0:5868e8752d44 380 #ifndef MICROPY_VM_HOOK_RETURN
pythontech 0:5868e8752d44 381 #define MICROPY_VM_HOOK_RETURN
pythontech 0:5868e8752d44 382 #endif
pythontech 0:5868e8752d44 383
pythontech 0:5868e8752d44 384 // Whether to include the garbage collector
pythontech 0:5868e8752d44 385 #ifndef MICROPY_ENABLE_GC
pythontech 0:5868e8752d44 386 #define MICROPY_ENABLE_GC (0)
pythontech 0:5868e8752d44 387 #endif
pythontech 0:5868e8752d44 388
pythontech 0:5868e8752d44 389 // Whether to enable finalisers in the garbage collector (ie call __del__)
pythontech 0:5868e8752d44 390 #ifndef MICROPY_ENABLE_FINALISER
pythontech 0:5868e8752d44 391 #define MICROPY_ENABLE_FINALISER (0)
pythontech 0:5868e8752d44 392 #endif
pythontech 0:5868e8752d44 393
pythontech 0:5868e8752d44 394 // Whether to check C stack usage. C stack used for calling Python functions,
pythontech 0:5868e8752d44 395 // etc. Not checking means segfault on overflow.
pythontech 0:5868e8752d44 396 #ifndef MICROPY_STACK_CHECK
pythontech 0:5868e8752d44 397 #define MICROPY_STACK_CHECK (0)
pythontech 0:5868e8752d44 398 #endif
pythontech 0:5868e8752d44 399
pythontech 0:5868e8752d44 400 // Whether to have an emergency exception buffer
pythontech 0:5868e8752d44 401 #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
pythontech 0:5868e8752d44 402 #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
pythontech 0:5868e8752d44 403 #endif
pythontech 0:5868e8752d44 404 #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
pythontech 0:5868e8752d44 405 # ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
pythontech 0:5868e8752d44 406 # define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
pythontech 0:5868e8752d44 407 # endif
pythontech 0:5868e8752d44 408 #endif
pythontech 0:5868e8752d44 409
pythontech 0:5868e8752d44 410 // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
pythontech 0:5868e8752d44 411 // handler) - if supported by a particular port.
pythontech 0:5868e8752d44 412 #ifndef MICROPY_ASYNC_KBD_INTR
pythontech 0:5868e8752d44 413 #define MICROPY_ASYNC_KBD_INTR (0)
pythontech 0:5868e8752d44 414 #endif
pythontech 0:5868e8752d44 415
pythontech 0:5868e8752d44 416 // Whether to include REPL helper function
pythontech 0:5868e8752d44 417 #ifndef MICROPY_HELPER_REPL
pythontech 0:5868e8752d44 418 #define MICROPY_HELPER_REPL (0)
pythontech 0:5868e8752d44 419 #endif
pythontech 0:5868e8752d44 420
pythontech 0:5868e8752d44 421 // Whether to include emacs-style readline behavior in REPL
pythontech 0:5868e8752d44 422 #ifndef MICROPY_REPL_EMACS_KEYS
pythontech 0:5868e8752d44 423 #define MICROPY_REPL_EMACS_KEYS (0)
pythontech 0:5868e8752d44 424 #endif
pythontech 0:5868e8752d44 425
pythontech 0:5868e8752d44 426 // Whether to implement auto-indent in REPL
pythontech 0:5868e8752d44 427 #ifndef MICROPY_REPL_AUTO_INDENT
pythontech 0:5868e8752d44 428 #define MICROPY_REPL_AUTO_INDENT (0)
pythontech 0:5868e8752d44 429 #endif
pythontech 0:5868e8752d44 430
pythontech 0:5868e8752d44 431 // Whether port requires event-driven REPL functions
pythontech 0:5868e8752d44 432 #ifndef MICROPY_REPL_EVENT_DRIVEN
pythontech 0:5868e8752d44 433 #define MICROPY_REPL_EVENT_DRIVEN (0)
pythontech 0:5868e8752d44 434 #endif
pythontech 0:5868e8752d44 435
pythontech 0:5868e8752d44 436 // Whether to include lexer helper function for unix
pythontech 0:5868e8752d44 437 #ifndef MICROPY_HELPER_LEXER_UNIX
pythontech 0:5868e8752d44 438 #define MICROPY_HELPER_LEXER_UNIX (0)
pythontech 0:5868e8752d44 439 #endif
pythontech 0:5868e8752d44 440
pythontech 0:5868e8752d44 441 // Long int implementation
pythontech 0:5868e8752d44 442 #define MICROPY_LONGINT_IMPL_NONE (0)
pythontech 0:5868e8752d44 443 #define MICROPY_LONGINT_IMPL_LONGLONG (1)
pythontech 0:5868e8752d44 444 #define MICROPY_LONGINT_IMPL_MPZ (2)
pythontech 0:5868e8752d44 445
pythontech 0:5868e8752d44 446 #ifndef MICROPY_LONGINT_IMPL
pythontech 0:5868e8752d44 447 #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
pythontech 0:5868e8752d44 448 #endif
pythontech 0:5868e8752d44 449
pythontech 0:5868e8752d44 450 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
pythontech 0:5868e8752d44 451 typedef long long mp_longint_impl_t;
pythontech 0:5868e8752d44 452 #endif
pythontech 0:5868e8752d44 453
pythontech 0:5868e8752d44 454 // Whether to include information in the byte code to determine source
pythontech 0:5868e8752d44 455 // line number (increases RAM usage, but doesn't slow byte code execution)
pythontech 0:5868e8752d44 456 #ifndef MICROPY_ENABLE_SOURCE_LINE
pythontech 0:5868e8752d44 457 #define MICROPY_ENABLE_SOURCE_LINE (0)
pythontech 0:5868e8752d44 458 #endif
pythontech 0:5868e8752d44 459
pythontech 0:5868e8752d44 460 // Whether to include doc strings (increases RAM usage)
pythontech 0:5868e8752d44 461 #ifndef MICROPY_ENABLE_DOC_STRING
pythontech 0:5868e8752d44 462 #define MICROPY_ENABLE_DOC_STRING (0)
pythontech 0:5868e8752d44 463 #endif
pythontech 0:5868e8752d44 464
pythontech 0:5868e8752d44 465 // Exception messages are short static strings
pythontech 0:5868e8752d44 466 #define MICROPY_ERROR_REPORTING_TERSE (1)
pythontech 0:5868e8752d44 467 // Exception messages provide basic error details
pythontech 0:5868e8752d44 468 #define MICROPY_ERROR_REPORTING_NORMAL (2)
pythontech 0:5868e8752d44 469 // Exception messages provide full info, e.g. object names
pythontech 0:5868e8752d44 470 #define MICROPY_ERROR_REPORTING_DETAILED (3)
pythontech 0:5868e8752d44 471
pythontech 0:5868e8752d44 472 #ifndef MICROPY_ERROR_REPORTING
pythontech 0:5868e8752d44 473 #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
pythontech 0:5868e8752d44 474 #endif
pythontech 0:5868e8752d44 475
pythontech 0:5868e8752d44 476 // Whether issue warnings during compiling/execution
pythontech 0:5868e8752d44 477 #ifndef MICROPY_WARNINGS
pythontech 0:5868e8752d44 478 #define MICROPY_WARNINGS (0)
pythontech 0:5868e8752d44 479 #endif
pythontech 0:5868e8752d44 480
pythontech 0:5868e8752d44 481 // Float and complex implementation
pythontech 0:5868e8752d44 482 #define MICROPY_FLOAT_IMPL_NONE (0)
pythontech 0:5868e8752d44 483 #define MICROPY_FLOAT_IMPL_FLOAT (1)
pythontech 0:5868e8752d44 484 #define MICROPY_FLOAT_IMPL_DOUBLE (2)
pythontech 0:5868e8752d44 485
pythontech 0:5868e8752d44 486 #ifndef MICROPY_FLOAT_IMPL
pythontech 0:5868e8752d44 487 #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
pythontech 0:5868e8752d44 488 #endif
pythontech 0:5868e8752d44 489
pythontech 0:5868e8752d44 490 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
pythontech 0:5868e8752d44 491 #define MICROPY_PY_BUILTINS_FLOAT (1)
pythontech 0:5868e8752d44 492 #define MICROPY_FLOAT_C_FUN(fun) fun##f
pythontech 0:5868e8752d44 493 typedef float mp_float_t;
pythontech 0:5868e8752d44 494 #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
pythontech 0:5868e8752d44 495 #define MICROPY_PY_BUILTINS_FLOAT (1)
pythontech 0:5868e8752d44 496 #define MICROPY_FLOAT_C_FUN(fun) fun
pythontech 0:5868e8752d44 497 typedef double mp_float_t;
pythontech 0:5868e8752d44 498 #else
pythontech 0:5868e8752d44 499 #define MICROPY_PY_BUILTINS_FLOAT (0)
pythontech 0:5868e8752d44 500 #endif
pythontech 0:5868e8752d44 501
pythontech 0:5868e8752d44 502 #ifndef MICROPY_PY_BUILTINS_COMPLEX
pythontech 0:5868e8752d44 503 #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
pythontech 0:5868e8752d44 504 #endif
pythontech 0:5868e8752d44 505
pythontech 0:5868e8752d44 506 // Enable features which improve CPython compatibility
pythontech 0:5868e8752d44 507 // but may lead to more code size/memory usage.
pythontech 0:5868e8752d44 508 // TODO: Originally intended as generic category to not
pythontech 0:5868e8752d44 509 // add bunch of once-off options. May need refactoring later
pythontech 0:5868e8752d44 510 #ifndef MICROPY_CPYTHON_COMPAT
pythontech 0:5868e8752d44 511 #define MICROPY_CPYTHON_COMPAT (1)
pythontech 0:5868e8752d44 512 #endif
pythontech 0:5868e8752d44 513
pythontech 0:5868e8752d44 514 // Whether POSIX-semantics non-blocking streams are supported
pythontech 0:5868e8752d44 515 #ifndef MICROPY_STREAMS_NON_BLOCK
pythontech 0:5868e8752d44 516 #define MICROPY_STREAMS_NON_BLOCK (0)
pythontech 0:5868e8752d44 517 #endif
pythontech 0:5868e8752d44 518
pythontech 0:5868e8752d44 519 // Whether to call __init__ when importing builtin modules for the first time
pythontech 0:5868e8752d44 520 #ifndef MICROPY_MODULE_BUILTIN_INIT
pythontech 0:5868e8752d44 521 #define MICROPY_MODULE_BUILTIN_INIT (0)
pythontech 0:5868e8752d44 522 #endif
pythontech 0:5868e8752d44 523
pythontech 0:5868e8752d44 524 // Whether module weak links are supported
pythontech 0:5868e8752d44 525 #ifndef MICROPY_MODULE_WEAK_LINKS
pythontech 0:5868e8752d44 526 #define MICROPY_MODULE_WEAK_LINKS (0)
pythontech 0:5868e8752d44 527 #endif
pythontech 0:5868e8752d44 528
Colin Hogben 2:c89e95946844 529 // Whether frozen modules are supported in the form of strings
Colin Hogben 2:c89e95946844 530 #ifndef MICROPY_MODULE_FROZEN_STR
Colin Hogben 2:c89e95946844 531 #define MICROPY_MODULE_FROZEN_STR (0)
Colin Hogben 2:c89e95946844 532 #endif
Colin Hogben 2:c89e95946844 533
Colin Hogben 2:c89e95946844 534 // Whether frozen modules are supported in the form of .mpy files
Colin Hogben 2:c89e95946844 535 #ifndef MICROPY_MODULE_FROZEN_MPY
Colin Hogben 2:c89e95946844 536 #define MICROPY_MODULE_FROZEN_MPY (0)
Colin Hogben 2:c89e95946844 537 #endif
Colin Hogben 2:c89e95946844 538
Colin Hogben 2:c89e95946844 539 // Convenience macro for whether frozen modules are supported
pythontech 0:5868e8752d44 540 #ifndef MICROPY_MODULE_FROZEN
Colin Hogben 2:c89e95946844 541 #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
pythontech 0:5868e8752d44 542 #endif
pythontech 0:5868e8752d44 543
pythontech 0:5868e8752d44 544 // Whether you can override builtins in the builtins module
pythontech 0:5868e8752d44 545 #ifndef MICROPY_CAN_OVERRIDE_BUILTINS
pythontech 0:5868e8752d44 546 #define MICROPY_CAN_OVERRIDE_BUILTINS (0)
pythontech 0:5868e8752d44 547 #endif
pythontech 0:5868e8752d44 548
pythontech 0:5868e8752d44 549 // Whether to check that the "self" argument of a builtin method has the
pythontech 0:5868e8752d44 550 // correct type. Such an explicit check is only needed if a builtin
pythontech 0:5868e8752d44 551 // method escapes to Python land without a first argument, eg
pythontech 0:5868e8752d44 552 // list.append([], 1). Without this check such calls will have undefined
pythontech 0:5868e8752d44 553 // behaviour (usually segfault) if the first argument is the wrong type.
pythontech 0:5868e8752d44 554 #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
pythontech 0:5868e8752d44 555 #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
pythontech 0:5868e8752d44 556 #endif
pythontech 0:5868e8752d44 557
pythontech 0:5868e8752d44 558 // Support for user-space VFS mount (selected ports)
pythontech 0:5868e8752d44 559 #ifndef MICROPY_FSUSERMOUNT
pythontech 0:5868e8752d44 560 #define MICROPY_FSUSERMOUNT (0)
pythontech 0:5868e8752d44 561 #endif
pythontech 0:5868e8752d44 562
pythontech 0:5868e8752d44 563 /*****************************************************************************/
pythontech 0:5868e8752d44 564 /* Fine control over Python builtins, classes, modules, etc */
pythontech 0:5868e8752d44 565
pythontech 0:5868e8752d44 566 // Whether to implement attributes on functions
pythontech 0:5868e8752d44 567 #ifndef MICROPY_PY_FUNCTION_ATTRS
pythontech 0:5868e8752d44 568 #define MICROPY_PY_FUNCTION_ATTRS (0)
pythontech 0:5868e8752d44 569 #endif
pythontech 0:5868e8752d44 570
pythontech 0:5868e8752d44 571 // Whether to support descriptors (__get__ and __set__)
pythontech 0:5868e8752d44 572 // This costs some code size and makes all load attrs and store attrs slow
pythontech 0:5868e8752d44 573 #ifndef MICROPY_PY_DESCRIPTORS
pythontech 0:5868e8752d44 574 #define MICROPY_PY_DESCRIPTORS (0)
pythontech 0:5868e8752d44 575 #endif
pythontech 0:5868e8752d44 576
Colin Hogben 2:c89e95946844 577 // Support for async/await/async for/async with
Colin Hogben 2:c89e95946844 578 #ifndef MICROPY_PY_ASYNC_AWAIT
Colin Hogben 2:c89e95946844 579 #define MICROPY_PY_ASYNC_AWAIT (1)
Colin Hogben 2:c89e95946844 580 #endif
Colin Hogben 2:c89e95946844 581
pythontech 0:5868e8752d44 582 // Whether str object is proper unicode
pythontech 0:5868e8752d44 583 #ifndef MICROPY_PY_BUILTINS_STR_UNICODE
pythontech 0:5868e8752d44 584 #define MICROPY_PY_BUILTINS_STR_UNICODE (0)
pythontech 0:5868e8752d44 585 #endif
pythontech 0:5868e8752d44 586
pythontech 0:5868e8752d44 587 // Whether str.splitlines() method provided
pythontech 0:5868e8752d44 588 #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
pythontech 0:5868e8752d44 589 #define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
pythontech 0:5868e8752d44 590 #endif
pythontech 0:5868e8752d44 591
pythontech 0:5868e8752d44 592 // Whether to support bytearray object
pythontech 0:5868e8752d44 593 #ifndef MICROPY_PY_BUILTINS_BYTEARRAY
pythontech 0:5868e8752d44 594 #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
pythontech 0:5868e8752d44 595 #endif
pythontech 0:5868e8752d44 596
pythontech 0:5868e8752d44 597 // Whether to support memoryview object
pythontech 0:5868e8752d44 598 #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
pythontech 0:5868e8752d44 599 #define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
pythontech 0:5868e8752d44 600 #endif
pythontech 0:5868e8752d44 601
pythontech 0:5868e8752d44 602 // Whether to support set object
pythontech 0:5868e8752d44 603 #ifndef MICROPY_PY_BUILTINS_SET
pythontech 0:5868e8752d44 604 #define MICROPY_PY_BUILTINS_SET (1)
pythontech 0:5868e8752d44 605 #endif
pythontech 0:5868e8752d44 606
pythontech 0:5868e8752d44 607 // Whether to support slice subscript operators and slice object
pythontech 0:5868e8752d44 608 #ifndef MICROPY_PY_BUILTINS_SLICE
pythontech 0:5868e8752d44 609 #define MICROPY_PY_BUILTINS_SLICE (1)
pythontech 0:5868e8752d44 610 #endif
pythontech 0:5868e8752d44 611
pythontech 0:5868e8752d44 612 // Whether to support slice attribute read access,
pythontech 0:5868e8752d44 613 // i.e. slice.start, slice.stop, slice.step
pythontech 0:5868e8752d44 614 #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
pythontech 0:5868e8752d44 615 #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
pythontech 0:5868e8752d44 616 #endif
pythontech 0:5868e8752d44 617
pythontech 0:5868e8752d44 618 // Whether to support frozenset object
pythontech 0:5868e8752d44 619 #ifndef MICROPY_PY_BUILTINS_FROZENSET
pythontech 0:5868e8752d44 620 #define MICROPY_PY_BUILTINS_FROZENSET (0)
pythontech 0:5868e8752d44 621 #endif
pythontech 0:5868e8752d44 622
pythontech 0:5868e8752d44 623 // Whether to support property object
pythontech 0:5868e8752d44 624 #ifndef MICROPY_PY_BUILTINS_PROPERTY
pythontech 0:5868e8752d44 625 #define MICROPY_PY_BUILTINS_PROPERTY (1)
pythontech 0:5868e8752d44 626 #endif
pythontech 0:5868e8752d44 627
pythontech 0:5868e8752d44 628 // Whether to implement the start/stop/step attributes (readback) on
pythontech 0:5868e8752d44 629 // the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
pythontech 0:5868e8752d44 630 #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
pythontech 0:5868e8752d44 631 #define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
pythontech 0:5868e8752d44 632 #endif
pythontech 0:5868e8752d44 633
pythontech 0:5868e8752d44 634 // Whether to support timeout exceptions (like socket.timeout)
pythontech 0:5868e8752d44 635 #ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR
pythontech 0:5868e8752d44 636 #define MICROPY_PY_BUILTINS_TIMEOUTERROR (0)
pythontech 0:5868e8752d44 637 #endif
pythontech 0:5868e8752d44 638
pythontech 0:5868e8752d44 639 // Whether to support complete set of special methods
pythontech 0:5868e8752d44 640 // for user classes, otherwise only the most used
pythontech 0:5868e8752d44 641 #ifndef MICROPY_PY_ALL_SPECIAL_METHODS
pythontech 0:5868e8752d44 642 #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
pythontech 0:5868e8752d44 643 #endif
pythontech 0:5868e8752d44 644
pythontech 0:5868e8752d44 645 // Whether to support compile function
pythontech 0:5868e8752d44 646 #ifndef MICROPY_PY_BUILTINS_COMPILE
pythontech 0:5868e8752d44 647 #define MICROPY_PY_BUILTINS_COMPILE (0)
pythontech 0:5868e8752d44 648 #endif
pythontech 0:5868e8752d44 649
pythontech 0:5868e8752d44 650 // Whether to support enumerate function(type)
pythontech 0:5868e8752d44 651 #ifndef MICROPY_PY_BUILTINS_ENUMERATE
pythontech 0:5868e8752d44 652 #define MICROPY_PY_BUILTINS_ENUMERATE (1)
pythontech 0:5868e8752d44 653 #endif
pythontech 0:5868e8752d44 654
pythontech 0:5868e8752d44 655 // Whether to support eval and exec functions
pythontech 0:5868e8752d44 656 // By default they are supported if the compiler is enabled
pythontech 0:5868e8752d44 657 #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
pythontech 0:5868e8752d44 658 #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
pythontech 0:5868e8752d44 659 #endif
pythontech 0:5868e8752d44 660
pythontech 0:5868e8752d44 661 // Whether to support the Python 2 execfile function
pythontech 0:5868e8752d44 662 #ifndef MICROPY_PY_BUILTINS_EXECFILE
pythontech 0:5868e8752d44 663 #define MICROPY_PY_BUILTINS_EXECFILE (0)
pythontech 0:5868e8752d44 664 #endif
pythontech 0:5868e8752d44 665
pythontech 0:5868e8752d44 666 // Whether to support filter function(type)
pythontech 0:5868e8752d44 667 #ifndef MICROPY_PY_BUILTINS_FILTER
pythontech 0:5868e8752d44 668 #define MICROPY_PY_BUILTINS_FILTER (1)
pythontech 0:5868e8752d44 669 #endif
pythontech 0:5868e8752d44 670
pythontech 0:5868e8752d44 671 // Whether to support reversed function(type)
pythontech 0:5868e8752d44 672 #ifndef MICROPY_PY_BUILTINS_REVERSED
pythontech 0:5868e8752d44 673 #define MICROPY_PY_BUILTINS_REVERSED (1)
pythontech 0:5868e8752d44 674 #endif
pythontech 0:5868e8752d44 675
pythontech 0:5868e8752d44 676 // Whether to define "NotImplemented" special constant
pythontech 0:5868e8752d44 677 #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
pythontech 0:5868e8752d44 678 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
pythontech 0:5868e8752d44 679 #endif
pythontech 0:5868e8752d44 680
pythontech 0:5868e8752d44 681 // Whether to support min/max functions
pythontech 0:5868e8752d44 682 #ifndef MICROPY_PY_BUILTINS_MIN_MAX
pythontech 0:5868e8752d44 683 #define MICROPY_PY_BUILTINS_MIN_MAX (1)
pythontech 0:5868e8752d44 684 #endif
pythontech 0:5868e8752d44 685
pythontech 0:5868e8752d44 686 // Whether to set __file__ for imported modules
pythontech 0:5868e8752d44 687 #ifndef MICROPY_PY___FILE__
pythontech 0:5868e8752d44 688 #define MICROPY_PY___FILE__ (1)
pythontech 0:5868e8752d44 689 #endif
pythontech 0:5868e8752d44 690
pythontech 0:5868e8752d44 691 // Whether to provide mem-info related functions in micropython module
pythontech 0:5868e8752d44 692 #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
pythontech 0:5868e8752d44 693 #define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
pythontech 0:5868e8752d44 694 #endif
pythontech 0:5868e8752d44 695
pythontech 0:5868e8752d44 696 // Whether to provide "array" module. Note that large chunk of the
pythontech 0:5868e8752d44 697 // underlying code is shared with "bytearray" builtin type, so to
pythontech 0:5868e8752d44 698 // get real savings, it should be disabled too.
pythontech 0:5868e8752d44 699 #ifndef MICROPY_PY_ARRAY
pythontech 0:5868e8752d44 700 #define MICROPY_PY_ARRAY (1)
pythontech 0:5868e8752d44 701 #endif
pythontech 0:5868e8752d44 702
pythontech 0:5868e8752d44 703 // Whether to support slice assignments for array (and bytearray).
pythontech 0:5868e8752d44 704 // This is rarely used, but adds ~0.5K of code.
pythontech 0:5868e8752d44 705 #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
pythontech 0:5868e8752d44 706 #define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
pythontech 0:5868e8752d44 707 #endif
pythontech 0:5868e8752d44 708
pythontech 0:5868e8752d44 709 // Whether to support attrtuple type (MicroPython extension)
pythontech 0:5868e8752d44 710 // It provides space-efficient tuples with attribute access
pythontech 0:5868e8752d44 711 #ifndef MICROPY_PY_ATTRTUPLE
pythontech 0:5868e8752d44 712 #define MICROPY_PY_ATTRTUPLE (1)
pythontech 0:5868e8752d44 713 #endif
pythontech 0:5868e8752d44 714
pythontech 0:5868e8752d44 715 // Whether to provide "collections" module
pythontech 0:5868e8752d44 716 #ifndef MICROPY_PY_COLLECTIONS
pythontech 0:5868e8752d44 717 #define MICROPY_PY_COLLECTIONS (1)
pythontech 0:5868e8752d44 718 #endif
pythontech 0:5868e8752d44 719
pythontech 0:5868e8752d44 720 // Whether to provide "collections.OrderedDict" type
pythontech 0:5868e8752d44 721 #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
pythontech 0:5868e8752d44 722 #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
pythontech 0:5868e8752d44 723 #endif
pythontech 0:5868e8752d44 724
pythontech 0:5868e8752d44 725 // Whether to provide "math" module
pythontech 0:5868e8752d44 726 #ifndef MICROPY_PY_MATH
pythontech 0:5868e8752d44 727 #define MICROPY_PY_MATH (1)
pythontech 0:5868e8752d44 728 #endif
pythontech 0:5868e8752d44 729
pythontech 0:5868e8752d44 730 // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
pythontech 0:5868e8752d44 731 #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
pythontech 0:5868e8752d44 732 #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
pythontech 0:5868e8752d44 733 #endif
pythontech 0:5868e8752d44 734
pythontech 0:5868e8752d44 735 // Whether to provide "cmath" module
pythontech 0:5868e8752d44 736 #ifndef MICROPY_PY_CMATH
pythontech 0:5868e8752d44 737 #define MICROPY_PY_CMATH (0)
pythontech 0:5868e8752d44 738 #endif
pythontech 0:5868e8752d44 739
pythontech 0:5868e8752d44 740 // Whether to provide "gc" module
pythontech 0:5868e8752d44 741 #ifndef MICROPY_PY_GC
pythontech 0:5868e8752d44 742 #define MICROPY_PY_GC (1)
pythontech 0:5868e8752d44 743 #endif
pythontech 0:5868e8752d44 744
pythontech 0:5868e8752d44 745 // Whether to return number of collected objects from gc.collect()
pythontech 0:5868e8752d44 746 #ifndef MICROPY_PY_GC_COLLECT_RETVAL
pythontech 0:5868e8752d44 747 #define MICROPY_PY_GC_COLLECT_RETVAL (0)
pythontech 0:5868e8752d44 748 #endif
pythontech 0:5868e8752d44 749
pythontech 0:5868e8752d44 750 // Whether to provide "io" module
pythontech 0:5868e8752d44 751 #ifndef MICROPY_PY_IO
pythontech 0:5868e8752d44 752 #define MICROPY_PY_IO (1)
pythontech 0:5868e8752d44 753 #endif
pythontech 0:5868e8752d44 754
pythontech 0:5868e8752d44 755 // Whether to provide "io.FileIO" class
pythontech 0:5868e8752d44 756 #ifndef MICROPY_PY_IO_FILEIO
pythontech 0:5868e8752d44 757 #define MICROPY_PY_IO_FILEIO (0)
pythontech 0:5868e8752d44 758 #endif
pythontech 0:5868e8752d44 759
pythontech 0:5868e8752d44 760 // Whether to provide "io.BytesIO" class
pythontech 0:5868e8752d44 761 #ifndef MICROPY_PY_IO_BYTESIO
pythontech 0:5868e8752d44 762 #define MICROPY_PY_IO_BYTESIO (1)
pythontech 0:5868e8752d44 763 #endif
pythontech 0:5868e8752d44 764
pythontech 0:5868e8752d44 765 // Whether to provide "io.BufferedWriter" class
pythontech 0:5868e8752d44 766 #ifndef MICROPY_PY_IO_BUFFEREDWRITER
pythontech 0:5868e8752d44 767 #define MICROPY_PY_IO_BUFFEREDWRITER (0)
pythontech 0:5868e8752d44 768 #endif
pythontech 0:5868e8752d44 769
pythontech 0:5868e8752d44 770 // Whether to provide "struct" module
pythontech 0:5868e8752d44 771 #ifndef MICROPY_PY_STRUCT
pythontech 0:5868e8752d44 772 #define MICROPY_PY_STRUCT (1)
pythontech 0:5868e8752d44 773 #endif
pythontech 0:5868e8752d44 774
pythontech 0:5868e8752d44 775 // Whether to provide "sys" module
pythontech 0:5868e8752d44 776 #ifndef MICROPY_PY_SYS
pythontech 0:5868e8752d44 777 #define MICROPY_PY_SYS (1)
pythontech 0:5868e8752d44 778 #endif
pythontech 0:5868e8752d44 779
pythontech 0:5868e8752d44 780 // Whether to provide "sys.maxsize" constant
pythontech 0:5868e8752d44 781 #ifndef MICROPY_PY_SYS_MAXSIZE
pythontech 0:5868e8752d44 782 #define MICROPY_PY_SYS_MAXSIZE (0)
pythontech 0:5868e8752d44 783 #endif
pythontech 0:5868e8752d44 784
pythontech 0:5868e8752d44 785 // Whether to provide "sys.modules" dictionary
pythontech 0:5868e8752d44 786 #ifndef MICROPY_PY_SYS_MODULES
pythontech 0:5868e8752d44 787 #define MICROPY_PY_SYS_MODULES (1)
pythontech 0:5868e8752d44 788 #endif
pythontech 0:5868e8752d44 789
pythontech 0:5868e8752d44 790 // Whether to provide "sys.exc_info" function
pythontech 0:5868e8752d44 791 // Avoid enabling this, this function is Python2 heritage
pythontech 0:5868e8752d44 792 #ifndef MICROPY_PY_SYS_EXC_INFO
pythontech 0:5868e8752d44 793 #define MICROPY_PY_SYS_EXC_INFO (0)
pythontech 0:5868e8752d44 794 #endif
pythontech 0:5868e8752d44 795
pythontech 0:5868e8752d44 796 // Whether to provide "sys.exit" function
pythontech 0:5868e8752d44 797 #ifndef MICROPY_PY_SYS_EXIT
pythontech 0:5868e8752d44 798 #define MICROPY_PY_SYS_EXIT (0)
pythontech 0:5868e8752d44 799 #endif
pythontech 0:5868e8752d44 800
pythontech 0:5868e8752d44 801 // Whether to provide sys.{stdin,stdout,stderr} objects
pythontech 0:5868e8752d44 802 #ifndef MICROPY_PY_SYS_STDFILES
pythontech 0:5868e8752d44 803 #define MICROPY_PY_SYS_STDFILES (0)
pythontech 0:5868e8752d44 804 #endif
pythontech 0:5868e8752d44 805
pythontech 0:5868e8752d44 806 // Whether to provide sys.{stdin,stdout,stderr}.buffer object
pythontech 0:5868e8752d44 807 // This is implemented per-port
pythontech 0:5868e8752d44 808 #ifndef MICROPY_PY_SYS_STDIO_BUFFER
pythontech 0:5868e8752d44 809 #define MICROPY_PY_SYS_STDIO_BUFFER (0)
pythontech 0:5868e8752d44 810 #endif
pythontech 0:5868e8752d44 811
pythontech 0:5868e8752d44 812 // Extended modules
pythontech 0:5868e8752d44 813
pythontech 0:5868e8752d44 814 #ifndef MICROPY_PY_UCTYPES
pythontech 0:5868e8752d44 815 #define MICROPY_PY_UCTYPES (0)
pythontech 0:5868e8752d44 816 #endif
pythontech 0:5868e8752d44 817
pythontech 0:5868e8752d44 818 #ifndef MICROPY_PY_UZLIB
pythontech 0:5868e8752d44 819 #define MICROPY_PY_UZLIB (0)
pythontech 0:5868e8752d44 820 #endif
pythontech 0:5868e8752d44 821
pythontech 0:5868e8752d44 822 #ifndef MICROPY_PY_UJSON
pythontech 0:5868e8752d44 823 #define MICROPY_PY_UJSON (0)
pythontech 0:5868e8752d44 824 #endif
pythontech 0:5868e8752d44 825
pythontech 0:5868e8752d44 826 #ifndef MICROPY_PY_URE
pythontech 0:5868e8752d44 827 #define MICROPY_PY_URE (0)
pythontech 0:5868e8752d44 828 #endif
pythontech 0:5868e8752d44 829
pythontech 0:5868e8752d44 830 #ifndef MICROPY_PY_UHEAPQ
pythontech 0:5868e8752d44 831 #define MICROPY_PY_UHEAPQ (0)
pythontech 0:5868e8752d44 832 #endif
pythontech 0:5868e8752d44 833
pythontech 0:5868e8752d44 834 #ifndef MICROPY_PY_UHASHLIB
pythontech 0:5868e8752d44 835 #define MICROPY_PY_UHASHLIB (0)
pythontech 0:5868e8752d44 836 #endif
pythontech 0:5868e8752d44 837
pythontech 0:5868e8752d44 838 #ifndef MICROPY_PY_UBINASCII
pythontech 0:5868e8752d44 839 #define MICROPY_PY_UBINASCII (0)
pythontech 0:5868e8752d44 840 #endif
pythontech 0:5868e8752d44 841
pythontech 0:5868e8752d44 842 #ifndef MICROPY_PY_URANDOM
pythontech 0:5868e8752d44 843 #define MICROPY_PY_URANDOM (0)
pythontech 0:5868e8752d44 844 #endif
pythontech 0:5868e8752d44 845
pythontech 0:5868e8752d44 846 // Whether to include: randrange, randint, choice, random, uniform
pythontech 0:5868e8752d44 847 #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
pythontech 0:5868e8752d44 848 #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
pythontech 0:5868e8752d44 849 #endif
pythontech 0:5868e8752d44 850
pythontech 0:5868e8752d44 851 #ifndef MICROPY_PY_MACHINE
pythontech 0:5868e8752d44 852 #define MICROPY_PY_MACHINE (0)
pythontech 0:5868e8752d44 853 #endif
pythontech 0:5868e8752d44 854
Colin Hogben 2:c89e95946844 855 #ifndef MICROPY_PY_MACHINE_I2C
Colin Hogben 2:c89e95946844 856 #define MICROPY_PY_MACHINE_I2C (0)
Colin Hogben 2:c89e95946844 857 #endif
Colin Hogben 2:c89e95946844 858
pythontech 0:5868e8752d44 859 #ifndef MICROPY_PY_USSL
pythontech 0:5868e8752d44 860 #define MICROPY_PY_USSL (0)
pythontech 0:5868e8752d44 861 #endif
pythontech 0:5868e8752d44 862
pythontech 0:5868e8752d44 863 #ifndef MICROPY_PY_WEBSOCKET
pythontech 0:5868e8752d44 864 #define MICROPY_PY_WEBSOCKET (0)
pythontech 0:5868e8752d44 865 #endif
pythontech 0:5868e8752d44 866
Colin Hogben 2:c89e95946844 867 #ifndef MICROPY_PY_FRAMEBUF
Colin Hogben 2:c89e95946844 868 #define MICROPY_PY_FRAMEBUF (0)
Colin Hogben 2:c89e95946844 869 #endif
Colin Hogben 2:c89e95946844 870
pythontech 0:5868e8752d44 871 /*****************************************************************************/
pythontech 0:5868e8752d44 872 /* Hooks for a port to add builtins */
pythontech 0:5868e8752d44 873
pythontech 0:5868e8752d44 874 // Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
pythontech 0:5868e8752d44 875 #ifndef MICROPY_PORT_BUILTINS
pythontech 0:5868e8752d44 876 #define MICROPY_PORT_BUILTINS
pythontech 0:5868e8752d44 877 #endif
pythontech 0:5868e8752d44 878
pythontech 0:5868e8752d44 879 // Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
pythontech 0:5868e8752d44 880 #ifndef MICROPY_PORT_BUILTIN_MODULES
pythontech 0:5868e8752d44 881 #define MICROPY_PORT_BUILTIN_MODULES
pythontech 0:5868e8752d44 882 #endif
pythontech 0:5868e8752d44 883
pythontech 0:5868e8752d44 884 // Any module weak links - see builtintables.c:mp_builtin_module_weak_links_table.
pythontech 0:5868e8752d44 885 #ifndef MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
pythontech 0:5868e8752d44 886 #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
pythontech 0:5868e8752d44 887 #endif
pythontech 0:5868e8752d44 888
pythontech 0:5868e8752d44 889 // Additional constant definitions for the compiler - see compile.c:mp_constants_table.
pythontech 0:5868e8752d44 890 #ifndef MICROPY_PORT_CONSTANTS
pythontech 0:5868e8752d44 891 #define MICROPY_PORT_CONSTANTS
pythontech 0:5868e8752d44 892 #endif
pythontech 0:5868e8752d44 893
pythontech 0:5868e8752d44 894 // Any root pointers for GC scanning - see mpstate.c
pythontech 0:5868e8752d44 895 #ifndef MICROPY_PORT_ROOT_POINTERS
pythontech 0:5868e8752d44 896 #define MICROPY_PORT_ROOT_POINTERS
pythontech 0:5868e8752d44 897 #endif
pythontech 0:5868e8752d44 898
pythontech 0:5868e8752d44 899 /*****************************************************************************/
pythontech 0:5868e8752d44 900 /* Miscellaneous settings */
pythontech 0:5868e8752d44 901
pythontech 0:5868e8752d44 902 // All uPy objects in ROM must be aligned on at least a 4 byte boundary
pythontech 0:5868e8752d44 903 // so that the small-int/qstr/pointer distinction can be made. For machines
pythontech 0:5868e8752d44 904 // that don't do this (eg 16-bit CPU), define the following macro to something
pythontech 0:5868e8752d44 905 // like __attribute__((aligned(4))).
pythontech 0:5868e8752d44 906 #ifndef MICROPY_OBJ_BASE_ALIGNMENT
pythontech 0:5868e8752d44 907 #define MICROPY_OBJ_BASE_ALIGNMENT
pythontech 0:5868e8752d44 908 #endif
pythontech 0:5868e8752d44 909
pythontech 0:5868e8752d44 910 // On embedded platforms, these will typically enable/disable irqs.
pythontech 0:5868e8752d44 911 #ifndef MICROPY_BEGIN_ATOMIC_SECTION
pythontech 0:5868e8752d44 912 #define MICROPY_BEGIN_ATOMIC_SECTION() (0)
pythontech 0:5868e8752d44 913 #endif
pythontech 0:5868e8752d44 914 #ifndef MICROPY_END_ATOMIC_SECTION
pythontech 0:5868e8752d44 915 #define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
pythontech 0:5868e8752d44 916 #endif
pythontech 0:5868e8752d44 917
pythontech 0:5868e8752d44 918 // Allow to override static modifier for global objects, e.g. to use with
pythontech 0:5868e8752d44 919 // object code analysis tools which don't support static symbols.
pythontech 0:5868e8752d44 920 #ifndef STATIC
pythontech 0:5868e8752d44 921 #define STATIC static
pythontech 0:5868e8752d44 922 #endif
pythontech 0:5868e8752d44 923
pythontech 0:5868e8752d44 924 #define BITS_PER_BYTE (8)
pythontech 0:5868e8752d44 925 #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
pythontech 0:5868e8752d44 926 // mp_int_t value with most significant bit set
pythontech 0:5868e8752d44 927 #define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
pythontech 0:5868e8752d44 928
pythontech 0:5868e8752d44 929 // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
pythontech 0:5868e8752d44 930 // defined and that they are the opposite of each other.
pythontech 0:5868e8752d44 931 #if defined(MP_ENDIANNESS_LITTLE)
pythontech 0:5868e8752d44 932 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
pythontech 0:5868e8752d44 933 #elif defined(MP_ENDIANNESS_BIG)
pythontech 0:5868e8752d44 934 #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
pythontech 0:5868e8752d44 935 #else
pythontech 0:5868e8752d44 936 // Endiannes not defined by port so try to autodetect it.
pythontech 0:5868e8752d44 937 #if defined(__BYTE_ORDER__)
pythontech 0:5868e8752d44 938 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
pythontech 0:5868e8752d44 939 #define MP_ENDIANNESS_LITTLE (1)
pythontech 0:5868e8752d44 940 #else
pythontech 0:5868e8752d44 941 #define MP_ENDIANNESS_LITTLE (0)
pythontech 0:5868e8752d44 942 #endif
pythontech 0:5868e8752d44 943 #elif defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN)
pythontech 0:5868e8752d44 944 #define MP_ENDIANNESS_LITTLE (1)
pythontech 0:5868e8752d44 945 #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined (_BIG_ENDIAN)
pythontech 0:5868e8752d44 946 #define MP_ENDIANNESS_LITTLE (0)
pythontech 0:5868e8752d44 947 #else
pythontech 0:5868e8752d44 948 #include <endian.h>
pythontech 0:5868e8752d44 949 #if defined(__BYTE_ORDER)
pythontech 0:5868e8752d44 950 #if __BYTE_ORDER == __LITTLE_ENDIAN
pythontech 0:5868e8752d44 951 #define MP_ENDIANNESS_LITTLE (1)
pythontech 0:5868e8752d44 952 #else
pythontech 0:5868e8752d44 953 #define MP_ENDIANNESS_LITTLE (0)
pythontech 0:5868e8752d44 954 #endif
pythontech 0:5868e8752d44 955 #else
pythontech 0:5868e8752d44 956 #error endianness not defined and cannot detect it
pythontech 0:5868e8752d44 957 #endif
pythontech 0:5868e8752d44 958 #endif
pythontech 0:5868e8752d44 959 #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
pythontech 0:5868e8752d44 960 #endif
pythontech 0:5868e8752d44 961
pythontech 0:5868e8752d44 962 // Make a pointer to RAM callable (eg set lower bit for Thumb code)
pythontech 0:5868e8752d44 963 // (This scheme won't work if we want to mix Thumb and normal ARM code.)
pythontech 0:5868e8752d44 964 #ifndef MICROPY_MAKE_POINTER_CALLABLE
pythontech 0:5868e8752d44 965 #define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
pythontech 0:5868e8752d44 966 #endif
pythontech 0:5868e8752d44 967
pythontech 0:5868e8752d44 968 // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
pythontech 0:5868e8752d44 969 // must be somehow reachable for marking by the GC, since the native code
pythontech 0:5868e8752d44 970 // generators store pointers to GC managed memory in the code.
pythontech 0:5868e8752d44 971 #ifndef MP_PLAT_ALLOC_EXEC
pythontech 0:5868e8752d44 972 #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
pythontech 0:5868e8752d44 973 #endif
pythontech 0:5868e8752d44 974
pythontech 0:5868e8752d44 975 #ifndef MP_PLAT_FREE_EXEC
pythontech 0:5868e8752d44 976 #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
pythontech 0:5868e8752d44 977 #endif
pythontech 0:5868e8752d44 978
pythontech 0:5868e8752d44 979 // This macro is used to do all output (except when MICROPY_PY_IO is defined)
pythontech 0:5868e8752d44 980 #ifndef MP_PLAT_PRINT_STRN
pythontech 0:5868e8752d44 981 #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
pythontech 0:5868e8752d44 982 #endif
pythontech 0:5868e8752d44 983
pythontech 0:5868e8752d44 984 #ifndef MP_SSIZE_MAX
pythontech 0:5868e8752d44 985 #define MP_SSIZE_MAX SSIZE_MAX
pythontech 0:5868e8752d44 986 #endif
pythontech 0:5868e8752d44 987
pythontech 0:5868e8752d44 988 // printf format spec to use for mp_int_t and friends
pythontech 0:5868e8752d44 989 #ifndef INT_FMT
pythontech 0:5868e8752d44 990 #if defined(__LP64__)
pythontech 0:5868e8752d44 991 // Archs where mp_int_t == long, long != int
pythontech 0:5868e8752d44 992 #define UINT_FMT "%lu"
pythontech 0:5868e8752d44 993 #define INT_FMT "%ld"
pythontech 0:5868e8752d44 994 #elif defined(_WIN64)
pythontech 0:5868e8752d44 995 #define UINT_FMT "%llu"
pythontech 0:5868e8752d44 996 #define INT_FMT "%lld"
pythontech 0:5868e8752d44 997 #else
pythontech 0:5868e8752d44 998 // Archs where mp_int_t == int
pythontech 0:5868e8752d44 999 #define UINT_FMT "%u"
pythontech 0:5868e8752d44 1000 #define INT_FMT "%d"
pythontech 0:5868e8752d44 1001 #endif
pythontech 0:5868e8752d44 1002 #endif //INT_FMT
pythontech 0:5868e8752d44 1003
pythontech 0:5868e8752d44 1004 // Modifier for function which doesn't return
pythontech 0:5868e8752d44 1005 #ifndef NORETURN
pythontech 0:5868e8752d44 1006 #define NORETURN __attribute__((noreturn))
pythontech 0:5868e8752d44 1007 #endif
pythontech 0:5868e8752d44 1008
pythontech 0:5868e8752d44 1009 // Modifier for weak functions
pythontech 0:5868e8752d44 1010 #ifndef MP_WEAK
pythontech 0:5868e8752d44 1011 #define MP_WEAK __attribute__((weak))
pythontech 0:5868e8752d44 1012 #endif
pythontech 0:5868e8752d44 1013
pythontech 0:5868e8752d44 1014 // Condition is likely to be true, to help branch prediction
pythontech 0:5868e8752d44 1015 #ifndef MP_LIKELY
pythontech 0:5868e8752d44 1016 #define MP_LIKELY(x) __builtin_expect((x), 1)
pythontech 0:5868e8752d44 1017 #endif
pythontech 0:5868e8752d44 1018
pythontech 0:5868e8752d44 1019 // Condition is likely to be false, to help branch prediction
pythontech 0:5868e8752d44 1020 #ifndef MP_UNLIKELY
pythontech 0:5868e8752d44 1021 #define MP_UNLIKELY(x) __builtin_expect((x), 0)
pythontech 0:5868e8752d44 1022 #endif
pythontech 0:5868e8752d44 1023
pythontech 0:5868e8752d44 1024 #endif // __MICROPY_INCLUDED_PY_MPCONFIG_H__