Wykres commitów

629 Commity (c13b2f2d0040cdf38ea3178717480d07f02c5245)

Autor SHA1 Wiadomość Data
Damien George c9845a0685 unix: Allow to build coverage build with OBJ_REPR_D. 2016-01-11 16:30:58 +00:00
Dave Hylands 11b97d7ec5 unix: Add socket.inet_ntop function 2016-01-11 12:08:07 +02:00
Damien George 5b3f0b7f39 py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure.  So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that).  This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
2016-01-11 00:49:27 +00:00
Damien George 4b72b3a133 py: Change type signature of builtin funs that take variable or kw args.
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
2016-01-11 00:49:27 +00:00
Damien George a0c97814df py: Change type of .make_new and .call args: mp_uint_t becomes size_t.
This patch changes the type signature of .make_new and .call object method
slots to use size_t for n_args and n_kw (was mp_uint_t.  Makes code more
efficient when mp_uint_t is larger than a machine word.  Doesn't affect
ports when size_t and mp_uint_t have the same size.
2016-01-11 00:48:41 +00:00
Paul Sokolovsky 8175877ad6 unix/modtime: strftime(): Support 2nd argument, but as time_t value.
Instead of struct tm like structure, as required by CPython.
2016-01-10 12:08:27 +02:00
Damien George 1b0aab621b py: Change struct and macro for builtin fun so they can be type checked. 2016-01-03 11:53:44 +00:00
Damien George ae4865efa1 unix/Makefile: Move include of mpconfigport.mk to before mkenv.mk.
So that if MICROPY_FORCE_32BIT is set mpconfigport.mk it influences
mkenv.mk.
2016-01-02 21:56:03 +00:00
Paul Sokolovsky 09630e48ce unix/.gitignore: Ignore gcov files. 2016-01-02 14:50:17 +02:00
Paul Sokolovsky 98f7729848 unix/unix_mphal: Be sure to wrap dupterm code with MICROPY_PY_OS_DUPTERM. 2016-01-01 22:55:45 +02:00
Paul Sokolovsky 8fa9264430 unix/unix_mphal: Handle exceptions in call to dupterm's .read(). 2016-01-01 22:39:29 +02:00
Paul Sokolovsky 30b7344eb0 extmod/moduos_dupterm: Make mp_uos_dupterm_tx_strn() function reusable.
Function to actually spool output terminal data to dupterm object.
2016-01-01 16:43:35 +02:00
Paul Sokolovsky 00ee84e1e1 py: Clean up instantiation of dupterm object.
To comply with already established scheme for extmod's.
2016-01-01 14:22:57 +02:00
Paul Sokolovsky 9bbfd5efd4 py/mpconfig: Make configuration of dupterm object reusable. 2016-01-01 13:16:18 +02:00
Paul Sokolovsky ddea7cb702 extmod/moduos_dupterm: Make uos.dupterm() implementation reusable.
That's just function which sets/gets dup terminal object, and can be
easily reused across ports.
2016-01-01 13:04:32 +02:00
Paul Sokolovsky 2c1620ce1f unix: Implement uos.dupterm(). Conditional on MICROPY_PY_OS_DUPTERM. 2015-12-28 01:13:21 +02:00
Paul Sokolovsky 1c9210bc2b unix/unix_mphal: Raise KeyboardInterrupt straight from signal handler.
POSIX doesn't guarantee something like that to work, but it works on any
system with careful signal implementation. Roughly, the requirement is
that signal handler is executed in the context of the process, its main
thread, etc. This is true for Linux. Also tested to work without issues
on MacOSX.
2015-12-23 00:07:00 +02:00
Damien George e9751d2ac0 unix: Properly cancel REPL input when Ctrl-C is pressed. 2015-12-22 22:06:09 +00:00
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