|
|
@ -1,4 +1,6 @@
|
|
|
|
use syscall::sys_exit;
|
|
|
|
use syscall::sys_exit;
|
|
|
|
|
|
|
|
use core::alloc::Layout;
|
|
|
|
|
|
|
|
use core::panic::PanicInfo;
|
|
|
|
|
|
|
|
|
|
|
|
#[linkage = "weak"]
|
|
|
|
#[linkage = "weak"]
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
@ -7,8 +9,7 @@ fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern fn _start(_argc: isize, _argv: *const *const u8) -> !
|
|
|
|
pub extern fn _start(_argc: isize, _argv: *const *const u8) -> ! {
|
|
|
|
{
|
|
|
|
|
|
|
|
main();
|
|
|
|
main();
|
|
|
|
sys_exit(0)
|
|
|
|
sys_exit(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -16,25 +17,35 @@ pub extern fn _start(_argc: isize, _argv: *const *const u8) -> !
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
fn eh_personality() {}
|
|
|
|
fn eh_personality() {}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
|
|
|
|
#[panic_implementation]
|
|
|
|
#[panic_implementation]
|
|
|
|
fn panic(info: &::core::panic::PanicInfo) -> ! {
|
|
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
|
|
let location = info.location().unwrap();
|
|
|
|
let location = info.location().unwrap();
|
|
|
|
let message = info.message().unwrap();
|
|
|
|
let message = info.message().unwrap();
|
|
|
|
println!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
|
|
|
|
println!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
|
|
|
|
sys_exit(1)
|
|
|
|
sys_exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "riscv32")]
|
|
|
|
#[lang = "oom"]
|
|
|
|
#[lang = "panic_fmt"]
|
|
|
|
fn oom(_: Layout) -> ! {
|
|
|
|
|
|
|
|
panic!("out of memory");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn panic_fmt(fmt: ::core::fmt::Arguments, file: &'static str, line: u32, col: u32) -> ! {
|
|
|
|
pub extern fn abort() -> ! {
|
|
|
|
println!("\n\nPANIC in {} at {}:{}\n {}", file, line, col, fmt);
|
|
|
|
sys_exit(2)
|
|
|
|
sys_exit(1)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
#[no_mangle]
|
|
|
|
#[lang = "oom"]
|
|
|
|
pub extern fn __mulsi3(mut a: u32, mut b: u32) -> u32 {
|
|
|
|
fn oom() -> ! {
|
|
|
|
let mut r: u32 = 0;
|
|
|
|
panic!("out of memory");
|
|
|
|
|
|
|
|
|
|
|
|
while a > 0 {
|
|
|
|
|
|
|
|
if a & 1 > 0 {
|
|
|
|
|
|
|
|
r += b;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
a >>= 1;
|
|
|
|
|
|
|
|
b <<= 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r
|
|
|
|
}
|
|
|
|
}
|