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;
5858
5959// / Terminate the program.
6060// /
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.
6465// /
6566// / The panic message will be printed to stderr before aborting. This behaviour
6667// / 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.
6871// /
6972// / # Safety
7073// /
@@ -78,8 +81,11 @@ void print_panic_location(const std::source_location& location) noexcept;
7881#else
7982 __private::print_panic_location (location);
8083#endif
84+
8185#if defined(SUS_PROVIDE_PANIC_HANDLER)
8286 SUS_PROVIDE_PANIC_HANDLER ();
87+ #elif __has_builtin(__builtin_trap)
88+ __builtin_trap ();
8389#else
8490 abort ();
8591#endif
You can’t perform that action at this time.
0 commit comments