Skip to content

Commit c8b80e4

Browse files
committed
lib/embed/abort_: Implementation of abort_() function raising uPy exception.
Helpful when porting existing C libraries to MicroPython. abort()ing in embedded environment isn't a good idea, so when compiling such library, -Dabort=abort_ option can be given to redirect standard abort() to this "safe" version.
1 parent 4f1b029 commit c8b80e4

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/embed/abort_.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <py/runtime.h>
2+
3+
void abort_(void) {
4+
nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "abort() called"));
5+
}

py/py.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ PY_O_BASENAME = \
221221
../extmod/vfs_fat_lexer.o \
222222
../extmod/vfs_fat_misc.o \
223223
../extmod/moduos_dupterm.o \
224+
../lib/embed/abort_.o \
224225

225226
# prepend the build destination prefix to the py object files
226227
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))

0 commit comments

Comments
 (0)