diff options
author | Damien George <damien@micropython.org> | 2024-07-18 13:24:27 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-07-20 12:18:07 +1000 |
commit | 5f3ecc29f8f0d69d15710ded3278fe055f532517 (patch) | |
tree | cbc86f92b5013e21b4f03421d2c16d1e0c552740 /extmod | |
parent | 69c25ea8653566ec97690b5121bd10b753c89426 (diff) | |
download | micropython-5f3ecc29f8f0d69d15710ded3278fe055f532517.tar.gz micropython-5f3ecc29f8f0d69d15710ded3278fe055f532517.zip |
extmod/modmachine: Use sys.exit as implementation of machine.soft_reset.
It does the same thing, raising `SystemExit`.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod')
-rw-r--r-- | extmod/modmachine.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/extmod/modmachine.c b/extmod/modmachine.c index a423d8067c..5906835949 100644 --- a/extmod/modmachine.c +++ b/extmod/modmachine.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "py/builtin.h" #include "py/runtime.h" #if MICROPY_PY_MACHINE @@ -35,6 +36,10 @@ #include "drivers/dht/dht.h" #endif +#if !MICROPY_PY_SYS_EXIT +#error MICROPY_PY_MACHINE requires MICROPY_PY_SYS_EXIT +#endif + // The port must provide implementations of these low-level machine functions. static void mp_machine_idle(void); @@ -61,11 +66,6 @@ NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args); #include MICROPY_PY_MACHINE_INCLUDEFILE #endif -static mp_obj_t machine_soft_reset(void) { - mp_raise_type(&mp_type_SystemExit); -} -static MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset); - #if MICROPY_PY_MACHINE_BOOTLOADER NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) { mp_machine_bootloader(n_args, args); @@ -156,7 +156,7 @@ static const mp_rom_map_elem_t machine_module_globals_table[] = { #endif // Reset related functions. - { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&mp_sys_exit_obj) }, #if MICROPY_PY_MACHINE_BOOTLOADER { MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) }, #endif |