Browse Source

解决无法编译的问题以及警告问题 (#20)

LoGin 1 year ago
parent
commit
b38c79420b
46 changed files with 278 additions and 206 deletions
  1. 14 1
      .vscode/settings.json
  2. 1 3
      Makefile
  3. 3 2
      build.rs
  4. 48 19
      dlibc/core_io/src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/util.rs
  5. 3 0
      dlibc/src/lib.rs
  6. 3 3
      dlibc/src/unix/header/arch_aarch64_user/mod.rs
  7. 3 3
      dlibc/src/unix/header/arch_x64_user/mod.rs
  8. 16 16
      dlibc/src/unix/header/dirent/mod.rs
  9. 0 1
      dlibc/src/unix/header/inttypes/mod.rs
  10. 0 1
      dlibc/src/unix/header/locale/mod.rs
  11. 2 1
      dlibc/src/unix/header/netdb/dns/mod.rs
  12. 11 9
      dlibc/src/unix/header/netdb/lookup.rs
  13. 2 2
      dlibc/src/unix/header/netdb/mod.rs
  14. 4 4
      dlibc/src/unix/header/signal/mod.rs
  15. 3 3
      dlibc/src/unix/header/stdio/mod.rs
  16. 3 3
      dlibc/src/unix/header/stdio/scanf.rs
  17. 43 17
      dlibc/src/unix/header/stdlib/mod.rs
  18. 1 1
      dlibc/src/unix/header/sys_procfs/mod.rs
  19. 1 1
      dlibc/src/unix/header/unistd/mod.rs
  20. 2 2
      dlibc/src/unix/ld_so/linker.rs
  21. 4 6
      dlibc/src/unix/ld_so/mod.rs
  22. 2 1
      dlibc/src/unix/ld_so/tcb.rs
  23. 5 4
      dlibc/src/unix/macros.rs
  24. 12 12
      dlibc/src/unix/mod.rs
  25. 3 11
      dlibc/src/unix/platform/dragonos/musl/mod.rs
  26. 9 10
      dlibc/src/unix/platform/dragonos/pal/mod.rs
  27. 1 0
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal.rs
  28. 44 37
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_signal.rs
  29. 10 11
      dlibc/src/unix/start.rs
  30. 2 6
      dlibc/src/unix/sync/mod.rs
  31. 1 0
      dlibc/src/unix/sync/once.rs
  32. 4 4
      src/lib.rs
  33. 0 5
      src/std/alloc.rs
  34. 1 0
      src/std/backtrace.rs
  35. 2 2
      src/std/collections/hash/map.rs
  36. 1 1
      src/std/error.rs
  37. 1 0
      src/std/panic.rs
  38. 2 0
      src/std/rt.rs
  39. 1 2
      src/std/sys/unix/fs.rs
  40. 1 0
      src/std/sys/unix/kernel_copy.rs
  41. 2 0
      src/std/sys/unix/net.rs
  42. 1 2
      src/std/sys/unix/process/process_unix.rs
  43. 2 0
      src/std/sys/unix/rand.rs
  44. 1 0
      src/std/sys/unix/stack_overflow.rs
  45. 2 0
      src/std/sys_common/backtrace.rs
  46. 1 0
      src/std/sys_common/wtf8.rs

+ 14 - 1
.vscode/settings.json

@@ -2,4 +2,17 @@
     "rust-analyzer.linkedProjects": [
         "./Cargo.toml",
     ],
-}
+    "rust-analyzer.check.overrideCommand": [
+        "cargo",
+        "+nightly",
+        "-Z",
+        "build-std=core,alloc,compiler_builtins",
+        "check",
+        "--workspace",
+        "--message-format=json",
+        "--target",
+        "target.json",
+    ],
+
+    "rust-analyzer.cargo.target": "x86_64-unknown-dragonos",
+}

+ 1 - 3
Makefile

@@ -77,8 +77,6 @@ all: | libs
 
 clean:
 	$(CARGO) clean
-	$(MAKE) -C tests clean
-	rm -rf sysroot
 
 check:
 	$(CARGO) check
@@ -96,7 +94,7 @@ install-headers: libs
 
 # $(BUILD)/release/libc.so
 libs: 
-	@cargo -Z build-std=core,alloc,compiler_builtins build --target x86_64-unknown-dragonos
+	@cargo -Z build-std=core,alloc,compiler_builtins build --target target.json --release
 #$(BUILD)/release/ld_so
 
 install-libs: libs

+ 3 - 2
build.rs

@@ -1,9 +1,10 @@
 extern crate cbindgen;
 extern crate cc;
 
-use std::{env, fs, fs::DirEntry, path::Path};
+use std::fs::DirEntry;
 
 // include src/header directories that don't start with '_'
+#[allow(dead_code)]
 fn include_dir(d: &DirEntry) -> bool {
     d.metadata().map(|m| m.is_dir()).unwrap_or(false)
         && d.path()
@@ -34,7 +35,7 @@ fn include_dir(d: &DirEntry) -> bool {
 // }
 
 fn main() {
-    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
+    // let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
 
     // Generate C includes
     // - based on contents of src/header/**

+ 48 - 19
dlibc/core_io/src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/util.rs

@@ -11,9 +11,10 @@
 #![allow(missing_copy_implementations)]
 
 use core::fmt;
-use io::{self, Read, Initializer, Write, ErrorKind};
-use core::mem;
-#[cfg(feature="alloc")] use io::BufRead;
+use io::{self, ErrorKind, Initializer, Read, Write};
+
+#[cfg(feature = "alloc")]
+use io::BufRead;
 
 /// Copies the entire contents of a reader into a writer.
 ///
@@ -51,10 +52,12 @@ use core::mem;
 /// }
 /// ```
 pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
-    where R: Read, W: Write
+where
+    R: Read,
+    W: Write,
 {
     let mut buf = unsafe {
-        let mut buf: [u8; super::DEFAULT_BUF_SIZE] = mem::uninitialized();
+        let mut buf: [u8; super::DEFAULT_BUF_SIZE] = [0u8; super::DEFAULT_BUF_SIZE];
         reader.initializer().initialize(&mut buf);
         buf
     };
@@ -78,7 +81,9 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
 /// the documentation of [`empty()`][`empty`] for more details.
 ///
 /// [`empty`]: fn.empty.html
-pub struct Empty { _priv: () }
+pub struct Empty {
+    _priv: (),
+}
 
 /// Constructs a new handle to an empty reader.
 ///
@@ -97,11 +102,15 @@ pub struct Empty { _priv: () }
 /// io::empty().read_to_string(&mut buffer).unwrap();
 /// assert!(buffer.is_empty());
 /// ```
-pub fn empty() -> Empty { Empty { _priv: () } }
+pub fn empty() -> Empty {
+    Empty { _priv: () }
+}
 
 impl Read for Empty {
     #[inline]
-    fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) }
+    fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
+        Ok(0)
+    }
 
     #[inline]
     unsafe fn initializer(&self) -> Initializer {
@@ -109,10 +118,12 @@ impl Read for Empty {
     }
 }
 
-#[cfg(feature="alloc")]
+#[cfg(feature = "alloc")]
 impl BufRead for Empty {
     #[inline]
-    fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) }
+    fn fill_buf(&mut self) -> io::Result<&[u8]> {
+        Ok(&[])
+    }
     #[inline]
     fn consume(&mut self, _n: usize) {}
 }
@@ -129,7 +140,9 @@ impl fmt::Debug for Empty {
 /// see the documentation of `repeat()` for more details.
 ///
 /// [repeat]: fn.repeat.html
-pub struct Repeat { byte: u8 }
+pub struct Repeat {
+    byte: u8,
+}
 
 /// Creates an instance of a reader that infinitely repeats one byte.
 ///
@@ -145,7 +158,9 @@ pub struct Repeat { byte: u8 }
 /// io::repeat(0b101).read_exact(&mut buffer).unwrap();
 /// assert_eq!(buffer, [0b101, 0b101, 0b101]);
 /// ```
-pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
+pub fn repeat(byte: u8) -> Repeat {
+    Repeat { byte: byte }
+}
 
 impl Read for Repeat {
     #[inline]
@@ -174,7 +189,9 @@ impl fmt::Debug for Repeat {
 /// see the documentation of `sink()` for more details.
 ///
 /// [sink]: fn.sink.html
-pub struct Sink { _priv: () }
+pub struct Sink {
+    _priv: (),
+}
 
 /// Creates an instance of a writer which will successfully consume all data.
 ///
@@ -190,13 +207,19 @@ pub struct Sink { _priv: () }
 /// let num_bytes = io::sink().write(&buffer).unwrap();
 /// assert_eq!(num_bytes, 5);
 /// ```
-pub fn sink() -> Sink { Sink { _priv: () } }
+pub fn sink() -> Sink {
+    Sink { _priv: () }
+}
 
 impl Write for Sink {
     #[inline]
-    fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) }
+    fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+        Ok(buf.len())
+    }
     #[inline]
-    fn flush(&mut self) -> io::Result<()> { Ok(()) }
+    fn flush(&mut self) -> io::Result<()> {
+        Ok(())
+    }
 }
 
 impl fmt::Debug for Sink {
@@ -208,7 +231,7 @@ impl fmt::Debug for Sink {
 #[cfg(test)]
 mod tests {
     use io::prelude::*;
-    use io::{copy, sink, empty, repeat};
+    use io::{copy, empty, repeat, sink};
 
     #[test]
     fn copy_copies() {
@@ -217,7 +240,10 @@ mod tests {
         assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
 
         let mut r = repeat(0).take(1 << 17);
-        assert_eq!(copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(), 1 << 17);
+        assert_eq!(
+            copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(),
+            1 << 17
+        );
     }
 
     #[test]
@@ -250,6 +276,9 @@ mod tests {
     fn take_some_bytes() {
         assert_eq!(repeat(4).take(100).bytes().count(), 100);
         assert_eq!(repeat(4).take(100).bytes().next().unwrap().unwrap(), 4);
-        assert_eq!(repeat(1).take(10).chain(repeat(2).take(10)).bytes().count(), 20);
+        assert_eq!(
+            repeat(1).take(10).chain(repeat(2).take(10)).bytes().count(),
+            20
+        );
     }
 }

+ 3 - 0
dlibc/src/lib.rs

@@ -29,6 +29,9 @@
     redundant_semicolons,
     unused_macros,
     unused_macro_rules,
+    internal_features,
+    hidden_glob_reexports,
+    ambiguous_glob_reexports,
 )]
 #![cfg_attr(libc_deny_warnings, deny(warnings))]
 // Attributes needed when building as part of the standard library

+ 3 - 3
dlibc/src/unix/header/arch_aarch64_user/mod.rs

@@ -22,8 +22,8 @@ pub type elf_fpregset_t = user_fpsimd_struct;
 pub extern "C" fn _cbindgen_only_generates_structs_if_they_are_mentioned_which_is_dumb_aarch64_user(
     _a: user_regs_struct,
     _b: user_fpsimd_struct,
-    _c: elf_gregset_t,
-    _d: elf_greg_t,
-    _e: elf_fpregset_t,
+    _c: *mut elf_gregset_t,
+    _d: *mut elf_greg_t,
+    _e: *mut elf_fpregset_t,
 ) {
 }

+ 3 - 3
dlibc/src/unix/header/arch_x64_user/mod.rs

@@ -74,8 +74,8 @@ pub extern "C" fn _cbindgen_only_generates_structs_if_they_are_mentioned_which_i
     _a: user_fpregs_struct,
     _b: user_regs_struct,
     _c: user,
-    _d: elf_gregset_t,
-    _e: elf_greg_t,
-    _f: elf_fpregset_t,
+    _d: *mut elf_gregset_t,
+    _e: *mut elf_greg_t,
+    _f: *mut elf_fpregset_t,
 ) {
 }

+ 16 - 16
dlibc/src/unix/header/dirent/mod.rs

@@ -1,4 +1,4 @@
-//! ::dirent implementation following http://pubs.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
+//! platform::dirent implementation following http://pubs.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
 
 use alloc::boxed::Box;
 use core::{mem, ptr};
@@ -12,7 +12,7 @@ use crate::unix::{
     platform,
 };
 
-const DIR_BUF_SIZE: usize = mem::size_of::<::dirent>() * 3;
+const DIR_BUF_SIZE: usize = mem::size_of::<platform::dirent>() * 3;
 
 // No repr(C) needed, C won't see the content
 pub struct DIR {
@@ -64,11 +64,11 @@ pub unsafe extern "C" fn dirfd(dir: *mut DIR) -> ::c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn readdir(dir: *mut DIR) -> *mut ::dirent {
+pub unsafe extern "C" fn readdir(dir: *mut DIR) -> *mut platform::dirent {
     if (*dir).index >= (*dir).len {
         let read = platform::pal::getdents(
             *(*dir).file,
-            (*dir).buf.as_mut_ptr() as *mut ::dirent,
+            (*dir).buf.as_mut_ptr() as *mut platform::dirent,
             (*dir).buf.len(),
         );
         if read <= 0 {
@@ -82,7 +82,7 @@ pub unsafe extern "C" fn readdir(dir: *mut DIR) -> *mut ::dirent {
         (*dir).len = read as usize;
     }
 
-    let ptr = (*dir).buf.as_mut_ptr().add((*dir).index) as *mut ::dirent;
+    let ptr = (*dir).buf.as_mut_ptr().add((*dir).index) as *mut platform::dirent;
 
     (*dir).offset = (*ptr).d_off as usize;
     (*dir).index += (*ptr).d_reclen as usize;
@@ -91,9 +91,9 @@ pub unsafe extern "C" fn readdir(dir: *mut DIR) -> *mut ::dirent {
 #[no_mangle]
 pub extern "C" fn readdir_r(
     _dir: *mut DIR,
-    _entry: *mut ::dirent,
-    _result: *mut *mut ::dirent,
-) -> *mut ::dirent {
+    _entry: *mut platform::dirent,
+    _result: *mut *mut platform::dirent,
+) -> *mut platform::dirent {
     unimplemented!(); // plus, deprecated
 }
 
@@ -115,8 +115,8 @@ pub unsafe extern "C" fn rewinddir(dir: *mut DIR) {
 
 #[no_mangle]
 pub unsafe extern "C" fn alphasort(
-    first: *mut *const ::dirent,
-    second: *mut *const ::dirent,
+    first: *mut *const platform::dirent,
+    second: *mut *const platform::dirent,
 ) -> ::c_int {
     string::strcoll((**first).d_name.as_ptr(), (**second).d_name.as_ptr())
 }
@@ -124,9 +124,9 @@ pub unsafe extern "C" fn alphasort(
 #[no_mangle]
 pub unsafe extern "C" fn scandir(
     dirp: *const ::c_char,
-    namelist: *mut *mut *mut ::dirent,
-    filter: Option<extern "C" fn(_: *const ::dirent) -> ::c_int>,
-    compare: Option<extern "C" fn(_: *mut *const ::dirent, _: *mut *const ::dirent) -> ::c_int>,
+    namelist: *mut *mut *mut platform::dirent,
+    filter: Option<extern "C" fn(_: *const platform::dirent) -> ::c_int>,
+    compare: Option<extern "C" fn(_: *mut *const platform::dirent, _: *mut *const platform::dirent) -> ::c_int>,
 ) -> ::c_int {
     let dir = opendir(dirp);
     if dir.is_null() {
@@ -142,7 +142,7 @@ pub unsafe extern "C" fn scandir(
     platform::errno = 0;
 
     loop {
-        let entry: *mut ::dirent = readdir(dir);
+        let entry: *mut platform::dirent = readdir(dir);
         if entry.is_null() {
             break;
         }
@@ -153,7 +153,7 @@ pub unsafe extern "C" fn scandir(
             }
         }
 
-        let copy = platform::alloc(mem::size_of::<::dirent>()) as *mut ::dirent;
+        let copy = platform::alloc(mem::size_of::<platform::dirent>()) as *mut platform::dirent;
         if copy.is_null() {
             break;
         }
@@ -182,7 +182,7 @@ pub unsafe extern "C" fn scandir(
         stdlib::qsort(
             *namelist as *mut ::c_void,
             len as ::size_t,
-            mem::size_of::<*mut ::dirent>(),
+            mem::size_of::<*mut platform::dirent>(),
             mem::transmute(compare),
         );
 

+ 0 - 1
dlibc/src/unix/header/inttypes/mod.rs

@@ -5,7 +5,6 @@ pub extern "C" fn imaxabs(i: ::intmax_t) -> ::intmax_t {
     i.abs()
 }
 
-#[no_mangle]
 #[repr(C)]
 pub struct imaxdiv_t {
     quot: ::intmax_t,

+ 0 - 1
dlibc/src/unix/header/locale/mod.rs

@@ -9,7 +9,6 @@ const EMPTY_PTR: *const ::c_char = "\0" as *const _ as *const ::c_char;
 static mut C_LOCALE: [::c_char; 2] = [b'C' as ::c_char, 0];
 
 #[repr(C)]
-#[no_mangle]
 pub struct lconv {
     currency_symbol: *const ::c_char,
     decimal_point: *const ::c_char,

+ 2 - 1
dlibc/src/unix/header/netdb/dns/mod.rs

@@ -126,7 +126,8 @@ impl Dns {
                 if i > data.len() {
                     return Err(format!("{}: {}: pop_n16", file!(), line!()));
                 }
-                u16::from(n16::from_bytes(&data[i - 2..i]))
+                let x = u16::from(n16::from_bytes(&data[i - 2..i]));
+                x
             }};
         };
 

+ 11 - 9
dlibc/src/unix/header/netdb/lookup.rs

@@ -5,6 +5,10 @@ use alloc::{
 };
 use core::mem;
 
+use super::{
+    dns::{Dns, DnsQuery},
+    sys::get_dns_server,
+};
 use crate::unix::header::{
     arpa_inet::htons,
     errno::*,
@@ -15,10 +19,6 @@ use crate::unix::header::{
     },
 };
 use unix::platform;
-use super::{
-    dns::{Dns, DnsQuery},
-    sys::get_dns_server,
-};
 
 pub struct LookupHost(IntoIter<in_addr>);
 
@@ -46,7 +46,7 @@ pub fn lookup_host(host: &str) -> Result<LookupHost, ::c_int> {
         let dns_addr = unsafe { mem::transmute::<[u8; 4], u32>(dns_arr) };
 
         let mut timespec = ::timespec::default();
-        unsafe{platform::pal::clock_gettime(::CLOCK_REALTIME, &mut timespec);}
+        platform::pal::clock_gettime(::CLOCK_REALTIME, &mut timespec);
         let tid = (timespec.tv_nsec >> 16) as u16;
 
         let packet = Dns {
@@ -80,14 +80,14 @@ pub fn lookup_host(host: &str) -> Result<LookupHost, ::c_int> {
                 return Err(EIO);
             }
             if ::send(sock, packet_data_ptr, packet_data_len, 0) < 0 {
-                Box::from_raw(packet_data_ptr);
+                let _ = Box::from_raw(packet_data_ptr);
                 return Err(EIO);
             }
             sock
         };
 
         unsafe {
-            Box::from_raw(packet_data_ptr);
+            let _ = Box::from_raw(packet_data_ptr);
         }
 
         let _i = 0 as socklen_t;
@@ -158,7 +158,9 @@ pub fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, ::c_int> {
 
     if dns_vec.len() == 4 {
         let mut timespec = ::timespec::default();
-        unsafe{platform::pal::clock_gettime(::CLOCK_REALTIME, &mut timespec);}
+
+        platform::pal::clock_gettime(::CLOCK_REALTIME, &mut timespec);
+
         let tid = (timespec.tv_nsec >> 16) as u16;
 
         let packet = Dns {
@@ -203,7 +205,7 @@ pub fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, ::c_int> {
         }
 
         unsafe {
-            Box::from_raw(packet_data_ptr);
+            let _ = Box::from_raw(packet_data_ptr);
         }
 
         let _i = mem::size_of::<sockaddr_in>() as socklen_t;

+ 2 - 2
dlibc/src/unix/header/netdb/mod.rs

@@ -867,9 +867,9 @@ pub unsafe extern "C" fn freeaddrinfo(res: *mut addrinfo) {
         }
         if !bai.ai_addr.is_null() {
             if bai.ai_addrlen == mem::size_of::<sockaddr_in>() {
-                Box::from_raw(bai.ai_addr as *mut sockaddr_in);
+                let _ = Box::from_raw(bai.ai_addr as *mut sockaddr_in);
             } else if bai.ai_addrlen == mem::size_of::<sockaddr_in6>() {
-                Box::from_raw(bai.ai_addr as *mut sockaddr_in6);
+                let _ = Box::from_raw(bai.ai_addr as *mut sockaddr_in6);
             } else {
                 eprintln!("freeaddrinfo: unknown ai_addrlen {}", bai.ai_addrlen);
             }

+ 4 - 4
dlibc/src/unix/header/signal/mod.rs

@@ -8,8 +8,8 @@ use crate::unix::header::errno;
 
 pub use self::platform::*;
 
+use crate::unix::header::signal::sys::NSIG;
 use crate::unix::platform;
-use crate::unix::header::signal::sys::{NSIG};
 
 #[cfg(target_os = "linux")]
 #[path = "linux.rs"]
@@ -204,13 +204,13 @@ pub extern "C" fn signal(
         sa_restorer: Some(__restore_rt),
         sa_mask: sigset_t::default(),
     };
-    let mut old_sa = mem::MaybeUninit::uninit();
+    let mut old_sa = mem::MaybeUninit::zeroed();
     if unsafe { sigaction(sig, &sa as *const sigaction, old_sa.as_mut_ptr()) } < 0 {
-        mem::forget(old_sa);
+        // mem::forget(old_sa);
         return unsafe { mem::transmute(SIG_ERR) };
     }
     let sa_handler = unsafe { old_sa.assume_init() }.sa_sigaction;
-    unsafe{Some(*(sa_handler as *const () as *const extern "C" fn(::c_int)))}
+    unsafe { Some(*(sa_handler as *const () as *const extern "C" fn(::c_int))) }
 }
 
 // #[no_mangle]

+ 3 - 3
dlibc/src/unix/header/stdio/mod.rs

@@ -1015,7 +1015,7 @@ pub unsafe extern "C" fn setvbuf(
 #[no_mangle]
 pub unsafe extern "C" fn tempnam(dir: *const ::c_char, pfx: *const ::c_char) -> *mut ::c_char {
     unsafe fn is_appropriate(pos_dir: *const ::c_char) -> bool {
-        !pos_dir.is_null() && ::access(pos_dir, ::W_OK) == 0
+        !pos_dir.is_null() && ::access(pos_dir, platform::W_OK) == 0
     }
 
     // directory search order is env!(TMPDIR), dir, P_tmpdir, "/tmp"
@@ -1197,6 +1197,6 @@ pub unsafe fn flush_io_streams() {
         let stream = &mut *stream;
         stream.flush()
     };
-    flush(stdout);
-    flush(stderr);
+    let _ = flush(stdout);
+    let _ = flush(stderr);
 }

+ 3 - 3
dlibc/src/unix/header/stdio/scanf.rs

@@ -239,13 +239,13 @@ unsafe fn inner_scanf(
                             }
                         }};
                         (c_double) => {
-                            parse_type!(noformat ::c_double);
+                            parse_type!(noformat ::c_double)
                         };
                         (c_float) => {
-                            parse_type!(noformat ::c_float);
+                            parse_type!(noformat ::c_float)
                         };
                         ($type:ident) => {
-                            parse_type!($type, $type);
+                            parse_type!($type, $type)
                         };
                         ($type:ident, $final:ty) => {{
                             let n = if n.is_empty() {

+ 43 - 17
dlibc/src/unix/header/stdlib/mod.rs

@@ -18,12 +18,7 @@ use crate::unix::header::{
     wchar::*,
 };
 
-use crate::unix::{
-    c_str::CStr,
-    fs::File,
-    ld_so,
-    platform,
-};
+use crate::unix::{c_str::CStr, fs::File, ld_so, platform};
 
 mod rand48;
 mod random;
@@ -370,7 +365,11 @@ pub extern "C" fn grantpt(_fildes: ::c_int) -> ::c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn initstate(seed: ::c_uint, state: *mut ::c_char, size: ::size_t) -> *mut ::c_char {
+pub unsafe extern "C" fn initstate(
+    seed: ::c_uint,
+    state: *mut ::c_char,
+    size: ::size_t,
+) -> *mut ::c_char {
     // Ported from musl
 
     if size < 8 {
@@ -539,7 +538,11 @@ pub unsafe extern "C" fn mblen(s: *const ::c_char, n: ::size_t) -> ::c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn mbstowcs(pwcs: *mut ::wchar_t, mut s: *const ::c_char, n: ::size_t) -> ::size_t {
+pub unsafe extern "C" fn mbstowcs(
+    pwcs: *mut ::wchar_t,
+    mut s: *const ::c_char,
+    n: ::size_t,
+) -> ::size_t {
     let mut state: mbstate_t = mbstate_t {};
     mbsrtowcs(pwcs, &mut s, n, &mut state)
 }
@@ -611,12 +614,16 @@ pub unsafe extern "C" fn mktemp(name: *mut ::c_char) -> *mut ::c_char {
 
 fn get_nstime() -> u64 {
     let mut ts = mem::MaybeUninit::uninit();
-    unsafe{platform::pal::clock_gettime(::CLOCK_MONOTONIC, ts.as_mut_ptr());}
+    platform::pal::clock_gettime(::CLOCK_MONOTONIC, ts.as_mut_ptr());
     unsafe { ts.assume_init() }.tv_nsec as u64
 }
 
 #[no_mangle]
-pub extern "C" fn mkostemps(name: *mut ::c_char, suffix_len: ::c_int, mut flags: ::c_int) -> ::c_int {
+pub extern "C" fn mkostemps(
+    name: *mut ::c_char,
+    suffix_len: ::c_int,
+    mut flags: ::c_int,
+) -> ::c_int {
     flags &= !::O_ACCMODE;
     flags |= ::O_RDWR | ::O_CREAT | ::O_EXCL;
 
@@ -811,7 +818,11 @@ pub unsafe extern "C" fn realloc(ptr: *mut ::c_void, size: ::size_t) -> *mut ::c
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn reallocarray(ptr: *mut ::c_void, m: ::size_t, n: ::size_t) -> *mut ::c_void {
+pub unsafe extern "C" fn reallocarray(
+    ptr: *mut ::c_void,
+    m: ::size_t,
+    n: ::size_t,
+) -> *mut ::c_void {
     //Handle possible integer overflow in size calculation
     match m.checked_mul(n) {
         Some(size) => realloc(ptr, size),
@@ -824,7 +835,10 @@ pub unsafe extern "C" fn reallocarray(ptr: *mut ::c_void, m: ::size_t, n: ::size
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char {
+pub unsafe extern "C" fn realpath(
+    pathname: *const ::c_char,
+    resolved: *mut ::c_char,
+) -> *mut ::c_char {
     let ptr = if resolved.is_null() {
         malloc(limits::PATH_MAX) as *mut ::c_char
     } else {
@@ -900,7 +914,8 @@ pub unsafe extern "C" fn setenv(
             core::ptr::write(existing.add(value_len), 0);
         } else {
             // Reuse platform::environ slot, but allocate a new pointer.
-            let ptr = platform::alloc(key_len as usize + 1 + value_len as usize + 1) as *mut ::c_char;
+            let ptr =
+                platform::alloc(key_len as usize + 1 + value_len as usize + 1) as *mut ::c_char;
             copy_kv(ptr, key, value, key_len, value_len);
             platform::environ.add(i).write(ptr);
         }
@@ -1010,7 +1025,8 @@ pub unsafe fn convert_octal(s: *const ::c_char) -> Option<(::c_ulong, isize, boo
 
 pub unsafe fn convert_hex(s: *const ::c_char) -> Option<(::c_ulong, isize, bool)> {
     if (*s != 0 && *s == b'0' as ::c_char)
-        && (*s.offset(1) != 0 && (*s.offset(1) == b'x' as ::c_char || *s.offset(1) == b'X' as ::c_char))
+        && (*s.offset(1) != 0
+            && (*s.offset(1) == b'x' as ::c_char || *s.offset(1) == b'X' as ::c_char))
     {
         convert_integer(s.offset(2), 16).map(|(val, idx, overflow)| (val, idx + 2, overflow))
     } else {
@@ -1018,7 +1034,10 @@ pub unsafe fn convert_hex(s: *const ::c_char) -> Option<(::c_ulong, isize, bool)
     }
 }
 
-pub unsafe fn convert_integer(s: *const ::c_char, base: ::c_int) -> Option<(::c_ulong, isize, bool)> {
+pub unsafe fn convert_integer(
+    s: *const ::c_char,
+    base: ::c_int,
+) -> Option<(::c_ulong, isize, bool)> {
     // -1 means the character is invalid
     #[rustfmt::skip]
     const LOOKUP_TABLE: [::c_long; 256] = [
@@ -1092,7 +1111,11 @@ pub unsafe extern "C" fn strtoul(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strtol(s: *const ::c_char, endptr: *mut *mut ::c_char, base: ::c_int) -> ::c_long {
+pub unsafe extern "C" fn strtol(
+    s: *const ::c_char,
+    endptr: *mut *mut ::c_char,
+    base: ::c_int,
+) -> ::c_long {
     strto_impl!(
         ::c_long,
         true,
@@ -1159,7 +1182,10 @@ pub unsafe extern "C" fn system(command: *const ::c_char) -> ::c_int {
             ptr::null(),
         ];
 
-        unistd::execv(shell as *const ::c_char, args.as_ptr() as *const *const ::c_char);
+        unistd::execv(
+            shell as *const ::c_char,
+            args.as_ptr() as *const *const ::c_char,
+        );
 
         exit(127);
 

+ 1 - 1
dlibc/src/unix/header/sys_procfs/mod.rs

@@ -64,7 +64,7 @@ pub type prpsinfo_t = elf_prpsinfo;
 #[no_mangle]
 pub extern "C" fn _cbindgen_only_generates_structs_if_they_are_mentioned_which_is_dumb_procfs(
     _a: psaddr_t,
-    _b: prgregset_t,
+    _b: *mut prgregset_t,
     _c: prfpregset_t,
     _d: lwpid_t,
     _e: prstatus_t,

+ 1 - 1
dlibc/src/unix/header/unistd/mod.rs

@@ -324,7 +324,7 @@ pub unsafe extern "C" fn gethostname(mut name: *mut ::c_char, mut len: ::size_t)
     let mut uts = mem::MaybeUninit::<::utsname>::uninit();
     let err = platform::pal::uname(uts.as_mut_ptr());
     if err < 0 {
-        mem::forget(uts);
+        // mem::forget(uts);
         return err;
     }
     for c in uts.assume_init().nodename.iter() {

+ 2 - 2
dlibc/src/unix/ld_so/linker.rs

@@ -350,7 +350,7 @@ impl Linker {
                                 sym
                             )))??;
                     let mut symbol = None;
-                    let mut found = false;
+                    let mut _found = false;
                     let lookup_start = match rel.r_type {
                         reloc::R_X86_64_COPY => 1,
                         _ => 0,
@@ -367,7 +367,7 @@ impl Linker {
                             );
                             symbol = Some(s);
                             t = lookup_obj.tls_offset;
-                            found = true;
+                            _found = true;
                             // Stop looking if any strong symbol is found
                             if strong {
                                 break;

+ 4 - 6
dlibc/src/unix/ld_so/mod.rs

@@ -2,9 +2,9 @@ use core::{mem, ptr};
 use goblin::elf::program_header::{self, program_header32, program_header64, ProgramHeader};
 
 use self::tcb::{Master, Tcb};
-use crate::unix::start::Stack;
-use crate::unix::platform;
 use crate::eprintln;
+use crate::unix::platform;
+use crate::unix::start::Stack;
 
 #[cfg(target_os = "redox")]
 pub const PATH_SEP: char = ';';
@@ -32,9 +32,7 @@ static mut STATIC_TCB_MASTER: Master = Master {
 fn panic_notls(msg: impl core::fmt::Display) -> ! {
     eprintln!("panicked in ld.so: {}", msg);
 
-    unsafe {
-        core::intrinsics::abort();
-    }
+    core::intrinsics::abort();
 }
 
 pub trait ExpectTlsFree {
@@ -150,7 +148,7 @@ pub unsafe fn init(_sp: &'static Stack) {
     }
     #[cfg(target_os = "dragonos")]
     {
-        const ARCH_GET_FS: usize = 0x1003;
+        // const ARCH_GET_FS: usize = 0x1003;
         // syscall!(ARCH_PRCTL, ARCH_GET_FS, &mut tp as *mut usize);
         // unimplemented!()
     }

+ 2 - 1
dlibc/src/unix/ld_so/tcb.rs

@@ -250,6 +250,7 @@ impl Tcb {
 
     /// Architecture specific code to read a usize from the TCB - x86_64
     #[inline(always)]
+    #[allow(dead_code)]
     #[cfg(target_arch = "x86_64")]
     unsafe fn arch_read(offset: usize) -> usize {
         let value;
@@ -273,7 +274,7 @@ impl Tcb {
     /// OS and architecture specific code to activate TLS - DragonOS x86_64
     #[cfg(all(target_os = "dragonos", target_arch = "x86_64"))]
     unsafe fn os_arch_activate(_tls_end: usize, _tls_len: usize) {
-        const ARCH_SET_FS: usize = 0x1002;
+        // const ARCH_SET_FS: usize = 0x1002;
         // syscall!(ARCH_PRCTL, ARCH_SET_FS, tls_end);
         unimplemented!()
     }

+ 5 - 4
dlibc/src/unix/macros.rs

@@ -133,8 +133,8 @@ macro_rules! strto_impl {
         const CHECK_SIGN: bool = $signed;
         const MAX_VAL: $rettype = $maxval;
         const MIN_VAL: $rettype = $minval;
-
-        let set_endptr = |idx: isize| {
+        #[allow(unused_mut)]
+        let mut set_endptr = |idx: isize| {
             if !$endptr.is_null() {
                 // This is stupid, but apparently strto* functions want
                 // const input but mut output, yet the man page says
@@ -143,8 +143,9 @@ macro_rules! strto_impl {
                 *$endptr = $s.offset(idx) as *mut _;
             }
         };
-
-        let invalid_input = || {
+        
+        #[allow(unused_mut)]
+        let mut invalid_input = || {
             ::errno = EINVAL;
             set_endptr(0);
         };

+ 12 - 12
dlibc/src/unix/mod.rs

@@ -805,7 +805,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "readdir@FBSD_1.0"
     )]
-    pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
+    pub fn readdir(dirp: *mut ::DIR) -> *mut platform::dirent;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
         link_name = "closedir$UNIX2003"
@@ -1386,12 +1386,12 @@ extern "C" {
         link_name = "tcdrain$UNIX2003"
     )]
     pub fn tcdrain(fd: ::c_int) -> ::c_int;
-    pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
-    pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
-    pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
-    pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
-    pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
-    pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int;
+    pub fn cfgetispeed(termios: *const platform::termios) -> ::speed_t;
+    pub fn cfgetospeed(termios: *const platform::termios) -> ::speed_t;
+    pub fn cfsetispeed(termios: *mut platform::termios, speed: ::speed_t) -> ::c_int;
+    pub fn cfsetospeed(termios: *mut platform::termios, speed: ::speed_t) -> ::c_int;
+    pub fn tcgetattr(fd: ::c_int, termios: *mut platform::termios) -> ::c_int;
+    pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const platform::termios) -> ::c_int;
     pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
     pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
     pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
@@ -1487,8 +1487,8 @@ cfg_if! {
             /// https://illumos.org/man/3lib/libc
             /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
             /// https://www.unix.com/man-page/opensolaris/3LIB/libc/
-            pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
-                             result: *mut *mut ::dirent) -> ::c_int;
+            pub fn readdir_r(dirp: *mut ::DIR, entry: *mut platform::dirent,
+                             result: *mut *mut platform::dirent) -> ::c_int;
         }
     }
 }
@@ -1558,8 +1558,8 @@ cfg_if! {
                     target_os = "nto",
                 )))] {
         extern {
-            pub fn cfmakeraw(termios: *mut ::termios);
-            pub fn cfsetspeed(termios: *mut ::termios,
+            pub fn cfmakeraw(termios: *mut platform::termios);
+            pub fn cfsetspeed(termios: *mut platform::termios,
                               speed: ::speed_t) -> ::c_int;
         }
    }
@@ -1617,4 +1617,4 @@ pub mod sync;
 
 mod io;
 
-pub use header::*;
+// pub use header::*;

+ 3 - 11
dlibc/src/unix/platform/dragonos/musl/mod.rs

@@ -1,16 +1,8 @@
 pub type pthread_t = *mut ::c_void;
 pub type clock_t = c_long;
-#[cfg_attr(
-    not(feature = "rustc-dep-of-std"),
-    deprecated(
-        since = "0.2.80",
-        note = "This type is changed to 64-bit in musl 1.2.0, \
-                we'll follow that change in the future release. \
-                See #1848 for more info."
-    )
-)]
-pub type time_t = c_long;
-pub type suseconds_t = c_long;
+
+pub type time_t = i64;
+pub type suseconds_t = i64;
 pub type ino_t = u64;
 pub type off_t = i64;
 pub type blkcnt_t = i64;

+ 9 - 10
dlibc/src/unix/platform/dragonos/pal/mod.rs

@@ -17,8 +17,7 @@ pub extern "C" fn e(sys: usize) -> usize {
     }
 }
 
-#[no_mangle]
-pub extern "C" fn getrandom(_buf: &mut [u8], _flags: ::c_uint) -> ::ssize_t {
+pub fn getrandom(_buf: &mut [u8], _flags: ::c_uint) -> ::ssize_t {
     0
 }
 
@@ -753,8 +752,8 @@ pub extern "C" fn syscall(_num: ::c_long) -> ::c_long {
 // 	unimplemented!()
 // }
 #[no_mangle]
-pub extern "C" fn pipe(fds: *mut ::c_int) -> ::c_int{
-	e(unsafe { syscall!(SYS_PIPE, fds) }) as ::c_int
+pub extern "C" fn pipe(fds: *mut ::c_int) -> ::c_int {
+    e(unsafe { syscall!(SYS_PIPE, fds) }) as ::c_int
 }
 // #[no_mangle]
 // pub extern "C" fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int{
@@ -783,8 +782,8 @@ pub extern "C" fn pipe(fds: *mut ::c_int) -> ::c_int{
 // 	unimplemented!()
 // }
 #[no_mangle]
-pub extern "C" fn setuid(uid: ::uid_t) -> ::c_int{
-	0
+pub extern "C" fn setuid(_uid: ::uid_t) -> ::c_int {
+    0
 }
 
 // #[cfg_attr(
@@ -922,8 +921,8 @@ pub extern "C" fn setuid(uid: ::uid_t) -> ::c_int{
 // }
 
 #[no_mangle]
-pub extern "C" fn signal(signum: ::c_int, handler: ::sighandler_t) -> ::sighandler_t{
-	0
+pub extern "C" fn signal(_signum: ::c_int, _handler: ::sighandler_t) -> ::sighandler_t {
+    0
     //unimplemented!()
 }
 
@@ -1780,8 +1779,8 @@ pub extern "C" fn pthread_setspecific(_key: ::pthread_key_t, _value: *const ::c_
 // 	unimplemented!()
 // }
 #[no_mangle]
-pub extern "C" fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int{
-	0
+pub extern "C" fn setgroups(_ngroups: ::size_t, _ptr: *const ::gid_t) -> ::c_int {
+    0
 }
 // #[no_mangle]
 // pub extern "C" fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int{

+ 1 - 0
dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal.rs

@@ -4,6 +4,7 @@ use crate::unix::platform::pal::e;
 use crate::unix::*;
 use dsc::syscall;
 
+#[allow(improper_ctypes_definitions)]
 pub extern "C" fn utimens(_path: &CStr, _times: *const timespec) -> ::c_int {
     // e(unsafe { syscall!(UTIMENSAT, AT_FDCWD, path.as_ptr(), times, 0) }) as ::c_int
     unimplemented!()

+ 44 - 37
dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_signal.rs

@@ -1,69 +1,76 @@
-use crate::unix::platform::pal::{e};
-use mem;
+use crate::unix::platform::pal::e;
 use crate::unix::*;
 use dsc::syscall;
+use mem;
 
 use stack_t;
 
 #[no_mangle]
 pub extern "C" fn getitimer(_which: ::c_int, _out: *mut ::itimerval) -> ::c_int {
-	// e(unsafe { syscall!(GETITIMER, which, out) }) as ::c_int
-	unimplemented!()
+    // e(unsafe { syscall!(GETITIMER, which, out) }) as ::c_int
+    unimplemented!()
 }
 
 #[no_mangle]
 pub extern "C" fn kill(pid: ::pid_t, sig: ::c_int) -> ::c_int {
-	e(unsafe { syscall!(SYS_KILL, pid, sig) }) as ::c_int
+    e(unsafe { syscall!(SYS_KILL, pid, sig) }) as ::c_int
 }
 
 #[no_mangle]
 pub extern "C" fn killpg(pgrp: ::pid_t, sig: ::c_int) -> ::c_int {
-	e(unsafe { syscall!(SYS_KILL, -(pgrp as isize) as ::pid_t, sig) }) as ::c_int
+    e(unsafe { syscall!(SYS_KILL, -(pgrp as isize) as ::pid_t, sig) }) as ::c_int
 }
 
 #[no_mangle]
 pub extern "C" fn raise(sig: ::c_int) -> ::c_int {
-	let tid = e(unsafe { syscall!(SYS_GETPID) }) as ::pid_t;
-	if tid == !0 {
-		-1
-	} else {
-		// e(unsafe { syscall!(TKILL, tid, sig) }) as ::c_int
-		self::kill(tid, sig)
-	}
+    let tid = e(unsafe { syscall!(SYS_GETPID) }) as ::pid_t;
+    if tid == !0 {
+        -1
+    } else {
+        // e(unsafe { syscall!(TKILL, tid, sig) }) as ::c_int
+        self::kill(tid, sig)
+    }
 }
 
 #[no_mangle]
-pub extern "C" fn setitimer(_which: ::c_int, _new: *const ::itimerval, _old: *mut ::itimerval) -> ::c_int {
-	// e(unsafe { syscall!(SETITIMER, which, new, old) }) as ::c_int
-	unimplemented!()
+pub extern "C" fn setitimer(
+    _which: ::c_int,
+    _new: *const ::itimerval,
+    _old: *mut ::itimerval,
+) -> ::c_int {
+    // e(unsafe { syscall!(SETITIMER, which, new, old) }) as ::c_int
+    unimplemented!()
 }
 
-
 #[no_mangle]
-pub extern "C" fn sigaction(
-	signum: ::c_int,
-	act: *const sigaction,
-	oldact: *mut sigaction)
-	-> ::c_int {
-	e(unsafe {
-		syscall!(
-			SYS_SIGACTION,
-			signum,
-			act,
-			oldact,
-			mem::size_of::<sigset_t>()
-		)
-	}) as ::c_int
+pub unsafe extern "C" fn sigaction(
+    signum: ::c_int,
+    act: *const sigaction,
+    oldact: *mut sigaction,
+) -> ::c_int {
+    e(unsafe {
+        syscall!(
+            SYS_SIGACTION,
+            signum,
+            act,
+            oldact,
+            mem::size_of::<sigset_t>()
+        )
+    }) as ::c_int
 }
 
 #[no_mangle]
 pub extern "C" fn sigaltstack(_ss: *const stack_t, _old_ss: *mut stack_t) -> ::c_int {
-	// e(unsafe { syscall!(SIGALTSTACK, ss, old_ss) }) as ::c_int
-	unimplemented!()
+    // e(unsafe { syscall!(SIGALTSTACK, ss, old_ss) }) as ::c_int
+    unimplemented!()
 }
 
 #[no_mangle]
-pub extern "C" fn sigprocmask(_how: ::c_int, _set: *const sigset_t, _oset: *mut sigset_t) -> ::c_int {
-	// e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as ::c_int
-	unimplemented!()
-}
+pub extern "C" fn sigprocmask(
+    _how: ::c_int,
+    _set: *const sigset_t,
+    _oset: *mut sigset_t,
+) -> ::c_int {
+    // e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as ::c_int
+    unimplemented!()
+}

+ 10 - 11
dlibc/src/unix/start.rs

@@ -1,13 +1,13 @@
-use alloc::{boxed::Box, vec::Vec};
-use core::{fmt::Debug, intrinsics, ptr};
-use unix::platform::allocator::new_mspace;
 use crate::unix::{
-    header::{libgen},
+    allocator::ALLOCATOR,
+    header::libgen,
     ld_so::{self, linker::Linker},
     platform::{self, get_auxvs},
     sync::mutex::Mutex,
-    allocator::ALLOCATOR,
 };
+use alloc::{boxed::Box, vec::Vec};
+use core::{fmt::Debug, intrinsics, ptr};
+use unix::platform::allocator::new_mspace;
 
 #[repr(C)]
 pub struct Stack {
@@ -46,9 +46,9 @@ impl Debug for Stack {
 
 unsafe fn copy_string_array(array: *const *const ::c_char, len: usize) -> Vec<*mut ::c_char> {
     //println!("copy_string_array: array: {:p}, len: {}", array, len);
-    
+
     let mut vec = Vec::with_capacity(len + 1);
-    
+
     for i in 0..len {
         let item = *array.add(i);
         let mut len = 0;
@@ -136,13 +136,13 @@ extern "C" fn init_array() {
     //     init_complete = true
     // }
 }
-use stdio;
+use header::stdio;
 
 fn io_init() {
     unsafe {
         // Initialize stdin/stdout/stderr,
         // see https://github.com/rust-lang/rust/issues/51718
-        
+
         stdio::stdin = stdio::default_stdin.get();
         stdio::stdout = stdio::default_stdout.get();
         stdio::stderr = stdio::default_stderr.get();
@@ -192,7 +192,6 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
 
     // Ensure correct host system before executing more system calls
     relibc_verify_host();
-    
 
     // Initialize TLS, if necessary
     ld_so::init(sp);
@@ -287,5 +286,5 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
     // not argv or envp, because programs like bash try to modify this *const* pointer :|
     platform::pal::exit(0);
 
-    unreachable!();
+    // unreachable!();
 }

+ 2 - 6
dlibc/src/unix/sync/mod.rs

@@ -9,11 +9,7 @@ pub use self::{
 };
 
 use crate::unix::platform;
-use core::{
-    cell::UnsafeCell,
-    ops::Deref,
-    sync::atomic::{self, AtomicI32 as AtomicInt},
-};
+use core::{cell::UnsafeCell, hint::spin_loop, ops::Deref, sync::atomic::AtomicI32 as AtomicInt};
 
 const FUTEX_WAIT: ::c_int = 0;
 const FUTEX_WAKE: ::c_int = 1;
@@ -87,7 +83,7 @@ impl AtomicLock {
     {
         // First, try spinning for really short durations
         for _ in 0..999 {
-            atomic::spin_loop_hint();
+            spin_loop();
             if attempt(self) == AttemptStatus::Desired {
                 return;
             }

+ 1 - 0
dlibc/src/unix/sync/once.rs

@@ -24,6 +24,7 @@ impl<T> Once<T> {
     where
         F: FnOnce() -> T,
     {
+        #[allow(deprecated)]
         match self
             .status
             .compare_and_swap(UNINITIALIZED, INITIALIZING, SeqCst)

+ 4 - 4
src/lib.rs

@@ -1,4 +1,7 @@
 #![no_std]
+#![allow(internal_features)]
+#![allow(incomplete_features)]
+#![allow(hidden_glob_reexports)]
 #![feature(allocator_api)]
 #![feature(core_intrinsics)]
 #![feature(linkage)]
@@ -9,6 +12,7 @@
 #![allow(non_camel_case_types)]
 #![allow(non_upper_case_globals)]
 #![feature(lang_items)]
+#![feature(provide_any)]
 #![feature(std_internals)]
 #![feature(extend_one)]
 #![feature(exact_size_is_empty)]
@@ -89,12 +93,9 @@
 #[macro_use]
 extern crate alloc;
 
-#[macro_use]
 extern crate memoffset;
 
-//TODO: fix this: adjust to dragonos sc
 #[cfg(target_os = "dragonos")]
-#[macro_use]
 extern crate dsc;
 
 #[macro_use]
@@ -104,7 +105,6 @@ pub mod std;
 pub use self::std::*;
 
 #[cfg(target_os = "dragonos")]
-#[macro_use]
 pub use dlibc::{eprint, eprintln, print, println};
 
 // use core::panic::PanicInfo;

+ 0 - 5
src/std/alloc.rs

@@ -63,11 +63,6 @@ use core::{mem, ptr};
 #[doc(inline)]
 pub use alloc::alloc::*;
 
-use core::alloc::AllocError;
-use core::alloc::Allocator;
-use core::alloc::GlobalAlloc;
-use core::alloc::Layout;
-
 /// The default memory allocator provided by the operating system.
 ///
 /// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows,

+ 1 - 0
src/std/backtrace.rs

@@ -84,6 +84,7 @@
 // a backtrace or actually symbolizing it.
 
 //use crate::std::backtrace_rs::{self, BytesOrWideString};
+#![allow(dead_code)]
 use crate::std::env;
 use crate::std::ffi::c_void;
 use crate::std::fmt;

+ 2 - 2
src/std/collections/hash/map.rs

@@ -11,8 +11,8 @@
 // use crate::std::collections::TryReserveErrorKind;
 // use crate::std::error::Error;
 // use crate::std::fmt::{self, Debug};
-// #[allow(deprecated)]
-use core::hash::{BuildHasher, Hash, Hasher, SipHasher13};
+#[allow(deprecated)]
+use core::hash::{Hasher, SipHasher13};
 // use crate::std::iter::FusedIterator;
 // use crate::std::ops::Index;
 // use crate::std::sys;

+ 1 - 1
src/std/error.rs

@@ -3,8 +3,8 @@
 use crate::std::backtrace::Backtrace;
 use crate::std::fmt::{self, Write};
 
+pub use core::any::{request_ref, request_value};
 pub use core::error::Error;
-pub use core::error::{request_ref, request_value, Request};
 
 mod private {
     // This is a hack to prevent `type_id` from being overridden by `Error`

+ 1 - 0
src/std/panic.rs

@@ -206,6 +206,7 @@ pub enum BacktraceStyle {
 }
 
 impl BacktraceStyle {
+    #[allow(dead_code)]
     pub(crate) fn full() -> Option<Self> {
         if cfg!(feature = "backtrace") {
             Some(BacktraceStyle::Full)

+ 2 - 0
src/std/rt.rs

@@ -86,6 +86,7 @@ macro_rules! rtunwrap {
 // Even though it is an `u8`, it only ever has 4 values. These are documented in
 // `compiler/rustc_session/src/config/sigpipe.rs`.
 #[cfg_attr(test, allow(dead_code))]
+#[allow(dead_code)]
 unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
     unsafe {
         sys::init(argc, argv, sigpipe);
@@ -116,6 +117,7 @@ pub(crate) fn cleanup() {
 // To reduce the generated code of the new `lang_start`, this function is doing
 // the real work.
 #[cfg(not(test))]
+#[allow(dead_code)]
 fn lang_start_internal(
     main: &(dyn Fn() -> i32 + Sync + crate::std::panic::RefUnwindSafe),
     argc: isize,

+ 1 - 2
src/std/sys/unix/fs.rs

@@ -40,14 +40,12 @@ use dlibc::{c_int, mode_t};
     target_os = "dragonos",
     all(target_os = "linux", target_env = "gnu")
 ))]
-use dlibc::c_char;
 #[cfg(any(
     target_os = "linux",
     target_os = "emscripten",
     target_os = "android",
     target_os = "dragonos",
 ))]
-use dlibc::dirfd;
 #[cfg(any(target_os = "linux", target_os = "emscripten",))]
 use dlibc::fstatat64;
 #[cfg(any(
@@ -1634,6 +1632,7 @@ pub fn readlink(p: &Path) -> io::Result<PathBuf> {
         let mut buf = Vec::with_capacity(256);
 
         loop {
+            #[allow(unused_unsafe)]
             let buf_read =
                 cvt(unsafe { dlibc::readlink(p, buf.as_mut_ptr() as *mut _, buf.capacity()) })?
                     as usize;

+ 1 - 0
src/std/sys/unix/kernel_copy.rs

@@ -66,6 +66,7 @@ use dlibc::sendfile as sendfile64;
 use dlibc::sendfile64;
 use dlibc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
 
+#[allow(dead_code)]
 pub(crate) fn copy_spec<R: Read + ?Sized, W: Write + ?Sized>(
     read: &mut R,
     write: &mut W,

+ 2 - 0
src/std/sys/unix/net.rs

@@ -445,6 +445,7 @@ impl Socket {
     }
 
     #[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonos"))]
+    #[allow(dead_code)]
     pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
         setsockopt(
             self,
@@ -455,6 +456,7 @@ impl Socket {
     }
 
     #[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonos"))]
+    #[allow(dead_code)]
     pub fn passcred(&self) -> io::Result<bool> {
         let passcred: dlibc::c_int = getsockopt(self, dlibc::SOL_SOCKET, dlibc::SO_PASSCRED)?;
         Ok(passcred != 0)

+ 1 - 2
src/std/sys/unix/process/process_unix.rs

@@ -6,7 +6,7 @@ use crate::std::num::NonZeroI32;
 use crate::std::sys;
 use crate::std::sys::cvt;
 use crate::std::sys::process::process_common::*;
-use crate::{print, println};
+
 use core::ffi::NonZero_c_int;
 use dlibc;
 
@@ -319,7 +319,6 @@ impl Command {
         stdio: ChildPipes,
         maybe_envp: Option<&CStringArray>,
     ) -> Result<!, io::Error> {
-
         use crate::std::sys::{self, cvt_r};
 
         if let Some(fd) = stdio.stdin.fd() {

+ 2 - 0
src/std/sys/unix/rand.rs

@@ -1,3 +1,4 @@
+#[allow(dead_code)]
 pub fn hashmap_random_keys() -> (u64, u64) {
     const KEY_LEN: usize = core::mem::size_of::<u64>();
 
@@ -138,6 +139,7 @@ mod imp {
         true
     }
 
+    #[allow(dead_code)]
     pub fn fill_bytes(v: &mut [u8]) {
         // getrandom_fill_bytes here can fail if getrandom() returns EAGAIN,
         // meaning it would have blocked because the non-blocking pool (urandom)

+ 1 - 0
src/std/sys/unix/stack_overflow.rs

@@ -112,6 +112,7 @@ mod imp {
     static MAIN_ALTSTACK: AtomicPtr<dlibc::c_void> = AtomicPtr::new(ptr::null_mut());
     static NEED_ALTSTACK: AtomicBool = AtomicBool::new(false);
 
+    #[allow(dead_code)]
     pub unsafe fn init() {
         let mut action: sigaction = mem::zeroed();
         for &signal in &[SIGSEGV, SIGBUS] {

+ 2 - 0
src/std/sys_common/backtrace.rs

@@ -2,9 +2,11 @@
 
 use crate::std::sync::{Mutex, PoisonError};
 
+#[allow(dead_code)]
 /// Max number of frames to print.
 const MAX_NB_FRAMES: usize = 100;
 
+#[allow(dead_code)]
 pub fn lock() -> impl Drop {
     static LOCK: Mutex<()> = Mutex::new(());
     LOCK.lock().unwrap_or_else(PoisonError::into_inner)

+ 1 - 0
src/std/sys_common/wtf8.rs

@@ -955,6 +955,7 @@ pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 {
 pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! {
     assert!(begin <= end);
     panic!("index {begin} and/or {end} in `{s:?}` do not lie on character boundary");
+    #[allow(unreachable_code)]
     loop {}
 }