summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-07-02 15:05:41 -0500
committerDamien George <damien@micropython.org>2022-07-18 13:52:01 +1000
commit85b4f36100aceeddd246f8b3a64436adc8dff867 (patch)
tree860e71761ed5fbf61f9f00b6e5117c992e0bd76d
parenta98aa66df64e2676a311139f43dee9d13bae2c42 (diff)
downloadmicropython-85b4f36100aceeddd246f8b3a64436adc8dff867.tar.gz
micropython-85b4f36100aceeddd246f8b3a64436adc8dff867.zip
py/modsys: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register cur_exception, sys_exitfunc, mp_sys_path_obj, mp_sys_argv_obj and sys_mutable instead of using a conditional inside of mp_state_vm_t. Signed-off-by: David Lechner <david@pybricks.com>
-rw-r--r--py/modsys.c20
-rw-r--r--py/mpstate.h22
2 files changed, 20 insertions, 22 deletions
diff --git a/py/modsys.c b/py/modsys.c
index a090f1212d..56e83029c4 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -286,4 +286,24 @@ const mp_obj_module_t mp_module_sys = {
MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys);
+// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists
+// must be initialised after the call to mp_init.
+MP_REGISTER_ROOT_POINTER(mp_obj_list_t mp_sys_path_obj);
+MP_REGISTER_ROOT_POINTER(mp_obj_list_t mp_sys_argv_obj);
+
+#if MICROPY_PY_SYS_EXC_INFO
+// current exception being handled, for sys.exc_info()
+MP_REGISTER_ROOT_POINTER(mp_obj_base_t * cur_exception);
+#endif
+
+#if MICROPY_PY_SYS_ATEXIT
+// exposed through sys.atexit function
+MP_REGISTER_ROOT_POINTER(mp_obj_t sys_exitfunc);
#endif
+
+#if MICROPY_PY_SYS_ATTR_DELEGATION
+// Contains mutable sys attributes.
+MP_REGISTER_ROOT_POINTER(mp_obj_t sys_mutable[MP_SYS_MUTABLE_NUM]);
+#endif
+
+#endif // MICROPY_PY_SYS
diff --git a/py/mpstate.h b/py/mpstate.h
index 87d367769e..b7c41c81fc 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -154,31 +154,9 @@ typedef struct _mp_state_vm_t {
mp_sched_item_t sched_queue[MICROPY_SCHEDULER_DEPTH];
#endif
- // current exception being handled, for sys.exc_info()
- #if MICROPY_PY_SYS_EXC_INFO
- mp_obj_base_t *cur_exception;
- #endif
-
- #if MICROPY_PY_SYS_ATEXIT
- // exposed through sys.atexit function
- mp_obj_t sys_exitfunc;
- #endif
-
// dictionary for the __main__ module
mp_obj_dict_t dict_main;
- #if MICROPY_PY_SYS
- // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists
- // must be initialised after the call to mp_init.
- mp_obj_list_t mp_sys_path_obj;
- mp_obj_list_t mp_sys_argv_obj;
-
- #if MICROPY_PY_SYS_ATTR_DELEGATION
- // Contains mutable sys attributes.
- mp_obj_t sys_mutable[MP_SYS_MUTABLE_NUM];
- #endif
- #endif
-
// dictionary for overridden builtins
#if MICROPY_CAN_OVERRIDE_BUILTINS
mp_obj_dict_t *mp_module_builtins_override_dict;