lib.rs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #![no_std]
  2. #![allow(non_camel_case_types)]
  3. #![allow(non_upper_case_globals)]
  4. #![allow(unused_variables)]
  5. #![feature(alloc)]
  6. #![feature(allocator_api)]
  7. #![feature(const_fn)]
  8. #![feature(const_raw_ptr_deref)]
  9. #![feature(const_str_as_bytes)]
  10. #![feature(const_vec_new)]
  11. #![feature(core_intrinsics)]
  12. #![feature(global_asm)]
  13. #![feature(lang_items)]
  14. #![feature(linkage)]
  15. #![feature(stmt_expr_attributes)]
  16. #![feature(str_internals)]
  17. #![feature(thread_local)]
  18. #![allow(clippy::cast_lossless)]
  19. #![allow(clippy::cast_ptr_alignment)]
  20. #![allow(clippy::derive_hash_xor_eq)]
  21. #![allow(clippy::eval_order_dependence)]
  22. #![allow(clippy::mut_from_ref)]
  23. #[macro_use]
  24. extern crate alloc;
  25. extern crate cbitset;
  26. extern crate core_io;
  27. #[macro_use]
  28. extern crate lazy_static;
  29. extern crate posix_regex;
  30. extern crate rand;
  31. extern crate va_list;
  32. #[cfg(target_os = "linux")]
  33. #[macro_use]
  34. extern crate sc;
  35. #[cfg(target_os = "redox")]
  36. extern crate syscall;
  37. #[cfg(target_os = "redox")]
  38. extern crate spin;
  39. #[macro_use]
  40. mod macros;
  41. pub mod c_str;
  42. pub mod cxa;
  43. pub mod db;
  44. pub mod fs;
  45. pub mod header;
  46. pub mod io;
  47. pub mod mutex;
  48. pub mod platform;
  49. pub mod start;
  50. use platform::{Allocator, Pal, Sys};
  51. #[global_allocator]
  52. static ALLOCATOR: Allocator = Allocator;
  53. #[cfg(not(test))]
  54. #[panic_handler]
  55. #[linkage = "weak"]
  56. #[no_mangle]
  57. pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
  58. use core::fmt::Write;
  59. let mut w = platform::FileWriter(2);
  60. let _ = w.write_fmt(format_args!("RELIBC PANIC: {}\n", pi));
  61. Sys::exit(1);
  62. }
  63. #[cfg(not(test))]
  64. #[lang = "eh_personality"]
  65. #[no_mangle]
  66. #[linkage = "weak"]
  67. pub extern "C" fn rust_eh_personality() {}
  68. #[cfg(not(test))]
  69. #[lang = "oom"]
  70. #[linkage = "weak"]
  71. #[no_mangle]
  72. pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! {
  73. use core::fmt::Write;
  74. let mut w = platform::FileWriter(2);
  75. let _ = w.write_fmt(format_args!(
  76. "RELIBC OOM: {} bytes aligned to {} bytes\n",
  77. layout.size(),
  78. layout.align()
  79. ));
  80. Sys::exit(1);
  81. }
  82. #[cfg(not(test))]
  83. #[allow(non_snake_case)]
  84. #[linkage = "weak"]
  85. #[no_mangle]
  86. pub extern "C" fn _Unwind_Resume() -> ! {
  87. use core::fmt::Write;
  88. let mut w = platform::FileWriter(2);
  89. let _ = w.write_str("_Unwind_Resume\n");
  90. Sys::exit(1);
  91. }