lib.rs 2.6 KB

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