forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation about float #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
massimosala
wants to merge
2,749
commits into
massimosala:master
Choose a base branch
from
micropython:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The test `micropython/ringio_async.py` is a test that requires async keyword support, and will fail with SyntaxError on targets that don't support async/await. Really it should be skipped on such targets, and this commit makes sure that's the case. Signed-off-by: Damien George <[email protected]>
This adds call to release UDP port in a timely manner, so they can be reused in subsequent tests. Otherwise, one could face issue like #17623. Signed-off-by: Yanfeng Liu <[email protected]>
This drops use of non-existing path `/usr/include/i686-linux-gnu` as default include paths shall suffice. Signed-off-by: Yanfeng Liu <[email protected]>
This commit adds a fast-path optimisation for when a BUILD_SLICE is immediately followed by a LOAD/STORE_SUBSCR for a native type, to avoid needing to allocate the slice on the heap. In some cases (e.g. `a[1:3] = x`) this can result in no allocations at all. We can't do this for instance types because the get/set/delattr implementation may keep a reference to the slice. Adds more tests to the basic slice tests to ensure that a stack-allocated slice never makes it to Python, and also a heapalloc test that verifies (when using bytecode) that assigning to a slice is no-alloc. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]> Signed-off-by: Damien George <[email protected]>
This adds support for %llx (needed by XINT_FMT for printing cell objects) and incidentally support for capitalized output of %P. It also reduces code size due to the common handling of all integers. Signed-off-by: Jeff Epler <[email protected]>
Test 'l' and 'll' sized objects. When the platform's `mp_int_t` is not 64 bits, dummy values are printed instead so the test result can match across all platforms. Ensure hex test values have a letter so 'x' vs 'X' is tested. And test 'p' and 'P' pointer printing. Signed-off-by: Jeff Epler <[email protected]>
This change is a no-op for the firmware. Signed-off-by: Damien George <[email protected]>
Really lwIP should provide this, to deregister all callbacks on the given netif. Signed-off-by: Damien George <[email protected]>
When mDNS is active on a netif it registers a lot of timeouts, namely: mdns_probe_and_announce mdns_handle_tc_question mdns_multicast_probe_timeout_reset_ipv4 mdns_multicast_timeout_25ttl_reset_ipv4 mdns_multicast_timeout_reset_ipv4 mdns_send_multicast_msg_delayed_ipv4 mdns_send_unicast_msg_delayed_ipv4 mdns_multicast_probe_timeout_reset_ipv6 mdns_multicast_timeout_25ttl_reset_ipv6 mdns_multicast_timeout_reset_ipv6 mdns_send_multicast_msg_delayed_ipv6 mdns_send_unicast_msg_delayed_ipv6 These may still be active after a netif is removed, and if they are called they will find that the mDNS state pointer in the netif is NULL and they will crash. These functions could be explicitly removed using `sys_untimeout()`, but `mdns_handle_tc_question()` is static so it's not possible to access it. Instead use the new `sys_untimeout_all_with_arg()` helper to deregister all timeout callbacks when a netif is removed. Fixes issue #17621. Signed-off-by: Damien George <[email protected]>
Running the unmodified `pio_uart_rx.py` example by uploading the file and importing it doesn't succeed, and instead emits a NameError at line 26. Signed-off-by: Anson Mansfield <[email protected]>
This commit improves get handling by guarding against implicit unknown symbols accessed directly by specific JS native APIs. Fixes issue #17657. Signed-off-by: Andrea Giammarchi <[email protected]>
These will run on all ports which support them, but importantly they'll also run on ports that don't support arbitrary precision but do support 64-bit long ints. Includes some test workarounds to account for things which will overflow once "long long" big integers overflow (added in follow-up commit): - uctypes_array_load_store test was failing already, now won't parse. - all the ffi_int tests contain 64-bit unsigned values, that won't parse as long long. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
These tests cover the use of mp_obj_new_int_from_str_len when mp_parse_num_integer overflows the SMALLINT limit, and also the case where the value may not be null terminated. Placed in a separate test file so that extmod/json test doesn't rely on bigint support. Signed-off-by: Yoctopuce dev <[email protected]> Signed-off-by: Angus Gratton <[email protected]>
Signed-off-by: Angus Gratton <[email protected]>
Relies on arbitrary precision math, so won't run on a port which has threads & limited bigint support. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
The other performance tests run and pass with only 64-bit big integer support. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Long long big integer support now raises an exception on overflow rather than returning an undefined result. Also adds an error when shifting by a negative value. The new arithmetic checks are added in the misc.h header. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Makes it compatible with the __builtin_mul_overflow() syntax, used in follow-up commit. Includes optimisation in runtime.c to minimise the code size impact from additional param. Signed-off-by: Damien George <[email protected]> Signed-off-by: Angus Gratton <[email protected]>
If big integer support is 'long long' then mp_parse_num_integer() can parse to it directly instead of failing over from small int. This means strtoll() is no longer pulled in, and fixes some bugs parsing long long integers (i.e. can now parse negative values correctly, can now parse values which aren't NULL terminated). The (default) smallint parsing compiled code should stay the same here, macros and a typedef are used to abstract some parts of it out. When bigint is long long we parse to 'unsigned long long' first (to avoid the code size hit of pulling in signed 64-bit math routines) and the convert to signed at the end. One tricky case this routine correctly overflows on is int("9223372036854775808") which is one more than LLONG_MAX in decimal. No unit test case added for this as it's too hard to detect 64-bit long integer mode. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Signed-off-by: Anson Mansfield <[email protected]>
Signed-off-by: Anson Mansfield <[email protected]>
This mutes usage error for blobless update from older `git` to reduce noise upon submodule updating. Signed-off-by: Yanfeng Liu <[email protected]>
This aligns the prefix string in L285 to that in L284 though the two strings have equal length. Signed-off-by: Yanfeng Liu <[email protected]>
This commit fixes building the "btree" example natmod on RV32 when Picolibc is being used and uses thread-local storage for storing the errno variable. The fix is surprisingly simple: Picolibc allows overriding the function that will provide a pointer to the "errno" variable, and the btree natmod integration code already has all of this machinery set up as part of its library integration. Redirecting Picolibc to the already existing pointer provider function via a compile-time definition is enough to let the module compile and pass QEMU tests. This workaround will work on any Picolibc versions (Arm, RV32, Xtensa, etc.) even if TLS support was not enabled to begin with, and will effectively do nothing if the toolchain used will rely on Newlib to provide standard C library functions. Given that the btree module now builds and passes the relevant natmod tests, said module is now part of the QEMU port's natmod testing procedure, and CI now will build the btree module for RV32 as part to its checks. Signed-off-by: Alessandro Gatti <[email protected]>
This commit adds some documentation on what are the limitations of using Picolibc as a standard C library for native modules. This also contains a reference to the "errno" issue when building natmods on RV32 that the PR this commit is part of, as it is not obvious how to approach this issue when encountered for the first time. Signed-off-by: Alessandro Gatti <[email protected]>
This is useful to distinguish between GIL and non-GIL builds. Signed-off-by: Damien George <[email protected]>
This is a workaround for the case where threading is enabled without a GIL. In such a configuration, creating a new global variable is not atomic and threads have race conditions resizing/accessing the global dict. Signed-off-by: Damien George <[email protected]>
This thread stress test is quite intensive and can run for a long time on certain targets. For example, builds with stackless enabled are slower than non-stackless, and this test in stackless mode takes around 2 minutes on the unix port of MicroPython with the existing parameters of `n_thread=20` and `n_loop=5`. It's not really necessary to test 20 threads at once, that's not really going to test anything more than 10 at once. So reduce the parameters to keep the running time reasonable. Signed-off-by: Damien George <[email protected]>
When detecting the target platform, also check if it has threading and whether the GIL is enabled or not (using the new attribute `sys.implementation._thread`). If threading is available, add the thread tests to the set of tests to run (unless the set of tests is explicitly given). With this change, the unix port no longer needs to explicitly run the set of thread tests, so that line has been removed from the Makefile. This change will make sure thread tests are run with other testing combinations. In particular, thread tests are now run: - on the unix port with the native emitter - on macOS builds - on unix qemu, the architectures MIPS, ARM and RISCV-64 Signed-off-by: Damien George <[email protected]>
This commit unifies the configuration of MICROPY_PY_CRYPTOLIB, MICROPY_PY_HASHLIB_MD5 and MICROPY_PY_HASHLIB_SHA1, so they are enabled by default if MICROPY_PY_SSL is enabled. This matches the existing configuration of most of the ports. With this change, all ports remain the same except: - reneses-ra now enables MICROPY_PY_CRYPTOLIB, MICROPY_PY_HASHLIB_MD5 and MICROPY_PY_HASHLIB_SHA1. - rp2 now enables MICROPY_PY_HASHLIB_MD5. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
This is a pretty fundamental module, and even minimal ports like unix and zephyr minimal have it enabled. So, enabled it by default at the lowest feature level. Most things in the `sys` module are configurable, and off by default, so it shouldn't add too much to ports that don't already have it enabled (which is just the minimal port). Also note that `sys` is still disabled on the bare-arm port, to keep that ultra minimal. It means we now have bare-arm without `sys` and the minimal port with `sys`. That will allow different code size comparisons if/when new `sys` features are added. Signed-off-by: Damien George <[email protected]>
The official mcux-sdk follows a slightly different structure to the current nxp_sdk submodule, with many drivers moved to a common location. To ease updating the newer versions of the SDK and/or add new families the nxp_sdk submodule has been updated to follow the structure of mcux-sdk, just trimmed down to families used here to considerably reduce the size. Signed-off-by: Andrew Leech <[email protected]>
These were regenerated by the NXP Config tool for v2.11. The board_init update was needed to ensure CLOCK_SetMode() is run at the appropriate time during startup. Signed-off-by: Andrew Leech <[email protected]>
If while a polling operation is active the stream is removed we should stop polling data from that stream. This was already the intended behaviour, but implemented incorrectly. Signed-off-by: Daniël van de Giessen <[email protected]>
When disconnecting from PPP the modem sends a confirmation. This message is received, like all messages, through the poll() method. lwIP may then immediately call our status callback with code PPPERR_USER to indicate the connection was closed. Our callback then immediately proceeds to free the PCB. Thus, during each new iteration of the loop in poll() we must check if we haven't disconnected in the meantime to prevent calling the pppos_input_tcpip with a PCB that is now NULL. Signed-off-by: Daniël van de Giessen <[email protected]>
This commit changes the "viper_ptr*_store_boundary" tests to make them fail more gracefully in low memory conditions. The original version of the tests compiled viper code blocks on the fly when it needed them, making them fail at runtime on some boards that do not come with enough memory for this test. This clashes with "run-tests.py"'s ability to look for a particular signature to mark tests as skipped due to not enough memory. Now compiled code blocks are generated at the beginning of the test inside an appropriate exception handler. In case of a memory error when pre-compiling a code block, the running test exits reporting a low memory condition to the test runner. This allows to have clean test runs on all platforms when it comes to viper pointer tests. Signed-off-by: Alessandro Gatti <[email protected]>
This commit lets board use a different floating point mode rather than the usual soft-float that was the original default for all QEMU-based boards. The configuration options are the same available in the "stm32" port. Boards can set "MICROPY_FLOAT_IMPL" to either "float", "double", or "none" to indicate which floating point mode they want, and optionally "SUPPORTS_HARDWARE_FP_SINGLE" or "SUPPORTS_HARDWARE_FP_DOUBLE" can be set to 1 to further indicate the hardware capabilities of the hardware floating point unit, if present. Signed-off-by: Alessandro Gatti <[email protected]>
This commit introduces a new target for the QEMU port called "MPS2_AN500", an ARMv7-M machine with a Cortex-M7 CPU and single-/double-precision floating point unit. Signed-off-by: Alessandro Gatti <[email protected]>
This commit extends the QEMU port's CPU error handler for the Arm target by printing out in detail the ARMv7-M debug registers if the firmware is compiled for such a target. Signed-off-by: Alessandro Gatti <[email protected]>
This commit lets CI extend the testing scope of the QEMU Arm target, by letting it perform the usual battery of tests (interpreter and natmods) also on hardfp targets. The default board for Arm testing lacks hardware floating point support, so natmods weren't tested in that specific configuration. With the introduction of the "MPS_AN500" QEMU target, now this is made possible as said board emulates a Cortex-M7 machine with a single- and double-precision floating point unit. To reduce the impact on build times, the "ci_qemu_build_arm_thumb" CI step was split in two: "ci_qemu_build_arm_thumb_softfp" and "ci_qemu_build_arm_thumb_hardfp" - so hopefully those can run in parallel whenever possible. Signed-off-by: Alessandro Gatti <[email protected]>
This commit fixes a linking issue on certain Arm toolchains where library code is compiled with exception support. If a library with exception support is included in the MicroPython build, the linker had no place to put the stack unwinding tables necessary to perform exception handling at runtime. This change adds a new section to the linkerscript (and therefore the final ELF file) where that data can be placed into. Signed-off-by: Alessandro Gatti <[email protected]>
This commits lifts the unconditional restriction on inline assembler FPU tests for the Qemu platform, and makes said restriction conditional to the lack of an available floating point unit on the running platform. The Qemu platform supported only emulated machines that could target up to a Cortex-M3, so an ArmV7-M target that had no support for floating point. With the addition of MPS2_AN500 to the list of emulated targets the range was extended to cover up to Cortex-M7, so a floating point unit may possibly be available and thus able to run the FPU inlineasm tests. For that, the test runner was changed to detect the running architecture when checking the target capabilities; if the target reports its MicroPython architecture to be either "armv7emsp" or "armv7emdp" (providing single-precision and double-precision floating point unit support respectively) then the FPU-only inline tests are not put into the blocked tests list. Signed-off-by: Alessandro Gatti <[email protected]>
This was missed as part of the transition to make_new a mp_obj_type_t slot. See also: 94beeab Signed-off-by: David Schneider <[email protected]>
This commit lets "tools/mpy-tool.py" extract MPY segments into their own files, one file per segment. A pair of new command line arguments were added, namely "-e"/"--extract" that takes a filename prefix to use as a base for the generated files' name, and "--extract-only" that - combined with "--extract" - allows selecting which kinds of segment should be dumped to the filesystem. So, for example, assuming there's a file called "module.mpy", running "./mpy-tool.py --extract segments module.mpy" would yield a series of files with names like "segments_0_module.py_QSTR_module.py.bin", "segments_1_module.py_META__module_.bin", "segments_2_module.py_QSTR_function.bin", etc. In short the file name format is "<base>_<count>_<sourcefile>_<segmentkind>_<segmentname>.bin", with <segmentkind> being META, QSTR, OBJ, or CODE. Source file names and segment names will only contain characters in the range "a-zA-Z0-9_-." to avoid having output file names with unexpected characters. The "--extract-only" option can accept one or more kinds, separated by commas and treated as case insensitive strings. The supported kinds match what is currently handled by the "MPYSegment" class in "tools/mpy-tool.py": "META", "QSTR", "OBJ", and "CODE". The absence of this command line option implies dumping every segment found. If "--extract" is passed along with "--merge", dumping is performed after the merge process takes place, in order to dump all possible segments that match the requested segment kinds. Signed-off-by: Alessandro Gatti <[email protected]>
The `thread/thread_gc1.py` test is a constant source of spurious failures in Github CI. This commit adds it to the list of tests skipped when running on Github CI using either macos, qemu_riscv64, qemu_mips, or qemu_arm, to help reduce the overall false positive rate and improve the predictive value of the test fail indication. Signed-off-by: Anson Mansfield <[email protected]>
These functions were removed in 6c9fca2 for v1.9.3. This commit removes their declarations as well. See-also: 6c9fca2 Signed-off-by: Anson Mansfield <[email protected]>
Re-organize `mp_parse_num_integer()` (for longlong) slightly so that the most negative 64-bit integer can be parsed. Fixes issue #17932. Signed-off-by: Jeff Epler <[email protected]>
These files are only built on demand for developers, and it is a quick process. Without FORCE, a sequence like this would leave the developer with an outdated `main.pp` to inspect: make build-standard/main.pp touch input.h make build-standard/main.pp # Rebuilds now, wouldn't have before Signed-off-by: Jeff Epler <[email protected]>
So it can be reused by other test runners. Signed-off-by: Damien George <[email protected]>
Back in commit 8978102 (see PR #16111) the `run-tests.py` script was changed to use an improved way of selecting the test instance, eg: $ ./run-tests.py -t a0 that would run on /dev/ttyACM0. This has been a very nice improvement, makes it easier to specify the target. This commit updates `run-multitests.py` to use the same scheme. It previously used `-i` but now that's changed to `-t`. Signed-off-by: Damien George <[email protected]>
Following the similar change to `run-tests.py` and `run-multitests.py`. What was previously, eg, `-p -d /dev/ttyACM0` is now `-t a0`. Signed-off-by: Damien George <[email protected]>
And the existing "-t" option is changed to "-m" (shorthand for the "--diff-time" option). Signed-off-by: Damien George <[email protected]>
The unix port doesn't have `micropython.alloc_emergency_exception_buf()` but it's still possible to run and pass this test. So make that call optional. Signed-off-by: Damien George <[email protected]>
These were missed in 2bba507 because they didn't use the `os.stat` pattern. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Reduces ESP32_GENERIC_C6 application flash size from 2024432 to 1813216 (206KB smaller). Also has benefit of reducing D/IRAM size, increasing free memory at runtime (167187 to 148584, -18603 bytes). Most of this savings comes from building with -Os instead of -O2, but about 10KB comes from using the SPI flash functions from the ROM. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Same optimisation that was applied to C6 in the parent commit, now applied to all RISC-V boards. +------------+------------+------------+------------+ | Size | Before | After | Delta | +------------+------------+------------+------------+ | C2 Binary | 1680384 | 1494224 | -186160 | | C2 D/IRAM | 83710 | 79080 | -4630 | | C3 Binary | 1833328 | 1636624 | -196704 | | C3 D/IRAM | 139608 | 131896 | -7712 | +------------+------------+------------+------------+ This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
I2S works on the ESP32-C6, and it now has enough space to fit. Signed-off-by: Jimisola Laursen <[email protected]> Signed-off-by: Damien George <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi
Please see
micropython#11735
The official page
https://docs.micropython.org/en/latest/genrst/builtin_types.html#float
should be updated about the different result of
(and eventually other inconsistencies) between Python and MicroPython.