diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 17:37:53 +0200 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 20:01:29 +0200 |
commit | b8c6c850421d0d81bb5ea9c340c4fcd958937165 (patch) | |
tree | ad436a0c375e70201bbf23631ca7fb94b2a80832 /cores/arduino/abi.cpp | |
parent | 4e469e0c83799ad6d3698e7cfa51ef8a5f2a2c76 (diff) |
Add weak `std::terminate()` implementation
This allows calling it from other places later. The default
implementation calls `abort()`, but making it weak allows user code to
override this function (either directly, or by including a library like
uclibc++ that implements `std::set_terminate()`).
Note that this does not add a declaration for this function, since the
standard dictates this to be in `<exception>`, but we cannot
meaningfully or completely implement that header, so better leave it to
be overridden by e.g. libraries like uclibc++.
Diffstat (limited to 'cores/arduino/abi.cpp')
-rw-r--r-- | cores/arduino/abi.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp index 8d719b8..b8f76cf 100644 --- a/cores/arduino/abi.cpp +++ b/cores/arduino/abi.cpp @@ -21,6 +21,12 @@ extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); +namespace std { + [[gnu::weak, noreturn]] void terminate() { + abort(); + } +} + void __cxa_pure_virtual(void) { // We might want to write some diagnostics to uart in this case //std::terminate(); |