extern "C" {
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
- /// `payload` is actually a `*mut &mut dyn BoxMeUp` but that would cause FFI warnings.
- /// It cannot be `Box<dyn BoxMeUp>` because the other end of this call does not depend
- /// on liballoc, and thus cannot use `Box`.
+ /// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not
+ /// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations
+ /// when using the "abort" panic runtime).
#[unwind(allowed)]
- fn __rust_start_panic(payload: usize) -> u32;
+ fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32;
}
/// This function is called by the panic runtime if FFI code catches a Rust
fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! {
let code = unsafe {
let obj = &mut msg as *mut &mut dyn BoxMeUp;
- __rust_start_panic(obj as usize)
+ __rust_start_panic(obj)
};
rtabort!("failed to initiate panic, error {}", code)
}