Skip to content

Commit 746b752

Browse files
committed
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).
1 parent 1f92ffb commit 746b752

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

cc3200/qstrdefsport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ Q(register)
228228
Q(unregister)
229229
Q(modify)
230230
Q(poll)
231+
Q(POLLIN)
232+
Q(POLLOUT)
233+
Q(POLLERR)
234+
Q(POLLHUP)
231235

232236
// for socket class
233237
Q(socket)

stmhal/moduselect.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
285285
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_uselect) },
286286
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
287287
{ MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
288+
{ MP_OBJ_NEW_QSTR(MP_QSTR_POLLIN), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_RD) },
289+
{ MP_OBJ_NEW_QSTR(MP_QSTR_POLLOUT), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_WR) },
290+
{ MP_OBJ_NEW_QSTR(MP_QSTR_POLLERR), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_ERR) },
291+
{ MP_OBJ_NEW_QSTR(MP_QSTR_POLLHUP), MP_OBJ_NEW_SMALL_INT(MP_IOCTL_POLL_HUP) },
288292
};
289293

290294
STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table);

stmhal/pybioctl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#define MP_IOCTL_POLL (0x100 | 1)
22

3+
// These values are compatible with Linux, which are in turn
4+
// compatible with iBCS2 spec.
35
#define MP_IOCTL_POLL_RD (0x0001)
4-
#define MP_IOCTL_POLL_WR (0x0002)
5-
#define MP_IOCTL_POLL_HUP (0x0004)
6+
#define MP_IOCTL_POLL_WR (0x0004)
67
#define MP_IOCTL_POLL_ERR (0x0008)
8+
#define MP_IOCTL_POLL_HUP (0x0010)

stmhal/qstrdefsport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ Q(poll)
427427
Q(register)
428428
Q(unregister)
429429
Q(modify)
430+
Q(POLLIN)
431+
Q(POLLOUT)
432+
Q(POLLERR)
433+
Q(POLLHUP)
430434

431435
// for input
432436
Q(input)

0 commit comments

Comments
 (0)