summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2021-03-11py/nlrx64: Fix typo in comment.Yonatan Goldschmidt
2021-03-11py/nlr: Implement NLR for AArch64.Yonatan Goldschmidt
2021-02-21py/mkrules.cmake: Add MICROPY_QSTRDEFS_PORT to qstr build process.Damien George
This allows a port to specify a custom qstrdefsport.h file, the same as the QSTR_DEFS variable in a Makefile. Signed-off-by: Damien George <damien@micropython.org>
2021-02-21py/mkrules.cmake: Rename QSTR_DEFS variables to QSTRDEFS.Damien George
And also MICROPY_PY_QSTRDEFS to MICROPY_QSTRDEFS_PY. These variables are all related. Signed-off-by: Damien George <damien@micropython.org>
2021-02-16py: Expand lists in core cmake custom commands.Maureen Helm
The core cmake rules use custom commands to invoke qstr processing scripts. For the zephyr port, it's possible that list arguments to these commands may contain generator expressions, therefore we need to expand them properly. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-15py,extmod: Add core cmake rule files.Damien George
These allow a port to use cmake natively instead of make. Signed-off-by: Damien George <damien@micropython.org>
2021-02-08py/mpz: Fix overflow of borrow in mpn_div.Damien George
For certain operands to mpn_div, the existing code path for `DIG_SIZE == MPZ_DBL_DIG_SIZE / 2` had a bug in it where borrow could still overflow in the `(x >= *n || *n - x <= borrow)` branch, ie `borrow + x - (mpz_dbl_dig_t)*n` overflows the borrow variable. In such cases the subsequent right-shift of borrow would not bring in the overflow bit, leading to an error in the result. An example division that had overflow when MPZ_DIG_SIZE = 16 is `(2 ** 48 - 1) ** 2 // (2 ** 48 - 1)`. This is fixed in this commit by simplifying the code and handling the low digits of borrow first, and then the upper bits (to shift down) separately. There is no longer a distinction between `DIG_SIZE < MPZ_DBL_DIG_SIZE / 2` and `DIG_SIZE == MPZ_DBL_DIG_SIZE / 2`. This commit also simplifies the second part of the calculation so that borrow does not need to be negated (instead the code just works knowing that borrow is negative and using + instead of - in calculations involving borrow). Fixes #6777. Signed-off-by: Damien George <damien@micropython.org>
2021-02-05py/gc: Change include of stdint.h to stddef.h.Damien George
No std-int types are used in gc.h, but size_t is which needs stddef.h. Signed-off-by: Damien George <damien@micropython.org>
2021-02-04py: Rename WORD_MSBIT_HIGH to MP_OBJ_WORD_MSBIT_HIGH.Damien George
To make it clear it is for mp_obj_t/mp_uint_t "word" types, and to prefix this macro with MP_. Signed-off-by: Damien George <damien@micropython.org>
2021-02-04all: Rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD.Damien George
The "word" referred to by BYTES_PER_WORD is actually the size of mp_obj_t which is not always the same as the size of a pointer on the target architecture. So rename this config value to better reflect what it measures, and also prefix it with MP_. For uses of BYTES_PER_WORD in setting the stack limit this has been changed to sizeof(void *), because the stack usually grows with machine-word sized values (eg an nlr_buf_t has many machine words in it). Signed-off-by: Damien George <damien@micropython.org>
2021-02-04py: Rename BITS_PER_BYTE to MP_BITS_PER_BYTE.Damien George
To give this macro a standard MP_ prefix. Signed-off-by: Damien George <damien@micropython.org>
2021-02-04py: Remove BITS_PER_WORD definition.Damien George
It's only used in one location, to test if << or >> will overflow when shifting mp_uint_t. For such a test it's clearer to use sizeof(lhs_val), which will be valid even if the type of lhs_val changes. Signed-off-by: Damien George <damien@micropython.org>
2021-02-04py/gc: Don't include mpconfig.h and misc.h in gc.h.Xiang Xiao
Because gc.h doesn't reference any symbol from these header files. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-03all: Bump version to 1.14.v1.14Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-01-31py/makeversionhdr: Honor SOURCE_DATE_EPOCH if present.iTitou
This environment variable, if defined during the build process, indicates a fixed time that should be used in place of "now" when such a time is explicitely referenced. This allows for reproducible builds of micropython. See https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: iTitou <moiandme@gmail.com>
2021-01-30py/persistentcode: Introduce MICROPY_PERSISTENT_CODE_SAVE_FILE option.David CARLIER
This should be enabled when the mp_raw_code_save_file function is needed. It is enabled for mpy-cross, and a check for defined(__APPLE__) is added to cover Mac M1 systems.
2021-01-30py/gc: Fix debug printing of pointer.stijn
When DEBUG_printf is the standard printf, compilers require the value for %p to be an actual pointer instead of an integer.
2021-01-30py/qstr.h: Remove QSTR_FROM_STR_STATIC macro.stijn
It practically does the same as qstr_from_str and was only used in one place, which should actually use the compile-time MP_QSTR_XXX form for consistency; qstr_from_str is for runtime strings only.
2021-01-29py/emitnative: Support binary ops on ARMv6M without use of ite instr.graham sanderson
2021-01-29py/emitinlinethumb: Exclude code using #if when ARMV7M disabled.Damien George
So there are no references to undeclared asm_thumb_mov_reg_i16(). Signed-off-by: Damien George <damien@micropython.org>
2021-01-29py/emitnative: Ensure encoding to load prelude_offset doesn't change sz.Damien George
Based on change made by Graham Sanderson. Signed-off-by: Damien George <damien@micropython.org>
2021-01-29py/asmthumb: Add support for ARMv6M in native emitter.graham sanderson
Adds a new compile-time option MICROPY_EMIT_THUMB_ARMV7M which is enabled by default (to get existing behaviour) and which should be disabled (set to 0) when building native emitter support (@micropython.native) on ARMv6M targets.
2021-01-29py/objfun: Support fun.__globals__ attribute.Damien George
This returns a reference to the globals dict associated with the function, ie the global scope that the function was defined in. This attribute is read-only but the dict itself is modifiable, per CPython behaviour. Signed-off-by: Damien George <damien@micropython.org>
2020-12-14py/mkrules.mk: Remove stray vpath and unused -Itmp, add $(Q) for $(AR).Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-12-14py/modmath: Simplify handling of positional args to reduce code size.Damien George
As a general pattern, required positional arguments that are not named do not need to be parsed using mp_arg_parse_all(). Signed-off-by: Damien George <damien@micropython.org>
2020-12-07py/mpprint: Fix length calculation for strings with precision-modifier.Joris Peeraer
Two issues are tackled: 1. The calculation of the correct length to print is fixed to treat the precision as a maximum length instead as the exact length. This is done for both qstr (%q) and for regular str (%s). 2. Fix the incorrect use of mp_printf("%.*s") to mp_print_strn(). Because of the fix of above issue, some testcases that would print an embedded null-byte (^@ in test-output) would now fail. The bug here is that "%s" was used to print null-bytes. Instead, mp_print_strn is used to make sure all bytes are outputted and the exact length is respected. Test-cases are added for both %s and %q with a combination of precision and padding specifiers.
2020-11-29py/mpprint: Prevent case fall-through when assert is disabled.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-24extmod/modbluetooth: Add API for L2CAP channels.Jim Mussared
Also known as L2CAP "connection oriented channels". This provides a socket-like data transfer mechanism for BLE. Currently only implemented for NimBLE on STM32 / Unix. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-12tools/makeqstrdefs.py: Run qstr preprocessing in parallel.Jim Mussared
This gives a substantial speedup of the preprocessing step, i.e. the generation of qstr.i.last. For example on a clean build, making qstr.i.last: 21s -> 4s on STM32 (WB55) 8.9 -> 1.8s on Unix (dev). Done in collaboration with @stinos. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-11py/binary: Fix sign extension setting wide integer on 32-bit archs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11py/mpz: Do sign extension in mpz_as_bytes for negative values.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29py/py.mk: Support C++ code for user C modules.stijn
Support C++ code in .cpp files by providing CXX counterparts of the _USERMOD_ flags we have for C already. This merely enables the Makefile of user C modules to use variables specific to C++ compilation, it is still up to each port's main Makefile to also include these in the build.
2020-10-29py: Workaround clang error when building misc.h with C++ compiler.stijn
2020-10-29py/makeqstrdefs.py: Support preprocessing C++ files for QSTR generation.stijn
When SCR_QSTR contains C++ files they should be preprocessed with the same compiler flags (CXXFLAGS) as they will be compiled with, to make sure code scanned for QSTR occurrences is effectively the code used in the rest of the build. The 'split SCR_QSTR in .c and .cpp files and process each with different flags' logic isn't trivial to express in a Makefile and the existing principle for deciding which files to preprocess was already rather complicated, so the actual preprocessing is moved into makeqstrdefs.py completely.
2020-10-29py/mkrules.mk: Add target for compiling C++ files.stijn
Move the target from the ESP32 Makefile since that does what is needed already, but also include files from user C modules as is done for the C files.
2020-10-29py/makeqstrdefs.py: Process C++ files as well.stijn
Preprocessed C++ code isn't different from C code when it comes to QSTR instances so process it as well.
2020-10-29py/makeqstrdefs.py: Fix beaviour when scanning non-C preprocessed files.stijn
When process_file() is passed a preprocessed C++ file for instance it won't find any lines containing .c files and the last_fname variable remains None, so handle that gracefully.
2020-10-22py, extmod: Introduce and use MP_FALLTHROUGH macro.Emil Renner Berthing
Newer GCC versions are able to warn about switch cases that fall through. This is usually a sign of a forgotten break statement, but in the few cases where a fall through is intended we annotate it with this macro to avoid the warning.
2020-10-22py/vmentrytable: Ignore GCC -Woverride-init.Emil Renner Berthing
Like Clang, GCC warns about this file, but only with -Woverride-init which is enabled by -Wextra. Disable the warnings for this file just like we do for Clang to make -Wextra happy.
2020-10-22py, extmod: Add explicit initializers for default values.Emil Renner Berthing
When compiling with -Wextra which includes -Wmissing-field-initializers GCC will warn that the defval field of mp_arg_val_t is not initialized. This is just a warning as it is defined to be zero initialized, but since it is a union it makes sense to be explicit about which member we're going to use, so add the explicit initializers and get rid of the warning.
2020-10-22py: Use unsigned comparison of chars.Emil Renner Berthing
On x86 chars are signed, but we're comparing a char to '0' + unsigned int, which is promoted to an unsigned int. Let's promote the char to unsigned before doing the comparison to avoid weird corner cases.
2020-10-22py/objexcept: Compare mp_emergency_exception_buf_size signed.Emil Renner Berthing
mp_emergency_exception_buf_size is signed, so let's make sure we compare it as such.
2020-10-22py/scope: Name and use id_kind_type_t.Emil Renner Berthing
The function scope_find_or_add_id used to take a scope_kind_t enum and save it in an uint8_t. Saving an enum in a uint8_t is fine, but everywhere this function is called it is not actually given a scope_kind_t but an anonymous enum instead. Let's give this enum a name and use that as the argument type. This doesn't change the generated code, but is a C type mismatch that unfortunately doesn't show up unless you enable -Wenum-conversion.
2020-10-10py/objtype: Handle __dict__ attribute when type has no locals.Jim Mussared
2020-10-10py/objdict: Add mp_const_empty_dict_obj, use it for mp_const_empty_map.Jim Mussared
2020-10-01py/parse: Expose rule-name printing as MICROPY_DEBUG_PARSE_RULE_NAME.Damien George
So it can be enabled without modifying the source. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01py/makeversionhdr.py: Match only git tags which look like versions.Mike Wadsten
Some downstream projects may use tags in their repositories for more than just designating MicroPython releases. In those cases, the makeversionhdr.py script would end up using a different tag than intended. So tell `git describe` to only match tags that look like a MicroPython version tag, such as `v1.12` or `v2.0`.
2020-09-25py/objarray.h: Add mp_obj_memoryview_init() helper function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-09-24py/objstr: Make bytes(bytes_obj) return bytes_obj.Iyassou Shimels
Calling the bytes constructor on a bytes object returns the original bytes object. This saves allocating a new instance, and matches CPython. Signed-off-by: Iyassou Shimels <s.iyassou@gmail.com>
2020-09-18py/dynruntime.h: Add mp_import_* and mp_load/store_*.Jim Mussared
These functions already exist in the fun table, and this commit just adds convenience macros for them.