2
0

lib.rs 2.4 KB

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