Merge tag 'v1.17' into merge-1.17
F-strings, new machine.I2S class, ESP32-C3 support and LEGO_HUB_NO6 board This release of MicroPython adds support for f-strings (PEP-498), with a few limitations compared to normal Python. F-strings are essentially syntactic sugar for "".format() and make formatting strings a lot more convenient. Other improvements to the core runtime include pretty printing OSError when it has two arguments (an errno code and a string), scheduling of KeyboardInterrupt on the main thread, and support for a single argument to the optimised form of StopIteration. In the machine module a new I2S class has been added, with support for esp32 and stm32 ports. This provides a consistent API for transmit and receive of audio data in blocking, non-blocking and asyncio-based operation. Also, the json module has support for the "separators" argument in the dump and dumps functions, and framebuf now includes a way to blit between frame buffers of different formats using a palette. A new, portable machine.bitstream function is also added which can output a stream of bits with configurable timing, and is used as the basis for driving WS2812 LEDs in a common way across ports. There has been some restructuring of the repository directory layout, with all third-party code now in the lib/ directory. And a new top-level directory shared/ has been added with first-party code that was previously in lib/ moved there. The docs have seen further improvement with enhancements and additions to the rp2 parts, as well as a new quick reference for the zephyr port. The terms master/slave have been replaced with controller/peripheral, mainly relating to I2C and SPI usage. And u-module references have been replaced with just the module name without the u-prefix to help clear up the intended usage of modules in MicroPython. For the esp8266 and esp32 ports, hidden networks are now included in WLAN scan results. On the esp32 the RMT class is enhanced with idle_level and write_pulses modes. There is initial support for ESP32-C3 chips with GENERIC_C3 and GENERIC_C3_USB boards. The javascript port has had its Makefile and garbage collector implementation reworked so it compiles and runs with latest the Emscripten using asyncify. The mimxrt port sees the addition of hardware I2C and SPI support, as well as some additional methods to the machine module. There is also support for Hyperflash chips. The nrf port now has full VFS storage support, enables source-line on traceback, and has .mpy features consistent with other ports. For the rp2 port there is now more configurability for boards, and more boards added. The stm32 port has a new LEGO_HUB_NO6 board definition with detailed information how to get this LEGO Hub running stock MicroPython. There is also now support to change the CPU frequency on STM32WB MCUs. And USBD_xxx descriptor options have been renamed to MICROPY_HW_USB_xxx. Thanks to everyone who contributed to this release: Amir Gonnen, Andrew Scheller, Bryan Tong Minh, Chris Wilson, Damien George, Daniel Mizyrycki, David Lechner, David P, Fernando, finefoot, Frank Pilhofer, Glenn Ruben Bakke, iabdalkader, Jeff Epler, Jim Mussared, Jonathan Hogg, Josh Klar, Josh Lloyd, Julia Hathaway, Krzysztof Adamski, Matúš Olekšák, Michael Weiss, Michel Bouwmans, Mike Causer, Mike Teachman, Ned Konz, NitiKaur, oclyke, Patrick Van Oosterwijck, Peter Hinch, Peter Züger, Philipp Ebensberger, robert-hh, Roberto Colistete Jr, Sashkoiv, Seon Rozenblum, Tobias Thyrrestrup, Tom McDermott, Will Sowerbutts, Yonatan Goldschmidt. What follows is a detailed list of changes, generated from the git commit history, and organised into sections. Main components =============== all: - fix signed shifts and NULL access errors from -fsanitize=undefined - update to point to files in new shared/ directory py core: - mpstate: make exceptions thread-local - mpstate: schedule KeyboardInterrupt on main thread - mperrno: add MP_ECANCELED error code - makeqstrdefs.py: don't include .h files explicitly in preprocessing - mark unused arguments from bytecode decoding macros - objexcept: pretty print OSError also when it has 2 arguments - makeversionhdr: add --tags arg to git describe - vm: simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode - objexcept: make mp_obj_exception_get_value support subclassed excs - support single argument to optimised MP_OBJ_STOP_ITERATION - introduce and use mp_raise_type_arg helper - modsys: optimise sys.exit for code size by using exception helpers - objexcept: make mp_obj_new_exception_arg1 inline - obj: fix formatting of comment for mp_obj_is_integer - emitnative: reuse need_reg_all func in need_stack_settled - emitnative: ensure stack settling is safe mid-branch - runtime: fix bool unary op for subclasses of native types - builtinimport: fix condition for including do_execute_raw_code() - mkrules: automatically build mpy-cross if it doesn't exist - implement partial PEP-498 (f-string) support - lexer: clear fstring_args vstr on lexer free - mkrules.mk: do submodule sync in "make submodules" extmod: - btstack: add missing call to mp_bluetooth_hci_uart_deinit - btstack: check that BLE is active before performing operations - uasyncio: get addr and bind server socket before creating task - axtls-include: add axtls_os_port.h to customise axTLS - update for move of crypto-algorithms, re1.5, uzlib to lib - moduselect: conditionally compile select() - nimble: fix leak in l2cap_send if send-while-stalled - btstack/btstack.mk: use -Wno-implicit-fallthrough, not =0 - utime: always invoke mp_hal_delay_ms when >= to 0ms - modbluetooth: clamp MTU values to 32->UINT16_MAX - nimble: allow modbluetooth binding to hook "sent HCI packet" - nimble: add "memory stalling" mechanism for l2cap_send - uasyncio: in open_connection use address info in socket creation - modujson: add support for dump/dumps separators keyword-argument - modlwip: fix close and clean up of UDP and raw sockets - modbluetooth: add send_update arg to gatts_write - add machine.bitstream - modframebuf: enable blit between different formats via a palette lib: - tinyusb: update to version 0.10.1 - pico-sdk: update to version 1.2.0 - utils/stdout_helpers: make mp_hal_stdout_tx_strn_cooked efficient - axtls: switch to repo at micropython/axtls - axtls: update to latest axtls 2.1.5 wih additional commits - re1.5: move re1.5 code from extmod to lib - uzlib: move uzlib code from extmod to lib - crypto-algorithms: move crypto-algorithms code from extmod to lib - update README's based on contents of these dirs drivers: - neopixel: add common machine.bitstream-based neopixel module - neopixel: optimize fill() for speed - neopixel: reduce code size of driver - cyw43: fix cyw43_deinit so it can be called many times in a row - cyw43: make wifi join fail if interface is not active mpy-cross: - disable stack check when building with Emscripten Support components ================== docs: - library: document new esp32.RMT features and fix wait_done - library: warn that ustruct doesn't handle spaces in format strings - esp8266/tutorial: change flash mode from dio to dout - replace master/slave with controller/peripheral in I2C and SPI - rp2: enhance quickref and change image to Pico pinout - rp2: update general section to give a brief technical overview - library/utime.rst: clarify behaviour and precision of sleep ms/us - library/uasyncio.rst: document stream readexactly() method - library/machine.I2S.rst: fix use of sd pin in examples - zephyr: add quick reference for the Zephyr port - library/zephyr: add libraries specific to the Zephyr port - templates: add unix and zephyr quickref links to top-index - rename ufoo.rst to foo.rst - replace ufoo with foo in all docs - library/index.rst: clarify module naming and purpose - library/builtins.rst: add module title - library/network.rst: simplify socket import - add docs for machine.bitstream and neopixel module - library: fix usage of :term: for frozen module reference - esp8266: use monospace for software tools - reference: mention that slicing a memoryview causes allocation examples: no changes specific to this component/port tests: - extmod: make uasyncio_heaplock test more deterministic - cpydiff/modules_struct_whitespace_in_format: run black - extmod/ujson: add tests for dump/dumps separators argument - run-multitests.py: add broadcast and wait facility - multi_bluetooth/ble_subscribe.py: add test for subscription - extmod/vfs_fat_finaliser.py: ensure alloc at never-used GC blocks - basics: split f-string debug printing to separate file with .exp - pybnative: make while.py test run on boards without pyb.delay tools: - autobuild: add scripts to build release firmware - remove obsolete build-stm-latest.sh script - ci.sh: run apt-get update in ci_powerpc_setup - makemanifest.py: allow passing flags to mpy-tool.py - autobuild: add mimxrt port to build scripts for nightly builds - pyboard.py: add cmd-line option to make soft reset configurable - mpremote: swap order of PID and VID in connect-list output - ci.sh: build unix dev variant as part of macOS CI - ci.sh: build GENERIC_C3 board as part of esp32 CI - autobuild: use separate IDF version to build newer esp32 SoCs - autobuild: add FeatherS2 and TinyS2 to esp32 auto builds - mpremote: add seek whence for mounted files - mpremote: raise OSError on unsupported RemoteFile.seek - autobuild: add the MIMXRT1050_EVKB board to the daily builds - ci.sh: add mpy-cross build to nrf port - codeformat.py: include ports/nrf/modules/nrf in code formatting - gen-cpydiff.py: don't rename foo to ufoo in diff output - autobuild: add auto build for Silicognition wESP32 - mpremote: fix connect-list in case VID/PID are None - mpremote: add "devs" shortcut for "connect list" - mpremote: remove support for pyb.USB_VCP in/out specialisation - autobuild: don't use "-B" for make, it's already a fresh build - pyboard.py: move --no-exclusive/--soft-reset out of mutex group - pyboard.py: make --no-follow use same variable as --follow - pyboard.py: add --exclusive to match --no-exclusive - pyboard.py: make --no-soft-reset consistent with other args - uncrustify: force 1 newline at end of file - mpremote: bump version to 0.0.6 CI: - workflows: add workflow to build and test javascript port - workflows: switch from Coveralls to Codecov - workflows: switch from lcov to gcov - workflows: add workflow to build and test unix dev variant The ports ========= all ports: - use common mp_hal_stdout_tx_strn_cooked instead of custom one - update for move of crypto-algorithms, uzlib to lib - rename USBD_VID/PID config macros to MICROPY_HW_USB_VID/PID bare-arm port: no changes specific to this component/port cc3200 port: no changes specific to this component/port esp8266 port: - add __len__ to NeoPixel driver to support iterating - Makefile: add more libm files to build - include hidden networks in WLAN.scan results - replace esp.neopixel with machine.bitstream - remove dead code for end_ticks in machine_bitstream esp32 port: - boards/sdkconfig.base: disable MEMPROT_FEATURE to alloc from IRAM - add __len__ to NeoPixel driver to support iterating - main: allow MICROPY_DIR to be overridden - esp32_rmt: fix RMT looping in newer IDF versions - esp32_rmt: enhance RMT with idle_level and write_pulses modes - add new machine.I2S class for I2S protocol support - machine_spi: calculate actual attained baudrate - machine_hw_spi: use a 2 item SPI queue for long transfers - machine_dac: add MICROPY_PY_MACHINE_DAC option, enable by default - machine_i2s: add MICROPY_PY_MACHINE_I2S option, enable by default - fix use of mp_int_t, size_t and uintptr_t - add initial support for ESP32C3 SoCs - boards/GENERIC_C3: add generic C3-based board - modmachine: release the GIL in machine.idle() - mphalport: always yield at least once in delay_ms - machine_uart: add flow kw-arg to enable hardware flow control - boards: add Silicognition wESP32 board configuration - mpconfigport.h: enable reverse and inplace special methods - include hidden networks in WLAN.scan results - makeimg.py: get bootloader and partition offset from sdkconfig - enable MICROPY_PY_FSTRINGS by default - machine_hw_spi: release GIL during transfers - machine_pin: make check for non-output pins respect chip variant - replace esp.neopixel with machine.bitstream - remove dead code for end_ticks in machine_bitstream - boards: add GENERIC_C3_USB board with USB serial/JTAG support javascript port: - rework Makefile and GC so it works with latest Emscripten - Makefile: suppress compiler errors from array bounds - Makefile: change variable to EXPORTED_RUNTIME_METHODS mimxrt port: - move calc_weekday helper function to timeutils - machine_spi: add the SPI class to the machine module - moduos: seed the PRNG on boot using the TRNG - boards: set vfs partition start to 1 MBbyte - main: skip running main.py if boot.py failed - main: extend the information returned by help() - mimxrt_flash: remove commented-out code - modmachine: add a few minor methods to the machine module - machine_led: use mp_raise_msg_varg helper - machine_i2c: add hardware-based machine.I2C to machine module - add support for Hyperflash chips - boards: add support for the MIMXRT1050_EVKB board - machine_pin: implement ioctl for Pin minimal port: - Makefile: add support for building with user C modules nrf port: - modules: replace master/slave with controller/peripheral in SPI - boards/common.ld: calculate unused flash region - modules/nrf: add new nrf module with flash block device - drivers: add support for using flash block device with SoftDevice - mpconfigport.h: expose nrf module when MICROPY_PY_NRF is set - README: update README.md to reflect internal file systems - mpconfigport.h: tune FAT FS configuration - Makefile: add _fs_size linker script override from make - modules/uos: allow a board to configure MICROPY_VFS_FAT/LFS1/LFS2 - mpconfigport.h: enable MICROPY_PY_IO_FILEIO when an FS is enabled - qstrdefsport.h: add entries for in-built FS mount points - main: add auto mount and auto format hook for internal flash FS - boards: enable needed features for FAT/LFS1/LFS2 - facilitate use of freeze manifest - boards: set FROZEN_MANIFEST blank when SD present on nrf51 targets - modules/scripts: add file system formatting script - Makefile: set default manifest file for all targets - mphalport: add dummy function for mp_hal_time_ns() - boards: enable MICROPY_VFS_LFS2 for all target boards - modules/uos: add ilistdir to uos module - modules/nrf: add function to enable/disable DCDC - enable source line on tracebacks - set .mpy features consistent with documentation and other ports pic16bit port: no changes specific to this component/port powerpc port: no changes specific to this component/port qemu-arm port: no changes specific to this component/port rp2 port: - use 0=Monday datetime convention in RTC - machine_rtc: in RTC.datetime, compute weekday automatically - CMakeLists.txt: suppress compiler errors for pico-sdk and tinyusb - tusb_config.h: set CFG_TUD_CDC_EP_BUFSIZE to 256 - machine_uart: add hardware flow control support - machine_uart: allow overriding default machine UART pins - machine_i2c: allow boards to configure I2C pins using new macros - machine_spi: allow boards to configure SPI pins using new macros - machine_uart: fix poll ioctl to also check hardware FIFO - machine_uart: fix read when FIFO has chars but ringbuf doesn't - tusb_port: allow boards to configure USB VID and PID - boards/ADAFRUIT_FEATHER_RP2040: configure custom VID/PID - boards/ADAFRUIT_FEATHER_RP2040: configure I2C/SPI default pins - boards/SPARKFUN_PROMICRO: configure UART/I2C/SPI default pins - boards/SPARKFUN_THINGPLUS: configure I2C/SPI default pins - boards: add Adafruit ItsyBitsy RP2040 - boards: add Adafruit QT Py RP2040 - boards: add Pimoroni Pico LiPo 4MB - boards: add Pimoroni Pico LiPo 16MB - boards: add Pimoroni Tiny 2040 - CMakeLists.txt: allow a board's cmake to set the manifest path - enable MICROPY_PY_FSTRINGS by default - Makefile: add "submodules" target, to match other ports - rp2_flash: disable IRQs while calling flash_erase/program - CMakeLists.txt: add option to enable double tap reset to bootrom - mpconfigport.h: allow boards to add root pointers samd port: - add support for building with user C modules stm32 port: - softtimer: add soft_timer_reinsert() helper function - mpbthciport: change from systick to soft-timer for BT scheduling - provide a custom BTstack runloop that integrates with soft timer - usb: make irq's default trigger enable all events - boardctrl: skip running main.py if boot.py had an error - sdio: fix undefined reference to DMA stream on H7 - dma: add DMAMUX configuration for H7 to fix dma_nohal_init - main: call mp_deinit() at end of main - adc: allow using ADC12 and ADC3 for H7 - adc: define the ADC instance used for internal channels - adc: simplify and generalise how pin_adcX table is defined - add new machine.I2S class for I2S protocol support - boards/NUCLEO_F446RE: fix I2C1 pin assignment to match datasheet - replace master/slave with controller/peripheral in I2C and SPI - systick: always POLL_HOOK when delaying for milliseconds - sdram: make SDRAM test cache aware, and optional failure with msg - boards/NUCLEO_F446RE: enable CAN bus support - boards: add support for SparkFun STM32 MicroMod Processor board - uart: fix LPUART1 baudrate set/get - uart: support low baudrates on LPUART1 - boards/STM32F429DISC: set correct UART2 pins and add UART3/6 - boards/NUCLEO_F439ZI: add board definition for NUCLEO_F439ZI - boards/LEGO_HUB_NO6: add board definition for LEGO_HUB_NO6 - Makefile: update to only pull in used Bluetooth library - README.md: update supported MCUs, and submodule and mboot use - usbd_desc: rename USBD_xxx descriptor opts to MICROPY_HW_USB_xxx - usbd_cdc_interface: rename USBD_CDC_xx opts to MICROPY_HW_USB_xx - powerctrl: support changing frequency on WB MCUs - boards/NUCLEO_H743ZI2: add modified version of NUCLEO_H743ZI - mbedtls: fix compile warning about uninitialized val - enable MICROPY_PY_FSTRINGS by default - add implementation of machine.bitstream - Makefile: allow GIT_SUBMODULES and LIBS to be extended - stm32_it: support TIM17 IRQs on WB MCUs - disable computed goto on constrained boards - storage: make extended-block-device more configurable - boards/LEGO_HUB_NO6: change SPI flash storage to use hardware SPI - boards/LEGO_HUB_NO6: skip first 1MiB of SPI flash for storage - boards/LEGO_HUB_NO6: add make commands to backup/restore firmware teensy port: no changes specific to this component/port unix port: - modffi: add option to lock GC in callback, and cfun access - Makefile: add back LIB_SRC_C to list of object files - variants: enable help and help("modules") on standard and dev - Makefile: disable error compression on arm-linux-gnueabi-gcc windows port: - Makefile: add .exe extension to executables name - appveyor: update to VS 2017 and use Python 3.8 for build/test zephyr port: - machine_spi: add support for hardware SPI
This commit is contained in:
commit
8d8f83bc05
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -145,6 +145,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git describe --dirty --tags
|
git describe --dirty --tags
|
||||||
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
|
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
|
||||||
|
- name: Set up Python 3.8
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install gettext
|
brew install gettext
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -4,17 +4,13 @@
|
|||||||
|
|
||||||
[submodule "lib/axtls"]
|
[submodule "lib/axtls"]
|
||||||
path = lib/axtls
|
path = lib/axtls
|
||||||
url = https://github.com/pfalcon/axtls
|
url = https://github.com/micropython/axtls.git
|
||||||
branch = micropython
|
|
||||||
[submodule "lib/libffi"]
|
[submodule "lib/libffi"]
|
||||||
path = lib/libffi
|
path = lib/libffi
|
||||||
url = https://github.com/atgreen/libffi
|
url = https://github.com/atgreen/libffi
|
||||||
[submodule "lib/berkeley-db-1.xx"]
|
[submodule "lib/berkeley-db-1.xx"]
|
||||||
path = lib/berkeley-db-1.xx
|
path = lib/berkeley-db-1.xx
|
||||||
url = https://github.com/pfalcon/berkeley-db-1.xx
|
url = https://github.com/pfalcon/berkeley-db-1.xx
|
||||||
[submodule "lib/uzlib"]
|
|
||||||
path = lib/uzlib
|
|
||||||
url = https://github.com/pfalcon/uzlib
|
|
||||||
[submodule "tools/uf2"]
|
[submodule "tools/uf2"]
|
||||||
path = tools/uf2
|
path = tools/uf2
|
||||||
url = https://github.com/Microsoft/uf2.git
|
url = https://github.com/Microsoft/uf2.git
|
||||||
|
64
LICENSE
64
LICENSE
@ -19,3 +19,67 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Unless specified otherwise (see below), the above license and copyright applies
|
||||||
|
to all files in this repository.
|
||||||
|
|
||||||
|
Individual files may include additional copyright holders.
|
||||||
|
|
||||||
|
The various ports of MicroPython may include third-party software that is
|
||||||
|
licensed under different terms. These licenses are summarised in the tree
|
||||||
|
below, please refer to these files and directories for further license and
|
||||||
|
copyright information. Note that (L)GPL-licensed code listed below is only
|
||||||
|
used during the build process and is not part of the compiled source code.
|
||||||
|
|
||||||
|
/ (MIT)
|
||||||
|
/drivers
|
||||||
|
/cc3000 (BSD-3-clause)
|
||||||
|
/cc3100 (BSD-3-clause)
|
||||||
|
/wiznet5k (BSD-3-clause)
|
||||||
|
/lib
|
||||||
|
/asf4 (Apache-2.0)
|
||||||
|
/axtls (BSD-3-clause)
|
||||||
|
/config
|
||||||
|
/scripts
|
||||||
|
/config (GPL-2.0-or-later)
|
||||||
|
/Rules.mak (GPL-2.0)
|
||||||
|
/berkeley-db-1xx (BSD-4-clause)
|
||||||
|
/btstack (See btstack/LICENSE)
|
||||||
|
/cmsis (BSD-3-clause)
|
||||||
|
/crypto-algorithms (NONE)
|
||||||
|
/libhydrogen (ISC)
|
||||||
|
/littlefs (BSD-3-clause)
|
||||||
|
/lwip (BSD-3-clause)
|
||||||
|
/mynewt-nimble (Apache-2.0)
|
||||||
|
/nrfx (BSD-3-clause)
|
||||||
|
/nxp_driver (BSD-3-Clause)
|
||||||
|
/oofatfs (BSD-1-clause)
|
||||||
|
/pico-sdk (BSD-3-clause)
|
||||||
|
/re15 (BSD-3-clause)
|
||||||
|
/stm32lib (BSD-3-clause)
|
||||||
|
/tinytest (BSD-3-clause)
|
||||||
|
/tinyusb (MIT)
|
||||||
|
/uzlib (Zlib)
|
||||||
|
/logo (uses OFL-1.1)
|
||||||
|
/ports
|
||||||
|
/cc3200
|
||||||
|
/hal (BSD-3-clause)
|
||||||
|
/simplelink (BSD-3-clause)
|
||||||
|
/FreeRTOS (GPL-2.0 with FreeRTOS exception)
|
||||||
|
/stm32
|
||||||
|
/usbd*.c (MCD-ST Liberty SW License Agreement V2)
|
||||||
|
/stm32_it.* (MIT + BSD-3-clause)
|
||||||
|
/system_stm32*.c (MIT + BSD-3-clause)
|
||||||
|
/boards
|
||||||
|
/startup_stm32*.s (BSD-3-clause)
|
||||||
|
/*/stm32*.h (BSD-3-clause)
|
||||||
|
/usbdev (MCD-ST Liberty SW License Agreement V2)
|
||||||
|
/usbhost (MCD-ST Liberty SW License Agreement V2)
|
||||||
|
/teensy
|
||||||
|
/core (PJRC.COM)
|
||||||
|
/zephyr
|
||||||
|
/src (Apache-2.0)
|
||||||
|
/tools
|
||||||
|
/dfu.py (LGPL-3.0-only)
|
||||||
|
1
conf.py
1
conf.py
@ -209,6 +209,7 @@ exclude_patterns = ["**/build*",
|
|||||||
"ports/stm/ref",
|
"ports/stm/ref",
|
||||||
"ports/unix",
|
"ports/unix",
|
||||||
"py",
|
"py",
|
||||||
|
"shared/*",
|
||||||
"shared-bindings/util.*",
|
"shared-bindings/util.*",
|
||||||
"shared-module",
|
"shared-module",
|
||||||
"supervisor",
|
"supervisor",
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#include "py/stream.h"
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "py/objlist.h"
|
#include "py/objlist.h"
|
||||||
#include "py/objstr.h"
|
#include "py/objstr.h"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stream.h"
|
#include "py/stream.h"
|
||||||
|
|
||||||
|
@ -222,6 +222,14 @@ TCP stream connections
|
|||||||
|
|
||||||
This is a coroutine, and a MicroPython extension.
|
This is a coroutine, and a MicroPython extension.
|
||||||
|
|
||||||
|
.. method:: Stream.readexactly(n)
|
||||||
|
|
||||||
|
Read exactly *n* bytes and return them as a bytes object.
|
||||||
|
|
||||||
|
Raises an ``EOFError`` exception if the stream ends before reading *n* bytes.
|
||||||
|
|
||||||
|
This is a coroutine.
|
||||||
|
|
||||||
.. method:: Stream.readline()
|
.. method:: Stream.readline()
|
||||||
|
|
||||||
Read a line and return it.
|
Read a line and return it.
|
@ -24,7 +24,7 @@ Example::
|
|||||||
|
|
||||||
# First, we need to open a stream which holds a database
|
# First, we need to open a stream which holds a database
|
||||||
# This is usually a file, but can be in-memory database
|
# This is usually a file, but can be in-memory database
|
||||||
# using uio.BytesIO, a raw flash partition, etc.
|
# using io.BytesIO, a raw flash partition, etc.
|
||||||
# Oftentimes, you want to create a database file if it doesn't
|
# Oftentimes, you want to create a database file if it doesn't
|
||||||
# exist and open if it exists. Idiom below takes care of this.
|
# exist and open if it exists. Idiom below takes care of this.
|
||||||
# DO NOT open database with "a+b" access mode.
|
# DO NOT open database with "a+b" access mode.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Builtin functions and exceptions
|
:mod:`builtins` -- builtin functions and exceptions
|
||||||
================================
|
===================================================
|
||||||
|
|
||||||
All builtin functions and exceptions are described here. They are also
|
All builtin functions and exceptions are described here. They are also
|
||||||
available via ``builtins`` module.
|
available via ``builtins`` module.
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
:mod:`uctypes` -- access binary data in a structured way
|
:mod:`uctypes` -- access binary data in a structured way
|
||||||
========================================================
|
========================================================
|
||||||
|
|
||||||
.. include:: ../templates/unsupported_in_circuitpython.inc
|
|
||||||
|
|
||||||
.. module:: uctypes
|
.. module:: uctypes
|
||||||
:synopsis: access binary data in a structured way
|
:synopsis: access binary data in a structured way
|
||||||
|
|
@ -105,16 +105,23 @@ Other methods
|
|||||||
Shift the contents of the FrameBuffer by the given vector. This may
|
Shift the contents of the FrameBuffer by the given vector. This may
|
||||||
leave a footprint of the previous colors in the FrameBuffer.
|
leave a footprint of the previous colors in the FrameBuffer.
|
||||||
|
|
||||||
.. method:: FrameBuffer.blit(fbuf, x, y[, key])
|
.. method:: FrameBuffer.blit(fbuf, x, y, key=-1, palette=None)
|
||||||
|
|
||||||
Draw another FrameBuffer on top of the current one at the given coordinates.
|
Draw another FrameBuffer on top of the current one at the given coordinates.
|
||||||
If *key* is specified then it should be a color integer and the
|
If *key* is specified then it should be a color integer and the
|
||||||
corresponding color will be considered transparent: all pixels with that
|
corresponding color will be considered transparent: all pixels with that
|
||||||
color value will not be drawn.
|
color value will not be drawn.
|
||||||
|
|
||||||
This method works between FrameBuffer instances utilising different formats,
|
The *palette* argument enables blitting between FrameBuffers with differing
|
||||||
but the resulting colors may be unexpected due to the mismatch in color
|
formats. Typical usage is to render a monochrome or grayscale glyph/icon to
|
||||||
formats.
|
a color display. The *palette* is a FrameBuffer instance whose format is
|
||||||
|
that of the current FrameBuffer. The *palette* height is one pixel and its
|
||||||
|
pixel width is the number of colors in the source FrameBuffer. The *palette*
|
||||||
|
for an N-bit source needs 2**N pixels; the *palette* for a monochrome source
|
||||||
|
would have 2 pixels representing background and foreground colors. The
|
||||||
|
application assigns a color to each pixel in the *palette*. The color of the
|
||||||
|
current pixel will be that of that *palette* pixel whose x position is the
|
||||||
|
color of the corresponding source pixel.
|
||||||
|
|
||||||
Constants
|
Constants
|
||||||
---------
|
---------
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
:mod:`uheapq` -- heap queue algorithm
|
:mod:`heapq` -- heap queue algorithm
|
||||||
=====================================
|
====================================
|
||||||
|
|
||||||
.. include:: ../templates/unsupported_in_circuitpython.inc
|
.. include:: ../templates/unsupported_in_circuitpython.inc
|
||||||
|
|
||||||
.. module:: uheapq
|
.. module:: heapq
|
||||||
:synopsis: heap queue algorithm
|
:synopsis: heap queue algorithm
|
||||||
|
|
||||||
|see_cpython_module| :mod:`cpython:heapq`.
|
|see_cpython_module| :mod:`cpython:heapq`.
|
@ -18,15 +18,14 @@ These libraries are not enabled on CircuitPython builds with
|
|||||||
limited flash memory, usually on non-Express builds:
|
limited flash memory, usually on non-Express builds:
|
||||||
``binascii``, ``errno``, ``json``, ``re``.
|
``binascii``, ``errno``, ``json``, ``re``.
|
||||||
|
|
||||||
These libraries are not currently enabled in any CircuitPython build, but may be in the future,
|
These libraries are not currently enabled in any CircuitPython build, but may be in the future:
|
||||||
with the ``u`` prefix dropped:
|
``ctypes``, ``hashlib``, ``zlib``.
|
||||||
``uctypes``, ``uhashlib``, ``uzlib``.
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
builtins.rst
|
builtins.rst
|
||||||
uheapq.rst
|
heapq.rst
|
||||||
array.rst
|
array.rst
|
||||||
binascii.rst
|
binascii.rst
|
||||||
collections.rst
|
collections.rst
|
||||||
@ -37,10 +36,10 @@ with the ``u`` prefix dropped:
|
|||||||
json.rst
|
json.rst
|
||||||
re.rst
|
re.rst
|
||||||
sys.rst
|
sys.rst
|
||||||
uasyncio.rst
|
asyncio.rst
|
||||||
uctypes.rst
|
ctypes.rst
|
||||||
uselect.rst
|
select.rst
|
||||||
uzlib.rst
|
zlib.rst
|
||||||
|
|
||||||
Omitted functions in the ``string`` library
|
Omitted functions in the ``string`` library
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
:mod:`uselect` -- wait for events on a set of streams
|
:mod:`select` -- wait for events on a set of streams
|
||||||
========================================================================
|
====================================================
|
||||||
|
|
||||||
.. include:: ../templates/unsupported_in_circuitpython.inc
|
.. include:: ../templates/unsupported_in_circuitpython.inc
|
||||||
|
|
||||||
.. module:: uselect
|
.. module:: select
|
||||||
:synopsis: wait for events on a set of streams
|
:synopsis: wait for events on a set of streams
|
||||||
|
|
||||||
|see_cpython_module| :mod:`cpython:select`.
|
|see_cpython_module| :mod:`cpython:select`.
|
||||||
@ -37,15 +37,15 @@ Methods
|
|||||||
|
|
||||||
Register ``stream`` *obj* for polling. *eventmask* is logical OR of:
|
Register ``stream`` *obj* for polling. *eventmask* is logical OR of:
|
||||||
|
|
||||||
* ``uselect.POLLIN`` - data available for reading
|
* ``select.POLLIN`` - data available for reading
|
||||||
* ``uselect.POLLOUT`` - more data can be written
|
* ``select.POLLOUT`` - more data can be written
|
||||||
|
|
||||||
Note that flags like ``uselect.POLLHUP`` and ``uselect.POLLERR`` are
|
Note that flags like ``select.POLLHUP`` and ``select.POLLERR`` are
|
||||||
*not* valid as input eventmask (these are unsolicited events which
|
*not* valid as input eventmask (these are unsolicited events which
|
||||||
will be returned from `poll()` regardless of whether they are asked
|
will be returned from `poll()` regardless of whether they are asked
|
||||||
for). This semantics is per POSIX.
|
for). This semantics is per POSIX.
|
||||||
|
|
||||||
*eventmask* defaults to ``uselect.POLLIN | uselect.POLLOUT``.
|
*eventmask* defaults to ``select.POLLIN | select.POLLOUT``.
|
||||||
|
|
||||||
It is OK to call this function multiple times for the same *obj*.
|
It is OK to call this function multiple times for the same *obj*.
|
||||||
Successive calls will update *obj*'s eventmask to the value of
|
Successive calls will update *obj*'s eventmask to the value of
|
||||||
@ -69,8 +69,8 @@ Methods
|
|||||||
Returns list of (``obj``, ``event``, ...) tuples. There may be other elements in
|
Returns list of (``obj``, ``event``, ...) tuples. There may be other elements in
|
||||||
tuple, depending on a platform and version, so don't assume that its size is 2.
|
tuple, depending on a platform and version, so don't assume that its size is 2.
|
||||||
The ``event`` element specifies which events happened with a stream and
|
The ``event`` element specifies which events happened with a stream and
|
||||||
is a combination of ``uselect.POLL*`` constants described above. Note that
|
is a combination of ``select.POLL*`` constants described above. Note that
|
||||||
flags ``uselect.POLLHUP`` and ``uselect.POLLERR`` can be returned at any time
|
flags ``select.POLLHUP`` and ``select.POLLERR`` can be returned at any time
|
||||||
(even if were not asked for), and must be acted on accordingly (the
|
(even if were not asked for), and must be acted on accordingly (the
|
||||||
corresponding stream unregistered from poll and likely closed), because
|
corresponding stream unregistered from poll and likely closed), because
|
||||||
otherwise all further invocations of `poll()` may return immediately with
|
otherwise all further invocations of `poll()` may return immediately with
|
@ -1,9 +1,9 @@
|
|||||||
:mod:`uzlib` -- zlib decompression
|
:mod:`zlib` -- zlib decompression
|
||||||
==================================
|
=================================
|
||||||
|
|
||||||
.. include:: ../templates/unsupported_in_circuitpython.inc
|
.. include:: ../templates/unsupported_in_circuitpython.inc
|
||||||
|
|
||||||
.. module:: uzlib
|
.. module:: zlib
|
||||||
:synopsis: zlib decompression
|
:synopsis: zlib decompression
|
||||||
|
|
||||||
|see_cpython_module| :mod:`cpython:zlib`.
|
|see_cpython_module| :mod:`cpython:zlib`.
|
@ -18,7 +18,7 @@ void *memmove(void *dest, const void *src, size_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *malloc(size_t n) {
|
void *malloc(size_t n) {
|
||||||
void *ptr = m_malloc(n, false);
|
void *ptr = m_malloc(n);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
void *realloc(void *ptr, size_t n) {
|
void *realloc(void *ptr, size_t n) {
|
||||||
@ -26,7 +26,7 @@ void *realloc(void *ptr, size_t n) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void *calloc(size_t n, size_t m) {
|
void *calloc(size_t n, size_t m) {
|
||||||
void *ptr = m_malloc(n * m, false);
|
void *ptr = m_malloc(n * m);
|
||||||
// memory already cleared by conservative GC
|
// memory already cleared by conservative GC
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(add_d_obj, add_d);
|
|||||||
// to use but has access to the globals dict of the module via self->globals.
|
// to use but has access to the globals dict of the module via self->globals.
|
||||||
STATIC mp_obj_t productf(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) {
|
STATIC mp_obj_t productf(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) {
|
||||||
// Check number of arguments is valid
|
// Check number of arguments is valid
|
||||||
mp_arg_check_num_mp(n_args, n_kw, 1, 1, false);
|
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||||
|
|
||||||
// Extract buffer pointer and verify typecode
|
// Extract buffer pointer and verify typecode
|
||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
|
@ -31,4 +31,7 @@ const mp_obj_module_t example_user_cmodule = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Register the module to make it available in Python.
|
// Register the module to make it available in Python.
|
||||||
MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, MODULE_CEXAMPLE_ENABLED);
|
// Note: the "1" in the third argument means this module is always enabled.
|
||||||
|
// This "1" can be optionally replaced with a macro like MODULE_CEXAMPLE_ENABLED
|
||||||
|
// which can then be used to conditionally enable this module.
|
||||||
|
MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, 1);
|
||||||
|
15
examples/usercmodule/cexample/micropython.cmake
Normal file
15
examples/usercmodule/cexample/micropython.cmake
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Create an INTERFACE library for our C module.
|
||||||
|
add_library(usermod_cexample INTERFACE)
|
||||||
|
|
||||||
|
# Add our source files to the lib
|
||||||
|
target_sources(usermod_cexample INTERFACE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/examplemodule.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add the current directory as an include directory.
|
||||||
|
target_include_directories(usermod_cexample INTERFACE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link our INTERFACE library to the usermod target.
|
||||||
|
target_link_libraries(usermod INTERFACE usermod_cexample)
|
@ -22,4 +22,7 @@ const mp_obj_module_t cppexample_user_cmodule = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Register the module to make it available in Python.
|
// Register the module to make it available in Python.
|
||||||
MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, MODULE_CPPEXAMPLE_ENABLED);
|
// Note: the "1" in the third argument means this module is always enabled.
|
||||||
|
// This "1" can be optionally replaced with a macro like MODULE_CPPEXAMPLE_ENABLED
|
||||||
|
// which can then be used to conditionally enable this module.
|
||||||
|
MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, 1);
|
||||||
|
16
examples/usercmodule/cppexample/micropython.cmake
Normal file
16
examples/usercmodule/cppexample/micropython.cmake
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Create an INTERFACE library for our CPP module.
|
||||||
|
add_library(usermod_cppexample INTERFACE)
|
||||||
|
|
||||||
|
# Add our source files to the library.
|
||||||
|
target_sources(usermod_cppexample INTERFACE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/example.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/examplemodule.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add the current directory as an include directory.
|
||||||
|
target_include_directories(usermod_cppexample INTERFACE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link our INTERFACE library to the usermod target.
|
||||||
|
target_link_libraries(usermod INTERFACE usermod_cppexample)
|
10
examples/usercmodule/micropython.cmake
Normal file
10
examples/usercmodule/micropython.cmake
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# This top-level micropython.cmake is responsible for listing
|
||||||
|
# the individual modules we want to include.
|
||||||
|
# Paths are absolute, and ${CMAKE_CURRENT_LIST_DIR} can be
|
||||||
|
# used to prefix subdirectories.
|
||||||
|
|
||||||
|
# Add the C example.
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/cexample/micropython.cmake)
|
||||||
|
|
||||||
|
# Add the CPP example.
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/cppexample/micropython.cmake)
|
55
extmod/axtls-include/axtls_os_port.h
Normal file
55
extmod/axtls-include/axtls_os_port.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Damien P. George
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef AXTLS_OS_PORT_H
|
||||||
|
#define AXTLS_OS_PORT_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include "py/stream.h"
|
||||||
|
#include "lib/crypto-algorithms/sha256.h"
|
||||||
|
|
||||||
|
#define SSL_CTX_MUTEX_INIT(mutex)
|
||||||
|
#define SSL_CTX_MUTEX_DESTROY(mutex)
|
||||||
|
#define SSL_CTX_LOCK(mutex)
|
||||||
|
#define SSL_CTX_UNLOCK(mutex)
|
||||||
|
|
||||||
|
#define SOCKET_READ(s, buf, size) mp_stream_posix_read((void *)s, buf, size)
|
||||||
|
#define SOCKET_WRITE(s, buf, size) mp_stream_posix_write((void *)s, buf, size)
|
||||||
|
#define SOCKET_CLOSE(A) UNUSED
|
||||||
|
#define SOCKET_ERRNO() errno
|
||||||
|
|
||||||
|
#define SHA256_CTX CRYAL_SHA256_CTX
|
||||||
|
#define SHA256_Init(ctx) sha256_init(ctx)
|
||||||
|
#define SHA256_Update(ctx, buf, size) sha256_update(ctx, buf, size)
|
||||||
|
#define SHA256_Final(hash, ctx) sha256_final(ctx, hash)
|
||||||
|
|
||||||
|
#define TTY_FLUSH()
|
||||||
|
|
||||||
|
#ifdef WDEV_HWRNG
|
||||||
|
// For esp8266 port: use the hardware RNG.
|
||||||
|
#define PLATFORM_RNG_U8() (*WDEV_HWRNG)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // AXTLS_OS_PORT_H
|
@ -4,8 +4,9 @@ set(MICROPY_EXTMOD_DIR "${MICROPY_DIR}/extmod")
|
|||||||
set(MICROPY_OOFATFS_DIR "${MICROPY_DIR}/lib/oofatfs")
|
set(MICROPY_OOFATFS_DIR "${MICROPY_DIR}/lib/oofatfs")
|
||||||
|
|
||||||
set(MICROPY_SOURCE_EXTMOD
|
set(MICROPY_SOURCE_EXTMOD
|
||||||
${MICROPY_DIR}/lib/embed/abort_.c
|
${MICROPY_DIR}/shared/libc/abort_.c
|
||||||
${MICROPY_DIR}/lib/utils/printf.c
|
${MICROPY_DIR}/shared/libc/printf.c
|
||||||
|
${MICROPY_EXTMOD_DIR}/machine_bitstream.c
|
||||||
${MICROPY_EXTMOD_DIR}/machine_i2c.c
|
${MICROPY_EXTMOD_DIR}/machine_i2c.c
|
||||||
${MICROPY_EXTMOD_DIR}/machine_mem.c
|
${MICROPY_EXTMOD_DIR}/machine_mem.c
|
||||||
${MICROPY_EXTMOD_DIR}/machine_pulse.c
|
${MICROPY_EXTMOD_DIR}/machine_pulse.c
|
||||||
|
@ -157,7 +157,7 @@ LWIP_DIR = lib/lwip/src
|
|||||||
INC += -I$(TOP)/$(LWIP_DIR)/include
|
INC += -I$(TOP)/$(LWIP_DIR)/include
|
||||||
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
|
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
|
||||||
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
|
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
|
||||||
SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c
|
SRC_MOD += extmod/modlwip.c shared/netutils/netutils.c
|
||||||
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
|
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
|
||||||
apps/mdns/mdns.c \
|
apps/mdns/mdns.c \
|
||||||
core/def.c \
|
core/def.c \
|
||||||
|
@ -244,8 +244,8 @@ STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, u
|
|||||||
formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col);
|
formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 4, 5, false);
|
mp_arg_check_num(n_args, n_kw, 4, 5, false);
|
||||||
|
|
||||||
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
|
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
|
||||||
o->base.type = type;
|
o->base.type = type;
|
||||||
@ -481,6 +481,10 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
|||||||
if (n_args > 4) {
|
if (n_args > 4) {
|
||||||
key = mp_obj_get_int(args[4]);
|
key = mp_obj_get_int(args[4]);
|
||||||
}
|
}
|
||||||
|
mp_obj_framebuf_t *palette = NULL;
|
||||||
|
if (n_args > 5 && args[5] != mp_const_none) {
|
||||||
|
palette = MP_OBJ_TO_PTR(mp_obj_cast_to_native_base(args[5], MP_OBJ_FROM_PTR(&mp_type_framebuf)));
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(x >= self->width) ||
|
(x >= self->width) ||
|
||||||
@ -504,6 +508,9 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
|||||||
int cx1 = x1;
|
int cx1 = x1;
|
||||||
for (int cx0 = x0; cx0 < x0end; ++cx0) {
|
for (int cx0 = x0; cx0 < x0end; ++cx0) {
|
||||||
uint32_t col = getpixel(source, cx1, y1);
|
uint32_t col = getpixel(source, cx1, y1);
|
||||||
|
if (palette) {
|
||||||
|
col = getpixel(palette, col, 0);
|
||||||
|
}
|
||||||
if (col != (uint32_t)key) {
|
if (col != (uint32_t)key) {
|
||||||
setpixel(self, cx0, y0, col);
|
setpixel(self, cx0, y0, col);
|
||||||
}
|
}
|
||||||
@ -513,7 +520,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 6, framebuf_blit);
|
||||||
|
|
||||||
STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) {
|
STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) {
|
||||||
mp_obj_framebuf_t *self = native_framebuf(self_in);
|
mp_obj_framebuf_t *self = native_framebuf(self_in);
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#if MICROPY_PY_UASYNCIO
|
#if MICROPY_PY_UASYNCIO
|
||||||
|
|
||||||
|
// Used when task cannot be guaranteed to be non-NULL.
|
||||||
|
#define TASK_PAIRHEAP(task) ((task) ? &(task)->pairheap : NULL)
|
||||||
|
|
||||||
#define TASK_STATE_RUNNING_NOT_WAITED_ON (mp_const_true)
|
#define TASK_STATE_RUNNING_NOT_WAITED_ON (mp_const_true)
|
||||||
#define TASK_STATE_DONE_NOT_WAITED_ON (mp_const_none)
|
#define TASK_STATE_DONE_NOT_WAITED_ON (mp_const_none)
|
||||||
#define TASK_STATE_DONE_WAS_WAITED_ON (mp_const_false)
|
#define TASK_STATE_DONE_WAS_WAITED_ON (mp_const_false)
|
||||||
@ -55,7 +58,7 @@ typedef struct _mp_obj_task_queue_t {
|
|||||||
STATIC const mp_obj_type_t task_queue_type;
|
STATIC const mp_obj_type_t task_queue_type;
|
||||||
STATIC const mp_obj_type_t task_type;
|
STATIC const mp_obj_type_t task_type;
|
||||||
|
|
||||||
STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
// Ticks for task ordering in pairing heap
|
// Ticks for task ordering in pairing heap
|
||||||
@ -81,9 +84,9 @@ STATIC int task_lt(mp_pairheap_t *n1, mp_pairheap_t *n2) {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
// TaskQueue class
|
// TaskQueue class
|
||||||
|
|
||||||
STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
(void)args;
|
(void)args;
|
||||||
mp_arg_check_num(n_args, kw_args, 0, 0, false);
|
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||||
mp_obj_task_queue_t *self = m_new_obj(mp_obj_task_queue_t);
|
mp_obj_task_queue_t *self = m_new_obj(mp_obj_task_queue_t);
|
||||||
self->base.type = type;
|
self->base.type = type;
|
||||||
self->heap = (mp_obj_task_t *)mp_pairheap_new(task_lt);
|
self->heap = (mp_obj_task_t *)mp_pairheap_new(task_lt);
|
||||||
@ -110,7 +113,7 @@ STATIC mp_obj_t task_queue_push_sorted(size_t n_args, const mp_obj_t *args) {
|
|||||||
assert(mp_obj_is_small_int(args[2]));
|
assert(mp_obj_is_small_int(args[2]));
|
||||||
task->ph_key = args[2];
|
task->ph_key = args[2];
|
||||||
}
|
}
|
||||||
self->heap = (mp_obj_task_t *)mp_pairheap_push(task_lt, &self->heap->pairheap, &task->pairheap);
|
self->heap = (mp_obj_task_t *)mp_pairheap_push(task_lt, TASK_PAIRHEAP(self->heap), TASK_PAIRHEAP(task));
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(task_queue_push_sorted_obj, 2, 3, task_queue_push_sorted);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(task_queue_push_sorted_obj, 2, 3, task_queue_push_sorted);
|
||||||
@ -156,8 +159,8 @@ STATIC const mp_obj_type_t task_queue_type = {
|
|||||||
// This is the core uasyncio context with cur_task, _task_queue and CancelledError.
|
// This is the core uasyncio context with cur_task, _task_queue and CancelledError.
|
||||||
STATIC mp_obj_t uasyncio_context = MP_OBJ_NULL;
|
STATIC mp_obj_t uasyncio_context = MP_OBJ_NULL;
|
||||||
|
|
||||||
STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 1, 2, false);
|
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||||
mp_obj_task_t *self = m_new_obj(mp_obj_task_t);
|
mp_obj_task_t *self = m_new_obj(mp_obj_task_t);
|
||||||
self->pairheap.base.type = type;
|
self->pairheap.base.type = type;
|
||||||
mp_pairheap_init_node(task_lt, &self->pairheap);
|
mp_pairheap_init_node(task_lt, &self->pairheap);
|
||||||
|
@ -205,7 +205,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) {
|
|||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64);
|
||||||
|
|
||||||
#if MICROPY_PY_UBINASCII_CRC32
|
#if MICROPY_PY_UBINASCII_CRC32
|
||||||
#include "../../lib/uzlib/src/tinf.h"
|
#include "lib/uzlib/tinf.h"
|
||||||
|
|
||||||
STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
|
||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
|
@ -74,8 +74,8 @@ STATIC NORETURN void syntax_error(void) {
|
|||||||
mp_raise_TypeError(MP_ERROR_TEXT("syntax error in uctypes descriptor"));
|
mp_raise_TypeError(MP_ERROR_TEXT("syntax error in uctypes descriptor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 2, 3, false);
|
mp_arg_check_num(n_args, n_kw, 2, 3, false);
|
||||||
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
|
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
|
||||||
o->base.type = type;
|
o->base.type = type;
|
||||||
o->addr = (void *)(uintptr_t)mp_obj_int_get_truncated(args[0]);
|
o->addr = (void *)(uintptr_t)mp_obj_int_get_truncated(args[0]);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#if MICROPY_SSL_MBEDTLS
|
#if MICROPY_SSL_MBEDTLS
|
||||||
#include "mbedtls/sha256.h"
|
#include "mbedtls/sha256.h"
|
||||||
#else
|
#else
|
||||||
#include "crypto-algorithms/sha256.h"
|
#include "lib/crypto-algorithms/sha256.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -106,11 +106,10 @@ static void check_not_unicode(const mp_obj_t arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MICROPY_PY_UHASHLIB_SHA256
|
#if MICROPY_PY_UHASHLIB_SHA256
|
||||||
#include "crypto-algorithms/sha256.c"
|
#include "lib/crypto-algorithms/sha256.c"
|
||||||
#endif
|
|
||||||
|
|
||||||
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||||
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
|
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
|
||||||
o->base.type = type;
|
o->base.type = type;
|
||||||
o->final = false;
|
o->final = false;
|
||||||
@ -160,6 +159,8 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_PY_UHASHLIB_SHA1
|
#if MICROPY_PY_UHASHLIB_SHA1
|
||||||
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
|
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
|
||||||
|
|
||||||
|
@ -17,6 +17,62 @@
|
|||||||
|
|
||||||
#if MICROPY_PY_UJSON
|
#if MICROPY_PY_UJSON
|
||||||
|
|
||||||
|
#if MICROPY_PY_UJSON_SEPARATORS
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DUMP_MODE_TO_STRING = 1,
|
||||||
|
DUMP_MODE_TO_STREAM = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
STATIC mp_obj_t mod_ujson_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) {
|
||||||
|
enum { ARG_separators };
|
||||||
|
static const mp_arg_t allowed_args[] = {
|
||||||
|
{ MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
|
||||||
|
};
|
||||||
|
|
||||||
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
|
mp_arg_parse_all(n_args - mode, pos_args + mode, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
|
mp_print_ext_t print_ext;
|
||||||
|
|
||||||
|
if (args[ARG_separators].u_obj == mp_const_none) {
|
||||||
|
print_ext.item_separator = ", ";
|
||||||
|
print_ext.key_separator = ": ";
|
||||||
|
} else {
|
||||||
|
mp_obj_t *items;
|
||||||
|
mp_obj_get_array_fixed_n(args[ARG_separators].u_obj, 2, &items);
|
||||||
|
print_ext.item_separator = mp_obj_str_get_str(items[0]);
|
||||||
|
print_ext.key_separator = mp_obj_str_get_str(items[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == DUMP_MODE_TO_STRING) {
|
||||||
|
// dumps(obj)
|
||||||
|
vstr_t vstr;
|
||||||
|
vstr_init_print(&vstr, 8, &print_ext.base);
|
||||||
|
mp_obj_print_helper(&print_ext.base, pos_args[0], PRINT_JSON);
|
||||||
|
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
||||||
|
} else {
|
||||||
|
// dump(obj, stream)
|
||||||
|
print_ext.base.data = MP_OBJ_TO_PTR(pos_args[1]);
|
||||||
|
print_ext.base.print_strn = mp_stream_write_adaptor;
|
||||||
|
mp_get_stream_raise(pos_args[1], MP_STREAM_OP_WRITE);
|
||||||
|
mp_obj_print_helper(&print_ext.base, pos_args[0], PRINT_JSON);
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC mp_obj_t mod_ujson_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
|
return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM);
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dump_obj, 2, mod_ujson_dump);
|
||||||
|
|
||||||
|
STATIC mp_obj_t mod_ujson_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
|
return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING);
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dumps_obj, 1, mod_ujson_dumps);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) {
|
STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) {
|
||||||
mp_get_stream_raise(stream, MP_STREAM_OP_WRITE);
|
mp_get_stream_raise(stream, MP_STREAM_OP_WRITE);
|
||||||
mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor};
|
mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor};
|
||||||
@ -33,6 +89,7 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) {
|
|||||||
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define JSON_DEBUG(...) (void)0
|
#define JSON_DEBUG(...) (void)0
|
||||||
// #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
|
// #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#define re1_5_stack_chk() MP_STACK_CHECK()
|
#define re1_5_stack_chk() MP_STACK_CHECK()
|
||||||
|
|
||||||
#include "re1.5/re1.5.h"
|
#include "lib/re1.5/re1.5.h"
|
||||||
|
|
||||||
#if MICROPY_PY_URE_DEBUG
|
#if MICROPY_PY_URE_DEBUG
|
||||||
#define FLAG_DEBUG 0x1000
|
#define FLAG_DEBUG 0x1000
|
||||||
@ -49,7 +49,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) {
|
|||||||
mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in);
|
mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_int_t no = mp_obj_get_int(no_in);
|
mp_int_t no = mp_obj_get_int(no_in);
|
||||||
if (no < 0 || no >= self->num_matches) {
|
if (no < 0 || no >= self->num_matches) {
|
||||||
mp_raise_arg1(&mp_type_IndexError, no_in);
|
mp_raise_type_arg(&mp_type_IndexError, no_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *start = self->caps[no * 2];
|
const char *start = self->caps[no * 2];
|
||||||
@ -88,7 +88,7 @@ STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span
|
|||||||
if (n_args == 2) {
|
if (n_args == 2) {
|
||||||
no = mp_obj_get_int(args[1]);
|
no = mp_obj_get_int(args[1]);
|
||||||
if (no < 0 || no >= self->num_matches) {
|
if (no < 0 || no >= self->num_matches) {
|
||||||
mp_raise_arg1(&mp_type_IndexError, args[1]);
|
mp_raise_type_arg(&mp_type_IndexError, args[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ STATIC mp_obj_t re_sub_helper(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match_no >= (unsigned int)match->num_matches) {
|
if (match_no >= (unsigned int)match->num_matches) {
|
||||||
mp_raise_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no));
|
mp_raise_type_arg(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *start_match = match->caps[match_no * 2];
|
const char *start_match = match->caps[match_no * 2];
|
||||||
@ -477,11 +477,11 @@ MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure, MICROPY_PY_URE);
|
|||||||
// only if module is enabled by config setting.
|
// only if module is enabled by config setting.
|
||||||
|
|
||||||
#define re1_5_fatal(x) assert(!x)
|
#define re1_5_fatal(x) assert(!x)
|
||||||
#include "re1.5/compilecode.c"
|
#include "lib/re1.5/compilecode.c"
|
||||||
#if MICROPY_PY_URE_DEBUG
|
#if MICROPY_PY_URE_DEBUG
|
||||||
#include "re1.5/dumpcode.c"
|
#include "lib/re1.5/dumpcode.c"
|
||||||
#endif
|
#endif
|
||||||
#include "re1.5/recursiveloop.c"
|
#include "lib/re1.5/recursiveloop.c"
|
||||||
#include "re1.5/charclass.c"
|
#include "lib/re1.5/charclass.c"
|
||||||
|
|
||||||
#endif // MICROPY_PY_URE
|
#endif // MICROPY_PY_URE
|
||||||
|
@ -87,6 +87,7 @@ STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) {
|
|||||||
return n_ready;
|
return n_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MICROPY_PY_USELECT_SELECT
|
||||||
// select(rlist, wlist, xlist[, timeout])
|
// select(rlist, wlist, xlist[, timeout])
|
||||||
STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
|
||||||
// get array data from tuple/list arguments
|
// get array data from tuple/list arguments
|
||||||
@ -153,6 +154,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select);
|
||||||
|
#endif // MICROPY_PY_USELECT_SELECT
|
||||||
|
|
||||||
typedef struct _mp_obj_poll_t {
|
typedef struct _mp_obj_poll_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
@ -335,7 +337,9 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll);
|
|||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = {
|
STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) },
|
||||||
|
#if MICROPY_PY_USELECT_SELECT
|
||||||
{ MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) },
|
||||||
|
#endif
|
||||||
{ MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) },
|
{ MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) },
|
{ MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) },
|
||||||
|
@ -55,8 +55,8 @@ STATIC bool time_less_than(struct qentry *item, struct qentry *parent) {
|
|||||||
return res && res < (MODULO / 2);
|
return res && res < (MODULO / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||||
mp_uint_t alloc = mp_obj_get_int(args[0]);
|
mp_uint_t alloc = mp_obj_get_int(args[0]);
|
||||||
mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc);
|
mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc);
|
||||||
o->base.type = type;
|
o->base.type = type;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#if MICROPY_PY_UZLIB
|
#if MICROPY_PY_UZLIB
|
||||||
|
|
||||||
#define UZLIB_CONF_PARANOID_CHECKS (1)
|
#define UZLIB_CONF_PARANOID_CHECKS (1)
|
||||||
#include "../lib/uzlib/src/tinf.h"
|
#include "lib/uzlib/tinf.h"
|
||||||
|
|
||||||
#if 0 // print debugging info
|
#if 0 // print debugging info
|
||||||
#define DEBUG_printf DEBUG_printf
|
#define DEBUG_printf DEBUG_printf
|
||||||
@ -48,8 +48,8 @@ STATIC int read_src_stream(TINF_DATA *data) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 1, 2, false);
|
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||||
mp_get_stream_raise(args[0], MP_STREAM_OP_READ);
|
mp_get_stream_raise(args[0], MP_STREAM_OP_READ);
|
||||||
mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t);
|
mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t);
|
||||||
o->base.type = type;
|
o->base.type = type;
|
||||||
@ -186,7 +186,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
|
|||||||
return res;
|
return res;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
mp_raise_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st));
|
mp_raise_type_arg(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st));
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress);
|
||||||
|
|
||||||
@ -209,10 +209,10 @@ const mp_obj_module_t mp_module_uzlib = {
|
|||||||
// only if module is enabled by config setting.
|
// only if module is enabled by config setting.
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
#include "../lib/uzlib/src/tinflate.c"
|
#include "lib/uzlib/tinflate.c"
|
||||||
#include "../lib/uzlib/src/tinfzlib.c"
|
#include "lib/uzlib/tinfzlib.c"
|
||||||
#include "../lib/uzlib/src/tinfgzip.c"
|
#include "lib/uzlib/tinfgzip.c"
|
||||||
#include "../lib/uzlib/src/adler32.c"
|
#include "lib/uzlib/adler32.c"
|
||||||
#include "../lib/uzlib/src/crc32.c"
|
#include "lib/uzlib/crc32.c"
|
||||||
|
|
||||||
#endif // MICROPY_PY_UZLIB
|
#endif // MICROPY_PY_UZLIB
|
||||||
|
@ -79,8 +79,8 @@ async def open_connection(host, port):
|
|||||||
from uerrno import EINPROGRESS
|
from uerrno import EINPROGRESS
|
||||||
import usocket as socket
|
import usocket as socket
|
||||||
|
|
||||||
ai = socket.getaddrinfo(host, port)[0] # TODO this is blocking!
|
ai = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0] # TODO this is blocking!
|
||||||
s = socket.socket()
|
s = socket.socket(ai[0], ai[1], ai[2])
|
||||||
s.setblocking(False)
|
s.setblocking(False)
|
||||||
ss = Stream(s)
|
ss = Stream(s)
|
||||||
try:
|
try:
|
||||||
@ -107,15 +107,7 @@ class Server:
|
|||||||
async def wait_closed(self):
|
async def wait_closed(self):
|
||||||
await self.task
|
await self.task
|
||||||
|
|
||||||
async def _serve(self, cb, host, port, backlog):
|
async def _serve(self, s, cb):
|
||||||
import usocket as socket
|
|
||||||
|
|
||||||
ai = socket.getaddrinfo(host, port)[0] # TODO this is blocking!
|
|
||||||
s = socket.socket()
|
|
||||||
s.setblocking(False)
|
|
||||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
||||||
s.bind(ai[-1])
|
|
||||||
s.listen(backlog)
|
|
||||||
# Accept incoming connections
|
# Accept incoming connections
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -137,9 +129,20 @@ class Server:
|
|||||||
# Helper function to start a TCP stream server, running as a new task
|
# Helper function to start a TCP stream server, running as a new task
|
||||||
# TODO could use an accept-callback on socket read activity instead of creating a task
|
# TODO could use an accept-callback on socket read activity instead of creating a task
|
||||||
async def start_server(cb, host, port, backlog=5):
|
async def start_server(cb, host, port, backlog=5):
|
||||||
s = Server()
|
import usocket as socket
|
||||||
s.task = core.create_task(s._serve(cb, host, port, backlog))
|
|
||||||
return s
|
# Create and bind server socket.
|
||||||
|
host = socket.getaddrinfo(host, port)[0] # TODO this is blocking!
|
||||||
|
s = socket.socket()
|
||||||
|
s.setblocking(False)
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
s.bind(host[-1])
|
||||||
|
s.listen(backlog)
|
||||||
|
|
||||||
|
# Create and return server object and task.
|
||||||
|
srv = Server()
|
||||||
|
srv.task = core.create_task(srv._serve(s, cb))
|
||||||
|
return srv
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8d93ddeaf3548d5466cee0a392a4ee89f07ce2e5
|
Subproject commit b913d064e525f674d0219524988e6d9d834fe09c
|
@ -27,7 +27,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
|
|||||||
|
|
||||||
STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
|
STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
|
||||||
mp_int_t ms = mp_obj_get_int(arg);
|
mp_int_t ms = mp_obj_get_int(arg);
|
||||||
if (ms > 0) {
|
if (ms >= 0) {
|
||||||
mp_hal_delay_ms(ms);
|
mp_hal_delay_ms(ms);
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
|
@ -150,7 +150,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
|
|||||||
#if MICROPY_VFS_LFS1
|
#if MICROPY_VFS_LFS1
|
||||||
if (memcmp(&buf[32], "littlefs", 8) == 0) {
|
if (memcmp(&buf[32], "littlefs", 8) == 0) {
|
||||||
// LFS1
|
// LFS1
|
||||||
mp_obj_t vfs = mp_type_vfs_lfs1.make_new(&mp_type_vfs_lfs1, 1, &bdev_obj, NULL);
|
mp_obj_t vfs = mp_type_vfs_lfs1.make_new(&mp_type_vfs_lfs1, 1, 0, &bdev_obj);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
return vfs;
|
return vfs;
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
|
|||||||
#if MICROPY_VFS_LFS2
|
#if MICROPY_VFS_LFS2
|
||||||
if (memcmp(&buf[0], "littlefs", 8) == 0) {
|
if (memcmp(&buf[0], "littlefs", 8) == 0) {
|
||||||
// LFS2
|
// LFS2
|
||||||
mp_obj_t vfs = mp_type_vfs_lfs2.make_new(&mp_type_vfs_lfs2, 1, &bdev_obj, NULL);
|
mp_obj_t vfs = mp_type_vfs_lfs2.make_new(&mp_type_vfs_lfs2, 1, 0, &bdev_obj);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
return vfs;
|
return vfs;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_VFS_FAT
|
#if MICROPY_VFS_FAT
|
||||||
return mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, &bdev_obj, NULL);
|
return mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &bdev_obj);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// no filesystem found
|
// no filesystem found
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "lib/oofatfs/ff.h"
|
#include "lib/oofatfs/ff.h"
|
||||||
#include "extmod/vfs_fat.h"
|
#include "extmod/vfs_fat.h"
|
||||||
#include "lib/timeutils/timeutils.h"
|
#include "shared/timeutils/timeutils.h"
|
||||||
#include "supervisor/filesystem.h"
|
#include "supervisor/filesystem.h"
|
||||||
#include "supervisor/shared/translate.h"
|
#include "supervisor/shared/translate.h"
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ STATIC mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) {
|
|||||||
return MP_IMPORT_STAT_NO_EXIST;
|
return MP_IMPORT_STAT_NO_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||||
|
|
||||||
// create new object
|
// create new object
|
||||||
fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t);
|
fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t);
|
||||||
@ -88,7 +88,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_del_obj, fat_vfs_del);
|
|||||||
|
|
||||||
STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
|
STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
|
||||||
// create new object
|
// create new object
|
||||||
fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, &bdev_in, NULL));
|
fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in));
|
||||||
|
|
||||||
// make the filesystem
|
// make the filesystem
|
||||||
uint8_t working_buf[FF_MAX_SS];
|
uint8_t working_buf[FF_MAX_SS];
|
||||||
|
@ -209,9 +209,9 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
|
|||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
|
mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
|
||||||
mp_arg_parse_all(n_args, args, kw_args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
|
mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
|
||||||
return file_open(NULL, type, arg_vals);
|
return file_open(NULL, type, arg_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#include "lib/timeutils/timeutils.h"
|
#include "shared/timeutils/timeutils.h"
|
||||||
#include "extmod/vfs.h"
|
#include "extmod/vfs.h"
|
||||||
#include "extmod/vfs_lfs.h"
|
#include "extmod/vfs_lfs.h"
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "py/objstr.h"
|
#include "py/objstr.h"
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "extmod/vfs.h"
|
#include "extmod/vfs.h"
|
||||||
#include "lib/timeutils/timeutils.h"
|
#include "shared/timeutils/timeutils.h"
|
||||||
|
|
||||||
STATIC int MP_VFS_LFSx(dev_ioctl)(const struct LFSx_API (config) * c, int cmd, int arg, bool must_return_int) {
|
STATIC int MP_VFS_LFSx(dev_ioctl)(const struct LFSx_API (config) * c, int cmd, int arg, bool must_return_int) {
|
||||||
mp_obj_t ret = mp_vfs_blockdev_ioctl(c->context, cmd, arg);
|
mp_obj_t ret = mp_vfs_blockdev_ioctl(c->context, cmd, arg);
|
||||||
@ -113,9 +113,9 @@ const char *MP_VFS_LFSx(make_path)(MP_OBJ_VFS_LFSx * self, mp_obj_t path_in) {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t MP_VFS_LFSx(make_new)(const mp_obj_type_t * type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
STATIC mp_obj_t MP_VFS_LFSx(make_new)(const mp_obj_type_t * type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(lfs_make_allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(lfs_make_allowed_args)];
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(lfs_make_allowed_args), lfs_make_allowed_args, args);
|
mp_arg_parse_all_kw_array(n_args, n_kw, pos_args, MP_ARRAY_SIZE(lfs_make_allowed_args), lfs_make_allowed_args, args);
|
||||||
|
|
||||||
MP_OBJ_VFS_LFSx *self = m_new0(MP_OBJ_VFS_LFSx, 1);
|
MP_OBJ_VFS_LFSx *self = m_new0(MP_OBJ_VFS_LFSx, 1);
|
||||||
self->base.type = type;
|
self->base.type = type;
|
||||||
|
@ -71,8 +71,8 @@ STATIC mp_import_stat_t mp_vfs_posix_import_stat(void *self_in, const char *path
|
|||||||
return MP_IMPORT_STAT_NO_EXIST;
|
return MP_IMPORT_STAT_NO_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||||
|
|
||||||
mp_obj_vfs_posix_t *vfs = m_new_obj(mp_obj_vfs_posix_t);
|
mp_obj_vfs_posix_t *vfs = m_new_obj(mp_obj_vfs_posix_t);
|
||||||
vfs->base.type = type;
|
vfs->base.type = type;
|
||||||
|
@ -89,14 +89,14 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
|
|||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
|
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
|
||||||
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
|
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
|
||||||
};
|
};
|
||||||
|
|
||||||
mp_arg_val_t arg_vals[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t arg_vals[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
|
mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
|
||||||
return mp_vfs_posix_file_open(type, arg_vals[0].u_obj, arg_vals[1].u_obj);
|
return mp_vfs_posix_file_open(type, arg_vals[0].u_obj, arg_vals[1].u_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
This directory contains standard, low-level C libraries with emphasis on
|
This directory contains third-party, low-level C libraries and SDKs.
|
||||||
being independent and efficient. They can be used by any port.
|
Libraries that do not target any specific platform are generally chosen
|
||||||
|
based on them being independent and efficient.
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 43a6e6bd3bbc03dc501e16b89fba0ef042ed3ea0
|
Subproject commit 531cab9c278c947d268bd4c94ecab9153a961b43
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
/*************************** HEADER FILES ***************************/
|
/*************************** HEADER FILES ***************************/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sha256.h"
|
#include "sha256.h"
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[])
|
|||||||
WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
||||||
|
|
||||||
for (i = 0, j = 0; i < 16; ++i, j += 4)
|
for (i = 0, j = 0; i < 16; ++i, j += 4)
|
||||||
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
|
m[i] = ((uint32_t)data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
|
||||||
for ( ; i < 64; ++i)
|
for ( ; i < 64; ++i)
|
||||||
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
|
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 27e4f4c15ba30c2cfc89575159e8efb50f95037e
|
|
78
lib/uzlib/adler32.c
Normal file
78
lib/uzlib/adler32.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Adler-32 checksum
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adler-32 algorithm taken from the zlib source, which is
|
||||||
|
* Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinf.h"
|
||||||
|
|
||||||
|
#define A32_BASE 65521
|
||||||
|
#define A32_NMAX 5552
|
||||||
|
|
||||||
|
uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum /* 1 */)
|
||||||
|
{
|
||||||
|
const unsigned char *buf = (const unsigned char *)data;
|
||||||
|
|
||||||
|
unsigned int s1 = prev_sum & 0xffff;
|
||||||
|
unsigned int s2 = prev_sum >> 16;
|
||||||
|
|
||||||
|
while (length > 0)
|
||||||
|
{
|
||||||
|
int k = length < A32_NMAX ? length : A32_NMAX;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = k / 16; i; --i, buf += 16)
|
||||||
|
{
|
||||||
|
s1 += buf[0]; s2 += s1; s1 += buf[1]; s2 += s1;
|
||||||
|
s1 += buf[2]; s2 += s1; s1 += buf[3]; s2 += s1;
|
||||||
|
s1 += buf[4]; s2 += s1; s1 += buf[5]; s2 += s1;
|
||||||
|
s1 += buf[6]; s2 += s1; s1 += buf[7]; s2 += s1;
|
||||||
|
|
||||||
|
s1 += buf[8]; s2 += s1; s1 += buf[9]; s2 += s1;
|
||||||
|
s1 += buf[10]; s2 += s1; s1 += buf[11]; s2 += s1;
|
||||||
|
s1 += buf[12]; s2 += s1; s1 += buf[13]; s2 += s1;
|
||||||
|
s1 += buf[14]; s2 += s1; s1 += buf[15]; s2 += s1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = k % 16; i; --i) { s1 += *buf++; s2 += s1; }
|
||||||
|
|
||||||
|
s1 %= A32_BASE;
|
||||||
|
s2 %= A32_BASE;
|
||||||
|
|
||||||
|
length -= k;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (s2 << 16) | s1;
|
||||||
|
}
|
63
lib/uzlib/crc32.c
Normal file
63
lib/uzlib/crc32.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* CRC32 checksum
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998-2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CRC32 algorithm taken from the zlib source, which is
|
||||||
|
* Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinf.h"
|
||||||
|
|
||||||
|
static const unsigned int tinf_crc32tab[16] = {
|
||||||
|
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190,
|
||||||
|
0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344,
|
||||||
|
0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278,
|
||||||
|
0xbdbdf21c
|
||||||
|
};
|
||||||
|
|
||||||
|
/* crc is previous value for incremental computation, 0xffffffff initially */
|
||||||
|
uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc)
|
||||||
|
{
|
||||||
|
const unsigned char *buf = (const unsigned char *)data;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < length; ++i)
|
||||||
|
{
|
||||||
|
crc ^= buf[i];
|
||||||
|
crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4);
|
||||||
|
crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return value suitable for passing in next time, for final value invert it
|
||||||
|
return crc/* ^ 0xffffffff*/;
|
||||||
|
}
|
45
lib/uzlib/defl_static.h
Normal file
45
lib/uzlib/defl_static.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) uzlib authors
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This files contains type declaration and prototypes for defl_static.c.
|
||||||
|
They may be altered/distinct from the originals used in PuTTY source
|
||||||
|
code. */
|
||||||
|
|
||||||
|
struct Outbuf {
|
||||||
|
unsigned char *outbuf;
|
||||||
|
int outlen, outsize;
|
||||||
|
unsigned long outbits;
|
||||||
|
int noutbits;
|
||||||
|
int comp_disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
void outbits(struct Outbuf *out, unsigned long bits, int nbits);
|
||||||
|
void zlib_start_block(struct Outbuf *ctx);
|
||||||
|
void zlib_finish_block(struct Outbuf *ctx);
|
||||||
|
void zlib_literal(struct Outbuf *ectx, unsigned char c);
|
||||||
|
void zlib_match(struct Outbuf *ectx, int distance, int len);
|
3
lib/uzlib/tinf.h
Normal file
3
lib/uzlib/tinf.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/* Compatibility header for the original tinf lib/older versions of uzlib.
|
||||||
|
Note: may be removed in the future, please migrate to uzlib.h. */
|
||||||
|
#include "uzlib.h"
|
9
lib/uzlib/tinf_compat.h
Normal file
9
lib/uzlib/tinf_compat.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/* This header contains compatibility defines for the original tinf API
|
||||||
|
and uzlib 2.x and below API. These defines are deprecated and going
|
||||||
|
to be removed in the future, so applications should migrate to new
|
||||||
|
uzlib API. */
|
||||||
|
#define TINF_DATA struct uzlib_uncomp
|
||||||
|
|
||||||
|
#define destSize dest_size
|
||||||
|
#define destStart dest_start
|
||||||
|
#define readSource source_read_cb
|
110
lib/uzlib/tinfgzip.c
Normal file
110
lib/uzlib/tinfgzip.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 by Paul Sokolovsky
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinf.h"
|
||||||
|
|
||||||
|
#define FTEXT 1
|
||||||
|
#define FHCRC 2
|
||||||
|
#define FEXTRA 4
|
||||||
|
#define FNAME 8
|
||||||
|
#define FCOMMENT 16
|
||||||
|
|
||||||
|
void tinf_skip_bytes(TINF_DATA *d, int num);
|
||||||
|
uint16_t tinf_get_uint16(TINF_DATA *d);
|
||||||
|
|
||||||
|
void tinf_skip_bytes(TINF_DATA *d, int num)
|
||||||
|
{
|
||||||
|
while (num--) uzlib_get_byte(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t tinf_get_uint16(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
unsigned int v = uzlib_get_byte(d);
|
||||||
|
v = (uzlib_get_byte(d) << 8) | v;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int uzlib_gzip_parse_header(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
unsigned char flg;
|
||||||
|
|
||||||
|
/* -- check format -- */
|
||||||
|
|
||||||
|
/* check id bytes */
|
||||||
|
if (uzlib_get_byte(d) != 0x1f || uzlib_get_byte(d) != 0x8b) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* check method is deflate */
|
||||||
|
if (uzlib_get_byte(d) != 8) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* get flag byte */
|
||||||
|
flg = uzlib_get_byte(d);
|
||||||
|
|
||||||
|
/* check that reserved bits are zero */
|
||||||
|
if (flg & 0xe0) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* -- find start of compressed data -- */
|
||||||
|
|
||||||
|
/* skip rest of base header of 10 bytes */
|
||||||
|
tinf_skip_bytes(d, 6);
|
||||||
|
|
||||||
|
/* skip extra data if present */
|
||||||
|
if (flg & FEXTRA)
|
||||||
|
{
|
||||||
|
unsigned int xlen = tinf_get_uint16(d);
|
||||||
|
tinf_skip_bytes(d, xlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* skip file name if present */
|
||||||
|
if (flg & FNAME) { while (uzlib_get_byte(d)); }
|
||||||
|
|
||||||
|
/* skip file comment if present */
|
||||||
|
if (flg & FCOMMENT) { while (uzlib_get_byte(d)); }
|
||||||
|
|
||||||
|
/* check header crc if present */
|
||||||
|
if (flg & FHCRC)
|
||||||
|
{
|
||||||
|
/*unsigned int hcrc =*/ tinf_get_uint16(d);
|
||||||
|
|
||||||
|
// TODO: Check!
|
||||||
|
// if (hcrc != (tinf_crc32(src, start - src) & 0x0000ffff))
|
||||||
|
// return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize for crc32 checksum */
|
||||||
|
d->checksum_type = TINF_CHKSUM_CRC;
|
||||||
|
d->checksum = ~0;
|
||||||
|
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
659
lib/uzlib/tinflate.c
Normal file
659
lib/uzlib/tinflate.c
Normal file
@ -0,0 +1,659 @@
|
|||||||
|
/*
|
||||||
|
* uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 by Paul Sokolovsky
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include "tinf.h"
|
||||||
|
|
||||||
|
#define UZLIB_DUMP_ARRAY(heading, arr, size) \
|
||||||
|
{ \
|
||||||
|
printf("%s", heading); \
|
||||||
|
for (int i = 0; i < size; ++i) { \
|
||||||
|
printf(" %d", (arr)[i]); \
|
||||||
|
} \
|
||||||
|
printf("\n"); \
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tinf_get_le_uint32(TINF_DATA *d);
|
||||||
|
uint32_t tinf_get_be_uint32(TINF_DATA *d);
|
||||||
|
|
||||||
|
/* --------------------------------------------------- *
|
||||||
|
* -- uninitialized global data (static structures) -- *
|
||||||
|
* --------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef RUNTIME_BITS_TABLES
|
||||||
|
|
||||||
|
/* extra bits and base tables for length codes */
|
||||||
|
unsigned char length_bits[30];
|
||||||
|
unsigned short length_base[30];
|
||||||
|
|
||||||
|
/* extra bits and base tables for distance codes */
|
||||||
|
unsigned char dist_bits[30];
|
||||||
|
unsigned short dist_base[30];
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
const unsigned char length_bits[30] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 1, 2, 2, 2, 2,
|
||||||
|
3, 3, 3, 3, 4, 4, 4, 4,
|
||||||
|
5, 5, 5, 5
|
||||||
|
};
|
||||||
|
const unsigned short length_base[30] = {
|
||||||
|
3, 4, 5, 6, 7, 8, 9, 10,
|
||||||
|
11, 13, 15, 17, 19, 23, 27, 31,
|
||||||
|
35, 43, 51, 59, 67, 83, 99, 115,
|
||||||
|
131, 163, 195, 227, 258
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char dist_bits[30] = {
|
||||||
|
0, 0, 0, 0, 1, 1, 2, 2,
|
||||||
|
3, 3, 4, 4, 5, 5, 6, 6,
|
||||||
|
7, 7, 8, 8, 9, 9, 10, 10,
|
||||||
|
11, 11, 12, 12, 13, 13
|
||||||
|
};
|
||||||
|
const unsigned short dist_base[30] = {
|
||||||
|
1, 2, 3, 4, 5, 7, 9, 13,
|
||||||
|
17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
|
257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
||||||
|
4097, 6145, 8193, 12289, 16385, 24577
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* special ordering of code length codes */
|
||||||
|
const unsigned char clcidx[] = {
|
||||||
|
16, 17, 18, 0, 8, 7, 9, 6,
|
||||||
|
10, 5, 11, 4, 12, 3, 13, 2,
|
||||||
|
14, 1, 15
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ----------------------- *
|
||||||
|
* -- utility functions -- *
|
||||||
|
* ----------------------- */
|
||||||
|
|
||||||
|
#ifdef RUNTIME_BITS_TABLES
|
||||||
|
/* build extra bits and base tables */
|
||||||
|
static void tinf_build_bits_base(unsigned char *bits, unsigned short *base, int delta, int first)
|
||||||
|
{
|
||||||
|
int i, sum;
|
||||||
|
|
||||||
|
/* build bits table */
|
||||||
|
for (i = 0; i < delta; ++i) bits[i] = 0;
|
||||||
|
for (i = 0; i < 30 - delta; ++i) bits[i + delta] = i / delta;
|
||||||
|
|
||||||
|
/* build base table */
|
||||||
|
for (sum = first, i = 0; i < 30; ++i)
|
||||||
|
{
|
||||||
|
base[i] = sum;
|
||||||
|
sum += 1 << bits[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* build the fixed huffman trees */
|
||||||
|
static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* build fixed length tree */
|
||||||
|
for (i = 0; i < 7; ++i) lt->table[i] = 0;
|
||||||
|
|
||||||
|
lt->table[7] = 24;
|
||||||
|
lt->table[8] = 152;
|
||||||
|
lt->table[9] = 112;
|
||||||
|
|
||||||
|
for (i = 0; i < 24; ++i) lt->trans[i] = 256 + i;
|
||||||
|
for (i = 0; i < 144; ++i) lt->trans[24 + i] = i;
|
||||||
|
for (i = 0; i < 8; ++i) lt->trans[24 + 144 + i] = 280 + i;
|
||||||
|
for (i = 0; i < 112; ++i) lt->trans[24 + 144 + 8 + i] = 144 + i;
|
||||||
|
|
||||||
|
/* build fixed distance tree */
|
||||||
|
for (i = 0; i < 5; ++i) dt->table[i] = 0;
|
||||||
|
|
||||||
|
dt->table[5] = 32;
|
||||||
|
|
||||||
|
for (i = 0; i < 32; ++i) dt->trans[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* given an array of code lengths, build a tree */
|
||||||
|
static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, unsigned int num)
|
||||||
|
{
|
||||||
|
unsigned short offs[16];
|
||||||
|
unsigned int i, sum;
|
||||||
|
|
||||||
|
/* clear code length count table */
|
||||||
|
for (i = 0; i < 16; ++i) t->table[i] = 0;
|
||||||
|
|
||||||
|
/* scan symbol lengths, and sum code length counts */
|
||||||
|
for (i = 0; i < num; ++i) t->table[lengths[i]]++;
|
||||||
|
|
||||||
|
#if UZLIB_CONF_DEBUG_LOG >= 2
|
||||||
|
UZLIB_DUMP_ARRAY("codelen counts:", t->table, TINF_ARRAY_SIZE(t->table));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In the lengths array, 0 means unused code. So, t->table[0] now contains
|
||||||
|
number of unused codes. But table's purpose is to contain # of codes of
|
||||||
|
particular length, and there're 0 codes of length 0. */
|
||||||
|
t->table[0] = 0;
|
||||||
|
|
||||||
|
/* compute offset table for distribution sort */
|
||||||
|
for (sum = 0, i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
|
offs[i] = sum;
|
||||||
|
sum += t->table[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UZLIB_CONF_DEBUG_LOG >= 2
|
||||||
|
UZLIB_DUMP_ARRAY("codelen offsets:", offs, TINF_ARRAY_SIZE(offs));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* create code->symbol translation table (symbols sorted by code) */
|
||||||
|
for (i = 0; i < num; ++i)
|
||||||
|
{
|
||||||
|
if (lengths[i]) t->trans[offs[lengths[i]]++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------- *
|
||||||
|
* -- decode functions -- *
|
||||||
|
* ---------------------- */
|
||||||
|
|
||||||
|
unsigned char uzlib_get_byte(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
/* If end of source buffer is not reached, return next byte from source
|
||||||
|
buffer. */
|
||||||
|
if (d->source < d->source_limit) {
|
||||||
|
return *d->source++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise if there's callback and we haven't seen EOF yet, try to
|
||||||
|
read next byte using it. (Note: the callback can also update ->source
|
||||||
|
and ->source_limit). */
|
||||||
|
if (d->readSource && !d->eof) {
|
||||||
|
int val = d->readSource(d);
|
||||||
|
if (val >= 0) {
|
||||||
|
return (unsigned char)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, we hit EOF (either from ->readSource() or from exhaustion
|
||||||
|
of the buffer), and it will be "sticky", i.e. further calls to this
|
||||||
|
function will end up here too. */
|
||||||
|
d->eof = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tinf_get_le_uint32(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
uint32_t val = 0;
|
||||||
|
int i;
|
||||||
|
for (i = 4; i--;) {
|
||||||
|
val = val >> 8 | ((uint32_t)uzlib_get_byte(d)) << 24;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tinf_get_be_uint32(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
uint32_t val = 0;
|
||||||
|
int i;
|
||||||
|
for (i = 4; i--;) {
|
||||||
|
val = val << 8 | uzlib_get_byte(d);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get one bit from source stream */
|
||||||
|
static int tinf_getbit(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
unsigned int bit;
|
||||||
|
|
||||||
|
/* check if tag is empty */
|
||||||
|
if (!d->bitcount--)
|
||||||
|
{
|
||||||
|
/* load next tag */
|
||||||
|
d->tag = uzlib_get_byte(d);
|
||||||
|
d->bitcount = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* shift bit out of tag */
|
||||||
|
bit = d->tag & 0x01;
|
||||||
|
d->tag >>= 1;
|
||||||
|
|
||||||
|
return bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read a num bit value from a stream and add base */
|
||||||
|
static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base)
|
||||||
|
{
|
||||||
|
unsigned int val = 0;
|
||||||
|
|
||||||
|
/* read num bits */
|
||||||
|
if (num)
|
||||||
|
{
|
||||||
|
unsigned int limit = 1 << (num);
|
||||||
|
unsigned int mask;
|
||||||
|
|
||||||
|
for (mask = 1; mask < limit; mask *= 2)
|
||||||
|
if (tinf_getbit(d)) val += mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val + base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* given a data stream and a tree, decode a symbol */
|
||||||
|
static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t)
|
||||||
|
{
|
||||||
|
int sum = 0, cur = 0, len = 0;
|
||||||
|
|
||||||
|
/* get more bits while code value is above sum */
|
||||||
|
do {
|
||||||
|
|
||||||
|
cur = 2*cur + tinf_getbit(d);
|
||||||
|
|
||||||
|
if (++len == TINF_ARRAY_SIZE(t->table)) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
sum += t->table[len];
|
||||||
|
cur -= t->table[len];
|
||||||
|
|
||||||
|
} while (cur >= 0);
|
||||||
|
|
||||||
|
sum += cur;
|
||||||
|
#if UZLIB_CONF_PARANOID_CHECKS
|
||||||
|
if (sum < 0 || sum >= TINF_ARRAY_SIZE(t->trans)) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return t->trans[sum];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* given a data stream, decode dynamic trees from it */
|
||||||
|
static int tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
|
||||||
|
{
|
||||||
|
/* code lengths for 288 literal/len symbols and 32 dist symbols */
|
||||||
|
unsigned char lengths[288+32];
|
||||||
|
unsigned int hlit, hdist, hclen, hlimit;
|
||||||
|
unsigned int i, num, length;
|
||||||
|
|
||||||
|
/* get 5 bits HLIT (257-286) */
|
||||||
|
hlit = tinf_read_bits(d, 5, 257);
|
||||||
|
|
||||||
|
/* get 5 bits HDIST (1-32) */
|
||||||
|
hdist = tinf_read_bits(d, 5, 1);
|
||||||
|
|
||||||
|
/* get 4 bits HCLEN (4-19) */
|
||||||
|
hclen = tinf_read_bits(d, 4, 4);
|
||||||
|
|
||||||
|
for (i = 0; i < 19; ++i) lengths[i] = 0;
|
||||||
|
|
||||||
|
/* read code lengths for code length alphabet */
|
||||||
|
for (i = 0; i < hclen; ++i)
|
||||||
|
{
|
||||||
|
/* get 3 bits code length (0-7) */
|
||||||
|
unsigned int clen = tinf_read_bits(d, 3, 0);
|
||||||
|
|
||||||
|
lengths[clcidx[i]] = clen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build code length tree, temporarily use length tree */
|
||||||
|
tinf_build_tree(lt, lengths, 19);
|
||||||
|
|
||||||
|
/* decode code lengths for the dynamic trees */
|
||||||
|
hlimit = hlit + hdist;
|
||||||
|
for (num = 0; num < hlimit; )
|
||||||
|
{
|
||||||
|
int sym = tinf_decode_symbol(d, lt);
|
||||||
|
unsigned char fill_value = 0;
|
||||||
|
int lbits, lbase = 3;
|
||||||
|
|
||||||
|
/* error decoding */
|
||||||
|
if (sym < 0) return sym;
|
||||||
|
|
||||||
|
switch (sym)
|
||||||
|
{
|
||||||
|
case 16:
|
||||||
|
/* copy previous code length 3-6 times (read 2 bits) */
|
||||||
|
if (num == 0) return TINF_DATA_ERROR;
|
||||||
|
fill_value = lengths[num - 1];
|
||||||
|
lbits = 2;
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
/* repeat code length 0 for 3-10 times (read 3 bits) */
|
||||||
|
lbits = 3;
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
/* repeat code length 0 for 11-138 times (read 7 bits) */
|
||||||
|
lbits = 7;
|
||||||
|
lbase = 11;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* values 0-15 represent the actual code lengths */
|
||||||
|
lengths[num++] = sym;
|
||||||
|
/* continue the for loop */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* special code length 16-18 are handled here */
|
||||||
|
length = tinf_read_bits(d, lbits, lbase);
|
||||||
|
if (num + length > hlimit) return TINF_DATA_ERROR;
|
||||||
|
for (; length; --length)
|
||||||
|
{
|
||||||
|
lengths[num++] = fill_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UZLIB_CONF_DEBUG_LOG >= 2
|
||||||
|
printf("lit code lengths (%d):", hlit);
|
||||||
|
UZLIB_DUMP_ARRAY("", lengths, hlit);
|
||||||
|
printf("dist code lengths (%d):", hdist);
|
||||||
|
UZLIB_DUMP_ARRAY("", lengths + hlit, hdist);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UZLIB_CONF_PARANOID_CHECKS
|
||||||
|
/* Check that there's "end of block" symbol */
|
||||||
|
if (lengths[256] == 0) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* build dynamic trees */
|
||||||
|
tinf_build_tree(lt, lengths, hlit);
|
||||||
|
tinf_build_tree(dt, lengths + hlit, hdist);
|
||||||
|
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------- *
|
||||||
|
* -- block inflate functions -- *
|
||||||
|
* ----------------------------- */
|
||||||
|
|
||||||
|
/* given a stream and two trees, inflate next byte of output */
|
||||||
|
static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
|
||||||
|
{
|
||||||
|
if (d->curlen == 0) {
|
||||||
|
unsigned int offs;
|
||||||
|
int dist;
|
||||||
|
int sym = tinf_decode_symbol(d, lt);
|
||||||
|
//printf("huff sym: %02x\n", sym);
|
||||||
|
|
||||||
|
if (d->eof) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* literal byte */
|
||||||
|
if (sym < 256) {
|
||||||
|
TINF_PUT(d, sym);
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end of block */
|
||||||
|
if (sym == 256) {
|
||||||
|
return TINF_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* substring from sliding dictionary */
|
||||||
|
sym -= 257;
|
||||||
|
if (sym >= 29) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* possibly get more bits from length code */
|
||||||
|
d->curlen = tinf_read_bits(d, length_bits[sym], length_base[sym]);
|
||||||
|
|
||||||
|
dist = tinf_decode_symbol(d, dt);
|
||||||
|
if (dist >= 30) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* possibly get more bits from distance code */
|
||||||
|
offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]);
|
||||||
|
|
||||||
|
/* calculate and validate actual LZ offset to use */
|
||||||
|
if (d->dict_ring) {
|
||||||
|
if (offs > d->dict_size) {
|
||||||
|
return TINF_DICT_ERROR;
|
||||||
|
}
|
||||||
|
/* Note: unlike full-dest-in-memory case below, we don't
|
||||||
|
try to catch offset which points to not yet filled
|
||||||
|
part of the dictionary here. Doing so would require
|
||||||
|
keeping another variable to track "filled in" size
|
||||||
|
of the dictionary. Appearance of such an offset cannot
|
||||||
|
lead to accessing memory outside of the dictionary
|
||||||
|
buffer, and clients which don't want to leak unrelated
|
||||||
|
information, should explicitly initialize dictionary
|
||||||
|
buffer passed to uzlib. */
|
||||||
|
|
||||||
|
d->lzOff = d->dict_idx - offs;
|
||||||
|
if (d->lzOff < 0) {
|
||||||
|
d->lzOff += d->dict_size;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* catch trying to point before the start of dest buffer */
|
||||||
|
if (offs > (unsigned int)(d->dest - d->destStart)) {
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
d->lzOff = -offs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy next byte from dict substring */
|
||||||
|
if (d->dict_ring) {
|
||||||
|
TINF_PUT(d, d->dict_ring[d->lzOff]);
|
||||||
|
if ((unsigned)++d->lzOff == d->dict_size) {
|
||||||
|
d->lzOff = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
d->dest[0] = d->dest[d->lzOff];
|
||||||
|
d->dest++;
|
||||||
|
}
|
||||||
|
d->curlen--;
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inflate next byte from uncompressed block of data */
|
||||||
|
static int tinf_inflate_uncompressed_block(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
if (d->curlen == 0) {
|
||||||
|
unsigned int length, invlength;
|
||||||
|
|
||||||
|
/* get length */
|
||||||
|
length = uzlib_get_byte(d);
|
||||||
|
length += 256 * uzlib_get_byte(d);
|
||||||
|
/* get one's complement of length */
|
||||||
|
invlength = uzlib_get_byte(d);
|
||||||
|
invlength += 256 * uzlib_get_byte(d);
|
||||||
|
/* check length */
|
||||||
|
if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* increment length to properly return TINF_DONE below, without
|
||||||
|
producing data at the same time */
|
||||||
|
d->curlen = length + 1;
|
||||||
|
|
||||||
|
/* make sure we start next block on a byte boundary */
|
||||||
|
d->bitcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--d->curlen == 0) {
|
||||||
|
return TINF_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char c = uzlib_get_byte(d);
|
||||||
|
TINF_PUT(d, c);
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------- *
|
||||||
|
* -- public functions -- *
|
||||||
|
* ---------------------- */
|
||||||
|
|
||||||
|
/* initialize global (static) data */
|
||||||
|
void uzlib_init(void)
|
||||||
|
{
|
||||||
|
#ifdef RUNTIME_BITS_TABLES
|
||||||
|
/* build extra bits and base tables */
|
||||||
|
tinf_build_bits_base(length_bits, length_base, 4, 3);
|
||||||
|
tinf_build_bits_base(dist_bits, dist_base, 2, 1);
|
||||||
|
|
||||||
|
/* fix a special case */
|
||||||
|
length_bits[28] = 0;
|
||||||
|
length_base[28] = 258;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize decompression structure */
|
||||||
|
void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen)
|
||||||
|
{
|
||||||
|
d->eof = 0;
|
||||||
|
d->bitcount = 0;
|
||||||
|
d->bfinal = 0;
|
||||||
|
d->btype = -1;
|
||||||
|
d->dict_size = dictLen;
|
||||||
|
d->dict_ring = dict;
|
||||||
|
d->dict_idx = 0;
|
||||||
|
d->curlen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inflate next output bytes from compressed stream */
|
||||||
|
int uzlib_uncompress(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
int res;
|
||||||
|
|
||||||
|
/* start a new block */
|
||||||
|
if (d->btype == -1) {
|
||||||
|
next_blk:
|
||||||
|
/* read final block flag */
|
||||||
|
d->bfinal = tinf_getbit(d);
|
||||||
|
/* read block type (2 bits) */
|
||||||
|
d->btype = tinf_read_bits(d, 2, 0);
|
||||||
|
|
||||||
|
#if UZLIB_CONF_DEBUG_LOG >= 1
|
||||||
|
printf("Started new block: type=%d final=%d\n", d->btype, d->bfinal);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (d->btype == 1) {
|
||||||
|
/* build fixed huffman trees */
|
||||||
|
tinf_build_fixed_trees(&d->ltree, &d->dtree);
|
||||||
|
} else if (d->btype == 2) {
|
||||||
|
/* decode trees from stream */
|
||||||
|
res = tinf_decode_trees(d, &d->ltree, &d->dtree);
|
||||||
|
if (res != TINF_OK) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* process current block */
|
||||||
|
switch (d->btype)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
/* decompress uncompressed block */
|
||||||
|
res = tinf_inflate_uncompressed_block(d);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
/* decompress block with fixed/dynamic huffman trees */
|
||||||
|
/* trees were decoded previously, so it's the same routine for both */
|
||||||
|
res = tinf_inflate_block_data(d, &d->ltree, &d->dtree);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return TINF_DATA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == TINF_DONE && !d->bfinal) {
|
||||||
|
/* the block has ended (without producing more data), but we
|
||||||
|
can't return without data, so start procesing next block */
|
||||||
|
goto next_blk;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res != TINF_OK) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (d->dest < d->dest_limit);
|
||||||
|
|
||||||
|
return TINF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inflate next output bytes from compressed stream, updating
|
||||||
|
checksum, and at the end of stream, verify it */
|
||||||
|
int uzlib_uncompress_chksum(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
unsigned char *data = d->dest;
|
||||||
|
|
||||||
|
res = uzlib_uncompress(d);
|
||||||
|
|
||||||
|
if (res < 0) return res;
|
||||||
|
|
||||||
|
switch (d->checksum_type) {
|
||||||
|
|
||||||
|
case TINF_CHKSUM_ADLER:
|
||||||
|
d->checksum = uzlib_adler32(data, d->dest - data, d->checksum);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TINF_CHKSUM_CRC:
|
||||||
|
d->checksum = uzlib_crc32(data, d->dest - data, d->checksum);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == TINF_DONE) {
|
||||||
|
unsigned int val;
|
||||||
|
|
||||||
|
switch (d->checksum_type) {
|
||||||
|
|
||||||
|
case TINF_CHKSUM_ADLER:
|
||||||
|
val = tinf_get_be_uint32(d);
|
||||||
|
if (d->checksum != val) {
|
||||||
|
return TINF_CHKSUM_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TINF_CHKSUM_CRC:
|
||||||
|
val = tinf_get_le_uint32(d);
|
||||||
|
if (~d->checksum != val) {
|
||||||
|
return TINF_CHKSUM_ERROR;
|
||||||
|
}
|
||||||
|
// Uncompressed size. TODO: Check
|
||||||
|
val = tinf_get_le_uint32(d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
66
lib/uzlib/tinfzlib.c
Normal file
66
lib/uzlib/tinfzlib.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 by Paul Sokolovsky
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinf.h"
|
||||||
|
|
||||||
|
int uzlib_zlib_parse_header(TINF_DATA *d)
|
||||||
|
{
|
||||||
|
unsigned char cmf, flg;
|
||||||
|
|
||||||
|
/* -- get header bytes -- */
|
||||||
|
|
||||||
|
cmf = uzlib_get_byte(d);
|
||||||
|
flg = uzlib_get_byte(d);
|
||||||
|
|
||||||
|
/* -- check format -- */
|
||||||
|
|
||||||
|
/* check checksum */
|
||||||
|
if ((256*cmf + flg) % 31) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* check method is deflate */
|
||||||
|
if ((cmf & 0x0f) != 8) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* check window size is valid */
|
||||||
|
if ((cmf >> 4) > 7) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* check there is no preset dictionary */
|
||||||
|
if (flg & 0x20) return TINF_DATA_ERROR;
|
||||||
|
|
||||||
|
/* initialize for adler32 checksum */
|
||||||
|
d->checksum_type = TINF_CHKSUM_ADLER;
|
||||||
|
d->checksum = 1;
|
||||||
|
|
||||||
|
return cmf >> 4;
|
||||||
|
}
|
169
lib/uzlib/uzlib.h
Normal file
169
lib/uzlib/uzlib.h
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
/*
|
||||||
|
* uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 by Joergen Ibsen / Jibz
|
||||||
|
* All Rights Reserved
|
||||||
|
* http://www.ibsensoftware.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 by Paul Sokolovsky
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express
|
||||||
|
* or implied warranty. In no event will the authors be
|
||||||
|
* held liable for any damages arising from the use of
|
||||||
|
* this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software
|
||||||
|
* for any purpose, including commercial applications,
|
||||||
|
* and to alter it and redistribute it freely, subject to
|
||||||
|
* the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be
|
||||||
|
* misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this
|
||||||
|
* software in a product, an acknowledgment in
|
||||||
|
* the product documentation would be appreciated
|
||||||
|
* but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked
|
||||||
|
* as such, and must not be misrepresented as
|
||||||
|
* being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from
|
||||||
|
* any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UZLIB_H_INCLUDED
|
||||||
|
#define UZLIB_H_INCLUDED
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "defl_static.h"
|
||||||
|
|
||||||
|
#include "uzlib_conf.h"
|
||||||
|
#if UZLIB_CONF_DEBUG_LOG
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calling convention */
|
||||||
|
#ifndef TINFCC
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
#define TINFCC __cdecl
|
||||||
|
#else
|
||||||
|
#define TINFCC
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ok status, more data produced */
|
||||||
|
#define TINF_OK 0
|
||||||
|
/* end of compressed stream reached */
|
||||||
|
#define TINF_DONE 1
|
||||||
|
#define TINF_DATA_ERROR (-3)
|
||||||
|
#define TINF_CHKSUM_ERROR (-4)
|
||||||
|
#define TINF_DICT_ERROR (-5)
|
||||||
|
|
||||||
|
/* checksum types */
|
||||||
|
#define TINF_CHKSUM_NONE 0
|
||||||
|
#define TINF_CHKSUM_ADLER 1
|
||||||
|
#define TINF_CHKSUM_CRC 2
|
||||||
|
|
||||||
|
/* helper macros */
|
||||||
|
#define TINF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
|
||||||
|
|
||||||
|
/* data structures */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned short table[16]; /* table of code length counts */
|
||||||
|
unsigned short trans[288]; /* code -> symbol translation table */
|
||||||
|
} TINF_TREE;
|
||||||
|
|
||||||
|
struct uzlib_uncomp {
|
||||||
|
/* Pointer to the next byte in the input buffer */
|
||||||
|
const unsigned char *source;
|
||||||
|
/* Pointer to the next byte past the input buffer (source_limit = source + len) */
|
||||||
|
const unsigned char *source_limit;
|
||||||
|
/* If source_limit == NULL, or source >= source_limit, this function
|
||||||
|
will be used to read next byte from source stream. The function may
|
||||||
|
also return -1 in case of EOF (or irrecoverable error). Note that
|
||||||
|
besides returning the next byte, it may also update source and
|
||||||
|
source_limit fields, thus allowing for buffered operation. */
|
||||||
|
int (*source_read_cb)(struct uzlib_uncomp *uncomp);
|
||||||
|
|
||||||
|
unsigned int tag;
|
||||||
|
unsigned int bitcount;
|
||||||
|
|
||||||
|
/* Destination (output) buffer start */
|
||||||
|
unsigned char *dest_start;
|
||||||
|
/* Current pointer in dest buffer */
|
||||||
|
unsigned char *dest;
|
||||||
|
/* Pointer past the end of the dest buffer, similar to source_limit */
|
||||||
|
unsigned char *dest_limit;
|
||||||
|
|
||||||
|
/* Accumulating checksum */
|
||||||
|
unsigned int checksum;
|
||||||
|
char checksum_type;
|
||||||
|
bool eof;
|
||||||
|
|
||||||
|
int btype;
|
||||||
|
int bfinal;
|
||||||
|
unsigned int curlen;
|
||||||
|
int lzOff;
|
||||||
|
unsigned char *dict_ring;
|
||||||
|
unsigned int dict_size;
|
||||||
|
unsigned int dict_idx;
|
||||||
|
|
||||||
|
TINF_TREE ltree; /* dynamic length/symbol tree */
|
||||||
|
TINF_TREE dtree; /* dynamic distance tree */
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "tinf_compat.h"
|
||||||
|
|
||||||
|
#define TINF_PUT(d, c) \
|
||||||
|
{ \
|
||||||
|
*d->dest++ = c; \
|
||||||
|
if (d->dict_ring) { d->dict_ring[d->dict_idx++] = c; if (d->dict_idx == d->dict_size) d->dict_idx = 0; } \
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char TINFCC uzlib_get_byte(TINF_DATA *d);
|
||||||
|
|
||||||
|
/* Decompression API */
|
||||||
|
|
||||||
|
void TINFCC uzlib_init(void);
|
||||||
|
void TINFCC uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen);
|
||||||
|
int TINFCC uzlib_uncompress(TINF_DATA *d);
|
||||||
|
int TINFCC uzlib_uncompress_chksum(TINF_DATA *d);
|
||||||
|
|
||||||
|
int TINFCC uzlib_zlib_parse_header(TINF_DATA *d);
|
||||||
|
int TINFCC uzlib_gzip_parse_header(TINF_DATA *d);
|
||||||
|
|
||||||
|
/* Compression API */
|
||||||
|
|
||||||
|
typedef const uint8_t *uzlib_hash_entry_t;
|
||||||
|
|
||||||
|
struct uzlib_comp {
|
||||||
|
struct Outbuf out;
|
||||||
|
|
||||||
|
uzlib_hash_entry_t *hash_table;
|
||||||
|
unsigned int hash_bits;
|
||||||
|
unsigned int dict_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
void TINFCC uzlib_compress(struct uzlib_comp *c, const uint8_t *src, unsigned slen);
|
||||||
|
|
||||||
|
/* Checksum API */
|
||||||
|
|
||||||
|
/* prev_sum is previous value for incremental computation, 1 initially */
|
||||||
|
uint32_t TINFCC uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum);
|
||||||
|
/* crc is previous value for incremental computation, 0xffffffff initially */
|
||||||
|
uint32_t TINFCC uzlib_crc32(const void *data, unsigned int length, uint32_t crc);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* UZLIB_H_INCLUDED */
|
22
lib/uzlib/uzlib_conf.h
Normal file
22
lib/uzlib/uzlib_conf.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 by Paul Sokolovsky
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UZLIB_CONF_H_INCLUDED
|
||||||
|
#define UZLIB_CONF_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef UZLIB_CONF_DEBUG_LOG
|
||||||
|
/* Debug logging level 0, 1, 2, etc. */
|
||||||
|
#define UZLIB_CONF_DEBUG_LOG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UZLIB_CONF_PARANOID_CHECKS
|
||||||
|
/* Perform extra checks on the input stream, even if they aren't proven
|
||||||
|
to be strictly required (== lack of them wasn't proven to lead to
|
||||||
|
crashes). */
|
||||||
|
#define UZLIB_CONF_PARANOID_CHECKS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* UZLIB_CONF_H_INCLUDED */
|
@ -4113,7 +4113,7 @@ msgstr "nilai sampling keluar dari jangkauan"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "kompilasi script tidak didukung"
|
msgstr "kompilasi script tidak didukung"
|
||||||
|
|
||||||
|
@ -2520,10 +2520,6 @@ msgstr ""
|
|||||||
msgid "a bytes-like object is required"
|
msgid "a bytes-like object is required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/embed/abort_.c
|
|
||||||
msgid "abort() called"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: shared-bindings/i2cperipheral/I2CPeripheral.c
|
#: shared-bindings/i2cperipheral/I2CPeripheral.c
|
||||||
msgid "address out of bounds"
|
msgid "address out of bounds"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -3104,26 +3100,6 @@ msgstr ""
|
|||||||
msgid "extra positional arguments given"
|
msgid "extra positional arguments given"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: py/parse.c
|
|
||||||
msgid "f-string expression part cannot include a '#'"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: py/parse.c
|
|
||||||
msgid "f-string expression part cannot include a backslash"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: py/parse.c
|
|
||||||
msgid "f-string: empty expression not allowed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: py/parse.c
|
|
||||||
msgid "f-string: expecting '}'"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: py/parse.c
|
|
||||||
msgid "f-string: single '}' is not allowed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c
|
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c
|
||||||
#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c
|
#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c
|
||||||
msgid "file must be a file opened in byte mode"
|
msgid "file must be a file opened in byte mode"
|
||||||
@ -3401,10 +3377,6 @@ msgstr ""
|
|||||||
msgid "invalid architecture"
|
msgid "invalid architecture"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/netutils/netutils.c
|
|
||||||
msgid "invalid arguments"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: shared-bindings/bitmaptools/__init__.c
|
#: shared-bindings/bitmaptools/__init__.c
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32"
|
msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32"
|
||||||
@ -4009,7 +3981,7 @@ msgid "queue overflow"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: py/parse.c
|
#: py/parse.c
|
||||||
msgid "raw f-strings are not implemented"
|
msgid "raw f-strings are not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/fft/fft_tools.c
|
#: extmod/ulab/code/numpy/fft/fft_tools.c
|
||||||
@ -4070,7 +4042,7 @@ msgstr ""
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -4346,7 +4318,7 @@ msgid "unicode name escapes"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: py/parse.c
|
#: py/parse.c
|
||||||
msgid "unindent does not match any outer indentation level"
|
msgid "unindent doesn't match any outer indent level"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: py/objstr.c
|
#: py/objstr.c
|
||||||
|
@ -4073,7 +4073,7 @@ msgstr ""
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -4144,7 +4144,7 @@ msgstr "Abtastrate außerhalb der Reichweite"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "kompilieren von Skripten nicht unterstützt"
|
msgstr "kompilieren von Skripten nicht unterstützt"
|
||||||
|
|
||||||
|
@ -4070,7 +4070,7 @@ msgstr ""
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -4114,7 +4114,7 @@ msgstr "sampling rate out of range"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "schedule queue full"
|
msgstr "schedule queue full"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "script compilation not supported"
|
msgstr "script compilation not supported"
|
||||||
|
|
||||||
|
@ -2943,7 +2943,7 @@ msgstr ""
|
|||||||
msgid "schedule stack full"
|
msgid "schedule stack full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -2950,7 +2950,7 @@ msgstr ""
|
|||||||
msgid "schedule stack full"
|
msgid "schedule stack full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -4161,7 +4161,7 @@ msgstr "frecuencia de muestreo fuera de rango"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "cola de planificación llena"
|
msgstr "cola de planificación llena"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "script de compilación no soportado"
|
msgstr "script de compilación no soportado"
|
||||||
|
|
||||||
|
@ -4121,7 +4121,7 @@ msgstr "pagpili ng rate wala sa sakop"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "script kompilasyon hindi supportado"
|
msgstr "script kompilasyon hindi supportado"
|
||||||
|
|
||||||
|
@ -4172,7 +4172,7 @@ msgstr "taux d'échantillonage hors bornes"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "file de schédule pleine"
|
msgstr "file de schédule pleine"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "compilation de script non supportée"
|
msgstr "compilation de script non supportée"
|
||||||
|
|
||||||
|
@ -4070,7 +4070,7 @@ msgstr ""
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -4137,7 +4137,7 @@ msgstr "frequenza di campionamento fuori intervallo"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "compilazione dello scrip non suportata"
|
msgstr "compilazione dello scrip non suportata"
|
||||||
|
|
||||||
|
@ -4093,7 +4093,7 @@ msgstr "サンプリングレートが範囲外"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "スクリプトのコンパイルは非対応"
|
msgstr "スクリプトのコンパイルは非対応"
|
||||||
|
|
||||||
|
@ -4074,7 +4074,7 @@ msgstr ""
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -4118,7 +4118,7 @@ msgstr "bemonsteringssnelheid buiten bereik"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "scriptcompilatie wordt niet ondersteund"
|
msgstr "scriptcompilatie wordt niet ondersteund"
|
||||||
|
|
||||||
|
@ -4090,7 +4090,7 @@ msgstr "częstotliwość próbkowania poza zakresem"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "kompilowanie skryptów nieobsługiwane"
|
msgstr "kompilowanie skryptów nieobsługiwane"
|
||||||
|
|
||||||
|
@ -4174,7 +4174,7 @@ msgstr "Taxa de amostragem fora do intervalo"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "fila de espera cheia"
|
msgstr "fila de espera cheia"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "compilação de script não suportada"
|
msgstr "compilação de script não suportada"
|
||||||
|
|
||||||
|
@ -4133,7 +4133,7 @@ msgstr "samplingsfrekvens utanför räckvidden"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "schemakön full"
|
msgstr "schemakön full"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "skriptkompilering stöds inte"
|
msgstr "skriptkompilering stöds inte"
|
||||||
|
|
||||||
|
@ -4133,7 +4133,7 @@ msgstr "qǔyàng lǜ chāochū fànwéi"
|
|||||||
msgid "schedule queue full"
|
msgid "schedule queue full"
|
||||||
msgstr "shí jiān biǎo duì liè yǐ mǎn"
|
msgstr "shí jiān biǎo duì liè yǐ mǎn"
|
||||||
|
|
||||||
#: lib/utils/pyexec.c py/builtinimport.c
|
#: shared/runtime/pyexec.c py/builtinimport.c
|
||||||
msgid "script compilation not supported"
|
msgid "script compilation not supported"
|
||||||
msgstr "bù zhīchí jiǎoběn biānyì"
|
msgstr "bù zhīchí jiǎoběn biānyì"
|
||||||
|
|
||||||
|
4
main.c
4
main.c
@ -40,8 +40,8 @@
|
|||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "py/stackctrl.h"
|
#include "py/stackctrl.h"
|
||||||
|
|
||||||
#include "lib/mp-readline/readline.h"
|
#include "shared/readline/readline.h"
|
||||||
#include "lib/utils/pyexec.h"
|
#include "shared/runtime/pyexec.h"
|
||||||
|
|
||||||
#include "background.h"
|
#include "background.h"
|
||||||
#include "mpconfigboard.h"
|
#include "mpconfigboard.h"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "py/mpstate.h"
|
#include "py/mpstate.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
|
|
||||||
#include "lib/utils/gchelper.h"
|
#include "shared/runtime/gchelper.h"
|
||||||
|
|
||||||
#if MICROPY_ENABLE_GC
|
#if MICROPY_ENABLE_GC
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@
|
|||||||
#define MICROPY_READER_POSIX (1)
|
#define MICROPY_READER_POSIX (1)
|
||||||
#define MICROPY_ENABLE_RUNTIME (0)
|
#define MICROPY_ENABLE_RUNTIME (0)
|
||||||
#define MICROPY_ENABLE_GC (1)
|
#define MICROPY_ENABLE_GC (1)
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
#define MICROPY_STACK_CHECK (1)
|
#define MICROPY_STACK_CHECK (1)
|
||||||
|
#endif
|
||||||
#define MICROPY_HELPER_LEXER_UNIX (1)
|
#define MICROPY_HELPER_LEXER_UNIX (1)
|
||||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
||||||
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
||||||
@ -54,6 +56,7 @@
|
|||||||
#define MICROPY_PY_ASYNC_AWAIT (1)
|
#define MICROPY_PY_ASYNC_AWAIT (1)
|
||||||
#define MICROPY_USE_INTERNAL_PRINTF (0)
|
#define MICROPY_USE_INTERNAL_PRINTF (0)
|
||||||
|
|
||||||
|
#define MICROPY_PY_FSTRINGS (1)
|
||||||
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
|
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
|
||||||
|
|
||||||
#if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
|
#if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
|
||||||
|
@ -69,7 +69,7 @@ endif
|
|||||||
SRC_C += \
|
SRC_C += \
|
||||||
main.c \
|
main.c \
|
||||||
gccollect.c \
|
gccollect.c \
|
||||||
lib/utils/gchelper_generic.c \
|
shared/runtime/gchelper_generic.c \
|
||||||
supervisor/stub/safe_mode.c \
|
supervisor/stub/safe_mode.c \
|
||||||
supervisor/stub/stack.c \
|
supervisor/stub/stack.c \
|
||||||
supervisor/shared/translate.c
|
supervisor/shared/translate.c
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
<Import Project="$(PyMsvcDir)sources.props" />
|
<Import Project="$(PyMsvcDir)sources.props" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="@(PyCoreSource)" />
|
<ClCompile Include="@(PyCoreSource)" />
|
||||||
<ClCompile Include="$(PyBaseDir)lib/utils/gchelper_generic.c" >
|
<ClCompile Include="$(PyBaseDir)shared/runtime/gchelper_generic.c" >
|
||||||
<PreprocessorDefinitions>MICROPY_GCREGS_SETJMP</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MICROPY_GCREGS_SETJMP</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="$(PyBaseDir)mpy-cross\gccollect.c"/>
|
<ClCompile Include="$(PyBaseDir)mpy-cross\gccollect.c"/>
|
||||||
|
@ -60,7 +60,7 @@ HAL_DIR=hal/$(MCU_SERIES)
|
|||||||
INC += -I. \
|
INC += -I. \
|
||||||
-I../.. \
|
-I../.. \
|
||||||
-I../lib/mp-readline \
|
-I../lib/mp-readline \
|
||||||
-I../lib/timeutils \
|
-I../shared/timeutils \
|
||||||
-Iasf4/$(CHIP_FAMILY) \
|
-Iasf4/$(CHIP_FAMILY) \
|
||||||
-Iasf4/$(CHIP_FAMILY)/hal/include \
|
-Iasf4/$(CHIP_FAMILY)/hal/include \
|
||||||
-Iasf4/$(CHIP_FAMILY)/hal/utils/include \
|
-Iasf4/$(CHIP_FAMILY)/hal/utils/include \
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "shared-bindings/busio/UART.h"
|
#include "shared-bindings/busio/UART.h"
|
||||||
|
|
||||||
#include "mpconfigport.h"
|
#include "mpconfigport.h"
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
|
|
||||||
#include "common-hal/canio/__init__.h"
|
#include "common-hal/canio/__init__.h"
|
||||||
#include "common-hal/canio/Listener.h"
|
#include "common-hal/canio/Listener.h"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "shared-bindings/i2cperipheral/I2CPeripheral.h"
|
#include "shared-bindings/i2cperipheral/I2CPeripheral.h"
|
||||||
#include "common-hal/busio/I2C.h"
|
#include "common-hal/busio/I2C.h"
|
||||||
|
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/mperrno.h"
|
#include "py/mperrno.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
#include "lib/utils/context_manager_helpers.h"
|
#include "shared/runtime/context_manager_helpers.h"
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
|
|
||||||
#include "shared-bindings/imagecapture/ParallelImageCapture.h"
|
#include "shared-bindings/imagecapture/ParallelImageCapture.h"
|
||||||
#include "shared-bindings/microcontroller/__init__.h"
|
#include "shared-bindings/microcontroller/__init__.h"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "lib/timeutils/timeutils.h"
|
#include "shared/timeutils/timeutils.h"
|
||||||
#include "shared-bindings/rtc/__init__.h"
|
#include "shared-bindings/rtc/__init__.h"
|
||||||
#include "supervisor/port.h"
|
#include "supervisor/port.h"
|
||||||
#include "supervisor/shared/translate.h"
|
#include "supervisor/shared/translate.h"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "lib/oofatfs/ff.h" /* FatFs lower layer API */
|
#include "lib/oofatfs/ff.h" /* FatFs lower layer API */
|
||||||
#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */
|
#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */
|
||||||
#include "lib/timeutils/timeutils.h"
|
#include "shared/timeutils/timeutils.h"
|
||||||
|
|
||||||
#if CIRCUITPY_RTC
|
#if CIRCUITPY_RTC
|
||||||
#include "shared-bindings/rtc/RTC.h"
|
#include "shared-bindings/rtc/RTC.h"
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lib/mp-readline/readline.h"
|
#include "shared/readline/readline.h"
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#include "py/mpstate.h"
|
#include "py/mpstate.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
@ -89,7 +89,7 @@ INC += \
|
|||||||
-I. \
|
-I. \
|
||||||
-I../.. \
|
-I../.. \
|
||||||
-I../lib/mp-readline \
|
-I../lib/mp-readline \
|
||||||
-I../lib/timeutils \
|
-I../shared/timeutils \
|
||||||
-I../../lib/tinyusb/src \
|
-I../../lib/tinyusb/src \
|
||||||
-I../../supervisor/shared/usb \
|
-I../../supervisor/shared/usb \
|
||||||
-Iboards/$(BOARD) \
|
-Iboards/$(BOARD) \
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user