macro_rules! define_panic_handler {
(loop) => { ... };
(unreachable) => { ... };
(web_api) => { ... };
(web_api: $buffer_bytes:literal) => { ... };
(custom, $func:path) => { ... };
}
Expand description
Defines a panic handler based on the chosen strategy.
loop
: Enters an infinite loop, ensuring the program halts without undefined behavior.unreachable
: optimally halts execution based on the target architecture.wasm32
: Usesunreachable()
to signal an unrecoverable state.x86_64
: Uses_mm_pause()
to reduce CPU power consumption.aarch64
: Uses__nop()
as a minimal halt.riscv64
: Useswfi
(wait-for-interrupt) to idle the core.- Fallback: Uses an infinite loop.
- (It uses
unsafe
, except forwasm32
and the fallback.
web_api
: Logs panic info to the Web console. It requires thejs
feature.- Accepts the size of the log buffer size in bytes. Defaults to
1024
bytes.
- Accepts the size of the log buffer size in bytes. Defaults to
custom
: Uses a user-provided function as the panic handler.