File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,16 @@ void print_panic_location(const std::source_location& location) noexcept;
58
58
59
59
// / Terminate the program.
60
60
// /
61
- // / The default behaviour of this function is to `abort()`. The behaviour of
62
- // / this function can be overridden by defining a `SUS_PROVIDE_PANIC_HANDLER()`
63
- // / macro when compiling the library.
61
+ // / The default behaviour of this function is to `__builtin_trap()` when
62
+ // / possible and `abort() otherwise`. The behaviour of this function can be
63
+ // / overridden by defining a `SUS_PROVIDE_PANIC_HANDLER()` macro when compiling
64
+ // / the library.
64
65
// /
65
66
// / The panic message will be printed to stderr before aborting. This behaviour
66
67
// / can be overridden by defining a `SUS_PROVIDE_PRINT_PANIC_LOCATION_HANDLER()`
67
- // / macro when compiling the library.
68
+ // / macro when compiling. The same handler must be used as when building the
69
+ // / library itself. So if used as a shared library, it can not be modified by
70
+ // / the calling code.
68
71
// /
69
72
// / # Safety
70
73
// /
@@ -78,8 +81,11 @@ void print_panic_location(const std::source_location& location) noexcept;
78
81
#else
79
82
__private::print_panic_location (location);
80
83
#endif
84
+
81
85
#if defined(SUS_PROVIDE_PANIC_HANDLER)
82
86
SUS_PROVIDE_PANIC_HANDLER ();
87
+ #elif __has_builtin(__builtin_trap)
88
+ __builtin_trap ();
83
89
#else
84
90
abort ();
85
91
#endif
You can’t perform that action at this time.
0 commit comments