aboutsummaryrefslogtreecommitdiff
path: root/ports/unix
AgeCommit message (Collapse)Author
2019-02-12unix/modmachine: Handle repeated /dev/mem open errors.Yonatan Goldschmidt
If opening of /dev/mem has failed an `OSError` is appropriately raised, but the next time `mem8/16/32` is accessed the invalid file descriptor is used and the program gets a SIGSEGV.
2019-02-12ports: Convert legacy uppercase macro names to lowercase.Damien George
2019-01-31py/warning: Support categories for warnings.Paul Sokolovsky
Python defines warnings as belonging to categories, where category is a warning type (descending from exception type). This is useful, as e.g. allows to disable warnings selectively and provide user-defined warning types. So, implement this in MicroPython, except that categories are represented just with strings. However, enough hooks are left to implement categories differently per-port (e.g. as types), without need to patch each and every usage.
2019-01-27py: Add optional support for 2-argument version of built-in next().stijn
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2019-01-27unix/mpthreadport: Remove busy wait loop in thread garbage collection.Mikhail Zakharov
One can't use pthread calls in a signal handler because they are not async-signal-safe (see man signal-safety). Instead, sem_post can be used to post from within a signal handler and this should be more efficient than using a busy wait loop, waiting on a volatile variable.
2019-01-27unix/mpthreadport: Cleanup used memory on thread exit.Mikhail Zakharov
2019-01-27unix/mpthreadport: Add thread deinit code to stop threads on exit.Mikhail Zakharov
Free unused memory for threads and cancel any outstanding threads on interpreter exit to avoid possible segmentaiton fault.
2018-11-26unix/modos: Rename unlink to remove to be consistent with other ports.Paul Sokolovsky
We standardized to provide uos.remove() as a more obvious and user-friendly name. That's what written in the docs. The Unix port implementation predates this convention, so update it now.
2018-10-23py/objmodule: Implement PEP 562's __getattr__ for modules.Paul m. p. P
Configurable via MICROPY_MODULE_GETATTR, disabled by default. Among other things __getattr__ for modules can help to build lazy loading / code unloading at runtime.
2018-10-22py/objstr: Make str.count() method configurable.Paul Sokolovsky
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled. Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling it saves 408 bytes on x86.
2018-10-19unix/Makefile: Allow to override/omit pthread lib name.Paul Sokolovsky
For example, on Android, pthread functions are part of libc, so LIBPTHREAD should be empty.
2018-10-17unix/modffi: Add support for "q"/"Q" specs (int64_t/uint64_t).Paul Sokolovsky
2018-10-17unix/modusocket: Finish socket.settimeout() implementation.Paul Sokolovsky
1. Return correct error code for non-blocking vs timed out socket (POSIX returns EAGAIN for both, we want ETIMEDOUT in case of timed out socket). To achieve this, blocking/non-blocking flag is added to the mp_obj_socket_t, to avoid issuing fcntl() syscall each time EAGAIN occurs. (mp_obj_socket_t used to be 8 bytes, having some room in a standard 16-byte alloc block.) 2. Handle socket.settimeout(0) properly - in Python, that means non-blocking mode, but SO_RCVTIMEO/SO_SNDTIMEO of 0 is infinite timeout. 3. Overall, make sure that socket.settimeout() call switches blocking state as expected.
2018-10-17unix/modusocket: Initial implementation of socket.settimeout().Danielle Madeley
2018-10-05unix/moduselect: Raise OSError(ENOENT) if obj to modify is not in pollerPaul Sokolovsky
Previously, the function silently succeeded. The new behavior is consistent with both baremetal uselect implementation and CPython 3.
2018-09-26unix/mpconfigport.h: Enable MICROPY_PY_UHASHLIB_MD5 for uhashlib.md5.Paul Sokolovsky
This will allow to e.g. implement HTTP Digest authentication. Adds 540 bytes for x86_32, 332 for arm_thumb2 (for Unix port, which already includes axTLS library).
2018-09-26py/modmath: Add math.factorial, optimised and non-opt implementations.Christopher Swenson
This commit adds the math.factorial function in two variants: - squared difference, which is faster than the naive version, relatively compact, and non-recursive; - a mildly optimised recursive version, faster than the above one. There are some more optimisations that could be done, but they tend to take more code, and more storage space. The recursive version seems like a sensible compromise. The new function is disabled by default, and uses the non-optimised version by default if it is enabled. The options are MICROPY_PY_MATH_FACTORIAL and MICROPY_OPT_MATH_FACTORIAL.
2018-09-20unix/modjni: Get building under coverage and nanbox builds.Damien George
Changes made: - make use of MP_OBJ_TO_PTR and MP_OBJ_FROM_PTR where necessary - fix shadowing of index variable i, renamed to j - fix type of above variable to size_t to prevent comparison warning - fix shadowing of res variable - use "(void)" instead of "()" for functions that take no arguments
2018-09-20unix/modjni: Update .getiter signature to include mp_obj_iter_buf_t* .Paul Sokolovsky
And thus be buildable again.
2018-09-20py/objstr: Make % (__mod__) formatting operator configurable.Paul Sokolovsky
Default is enabled, disabled for minimal builds. Saves 1296 bytes on x86, 976 bytes on ARM.
2018-09-14unix/modos: Include extmod/vfs.h for MP_S_IFDIR, etc.Paul Sokolovsky
If DTTOIF() macro is not defined, the code refers to MP_S_IFDIR, etc. symbols defined in extmod/vfs.h, so should include it. This fixes build for Android.
2018-09-12unix/mpconfigport_coverage.h: Enable uhashlib.md5.Damien George
2018-09-10unix/Makefile: Build libffi inside $BUILD.Paul Sokolovsky
Avoids polluting the source tree, allows to build for different (sub)archs without intermediate cleaning.
2018-09-08unix/Makefile: Remove building of libaxtls.a which is no longer needed.Damien George
2018-08-14unix/Makefile: Enable ussl module with nanbox build.Damien George
2018-08-14unix/Makefile: coverage: Explicitly build "axtls" too.Paul Sokolovsky
"coverage" build uses different BUILD directory comparing to the normal build. Previously, any build picked up libaxtls.a from normal build's directory, but that was fixed recently. So, for each build, we must build axtls explicitly. This fixes Travis build in particular.
2018-08-02py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.Damien George
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to MICROPY_DEBUG_PRINTER, moving its default definition from lib/utils/printf.c to py/mpconfig.h to make it official and documented, and makes this macro a pointer rather than the actual mp_print_t struct. This is done to get consistency with MICROPY_ERROR_PRINTER, and provide this macro for use outside just lib/utils/printf.c. Ports are updated to use the new macro name.
2018-07-20unix: Use MP_STREAM_GET_FILENO to allow uselect to poll general objects.Damien George
This mechanism will scale to to an arbitrary number of pollable objects, so long as they implement the MP_STREAM_GET_FILENO ioctl. Since ussl objects pass through ioctl requests transparently to the underlying socket object, it will allow ussl sockets to be polled. And a user object with uio.IOBase as a base could support polling.
2018-07-11unix/modos: Convert dir-type to stat-type for file type in ilistdir.Damien George
Fixes issue #3931.
2018-07-02unix/mpconfigport_coverage: Enable ure groups, span, start, end and sub.Damien George
2018-06-27unix/mpconfigport.h: Enable MICROPY_PY_UCRYPTOLIB.Paul Sokolovsky
2018-06-27extmod/moducryptolib: Add ucryptolib module with crypto functions.Paul Sokolovsky
The API follows guidelines of https://www.python.org/dev/peps/pep-0272/, but is optimized for code size, with the idea that full PEP 0272 compatibility can be added with a simple Python wrapper mode. The naming of the module follows (u)hashlib pattern. At the bare minimum, this module is expected to provide: * AES128, ECB (i.e. "null") mode, encrypt only Implementation in this commit is based on axTLS routines, and implements following: * AES 128 and 256 * ECB and CBC modes * encrypt and decrypt
2018-06-18tests/unix/extra_coverage: Don't test stream objs with NULL write fun.Damien George
This behaviour of a NULL write C method on a stream that uses the write adaptor objects is no longer supported. It was only ever used by the coverage build for testing the fail path of mp_get_stream_raise().
2018-06-12ports: Enable IOBase on unix, stm32, esp8266 and esp32.Damien George
It's a core feature, in particular required for user-streams with uasyncio.
2018-06-12ports: Call gc_sweep_all() when doing a soft reset.Damien George
This calls finalisers of things like files and sockets to cleanly close them.
2018-06-06unix/moduos_vfs: Add missing uos functions from traditional uos module.Damien George
Now that the coverage build has fully switched to the VFS sub-system these functions were no longer available, so add them to the uos_vfs module. Also, vfs_open is no longer needed, it's available as the built-in open.
2018-06-06unix: Support MICROPY_VFS_POSIX and enable it in coverage build.Damien George
The unix coverage build is now switched fully to the VFS implementation, ie the uos module is the uos_vfs module. For example, one can now sandbox uPy to their home directory via: $ ./micropython_coverage >>> import uos >>> uos.umount('/') # unmount existing root VFS >>> vfs = uos.VfsPosix('/home/user') # create new POSIX VFS >>> uos.mount(vfs, '/') # mount new POSIX VFS at root Some filesystem/OS features may no longer work with the coverage build due to this change, and these need to be gradually fixed. The standard unix port remains unchanged, it still uses the traditional uos module which directly accesses the underlying host filesystem.
2018-05-22ports: Enable MICROPY_PY_BUILTINS_ROUND_INT on selected ports.Damien George
2018-04-10py/stream: Switch stream close operation from method to ioctl.Damien George
This patch moves the implementation of stream closure from a dedicated method to the ioctl of the stream protocol, for each type that implements closing. The benefits of this are: 1. Rounds out the stream ioctl function, which already includes flush, seek and poll (among other things). 2. Makes calling mp_stream_close() on an object slightly more efficient because it now no longer needs to lookup the close method and call it, rather it just delegates straight to the ioctl function (if it exists). 3. Reduces code size and allows future types that implement the stream protocol to be smaller because they don't need a dedicated close method. Code size reduction is around 200 bytes smaller for x86 archs and around 30 bytes smaller for the bare-metal archs.
2018-03-08unix/coverage: Allow coverage tests to pass with debugging disabled.Damien George
2018-03-02tests: Move heap-realloc-while-locked test from C to Python.Damien George
This test for calling gc_realloc() while the GC is locked can be done in pure Python, so better to do it that way since it can then be tested on more ports.
2018-03-01tests/unix: Add coverage tests for various GC calls.Damien George
2018-02-27tests/unix: Add coverage test for VM executing invalid bytecode.Damien George
2018-02-25tests/unix: Add coverage tests for mpz_set_from_float, mpz_mul_inpl.Damien George
These new tests cover cases that can't be reached from Python and get coverage of py/mpz.c to 100%. These "unreachable from Python" pieces of code could be removed but they form an integral part of the mpz C API and may be useful for non-Python usage of mpz.
2018-02-21ports: Enable ucollections.deque on relevant ports.Damien George
These ports are all capable of running uasyncio.
2018-02-14unix/mpconfigport_coverage: Enable range (in)equality comparison.Damien George
2018-02-14unix/Makefile,embedding/Makefile: Remove obsolete use of STMHAL_SRC_C.Damien George
2018-02-08.travis.yml,ports/unix/Makefile: Add coverage test for script via stdin.Damien George
2018-02-08tests/unix: Add coverage test for calling mp_obj_new_bytearray.Damien George
2017-12-19unix/mpconfigport_coverage.h: Enable MICROPY_PY_IO_RESOURCE_STREAM.Damien George
Where possible it's important to test all code in the code base.