diff options
| author | Kamil Klimek | 2019-10-25 17:28:29 +0200 |
|---|---|---|
| committer | Damien George | 2019-10-29 23:05:07 +1100 |
| commit | 53f3cbc2c4f07236fe022c9c7af20b33443c60b1 (patch) | |
| tree | d963c045b94cedc74672eff4a0af8746cb71c112 | |
| parent | a8138b75b1d3ca8af01e4ad717c6cdb3f733c61d (diff) | |
zephyr/main: Use mp_stack API instead of local pointer for stack top.
The MP_STATE_THREAD(stack_top) is always available so use it instead of
creating a separate variable. This also allows gc_collect() to be used as
an independent function, without real_main() being called.
| -rw-r--r-- | ports/zephyr/main.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ports/zephyr/main.c b/ports/zephyr/main.c index a28fb3792..00dc71e28 100644 --- a/ports/zephyr/main.c +++ b/ports/zephyr/main.c @@ -48,7 +48,6 @@ #include TEST #endif -static char *stack_top; static char heap[MICROPY_HEAP_SIZE]; void init_zephyr(void) { @@ -79,9 +78,7 @@ void init_zephyr(void) { } int real_main(void) { - int stack_dummy; - stack_top = (char*)&stack_dummy; - mp_stack_set_top(stack_top); + mp_stack_ctrl_init(); // Make MicroPython's stack limit somewhat smaller than full stack available mp_stack_set_limit(CONFIG_MAIN_STACK_SIZE - 512); @@ -130,7 +127,7 @@ void gc_collect(void) { // pointers from CPU registers, and thus may function incorrectly. void *dummy; gc_collect_start(); - gc_collect_root(&dummy, ((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); + gc_collect_root(&dummy, ((mp_uint_t)MP_STATE_THREAD(stack_top) - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); gc_collect_end(); //gc_dump_info(); } |
