Skip to content

Commit 013d53c

Browse files
committed
Remove skeletal modselect from extmod and just put it in stmhal.
1 parent e2a6186 commit 013d53c

10 files changed

Lines changed: 36 additions & 93 deletions

File tree

extmod/modselect.c

Lines changed: 0 additions & 74 deletions
This file was deleted.

py/builtin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,3 @@ extern struct _dummy_t mp_sys_stderr_obj;
8989
// extmod modules
9090
extern const mp_obj_module_t mp_module_uctypes;
9191
extern const mp_obj_module_t mp_module_zlibd;
92-
extern const mp_obj_module_t mp_module_select;

py/builtintables.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
200200
#if MICROPY_PY_ZLIBD
201201
{ MP_OBJ_NEW_QSTR(MP_QSTR_zlibd), (mp_obj_t)&mp_module_zlibd },
202202
#endif
203-
#if MICROPY_PY_SELECT
204-
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select },
205-
#endif
206203

207204
// extra builtin modules as defined by a port
208205
MICROPY_PORT_BUILTIN_MODULES

py/mpconfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,6 @@ typedef double mp_float_t;
390390
#define MICROPY_PY_ZLIBD (0)
391391
#endif
392392

393-
#ifndef MICROPY_PY_SELECT
394-
#define MICROPY_PY_SELECT (0)
395-
#endif
396-
397393
/*****************************************************************************/
398394
/* Hooks for a port to add builtins */
399395

py/py.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ PY_O_BASENAME = \
112112
pfenv_printf.o \
113113
../extmod/moductypes.o \
114114
../extmod/modzlibd.o \
115-
../extmod/modselect.o \
116115

117116
# prepend the build destination prefix to the py object files
118117
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))

py/qstrdefs.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,3 @@ Q(deleter)
463463
Q(zlibd)
464464
Q(decompress)
465465
#endif
466-
467-
#if MICROPY_PY_SELECT
468-
Q(select)
469-
Q(poll)
470-
Q(register)
471-
Q(unregister)
472-
Q(modify)
473-
#endif

stmhal/modselect.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
#include "objlist.h"
3838
#include "pybioctl.h"
3939

40-
/// \moduleref select
40+
/// \module select - Provides select function to wait for events on a stream
41+
///
42+
/// This module provides the select function.
4143

4244
typedef struct _poll_obj_t {
4345
mp_obj_t obj;
@@ -278,3 +280,26 @@ STATIC mp_obj_t select_poll(void) {
278280
return poll;
279281
}
280282
MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll);
283+
284+
STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
285+
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_select) },
286+
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
287+
{ MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
288+
};
289+
290+
STATIC const mp_obj_dict_t mp_module_select_globals = {
291+
.base = {&mp_type_dict},
292+
.map = {
293+
.all_keys_are_qstrs = 1,
294+
.table_is_fixed_array = 1,
295+
.used = MP_ARRAY_SIZE(mp_module_select_globals_table),
296+
.alloc = MP_ARRAY_SIZE(mp_module_select_globals_table),
297+
.table = (mp_map_elem_t*)mp_module_select_globals_table,
298+
},
299+
};
300+
301+
const mp_obj_module_t mp_module_select = {
302+
.base = { &mp_type_module },
303+
.name = MP_QSTR_select,
304+
.globals = (mp_obj_dict_t*)&mp_module_select_globals,
305+
};

stmhal/mpconfigport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#define MICROPY_PY_IO_FILEIO (1)
5858
#define MICROPY_PY_UCTYPES (1)
5959
#define MICROPY_PY_ZLIBD (1)
60-
#define MICROPY_PY_SELECT (1)
6160

6261
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
6362
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
@@ -76,6 +75,7 @@ extern const struct _mp_obj_module_t os_module;
7675
extern const struct _mp_obj_module_t pyb_module;
7776
extern const struct _mp_obj_module_t stm_module;
7877
extern const struct _mp_obj_module_t time_module;
78+
extern const struct _mp_obj_module_t mp_module_select;
7979

8080
#if MICROPY_PY_WIZNET5K
8181
extern const struct _mp_obj_module_t mp_module_wiznet5k;
@@ -89,6 +89,7 @@ extern const struct _mp_obj_module_t mp_module_wiznet5k;
8989
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
9090
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
9191
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
92+
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select }, \
9293
MICROPY_PY_WIZNET5K_DEF \
9394

9495
// extra constants

stmhal/portmodules.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern const mp_obj_module_t os_module;
2828
extern const mp_obj_module_t pyb_module;
2929
extern const mp_obj_module_t stm_module;
3030
extern const mp_obj_module_t time_module;
31+
extern const mp_obj_module_t mp_module_select;
3132

3233
// additional helper functions exported by the modules
3334

stmhal/qstrdefsport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ Q(localtime)
269269
Q(mktime)
270270
Q(sleep)
271271

272+
// for select module
273+
Q(select)
274+
Q(poll)
275+
Q(register)
276+
Q(unregister)
277+
Q(modify)
278+
272279
// for input
273280
Q(input)
274281

0 commit comments

Comments
 (0)