From 999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 27 Nov 2015 17:01:44 +0000 Subject: 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. --- unix/modos.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'unix/modos.c') diff --git a/unix/modos.c b/unix/modos.c index 3e8c5a6eb4..faf33dac9c 100644 --- a/unix/modos.c +++ b/unix/modos.c @@ -53,7 +53,7 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) { int res = stat(path, &sb); RAISE_ERRNO(res, errno); - mp_obj_tuple_t *t = mp_obj_new_tuple(10, NULL); + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); t->items[0] = MP_OBJ_NEW_SMALL_INT(sb.st_mode); t->items[1] = MP_OBJ_NEW_SMALL_INT(sb.st_ino); t->items[2] = MP_OBJ_NEW_SMALL_INT(sb.st_dev); @@ -64,7 +64,7 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) { t->items[7] = MP_OBJ_NEW_SMALL_INT(sb.st_atime); t->items[8] = MP_OBJ_NEW_SMALL_INT(sb.st_mtime); t->items[9] = MP_OBJ_NEW_SMALL_INT(sb.st_ctime); - return t; + return MP_OBJ_FROM_PTR(t); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_stat_obj, mod_os_stat); @@ -94,7 +94,7 @@ STATIC mp_obj_t mod_os_statvfs(mp_obj_t path_in) { int res = STATVFS(path, &sb); RAISE_ERRNO(res, errno); - mp_obj_tuple_t *t = mp_obj_new_tuple(10, NULL); + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); t->items[0] = MP_OBJ_NEW_SMALL_INT(sb.f_bsize); t->items[1] = MP_OBJ_NEW_SMALL_INT(sb.f_frsize); t->items[2] = MP_OBJ_NEW_SMALL_INT(sb.f_blocks); @@ -105,7 +105,7 @@ STATIC mp_obj_t mod_os_statvfs(mp_obj_t path_in) { t->items[7] = MP_OBJ_NEW_SMALL_INT(F_FAVAIL); t->items[8] = MP_OBJ_NEW_SMALL_INT(F_FLAG); t->items[9] = MP_OBJ_NEW_SMALL_INT(F_NAMEMAX); - return t; + return MP_OBJ_FROM_PTR(t); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_statvfs_obj, mod_os_statvfs); #endif -- cgit v1.2.3