Commit Graph

16 Commits

Author SHA1 Message Date
Damien George
503089ea9d unix: Use mp_raise_OSError helper function. 2016-10-07 14:05:15 +11:00
Damien George
93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Renato Aguiar
081c0648ec unix: Fix build for when MICROPY_PY_SOCKET=0. 2016-09-12 16:43:56 +10:00
Paul Sokolovsky
a4aaf82421 unix/moduselect: Allow poll.register(), etc. accept fd-like objects.
This includes file and socket objects, backed by Unix file descriptor.
This improves compatibility with stmhal's uselect (and convenience of
use), though not completely: return value from poll.poll() is still
raw file descriptor.
2016-08-07 01:25:59 +03: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
1b0aab621b py: Change struct and macro for builtin fun so they can be type checked. 2016-01-03 11:53:44 +00:00
Paul Sokolovsky
2d11b17419 unix/moduselect: Make configurable with MICROPY_PY_USELECT. 2015-12-13 08:47:42 +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
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
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
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
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