kendryte / kendryte-gnu-toolchain

Kendryte GNU Toolchain
Other
74 stars 25 forks source link

I found a problem with the type size. #1

Closed xiaoxiaohuixxh closed 5 years ago

xiaoxiaohuixxh commented 5 years ago

run printf("void %d, uintptr_t %d, mp_int_t %d, mp_uint_t %d, uintptr_t %d\n",sizeof(void*),sizeof(uintptr_t), sizeof(mp_int_t), sizeof(mp_uint_t),sizeof(uintptr_t)); res:void 8, uintptr_t 8, mp_int_t 4, mp_uint_t 4, uintptr_t 8

minux commented 5 years ago

Do you mean that the size of mp_int_t and mp_uint_t should be 8 instead of 4? (I assume you're talking about types in micropython.)

This has nothing to do with the toolchain. You should report this to the micropython maintainers. (But please note: on K210, you could truncate the higher 32-bit of a pointer and still retain all the essential address information: the physical address space is only 32-bit even though it's a 64-bit CPU. Therefore, there is nothing wrong with using 32-bit mp_int_t and mp_uint_t.)

xiaoxiaohuixxh commented 5 years ago

void ptr = (void)(uintptr_t)code_state->fun_bc->const_table[unum] addr only left shift 32bit when the unum add one。 but void ptr = (void)(uint64_t *)code_state->fun_bc->const_table[unum] it run well

xiaoxiaohuixxh commented 5 years ago

uintptr_t should be defined by stdint.h, and it should be the same size as a pointer word.

minux commented 5 years ago

In the output you've shown, sizeof(uintptr_t) = 8, as expected.

minux commented 5 years ago

Timed out, closing.

@xiaoxiaohuixxh please reopen this issue if you find the toolchain is using 32-bit uintptr_t.