1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-24 00:46:17 +04:00
rCore/src/lang.rs

38 lines
913 B
Rust
Raw Normal View History

// Rust language features implementions
use core::panic::PanicInfo;
#[lang = "eh_personality"]
extern fn eh_personality() {
}
#[cfg(target_arch = "x86_64")]
#[panic_implementation]
#[no_mangle]
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") {
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 { }
}
}
#[cfg(target_arch = "riscv")]
#[lang = "panic_fmt"]
#[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);
loop {}
}
#[cfg(target_arch = "x86_64")]
#[lang = "oom"]
#[no_mangle]
fn oom() -> ! {
panic!("out of memory");
}