Just getting my feet wet with the MicroPython codebase, and porting it to an ARM-based platform.
I think I understand how the heap works in the "minimal" platform design, but I was surprised that it was an array of "char" instead of an array of "uint32_t". On a platform that requires alignment of 32-bit values, wouldn't it make more sense to create an array of uint32_t to use for the heap? Does it happen to work with that platform because the heap is allocated after "stack_top", which is a pointer and therefore aligned?
Heap allocation and uint32_t alignment
Re: Heap allocation and uint32_t alignment
I agree that it would be safer to declare the heap as an array of unit32_t's.
On stmhal, the heap is aligned in the linker script file.
On unix, the heap is allocated from the C runtime heap, so its automatically aligned.
The fact that its declared after stacktop will make it be 4-byte aligned, but it could be unaligned if you changed the code.
On stmhal, the heap is aligned in the linker script file.
On unix, the heap is allocated from the C runtime heap, so its automatically aligned.
The fact that its declared after stacktop will make it be 4-byte aligned, but it could be unaligned if you changed the code.