summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-26 17:18:12 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-07 20:42:01 +0100
commit013d53c0b48cd22ef9476f048c2f944a86d5ce67 (patch)
tree753686da1b33b96829df9b2c4d3bd4f9739a9ea7
parente2a618615df33d884dde975c3e0a0727d9ea9629 (diff)
downloadmicropython-013d53c0b48cd22ef9476f048c2f944a86d5ce67.tar.gz
micropython-013d53c0b48cd22ef9476f048c2f944a86d5ce67.zip
Remove skeletal modselect from extmod and just put it in stmhal.
-rw-r--r--extmod/modselect.c74
-rw-r--r--py/builtin.h1
-rw-r--r--py/builtintables.c3
-rw-r--r--py/mpconfig.h4
-rw-r--r--py/py.mk1
-rw-r--r--py/qstrdefs.h8
-rw-r--r--stmhal/modselect.c27
-rw-r--r--stmhal/mpconfigport.h3
-rw-r--r--stmhal/portmodules.h1
-rw-r--r--stmhal/qstrdefsport.h7
10 files changed, 36 insertions, 93 deletions
diff --git a/extmod/modselect.c b/extmod/modselect.c
deleted file mode 100644
index 64f0517bdc..0000000000
--- a/extmod/modselect.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Damien P. George
- *
- * 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.
- */
-
-#include <assert.h>
-#include <string.h>
-#include <stdint.h>
-#include "mpconfig.h"
-#include "misc.h"
-#include "nlr.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "objtuple.h"
-#include "binary.h"
-
-#if MICROPY_PY_SELECT
-
-/// \module select - Provides select function to wait for events on a stream
-///
-/// This module provides the select function.
-
-// This is just a skeleton. Individual functions must be implemented by a port.
-// For the following, specific types don't matter, only addresses.
-struct _dummy_t;
-extern struct _dummy_t mp_select_select_obj;
-extern struct _dummy_t mp_select_poll_obj;
-
-STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
- { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_select) },
- { MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
- { MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
-};
-
-STATIC const mp_obj_dict_t mp_module_select_globals = {
- .base = {&mp_type_dict},
- .map = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = MP_ARRAY_SIZE(mp_module_select_globals_table),
- .alloc = MP_ARRAY_SIZE(mp_module_select_globals_table),
- .table = (mp_map_elem_t*)mp_module_select_globals_table,
- },
-};
-
-const mp_obj_module_t mp_module_select = {
- .base = { &mp_type_module },
- .name = MP_QSTR_select,
- .globals = (mp_obj_dict_t*)&mp_module_select_globals,
-};
-
-#endif // MICROPY_PY_SELECT
diff --git a/py/builtin.h b/py/builtin.h
index 2ccd4481a2..1bb61f6ebc 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -89,4 +89,3 @@ extern struct _dummy_t mp_sys_stderr_obj;
// extmod modules
extern const mp_obj_module_t mp_module_uctypes;
extern const mp_obj_module_t mp_module_zlibd;
-extern const mp_obj_module_t mp_module_select;
diff --git a/py/builtintables.c b/py/builtintables.c
index ad2e0bb55f..08b6b16493 100644
--- a/py/builtintables.c
+++ b/py/builtintables.c
@@ -200,9 +200,6 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
#if MICROPY_PY_ZLIBD
{ MP_OBJ_NEW_QSTR(MP_QSTR_zlibd), (mp_obj_t)&mp_module_zlibd },
#endif
-#if MICROPY_PY_SELECT
- { MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select },
-#endif
// extra builtin modules as defined by a port
MICROPY_PORT_BUILTIN_MODULES
diff --git a/py/mpconfig.h b/py/mpconfig.h
index fc5d6ce2e1..adbcb0eb71 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -390,10 +390,6 @@ typedef double mp_float_t;
#define MICROPY_PY_ZLIBD (0)
#endif
-#ifndef MICROPY_PY_SELECT
-#define MICROPY_PY_SELECT (0)
-#endif
-
/*****************************************************************************/
/* Hooks for a port to add builtins */
diff --git a/py/py.mk b/py/py.mk
index 9101704b7e..e2288d3821 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -112,7 +112,6 @@ PY_O_BASENAME = \
pfenv_printf.o \
../extmod/moductypes.o \
../extmod/modzlibd.o \
- ../extmod/modselect.o \
# prepend the build destination prefix to the py object files
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 68681e47be..d41029a1fa 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -463,11 +463,3 @@ Q(deleter)
Q(zlibd)
Q(decompress)
#endif
-
-#if MICROPY_PY_SELECT
-Q(select)
-Q(poll)
-Q(register)
-Q(unregister)
-Q(modify)
-#endif
diff --git a/stmhal/modselect.c b/stmhal/modselect.c
index c7ef3bbec6..6594ad2180 100644
--- a/stmhal/modselect.c
+++ b/stmhal/modselect.c
@@ -37,7 +37,9 @@
#include "objlist.h"
#include "pybioctl.h"
-/// \moduleref select
+/// \module select - Provides select function to wait for events on a stream
+///
+/// This module provides the select function.
typedef struct _poll_obj_t {
mp_obj_t obj;
@@ -278,3 +280,26 @@ STATIC mp_obj_t select_poll(void) {
return poll;
}
MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll);
+
+STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
+ { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_select) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
+};
+
+STATIC const mp_obj_dict_t mp_module_select_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = MP_ARRAY_SIZE(mp_module_select_globals_table),
+ .alloc = MP_ARRAY_SIZE(mp_module_select_globals_table),
+ .table = (mp_map_elem_t*)mp_module_select_globals_table,
+ },
+};
+
+const mp_obj_module_t mp_module_select = {
+ .base = { &mp_type_module },
+ .name = MP_QSTR_select,
+ .globals = (mp_obj_dict_t*)&mp_module_select_globals,
+};
diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h
index 1365604417..bfd399a76e 100644
--- a/stmhal/mpconfigport.h
+++ b/stmhal/mpconfigport.h
@@ -57,7 +57,6 @@
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_UCTYPES (1)
#define MICROPY_PY_ZLIBD (1)
-#define MICROPY_PY_SELECT (1)
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
@@ -76,6 +75,7 @@ extern const struct _mp_obj_module_t os_module;
extern const struct _mp_obj_module_t pyb_module;
extern const struct _mp_obj_module_t stm_module;
extern const struct _mp_obj_module_t time_module;
+extern const struct _mp_obj_module_t mp_module_select;
#if MICROPY_PY_WIZNET5K
extern const struct _mp_obj_module_t mp_module_wiznet5k;
@@ -89,6 +89,7 @@ extern const struct _mp_obj_module_t mp_module_wiznet5k;
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select }, \
MICROPY_PY_WIZNET5K_DEF \
// extra constants
diff --git a/stmhal/portmodules.h b/stmhal/portmodules.h
index 491df6bc49..d71f74e73c 100644
--- a/stmhal/portmodules.h
+++ b/stmhal/portmodules.h
@@ -28,6 +28,7 @@ extern const mp_obj_module_t os_module;
extern const mp_obj_module_t pyb_module;
extern const mp_obj_module_t stm_module;
extern const mp_obj_module_t time_module;
+extern const mp_obj_module_t mp_module_select;
// additional helper functions exported by the modules
diff --git a/stmhal/qstrdefsport.h b/stmhal/qstrdefsport.h
index ab5b23f59f..7f19d1f09b 100644
--- a/stmhal/qstrdefsport.h
+++ b/stmhal/qstrdefsport.h
@@ -269,6 +269,13 @@ Q(localtime)
Q(mktime)
Q(sleep)
+// for select module
+Q(select)
+Q(poll)
+Q(register)
+Q(unregister)
+Q(modify)
+
// for input
Q(input)