diff options
author | Damien George <damien.p.george@gmail.com> | 2015-11-27 17:01:44 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-29 14:25:35 +0000 |
commit | 999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch) | |
tree | 897eb07b82f1893cfd413b9ef7f625cd996f859d /unix/modtermios.c | |
parent | cbf7674025814797f5c537d6d1c195efe58ccaaf (diff) |
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.
This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
Diffstat (limited to 'unix/modtermios.c')
-rw-r--r-- | unix/modtermios.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/unix/modtermios.c b/unix/modtermios.c index c49014c94..a70edf5bf 100644 --- a/unix/modtermios.c +++ b/unix/modtermios.c @@ -44,7 +44,7 @@ STATIC mp_obj_t mod_termios_tcgetattr(mp_obj_t fd_in) { int res = tcgetattr(fd, &term); RAISE_ERRNO(res, errno); - mp_obj_list_t *r = mp_obj_new_list(7, NULL); + mp_obj_list_t *r = MP_OBJ_TO_PTR(mp_obj_new_list(7, NULL)); r->items[0] = MP_OBJ_NEW_SMALL_INT(term.c_iflag); r->items[1] = MP_OBJ_NEW_SMALL_INT(term.c_oflag); r->items[2] = MP_OBJ_NEW_SMALL_INT(term.c_cflag); @@ -52,8 +52,8 @@ STATIC mp_obj_t mod_termios_tcgetattr(mp_obj_t fd_in) { r->items[4] = MP_OBJ_NEW_SMALL_INT(cfgetispeed(&term)); r->items[5] = MP_OBJ_NEW_SMALL_INT(cfgetospeed(&term)); - mp_obj_list_t *cc = mp_obj_new_list(NCCS, NULL); - r->items[6] = cc; + mp_obj_list_t *cc = MP_OBJ_TO_PTR(mp_obj_new_list(NCCS, NULL)); + r->items[6] = MP_OBJ_FROM_PTR(cc); for (int i = 0; i < NCCS; i++) { if (i == VMIN || i == VTIME) { cc->items[i] = MP_OBJ_NEW_SMALL_INT(term.c_cc[i]); @@ -63,7 +63,7 @@ STATIC mp_obj_t mod_termios_tcgetattr(mp_obj_t fd_in) { cc->items[i] = mp_obj_new_bytes(&term.c_cc[i], 1); } } - return r; + return MP_OBJ_FROM_PTR(r); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_termios_tcgetattr_obj, mod_termios_tcgetattr); @@ -80,14 +80,14 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t } assert(MP_OBJ_IS_TYPE(attrs_in, &mp_type_list)); - mp_obj_list_t *attrs = attrs_in; + mp_obj_list_t *attrs = MP_OBJ_TO_PTR(attrs_in); term.c_iflag = mp_obj_get_int(attrs->items[0]); term.c_oflag = mp_obj_get_int(attrs->items[1]); term.c_cflag = mp_obj_get_int(attrs->items[2]); term.c_lflag = mp_obj_get_int(attrs->items[3]); - mp_obj_list_t *cc = attrs->items[6]; + mp_obj_list_t *cc = MP_OBJ_TO_PTR(attrs->items[6]); for (int i = 0; i < NCCS; i++) { if (i == VMIN || i == VTIME) { term.c_cc[i] = mp_obj_get_int(cc->items[i]); |