Wykres commitów

611 Commity (b61336483b8b4729309f95d232306ced97b00840)

Autor SHA1 Wiadomość Data
Dave Hylands 755b01439b unix: machine_mem improvements
This basically introduces the MICROPY_MACHINE_MEM_GET_READ_ADDR
and MICROPY_MACHINE_MEM_GET_WRITE_ADDR macros. If one of them is
not defined, then a default identity function is provided.
2015-12-18 22:01:03 +02:00
Paul Sokolovsky 2eb844e0b4 ports: Rename "machine" module to "umachine".
To let unix port implement "machine" functionality on Python level, and
keep consistent naming in other ports (baremetal ports will use magic
module "symlinking" to still load it on "import machine").

Fixes #1701.
2015-12-18 02:39:52 +02:00
Paul Sokolovsky 5efd3f0dca windows: Make keyboard_interrupt_obj available, it's standard feature. 2015-12-18 01:07:27 +02:00
Paul Sokolovsky 3c2b377711 unix/unix_mphal: Just consistently set sigaction.sa_flags to 0. 2015-12-18 01:07:27 +02:00
Paul Sokolovsky 3db2b23060 unix/unix_mphal: Properly initialize struct sigaction.
This solves long-standing non-deterministic bug, which manifested itself
on x86 32-bit (at least of reported cases) - segfault on Ctrl+C (i.e.
SIGINT).
2015-12-17 23:24:35 +02:00
Damien George 0d7de08e06 unix: Change define logic of _DIRENT_HAVE_D_INO to match other macros. 2015-12-16 14:17:56 +00:00
pohmelie 64a909ef51 unix: Add FreeDos target 2015-12-16 13:28:12 +00:00
Damien George a1528364b3 unix/modos: Fix silly bugs in ilistdir tuple creation. 2015-12-16 13:26:20 +00:00
Damien George 3386477b29 unix/modos: Allow to configure use of d_ino using _DIRENT_HAVE_D_INO.
Ports will need to #define _DIRENT_HAVE_D_INO (0) to disable d_ino use.
2015-12-16 13:21:09 +00:00
Paul Sokolovsky 130fde8130 uos: Add errno() function to get/set errno value. 2015-12-16 00:38:26 +02:00
Paul Sokolovsky d874702fe1 unix/modos: Implement ilistdir().
ilistdir() returns iterator which yields triples of (name, type, ino)
where ino is inode number for entry's data, type of entry (file/dir/etc.),
and name of file/dir. listdir() can be easily implemented in terms of this
iterator (which is otherwise more efficient in terms of memory use and may
save expensive call to stat() for each returned entry).

CPython has os.scandir() which also returns an iterator, but it yields
more complex objects of DirEntry type. scandir() can also be easily
implemented in terms of ilistdir().
2015-12-14 23:48:12 +02:00
Paul Sokolovsky 8fb255dc34 unix/modtime: Add strftime() function (only single argument is supported).
Following "don't rely on FFI for basic functionality" approach.
2015-12-14 00:10:57 +02:00
Paul Sokolovsky 2d11b17419 unix/moduselect: Make configurable with MICROPY_PY_USELECT. 2015-12-13 08:47:42 +02:00
Dave Hylands f925165942 unix: Move modmachine into unix directory
This leaves behind the common functionality in extmod/machine_mem.c
which can be used by all ports.
2015-12-13 01:21:36 +02:00
Paul Sokolovsky a6eff059b9 unix: Rename "_os" module to "uos" for consistency with baremetal ports. 2015-12-12 00:04:35 +02:00
Paul Sokolovsky c1481bb0ab unix/moduselect: Implement "one-shot" flag for poll.poll().
After an I/O event is triggered for fd, event flags are automatically reset,
so no further events are reported until new event flags are set. This is
an optimization for uasyncio, required to account for coroutine semantics:
each coroutine issues explicit read/write async call, and once that trigger,
no events should be reported to coroutine, unless it again explicitly
requests it. One-shot mode saves one linear scan over the poll array.
2015-12-11 23:36:37 +02:00
Paul Sokolovsky d288ae8eb9 unix/modtermios: DJGPP appears to have unicode-capable cc_t type.
At least it's defined as "unsiged". We don't try to support unicode still,
but at least apply workaround for DJGPP build.
2015-12-09 22:01:29 +02:00
Paul Sokolovsky ce936edf62 unix/modtermios: Provide B57600 and B115200 constants only if defined. 2015-12-09 21:49:09 +02:00
Paul Sokolovsky 3a309d93b1 unix/main: mp_verbose_flag available only if MICROPY_DEBUG_PRINTERS is true.
Not available for minimal build for example.
2015-12-07 20:09:20 +02:00
pohmelie 354e688d8e py: Add MICROPY_PY_BUILTINS_MIN_MAX, disable for minimal ports. 2015-12-07 18:56:25 +02:00
Paul Sokolovsky 082b12128d unix/moduselect: register(): Allow to call with duplicate file descriptor.
Per CPython docs, "Registering a file descriptor that’s already registered
is not an error, and has the same effect as registering the descriptor
exactly once."
https://docs.python.org/3/library/select.html#select.poll.register

That's somewhat ambiguous, what's implemented here is that if fd si not
yet registered, it is registered. Otherwise, the effect is equivalent to
modify() method.
2015-12-05 15:16:49 +02:00
Paul Sokolovsky 5ae3ddcc9a unix/main: Check pending exception at the end of code block execution.
Usually this checking is done by VM on jump instructions, but for linear
sequences of instructions and builtin functions this won't happen. Particular
target of this change is long-running builtin functions like time.sleep().
2015-12-04 19:16:56 +02:00
Paul Sokolovsky 30d0cf4885 unix/mpconfigport: Typo fix in comment. 2015-12-03 01:41:26 +02:00
Paul Sokolovsky d735278c9f unix/mpconfigport.h: For MICROPY_NO_ALLOCA=1, don't even include alloca.h. 2015-12-02 16:05:02 +02:00
Paul Sokolovsky 3376875bc8 unix/modtime: sleep(): Return early if KeyboardInterrupt is pending
As set by signal handler. This assumes that exception will be raised
somewhere else, which so far doesn't happen for single function call.
Still, it makes sense to handle that in some common place.
2015-12-02 00:37:25 +02:00
Paul Sokolovsky bd33aa313e unix/moduselect: Support growing of poll array. 2015-11-30 00:54:14 +02:00
Damien George 999cedb90f py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.

This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
2015-11-29 14:25:35 +00:00
Damien George cbf7674025 py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
Paul Sokolovsky fad7d9317b unix/modtime: Unbreak Windows build after changes to check select() result. 2015-11-29 14:31:58 +02:00
Paul Sokolovsky 0bb57bf5bf unix/modtime: sleep(): Automatically restart after receiving EINTR.
THis is required to deal well with signals, signals being the closest
analogue of hardware interrupts for POSIX. This is also CPython 3.5
compliant behavior (PEP 475).

The main problem implementing this is to figure out how much time was
spent in waiting so far/how much is remaining. It's well-known fact that
Linux updates select()'s timeout value when returning with EINTR to the
remaining wait time. Here's what POSIX-based standards say about this:
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html):

"Upon successful completion, the select() function may modify the object
pointed to by the timeout argument."

I.e. it allows to modify timeout value, but doesn't say how exactly it is
modified. And actually, it allows such modification only "upon successful
completion", which returning with EINTR error hardly is.

POSIX also allows to request automatic EINTR restart for system calls using
sigaction call with SA_RESTART flag, but here's what the same document says
about it:

"If SA_RESTART has been set for the interrupting signal, it is
implementation-defined whether the function restarts or returns with
[EINTR]."

In other words, POSIX doesn't leave room for both portable and efficient
handling of this matter, so the code just allows to manually select
Linux-compatible behavior with MICROPY_SELECT_REMAINING_TIME option,
or otherwise will just raise OSError. When systems with non-Linux behavior
are found, they can be handled separately.
2015-11-29 14:21:06 +02:00
Paul Sokolovsky 698a6a9d7d unix/moduselect: poll.register(): Reuse freed entries in poll array. 2015-11-29 00:06:51 +02:00
Paul Sokolovsky 19920e25f9 unix/moduselect: Fix bug in poll.poll() scanning loop. 2015-11-28 17:34:46 +02:00
Damien George 7a5a4fe271 unix/unix_mphal: Use size_t instead of mp_uint_t in stdout_tx_strn decls. 2015-11-27 14:03:53 +00:00
Paul Sokolovsky 7dec35d7cc unix/modos: Remove duplicate level of #if MICROPY_PY_OS_STATVFS. 2015-11-26 17:46:26 +02:00
Paul Sokolovsky 9f10d3fb63 unix/main: Get rid of perror() which uses stdio. 2015-11-23 00:10:38 +02:00
Paul Sokolovsky c3280d83e7 unix: Use printf() implementation in terms of mp_printf().
In other words, unix port now uses overriden printf(), instead of using
libc's. This should remove almost all dependency on libc stdio (which
is bloated).
2015-11-22 00:44:41 +02:00
Paul Sokolovsky ede1f547e7 unix/modsocket: Use snprintf(), as defined by lib/utils/printf.c. 2015-11-21 17:21:49 +02:00
Paul Sokolovsky 295ea12411 py/emitglue: Host definition of mp_verbose_flag.
This may not seem like the ideal place, but is actually the only place
in py/ where it gets referenced, so is just right.
2015-11-21 16:54:15 +02:00
Paul Sokolovsky 3ba61656bd unix/modsocket: Implement sockaddr() function to decode raw socket address.
Return tuple of (address_family, net_addr, [port, [extra_data]]). net_addr
is still raw network address as bytes object, but suitable for passing to
inet_ntop() function. At the very least, sockaddr() will separate address
family value from binary socket address (and currently, only AF_INET family
is decoded).
2015-11-21 01:38:59 +02:00
Paul Sokolovsky 2ae7ced721 unix/modsocket: Removed dangling references to sockaddr_in_type. 2015-11-20 21:32:27 +02:00
Paul Sokolovsky acb743da64 unix/modffi: Mark 'O' type specifier as implemented. 2015-11-20 17:51:37 +02:00
Damien George 54df549b5f unix/moduselect: Initialise variable so can compile in non-debug mode. 2015-11-20 12:51:00 +00:00
Paul Sokolovsky 65971f5160 unix: Add "uselect" module, with poll() function.
Underlyingly, uses standard POSIX poll() for portability.
2015-11-17 00:35:57 +02:00
Paul Sokolovsky 79c4ec1102 unix/input: Switch to POSIX I/O for history reading/writing. 2015-11-16 07:40:56 +02:00
Paul Sokolovsky ec314c951d unix/modos: getenv(): Handle non-existing envvar correctly. 2015-11-14 17:12:04 +02:00
Paul Sokolovsky 908f5159cf unix/modos: Add Windows workaround for mkdir(). 2015-11-14 02:35:38 +02:00
Paul Sokolovsky 27dafa5ed5 unix/modos: Add mkdir().
Dependency of upip.
2015-11-13 22:26:51 +02:00
Paul Sokolovsky d8557834c0 unix/modos: Add getenv().
Dependency of upip.
2015-11-13 21:30:06 +02:00
Paul Sokolovsky a01f6c9ae7 unix/main: Remove stray mp_printf() from previous commit. 2015-11-13 17:33:42 +02:00
Paul Sokolovsky 66fd3e4a7b unix: Use standard mphalport.h header.
This also unbreaks "make minimal".
2015-11-13 15:44:26 +02:00