diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-10-13 00:37:30 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-10-13 00:37:55 +0300 |
commit | 21f43ba9b0a9a2bc74398e041c6f767a8d1278db (patch) | |
tree | da64f48e0fd5399a36c04ead78456dd10f418717 | |
parent | 3c9c3687d6c1001b88ef6dde200566456a1f2641 (diff) | |
download | micropython-21f43ba9b0a9a2bc74398e041c6f767a8d1278db.tar.gz micropython-21f43ba9b0a9a2bc74398e041c6f767a8d1278db.zip |
unix/modtermios: tcsetattr: If 0 passed for "when" param, treat as TCSANOW.
As we dn't export constants for TCSANOW, etc., zero makes a good "don't
care" param, and now it will work also under Android Bionic and any other
libc.
-rw-r--r-- | unix/modtermios.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/unix/modtermios.c b/unix/modtermios.c index 091e5e5f77..393c6fdcf1 100644 --- a/unix/modtermios.c +++ b/unix/modtermios.c @@ -71,6 +71,14 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t struct termios term; int fd = mp_obj_get_int(fd_in); int when = mp_obj_get_int(when_in); + if (when == 0) { + // We don't export TCSANOW and friends to save on code space. Then + // common lazy sense says that passing 0 should be godo enough, and + // it is e.g. for glibc. But for other libc's it's not, so set just + // treat 0 as defauling to TCSANOW. + when = TCSANOW; + } + assert(MP_OBJ_IS_TYPE(attrs_in, &mp_type_list)); mp_obj_list_t *attrs = attrs_in; |