summaryrefslogtreecommitdiff
path: root/py/modthread.c
diff options
context:
space:
mode:
authorDaniël van de Giessen <daniel@dvdgiessen.nl>2024-02-28 12:41:41 +0100
committerDaniël van de Giessen <daniel@dvdgiessen.nl>2024-02-29 14:28:58 +0100
commitbc424ddc4165ffd8203b4e781f7c686598601e15 (patch)
tree2cd881caccdb3605fa4f68d71e23d4d820c66b47 /py/modthread.c
parent678707c8b07323c5b914778708a2858387c3b60c (diff)
py/modthread: Move thread state initialisation to shared function.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Diffstat (limited to 'py/modthread.c')
-rw-r--r--py/modthread.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/py/modthread.c b/py/modthread.c
index 3a8a1e03c..9fc20570b 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -160,10 +160,7 @@ STATIC void *thread_entry(void *args_in) {
thread_entry_args_t *args = (thread_entry_args_t *)args_in;
mp_state_thread_t ts;
- mp_thread_set_state(&ts);
-
- mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
- mp_stack_set_limit(args->stack_size);
+ mp_thread_init_state(&ts, args->stack_size, args->dict_locals, args->dict_globals);
#if MICROPY_ENABLE_PYSTACK
// TODO threading and pystack is not fully supported, for now just make a small stack
@@ -171,16 +168,6 @@ STATIC void *thread_entry(void *args_in) {
mp_pystack_init(mini_pystack, &mini_pystack[128]);
#endif
- // The GC starts off unlocked on this thread.
- ts.gc_lock_depth = 0;
-
- ts.nlr_jump_callback_top = NULL;
- ts.mp_pending_exception = MP_OBJ_NULL;
-
- // set locals and globals from the calling context
- mp_locals_set(args->dict_locals);
- mp_globals_set(args->dict_globals);
-
MP_THREAD_GIL_ENTER();
// signal that we are set up and running