mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python] Fixed the Python stack length computation.
On the device, the stack is stored in reverse order, but it might not be the case on other platforms, which changes stack length computation. Change-Id: I0218224a77465b9672f137771c00f734fdfaea64
This commit is contained in:
@@ -133,7 +133,17 @@ void gc_collect(void) {
|
||||
setjmp(regs);
|
||||
|
||||
void **regs_ptr = (void**)(void*)®s;
|
||||
gc_collect_root(regs_ptr, ((uintptr_t)python_stack_top - (uintptr_t)®s) / sizeof(uintptr_t));
|
||||
|
||||
/* On the device, the stack is stored in reverse order, but it might not be
|
||||
* the case on a computer. We thus have to take the absolute value of the
|
||||
* addresses difference. */
|
||||
size_t stackLength;
|
||||
if ((uintptr_t)python_stack_top > (uintptr_t)(®s)) {
|
||||
stackLength = (((uintptr_t)python_stack_top - (uintptr_t)(®s)) / sizeof(uintptr_t));
|
||||
} else {
|
||||
stackLength = (((uintptr_t)(®s) - (uintptr_t)python_stack_top) / sizeof(uintptr_t));
|
||||
}
|
||||
gc_collect_root(regs_ptr, stackLength);
|
||||
|
||||
gc_collect_end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user