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).
This commit is contained in:
parent
1f92ffb5b7
commit
746b752b8e
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -427,6 +427,10 @@ Q(poll)
|
|||
Q(register)
|
||||
Q(unregister)
|
||||
Q(modify)
|
||||
Q(POLLIN)
|
||||
Q(POLLOUT)
|
||||
Q(POLLERR)
|
||||
Q(POLLHUP)
|
||||
|
||||
// for input
|
||||
Q(input)
|
||||
|
|
Loading…
Reference in New Issue