embed: Improve stack top estimation.

Obtaining the stack-top via a few function calls may yield a pointer which
is too deep within the stack.  So require the user to obtain it from a
higher level (or via some other means).

Fixes issue #11781.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
This commit is contained in:
YAMAMOTO Takashi
2024-02-09 14:03:00 +09:00
committed by Damien George
parent be8d660fc2
commit d2a3cd7ac4
3 changed files with 11 additions and 4 deletions

View File

@@ -34,8 +34,8 @@
#include "port/micropython_embed.h"
// Initialise the runtime.
void mp_embed_init(void *gc_heap, size_t gc_heap_size) {
mp_stack_ctrl_init();
void mp_embed_init(void *gc_heap, size_t gc_heap_size, void *stack_top) {
mp_stack_set_top(stack_top);
gc_init(gc_heap, (uint8_t *)gc_heap + gc_heap_size);
mp_init();
}

View File

@@ -29,7 +29,7 @@
#include <stddef.h>
#include <stdint.h>
void mp_embed_init(void *gc_heap, size_t gc_heap_size);
void mp_embed_init(void *gc_heap, size_t gc_heap_size, void *stack_top);
void mp_embed_deinit(void);
// Only available if MICROPY_ENABLE_COMPILER is enabled.