From 746b752b8efd089c8dd37e615949315973a8d370 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 9 Nov 2015 22:10:01 +0200 Subject: [PATCH] stmhal/moduselect: Expose POLLIN/OUT/ERR/HUP constants. This makes select.poll() interface fully compatible with CpYthon. Also, make their numeric values of these options compatible with Linux (and by extension, with iBCS2 standard, which jopefully means compatibility with other Unices too). --- cc3200/qstrdefsport.h | 4 ++++ stmhal/moduselect.c | 4 ++++ stmhal/pybioctl.h | 6 ++++-- stmhal/qstrdefsport.h | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cc3200/qstrdefsport.h b/cc3200/qstrdefsport.h index c4039d012b..d88c05a0f7 100644 --- a/cc3200/qstrdefsport.h +++ b/cc3200/qstrdefsport.h @@ -228,6 +228,10 @@ Q(register) Q(unregister) Q(modify) Q(poll) +Q(POLLIN) +Q(POLLOUT) +Q(POLLERR) +Q(POLLHUP) // for socket class Q(socket) diff --git a/stmhal/moduselect.c b/stmhal/moduselect.c index 232520ec44..592c3fa3f8 100644 --- a/stmhal/moduselect.c +++ b/stmhal/moduselect.c @@ -285,6 +285,10 @@ STATIC const mp_map_elem_t mp_module_select_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_uselect) }, { 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 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_POLLIN), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_RD) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_POLLOUT), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_WR) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_POLLERR), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_ERR) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_POLLHUP), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_HUP) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); diff --git a/stmhal/pybioctl.h b/stmhal/pybioctl.h index 79f994b8b6..b71e04ed5d 100644 --- a/stmhal/pybioctl.h +++ b/stmhal/pybioctl.h @@ -1,6 +1,8 @@ #define MP_IOCTL_POLL (0x100 | 1) +// These values are compatible with Linux, which are in turn +// compatible with iBCS2 spec. #define MP_IOCTL_POLL_RD (0x0001) -#define MP_IOCTL_POLL_WR (0x0002) -#define MP_IOCTL_POLL_HUP (0x0004) +#define MP_IOCTL_POLL_WR (0x0004) #define MP_IOCTL_POLL_ERR (0x0008) +#define MP_IOCTL_POLL_HUP (0x0010) diff --git a/stmhal/qstrdefsport.h b/stmhal/qstrdefsport.h index e2eabe3a3f..5cb2557a7a 100644 --- a/stmhal/qstrdefsport.h +++ b/stmhal/qstrdefsport.h @@ -427,6 +427,10 @@ Q(poll) Q(register) Q(unregister) Q(modify) +Q(POLLIN) +Q(POLLOUT) +Q(POLLERR) +Q(POLLHUP) // for input Q(input)