aboutsummaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 17:01:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-29 14:25:35 +0000
commit999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch)
tree897eb07b82f1893cfd413b9ef7f625cd996f859d /py/binary.c
parentcbf7674025814797f5c537d6d1c195efe58ccaaf (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 'py/binary.c')
-rw-r--r--py/binary.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/py/binary.c b/py/binary.c
index c9ce0585d..699324bc6 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -147,7 +147,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
return ((mp_obj_t*)p)[index];
// Extension to CPython: array of pointers
case 'P':
- return mp_obj_new_int((mp_int_t)((void**)p)[index]);
+ return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]);
}
return MP_OBJ_NEW_SMALL_INT(val);
}
@@ -199,7 +199,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
if (val_type == 'O') {
return (mp_obj_t)(mp_uint_t)val;
} else if (val_type == 'S') {
- const char *s_val = (const char*)(mp_uint_t)val;
+ const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val;
return mp_obj_new_str(s_val, strlen(s_val), false);
#if MICROPY_PY_BUILTINS_FLOAT
} else if (val_type == 'f') {
@@ -374,6 +374,6 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
#endif
// Extension to CPython: array of pointers
case 'P':
- ((void**)p)[index] = (void*)val;
+ ((void**)p)[index] = (void*)(uintptr_t)val;
}
}