lib.rs 2.4 KB

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