summaryrefslogtreecommitdiffstatshomepage
path: root/py/binary.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-05-09 10:41:00 +1000
committerDamien George <damien.p.george@gmail.com>2017-05-09 10:41:00 +1000
commit6cfa61a4cc60a877836537092d763bce3444588a (patch)
tree8773265bc4bfd77d6592940e50cf9d98b6276b73 /py/binary.c
parent4a4490ffcc906fe88e157dc926be54030c6fbf72 (diff)
downloadmicropython-6cfa61a4cc60a877836537092d763bce3444588a.tar.gz
micropython-6cfa61a4cc60a877836537092d763bce3444588a.zip
py/binary: Handle storing big-ints to all arrays types.
Prior to this patch only 'q' and 'Q' type arrays could store big-int values. With this patch any big int that is stored to an array is handled by the big-int implementation, regardless of the typecode of the array. This allows arrays to work with all type sizes on all architectures.
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/py/binary.c b/py/binary.c
index 6450478cc1..34feb384ea 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -327,9 +327,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
break;
default:
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
- if ((typecode | 0x20) == 'q' && MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
+ if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
+ size_t size = mp_binary_get_size('@', typecode, NULL);
mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG,
- sizeof(long long), (byte*)&((long long*)p)[index]);
+ size, (uint8_t*)p + index * size);
return;
}
#endif