Skip to content

Commit fe997bd

Browse files
committed
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>
1 parent 773fcbe commit fe997bd

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

extmod/modmachine.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include "drivers/dht/dht.h"
3636
#endif
3737

38+
#if !MICROPY_PY_SYS_EXIT
39+
#error MICROPY_PY_MACHINE requires MICROPY_PY_SYS_EXIT
40+
#endif
41+
3842
// The port must provide implementations of these low-level machine functions.
3943

4044
static void mp_machine_idle(void);
@@ -61,11 +65,6 @@ NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args);
6165
#include MICROPY_PY_MACHINE_INCLUDEFILE
6266
#endif
6367

64-
static mp_obj_t machine_soft_reset(void) {
65-
mp_raise_type(&mp_type_SystemExit);
66-
}
67-
static MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
68-
6968
#if MICROPY_PY_MACHINE_BOOTLOADER
7069
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
7170
mp_machine_bootloader(n_args, args);
@@ -156,7 +155,7 @@ static const mp_rom_map_elem_t machine_module_globals_table[] = {
156155
#endif
157156

158157
// Reset related functions.
159-
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) },
158+
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&mp_sys_exit_obj) },
160159
#if MICROPY_PY_MACHINE_BOOTLOADER
161160
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
162161
#endif

py/builtin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ MP_DECLARE_CONST_FUN_OBJ_2(mp_op_getitem_obj);
126126
MP_DECLARE_CONST_FUN_OBJ_3(mp_op_setitem_obj);
127127
MP_DECLARE_CONST_FUN_OBJ_2(mp_op_delitem_obj);
128128

129+
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj);
130+
129131
// Modules needed by the runtime.
130132
extern const mp_obj_dict_t mp_module_builtins_globals;
131133
extern const mp_obj_module_t mp_module___main__;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy