1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 16:36:18 +04:00
rCore/kernel/src/lang.rs

38 lines
915 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) -> ! {
2018-07-12 16:45:22 +04:00
error!("\n\nPANIC in {} at {}:{}\n {}", file, line, col, fmt);
loop {}
}
#[cfg(target_arch = "x86_64")]
#[lang = "oom"]
#[no_mangle]
pub fn oom() -> ! {
panic!("out of memory");
}