2015-11-16 17:35:29 -05:00
|
|
|
/*
|
2017-06-30 03:22:17 -04:00
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
2015-11-16 17:35:29 -05:00
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Damien P. George
|
2017-02-12 16:23:23 -05:00
|
|
|
* Copyright (c) 2015-2017 Paul Sokolovsky
|
2015-11-16 17:35:29 -05:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-12-13 01:47:00 -05:00
|
|
|
#include "py/mpconfig.h"
|
|
|
|
|
2016-11-20 16:48:55 -05:00
|
|
|
#if MICROPY_PY_USELECT_POSIX
|
2015-12-13 01:47:00 -05:00
|
|
|
|
2021-02-14 23:49:20 -05:00
|
|
|
#if MICROPY_PY_USELECT
|
|
|
|
#error "Can't have both MICROPY_PY_USELECT and MICROPY_PY_USELECT_POSIX."
|
|
|
|
#endif
|
|
|
|
|
2015-11-16 17:35:29 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <poll.h>
|
|
|
|
|
2016-10-06 23:05:15 -04:00
|
|
|
#include "py/runtime.h"
|
2018-07-19 23:09:49 -04:00
|
|
|
#include "py/stream.h"
|
2015-11-16 17:35:29 -05:00
|
|
|
#include "py/obj.h"
|
|
|
|
#include "py/objlist.h"
|
|
|
|
#include "py/objtuple.h"
|
|
|
|
#include "py/mphal.h"
|
2020-01-22 19:14:03 -05:00
|
|
|
#include "py/mpthread.h"
|
2016-08-06 18:21:42 -04:00
|
|
|
|
2017-11-06 18:13:19 -05:00
|
|
|
#define DEBUG 0
|
|
|
|
|
2016-09-08 18:13:58 -04:00
|
|
|
#if MICROPY_PY_SOCKET
|
2016-08-06 18:21:42 -04:00
|
|
|
extern const mp_obj_type_t mp_type_socket;
|
2016-09-08 18:13:58 -04:00
|
|
|
#endif
|
2015-11-16 17:35:29 -05:00
|
|
|
|
2015-12-11 16:36:29 -05:00
|
|
|
// Flags for poll()
|
|
|
|
#define FLAG_ONESHOT (1)
|
|
|
|
|
2015-11-16 17:35:29 -05:00
|
|
|
/// \class Poll - poll class
|
|
|
|
|
|
|
|
typedef struct _mp_obj_poll_t {
|
|
|
|
mp_obj_base_t base;
|
|
|
|
unsigned short alloc;
|
|
|
|
unsigned short len;
|
|
|
|
struct pollfd *entries;
|
2016-12-30 16:07:18 -05:00
|
|
|
mp_obj_t *obj_map;
|
2017-02-12 16:23:23 -05:00
|
|
|
short iter_cnt;
|
|
|
|
short iter_idx;
|
|
|
|
int flags;
|
|
|
|
// callee-owned tuple
|
|
|
|
mp_obj_t ret_tuple;
|
2015-11-16 17:35:29 -05:00
|
|
|
} mp_obj_poll_t;
|
|
|
|
|
2016-08-06 18:21:42 -04:00
|
|
|
STATIC int get_fd(mp_obj_t fdlike) {
|
2019-01-30 06:05:48 -05:00
|
|
|
if (mp_obj_is_obj(fdlike)) {
|
2018-07-19 23:09:49 -04:00
|
|
|
const mp_stream_p_t *stream_p = mp_get_stream_raise(fdlike, MP_STREAM_OP_IOCTL);
|
|
|
|
int err;
|
|
|
|
mp_uint_t res = stream_p->ioctl(fdlike, MP_STREAM_GET_FILENO, 0, &err);
|
|
|
|
if (res != MP_STREAM_ERROR) {
|
|
|
|
return res;
|
|
|
|
}
|
2016-08-06 18:21:42 -04:00
|
|
|
}
|
2018-07-19 23:09:49 -04:00
|
|
|
return mp_obj_get_int(fdlike);
|
2016-08-06 18:21:42 -04:00
|
|
|
}
|
|
|
|
|
2015-11-16 17:35:29 -05:00
|
|
|
/// \method register(obj[, eventmask])
|
2016-01-03 09:21:40 -05:00
|
|
|
STATIC mp_obj_t poll_register(size_t n_args, const mp_obj_t *args) {
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]);
|
2019-01-30 06:05:48 -05:00
|
|
|
bool is_fd = mp_obj_is_int(args[1]);
|
2016-08-06 18:21:42 -04:00
|
|
|
int fd = get_fd(args[1]);
|
|
|
|
|
2015-11-16 17:35:29 -05:00
|
|
|
mp_uint_t flags;
|
|
|
|
if (n_args == 3) {
|
|
|
|
flags = mp_obj_get_int(args[2]);
|
|
|
|
} else {
|
|
|
|
flags = POLLIN | POLLOUT;
|
|
|
|
}
|
|
|
|
|
2015-12-05 07:53:53 -05:00
|
|
|
struct pollfd *free_slot = NULL;
|
|
|
|
|
|
|
|
struct pollfd *entry = self->entries;
|
|
|
|
for (int i = 0; i < self->len; i++, entry++) {
|
|
|
|
int entry_fd = entry->fd;
|
|
|
|
if (entry_fd == fd) {
|
|
|
|
entry->events = flags;
|
|
|
|
return mp_const_false;
|
|
|
|
}
|
|
|
|
if (entry_fd == -1) {
|
|
|
|
free_slot = entry;
|
2015-11-28 17:05:56 -05:00
|
|
|
}
|
2015-12-05 07:53:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (free_slot == NULL) {
|
|
|
|
if (self->len >= self->alloc) {
|
2015-11-29 17:53:46 -05:00
|
|
|
self->entries = m_renew(struct pollfd, self->entries, self->alloc, self->alloc + 4);
|
2016-12-30 16:07:18 -05:00
|
|
|
if (self->obj_map) {
|
|
|
|
self->obj_map = m_renew(mp_obj_t, self->obj_map, self->alloc, self->alloc + 4);
|
|
|
|
}
|
2015-11-29 17:53:46 -05:00
|
|
|
self->alloc += 4;
|
2015-11-28 17:05:56 -05:00
|
|
|
}
|
2015-12-05 07:53:53 -05:00
|
|
|
free_slot = &self->entries[self->len++];
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-12-30 16:07:18 -05:00
|
|
|
if (!is_fd) {
|
|
|
|
if (self->obj_map == NULL) {
|
|
|
|
self->obj_map = m_new0(mp_obj_t, self->alloc);
|
|
|
|
}
|
|
|
|
self->obj_map[free_slot - self->entries] = args[1];
|
|
|
|
}
|
|
|
|
|
2015-12-05 07:53:53 -05:00
|
|
|
free_slot->fd = fd;
|
|
|
|
free_slot->events = flags;
|
|
|
|
free_slot->revents = 0;
|
|
|
|
return mp_const_true;
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_register_obj, 2, 3, poll_register);
|
|
|
|
|
|
|
|
/// \method unregister(obj)
|
|
|
|
STATIC mp_obj_t poll_unregister(mp_obj_t self_in, mp_obj_t obj_in) {
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in);
|
2015-11-16 17:35:29 -05:00
|
|
|
struct pollfd *entries = self->entries;
|
2016-08-06 18:21:42 -04:00
|
|
|
int fd = get_fd(obj_in);
|
2015-11-16 17:35:29 -05:00
|
|
|
for (int i = self->len - 1; i >= 0; i--) {
|
|
|
|
if (entries->fd == fd) {
|
|
|
|
entries->fd = -1;
|
2016-12-30 16:07:18 -05:00
|
|
|
if (self->obj_map) {
|
2016-12-31 03:19:25 -05:00
|
|
|
self->obj_map[entries - self->entries] = MP_OBJ_NULL;
|
2016-12-30 16:07:18 -05:00
|
|
|
}
|
2015-11-16 17:35:29 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
entries++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO raise KeyError if obj didn't exist in map
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_2(poll_unregister_obj, poll_unregister);
|
|
|
|
|
|
|
|
/// \method modify(obj, eventmask)
|
|
|
|
STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmask_in) {
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in);
|
2015-11-16 17:35:29 -05:00
|
|
|
struct pollfd *entries = self->entries;
|
2016-08-06 18:21:42 -04:00
|
|
|
int fd = get_fd(obj_in);
|
2015-11-16 17:35:29 -05:00
|
|
|
for (int i = self->len - 1; i >= 0; i--) {
|
|
|
|
if (entries->fd == fd) {
|
|
|
|
entries->events = mp_obj_get_int(eventmask_in);
|
2018-09-28 14:49:42 -04:00
|
|
|
return mp_const_none;
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
entries++;
|
|
|
|
}
|
|
|
|
|
2018-09-28 14:49:42 -04:00
|
|
|
// obj doesn't exist in poller
|
|
|
|
mp_raise_OSError(MP_ENOENT);
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify);
|
|
|
|
|
2017-02-12 16:23:23 -05:00
|
|
|
STATIC int poll_poll_internal(size_t n_args, const mp_obj_t *args) {
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]);
|
2015-11-16 17:35:29 -05:00
|
|
|
|
2015-12-11 16:36:29 -05:00
|
|
|
// work out timeout (it's given already in ms)
|
2015-11-16 17:35:29 -05:00
|
|
|
int timeout = -1;
|
2015-12-11 16:36:29 -05:00
|
|
|
int flags = 0;
|
|
|
|
if (n_args >= 2) {
|
2015-11-16 17:35:29 -05:00
|
|
|
if (args[1] != mp_const_none) {
|
|
|
|
mp_int_t timeout_i = mp_obj_get_int(args[1]);
|
|
|
|
if (timeout_i >= 0) {
|
|
|
|
timeout = timeout_i;
|
|
|
|
}
|
|
|
|
}
|
2015-12-11 16:36:29 -05:00
|
|
|
if (n_args >= 3) {
|
|
|
|
flags = mp_obj_get_int(args[2]);
|
|
|
|
}
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
|
2017-02-12 16:23:23 -05:00
|
|
|
self->flags = flags;
|
|
|
|
|
2020-01-23 00:54:38 -05:00
|
|
|
int n_ready;
|
|
|
|
MP_HAL_RETRY_SYSCALL(n_ready, poll(self->entries, self->len, timeout), mp_raise_OSError(err));
|
2017-02-12 16:23:23 -05:00
|
|
|
return n_ready;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \method poll([timeout])
|
|
|
|
/// Timeout is in milliseconds.
|
|
|
|
STATIC mp_obj_t poll_poll(size_t n_args, const mp_obj_t *args) {
|
|
|
|
int n_ready = poll_poll_internal(n_args, args);
|
|
|
|
|
2015-11-16 17:35:29 -05:00
|
|
|
if (n_ready == 0) {
|
|
|
|
return mp_const_empty_tuple;
|
|
|
|
}
|
|
|
|
|
2017-02-12 16:23:23 -05:00
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]);
|
|
|
|
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_list_t *ret_list = MP_OBJ_TO_PTR(mp_obj_new_list(n_ready, NULL));
|
2015-11-16 17:35:29 -05:00
|
|
|
int ret_i = 0;
|
|
|
|
struct pollfd *entries = self->entries;
|
2015-11-28 10:34:20 -05:00
|
|
|
for (int i = 0; i < self->len; i++, entries++) {
|
2015-11-16 17:35:29 -05:00
|
|
|
if (entries->revents != 0) {
|
2015-11-27 12:01:44 -05:00
|
|
|
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL));
|
2016-12-30 16:07:18 -05:00
|
|
|
// If there's an object stored, return it, otherwise raw fd
|
2016-12-31 03:19:25 -05:00
|
|
|
if (self->obj_map && self->obj_map[i] != MP_OBJ_NULL) {
|
2016-12-30 16:07:18 -05:00
|
|
|
t->items[0] = self->obj_map[i];
|
|
|
|
} else {
|
|
|
|
t->items[0] = MP_OBJ_NEW_SMALL_INT(entries->fd);
|
|
|
|
}
|
2015-11-16 17:35:29 -05:00
|
|
|
t->items[1] = MP_OBJ_NEW_SMALL_INT(entries->revents);
|
2015-11-27 12:01:44 -05:00
|
|
|
ret_list->items[ret_i++] = MP_OBJ_FROM_PTR(t);
|
2017-02-12 16:23:23 -05:00
|
|
|
if (self->flags & FLAG_ONESHOT) {
|
2015-12-11 16:36:29 -05:00
|
|
|
entries->events = 0;
|
|
|
|
}
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-27 12:01:44 -05:00
|
|
|
return MP_OBJ_FROM_PTR(ret_list);
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
2015-12-11 16:36:29 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_poll_obj, 1, 3, poll_poll);
|
2015-11-16 17:35:29 -05:00
|
|
|
|
2017-02-12 16:23:23 -05:00
|
|
|
STATIC mp_obj_t poll_ipoll(size_t n_args, const mp_obj_t *args) {
|
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]);
|
|
|
|
|
|
|
|
if (self->ret_tuple == MP_OBJ_NULL) {
|
|
|
|
self->ret_tuple = mp_obj_new_tuple(2, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int n_ready = poll_poll_internal(n_args, args);
|
|
|
|
self->iter_cnt = n_ready;
|
|
|
|
self->iter_idx = 0;
|
|
|
|
|
|
|
|
return args[0];
|
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(poll_ipoll_obj, 1, 3, poll_ipoll);
|
|
|
|
|
|
|
|
STATIC mp_obj_t poll_iternext(mp_obj_t self_in) {
|
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in);
|
|
|
|
|
|
|
|
if (self->iter_cnt == 0) {
|
|
|
|
return MP_OBJ_STOP_ITERATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->iter_cnt--;
|
|
|
|
|
2017-03-05 07:51:22 -05:00
|
|
|
struct pollfd *entries = self->entries + self->iter_idx;
|
2017-02-12 16:23:23 -05:00
|
|
|
for (int i = self->iter_idx; i < self->len; i++, entries++) {
|
2017-03-05 07:51:22 -05:00
|
|
|
self->iter_idx++;
|
2017-02-12 16:23:23 -05:00
|
|
|
if (entries->revents != 0) {
|
|
|
|
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->ret_tuple);
|
|
|
|
// If there's an object stored, return it, otherwise raw fd
|
|
|
|
if (self->obj_map && self->obj_map[i] != MP_OBJ_NULL) {
|
|
|
|
t->items[0] = self->obj_map[i];
|
|
|
|
} else {
|
|
|
|
t->items[0] = MP_OBJ_NEW_SMALL_INT(entries->fd);
|
|
|
|
}
|
|
|
|
t->items[1] = MP_OBJ_NEW_SMALL_INT(entries->revents);
|
|
|
|
if (self->flags & FLAG_ONESHOT) {
|
|
|
|
entries->events = 0;
|
|
|
|
}
|
|
|
|
return MP_OBJ_FROM_PTR(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!"inconsistent number of poll active entries");
|
|
|
|
self->iter_cnt = 0;
|
|
|
|
return MP_OBJ_STOP_ITERATION;
|
|
|
|
}
|
|
|
|
|
2017-11-06 18:13:19 -05:00
|
|
|
#if DEBUG
|
2017-11-06 17:43:21 -05:00
|
|
|
STATIC mp_obj_t poll_dump(mp_obj_t self_in) {
|
|
|
|
mp_obj_poll_t *self = MP_OBJ_TO_PTR(self_in);
|
|
|
|
|
|
|
|
struct pollfd *entries = self->entries;
|
|
|
|
for (int i = self->len - 1; i >= 0; i--) {
|
|
|
|
printf("fd: %d ev: %x rev: %x", entries->fd, entries->events, entries->revents);
|
|
|
|
if (self->obj_map) {
|
|
|
|
printf(" obj: %p", self->obj_map[entries - self->entries]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
entries++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(poll_dump_obj, poll_dump);
|
2017-11-06 18:13:19 -05:00
|
|
|
#endif
|
2017-11-06 17:43:21 -05:00
|
|
|
|
2015-11-27 08:38:15 -05:00
|
|
|
STATIC const mp_rom_map_elem_t poll_locals_dict_table[] = {
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(&poll_register_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_unregister), MP_ROM_PTR(&poll_unregister_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_modify), MP_ROM_PTR(&poll_modify_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&poll_poll_obj) },
|
2017-02-12 16:23:23 -05:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_ipoll), MP_ROM_PTR(&poll_ipoll_obj) },
|
2017-11-06 18:13:19 -05:00
|
|
|
#if DEBUG
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&poll_dump_obj) },
|
|
|
|
#endif
|
2015-11-16 17:35:29 -05:00
|
|
|
};
|
|
|
|
STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table);
|
|
|
|
|
|
|
|
STATIC const mp_obj_type_t mp_type_poll = {
|
|
|
|
{ &mp_type_type },
|
|
|
|
.name = MP_QSTR_poll,
|
2016-01-09 18:14:54 -05:00
|
|
|
.getiter = mp_identity_getiter,
|
2017-02-12 16:23:23 -05:00
|
|
|
.iternext = poll_iternext,
|
2020-02-26 23:36:53 -05:00
|
|
|
.locals_dict = (void *)&poll_locals_dict,
|
2015-11-16 17:35:29 -05:00
|
|
|
};
|
|
|
|
|
2016-01-03 09:21:40 -05:00
|
|
|
STATIC mp_obj_t select_poll(size_t n_args, const mp_obj_t *args) {
|
2015-11-16 17:35:29 -05:00
|
|
|
int alloc = 4;
|
|
|
|
if (n_args > 0) {
|
|
|
|
alloc = mp_obj_get_int(args[0]);
|
|
|
|
}
|
2022-04-22 03:09:15 -04:00
|
|
|
mp_obj_poll_t *poll = mp_obj_malloc(mp_obj_poll_t, &mp_type_poll);
|
2015-11-16 17:35:29 -05:00
|
|
|
poll->entries = m_new(struct pollfd, alloc);
|
|
|
|
poll->alloc = alloc;
|
|
|
|
poll->len = 0;
|
2016-12-30 16:07:18 -05:00
|
|
|
poll->obj_map = NULL;
|
2017-02-12 16:23:23 -05:00
|
|
|
poll->iter_cnt = 0;
|
|
|
|
poll->ret_tuple = MP_OBJ_NULL;
|
2015-11-27 12:01:44 -05:00
|
|
|
return MP_OBJ_FROM_PTR(poll);
|
2015-11-16 17:35:29 -05:00
|
|
|
}
|
|
|
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_poll_obj, 0, 1, select_poll);
|
|
|
|
|
2015-11-27 08:38:15 -05:00
|
|
|
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_poll), MP_ROM_PTR(&mp_select_poll_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(POLLIN) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(POLLOUT) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_POLLERR), MP_ROM_INT(POLLERR) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_POLLHUP), MP_ROM_INT(POLLHUP) },
|
2015-11-16 17:35:29 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table);
|
|
|
|
|
|
|
|
const mp_obj_module_t mp_module_uselect = {
|
|
|
|
.base = { &mp_type_module },
|
2020-02-26 23:36:53 -05:00
|
|
|
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
|
2015-11-16 17:35:29 -05:00
|
|
|
};
|
2015-12-13 01:47:00 -05:00
|
|
|
|
2022-05-31 08:56:11 -04:00
|
|
|
MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect);
|
2022-04-20 07:24:01 -04:00
|
|
|
|
2016-11-20 16:48:55 -05:00
|
|
|
#endif // MICROPY_PY_USELECT_POSIX
|