2018-04-04 16:56:56 +04:00
|
|
|
// Rust language features implementions
|
|
|
|
|
2018-06-19 19:43:40 +04:00
|
|
|
use core::panic::PanicInfo;
|
2018-04-04 16:56:56 +04:00
|
|
|
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
extern fn eh_personality() {
|
|
|
|
}
|
|
|
|
|
2018-07-03 18:27:55 +04:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2018-06-19 19:43:40 +04:00
|
|
|
#[panic_implementation]
|
2018-04-04 16:56:56 +04:00
|
|
|
#[no_mangle]
|
2018-06-19 19:43:40 +04:00
|
|
|
pub fn panic(info: &PanicInfo) -> ! {
|
|
|
|
let location = info.location().unwrap();
|
|
|
|
let message = info.message().unwrap();
|
|
|
|
error!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
|
2018-04-09 13:02:18 +04:00
|
|
|
if cfg!(feature = "qemu_auto_exit") {
|
2018-07-03 18:27:55 +04:00
|
|
|
use arch::cpu;
|
2018-04-09 17:20:47 +04:00
|
|
|
unsafe{ cpu::exit_in_qemu(3) }
|
2018-04-09 13:02:18 +04:00
|
|
|
} else {
|
|
|
|
loop { }
|
|
|
|
}
|
|
|
|
}
|
2018-06-19 19:43:40 +04:00
|
|
|
|
2018-07-03 18:27:55 +04:00
|
|
|
#[cfg(target_arch = "riscv")]
|
|
|
|
#[lang = "panic_fmt"]
|
2018-07-06 19:02:10 +04:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn panic_fmt(fmt: ::core::fmt::Arguments, file: &'static str, line: u32, col: u32) -> ! {
|
|
|
|
println!("\n\nPANIC in {} at {}:{}\n {}", file, line, col, fmt);
|
2018-07-03 18:27:55 +04:00
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
2018-06-19 19:43:40 +04:00
|
|
|
#[lang = "oom"]
|
|
|
|
#[no_mangle]
|
2018-07-10 13:07:03 +04:00
|
|
|
pub fn oom() -> ! {
|
2018-06-19 19:43:40 +04:00
|
|
|
panic!("out of memory");
|
|
|
|
}
|