lib.rs 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #![no_std]
  2. #![feature(lang_items)]
  3. extern crate compiler_builtins;
  4. extern crate platform;
  5. extern crate fcntl;
  6. extern crate stdio;
  7. extern crate stdlib;
  8. extern crate string;
  9. extern crate unistd;
  10. use core::fmt;
  11. struct PanicWriter;
  12. impl fmt::Write for PanicWriter {
  13. fn write_str(&mut self, s: &str) -> fmt::Result {
  14. platform::write(2, s.as_bytes());
  15. Ok(())
  16. }
  17. }
  18. #[lang = "eh_personality"]
  19. #[no_mangle]
  20. pub extern "C" fn rust_eh_personality() {}
  21. #[lang = "panic_fmt"]
  22. #[no_mangle]
  23. pub extern "C" fn rust_begin_unwind(fmt: fmt::Arguments, file: &str, line: u32) -> ! {
  24. use fmt::Write;
  25. let _ = PanicWriter.write_fmt(format_args!("{}:{}: {}\n", file, line, fmt));
  26. platform::exit(1);
  27. }
  28. #[allow(non_snake_case)]
  29. #[no_mangle]
  30. pub extern "C" fn _Unwind_Resume() -> ! {
  31. use fmt::Write;
  32. let _ = PanicWriter.write_str("_Unwind_Resume\n");
  33. platform::exit(1);
  34. }