diff options
| author | David Lechner <david@pybricks.com> | 2021-07-06 18:08:18 -0500 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-07-17 23:32:39 +1000 |
| commit | 8758504f0f1c300ec2bc40f4e3b9627c8e8562dd (patch) | |
| tree | fe6a012a700997a406e31536ff80650e088763af | |
| parent | 8be29b9b1b0fc2709d6ace3a9ff32092052359f6 (diff) | |
extmod/moduselect: Conditionally compile select().
This adds #if MICROPY_PY_USELECT_SELECT around the uselect.select()
function. According to the docs, this function is only for CPython
compatibility and should not normally be used. So we can disable it
and save a few bytes of flash space where possible.
Signed-off-by: David Lechner <david@pybricks.com>
| -rw-r--r-- | extmod/moduselect.c | 4 | ||||
| -rw-r--r-- | py/mpconfig.h | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/extmod/moduselect.c b/extmod/moduselect.c index fbd51960d..cf47f02af 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -107,6 +107,7 @@ STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) { return n_ready; } +#if MICROPY_PY_USELECT_SELECT // select(rlist, wlist, xlist[, timeout]) STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { // get array data from tuple/list arguments @@ -173,6 +174,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); +#endif // MICROPY_PY_USELECT_SELECT typedef struct _mp_obj_poll_t { mp_obj_base_t base; @@ -355,7 +357,9 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, + #if MICROPY_PY_USELECT_SELECT { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, + #endif { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, { MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) }, { MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) }, diff --git a/py/mpconfig.h b/py/mpconfig.h index 48c4c6d34..f67e11cd4 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1316,6 +1316,13 @@ typedef double mp_float_t; #define MICROPY_PY_USELECT (0) #endif +// Whether to enable the select() function in the "uselect" module (baremetal +// implementation). This is present for compatibility but can be disabled to +// save space. +#ifndef MICROPY_PY_USELECT_SELECT +#define MICROPY_PY_USELECT_SELECT (1) +#endif + // Whether to provide "utime" module functions implementation // in terms of mp_hal_* functions. #ifndef MICROPY_PY_UTIME_MP_HAL |
