py/runtime: Move MICROPY_PORT_INIT_FUNC near the end of mp_init().
This moves the MICROPY_PORT_INIT_FUNC hook to the end of mp_init(), just before MP_THREAD_GIL_ENTER(), so that everything (in particular the GIL mutex) is intialized before the hook is called. MICROPY_PORT_DEINIT_FUNC is also moved to be symmetric (but there is no functional change there). If a port needs to perform initialisation earlier than MICROPY_PORT_INIT_FUNC then it can do it before calling mp_init().
This commit is contained in:
parent
853aaa06f2
commit
339d0816c5
20
py/runtime.c
20
py/runtime.c
@ -81,11 +81,6 @@ void mp_init(void) {
|
||||
MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
|
||||
#endif
|
||||
|
||||
// call port specific initialization if any
|
||||
#ifdef MICROPY_PORT_INIT_FUNC
|
||||
MICROPY_PORT_INIT_FUNC;
|
||||
#endif
|
||||
|
||||
#if MICROPY_ENABLE_COMPILER
|
||||
// optimization disabled by default
|
||||
MP_STATE_VM(mp_optimise_value) = 0;
|
||||
@ -140,19 +135,24 @@ void mp_init(void) {
|
||||
mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
|
||||
#endif
|
||||
|
||||
// call port specific initialization if any
|
||||
#ifdef MICROPY_PORT_INIT_FUNC
|
||||
MICROPY_PORT_INIT_FUNC;
|
||||
#endif
|
||||
|
||||
MP_THREAD_GIL_ENTER();
|
||||
}
|
||||
|
||||
void mp_deinit(void) {
|
||||
MP_THREAD_GIL_EXIT();
|
||||
|
||||
// call port specific deinitialization if any
|
||||
#ifdef MICROPY_PORT_DEINIT_FUNC
|
||||
MICROPY_PORT_DEINIT_FUNC;
|
||||
#endif
|
||||
|
||||
//mp_obj_dict_free(&dict_main);
|
||||
//mp_map_deinit(&MP_STATE_VM(mp_loaded_modules_map));
|
||||
|
||||
// call port specific deinitialization if any
|
||||
#ifdef MICROPY_PORT_DEINIT_FUNC
|
||||
MICROPY_PORT_DEINIT_FUNC;
|
||||
#endif
|
||||
}
|
||||
|
||||
mp_obj_t mp_load_name(qstr qst) {
|
||||
|
Loading…
Reference in New Issue
Block a user