Commit 746b752b authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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).
parent 1f92ffb5
...@@ -228,6 +228,10 @@ Q(register) ...@@ -228,6 +228,10 @@ Q(register)
Q(unregister) Q(unregister)
Q(modify) Q(modify)
Q(poll) Q(poll)
Q(POLLIN)
Q(POLLOUT)
Q(POLLERR)
Q(POLLHUP)
// for socket class // for socket class
Q(socket) Q(socket)
......
...@@ -285,6 +285,10 @@ STATIC const mp_map_elem_t mp_module_select_globals_table[] = { ...@@ -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___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_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_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); STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table);
......
#define MP_IOCTL_POLL (0x100 | 1) #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_RD (0x0001)
#define MP_IOCTL_POLL_WR (0x0002) #define MP_IOCTL_POLL_WR (0x0004)
#define MP_IOCTL_POLL_HUP (0x0004)
#define MP_IOCTL_POLL_ERR (0x0008) #define MP_IOCTL_POLL_ERR (0x0008)
#define MP_IOCTL_POLL_HUP (0x0010)
...@@ -427,6 +427,10 @@ Q(poll) ...@@ -427,6 +427,10 @@ Q(poll)
Q(register) Q(register)
Q(unregister) Q(unregister)
Q(modify) Q(modify)
Q(POLLIN)
Q(POLLOUT)
Q(POLLERR)
Q(POLLHUP)
// for input // for input
Q(input) Q(input)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment