Browse Source

rustfmt (#23)

* cargo nightly

* 固定工具链为2023-08-13(rust-1.73)

* rust 20230815

* 解决cargo check报错问题

* rustfmt
LoGin 1 year ago
parent
commit
a1cd34728e
96 changed files with 741 additions and 590 deletions
  1. 6 2
      .cargo/config.toml
  2. 2 3
      .vscode/settings.json
  3. 1 1
      Makefile
  4. 76 52
      dlibc/core_io/build.rs
  5. 31 19
      dlibc/core_io/src/lib.rs
  6. 100 71
      dlibc/posix-regex/src/compile.rs
  7. 119 81
      dlibc/posix-regex/src/matcher.rs
  8. 8 12
      dlibc/src/lib.rs
  9. 0 1
      dlibc/src/unix/c_vec.rs
  10. 4 4
      dlibc/src/unix/fs.rs
  11. 1 1
      dlibc/src/unix/header/_aio/mod.rs
  12. 1 1
      dlibc/src/unix/header/_fenv/mod.rs
  13. 0 1
      dlibc/src/unix/header/arch_aarch64_user/mod.rs
  14. 7 3
      dlibc/src/unix/header/arpa_inet/mod.rs
  15. 3 1
      dlibc/src/unix/header/ctype/mod.rs
  16. 3 1
      dlibc/src/unix/header/dirent/mod.rs
  17. 1 1
      dlibc/src/unix/header/dl-tls/mod.rs
  18. 2 2
      dlibc/src/unix/header/dlfcn/mod.rs
  19. 30 31
      dlibc/src/unix/header/elf/mod.rs
  20. 6 4
      dlibc/src/unix/header/fcntl/mod.rs
  21. 0 1
      dlibc/src/unix/header/fnmatch/mod.rs
  22. 3 3
      dlibc/src/unix/header/getopt/mod.rs
  23. 0 2
      dlibc/src/unix/header/grp/mod.rs
  24. 0 2
      dlibc/src/unix/header/locale/mod.rs
  25. 0 4
      dlibc/src/unix/header/netdb/dns/mod.rs
  26. 1 1
      dlibc/src/unix/header/netdb/dragonos.rs
  27. 4 1
      dlibc/src/unix/header/netdb/host.rs
  28. 15 6
      dlibc/src/unix/header/netdb/mod.rs
  29. 0 2
      dlibc/src/unix/header/netinet_tcp/mod.rs
  30. 3 4
      dlibc/src/unix/header/poll/mod.rs
  31. 0 1
      dlibc/src/unix/header/pwd/dragonos.rs
  32. 0 1
      dlibc/src/unix/header/pwd/linux.rs
  33. 0 1
      dlibc/src/unix/header/pwd/mod.rs
  34. 0 1
      dlibc/src/unix/header/pwd/redox.rs
  35. 5 1
      dlibc/src/unix/header/regex/mod.rs
  36. 0 2
      dlibc/src/unix/header/semaphore/mod.rs
  37. 0 2
      dlibc/src/unix/header/stdio/constants.rs
  38. 2 6
      dlibc/src/unix/header/stdio/helpers.rs
  39. 26 11
      dlibc/src/unix/header/stdio/mod.rs
  40. 6 5
      dlibc/src/unix/header/stdio/printf.rs
  41. 2 2
      dlibc/src/unix/header/stdio/scanf.rs
  42. 0 2
      dlibc/src/unix/header/stdlib/rand48.rs
  43. 0 1
      dlibc/src/unix/header/stdlib/random.rs
  44. 11 4
      dlibc/src/unix/header/stdlib/sort.rs
  45. 46 12
      dlibc/src/unix/header/string/mod.rs
  46. 5 1
      dlibc/src/unix/header/strings/mod.rs
  47. 0 2
      dlibc/src/unix/header/sys_auxv/mod.rs
  48. 1 3
      dlibc/src/unix/header/sys_epoll/mod.rs
  49. 0 1
      dlibc/src/unix/header/sys_file/mod.rs
  50. 0 1
      dlibc/src/unix/header/sys_ioctl/linux.rs
  51. 0 2
      dlibc/src/unix/header/sys_ioctl/mod.rs
  52. 5 3
      dlibc/src/unix/header/sys_mman/mod.rs
  53. 0 1
      dlibc/src/unix/header/sys_procfs/mod.rs
  54. 1 1
      dlibc/src/unix/header/sys_ptrace/mod.rs
  55. 0 3
      dlibc/src/unix/header/sys_random/mod.rs
  56. 4 6
      dlibc/src/unix/header/sys_select/mod.rs
  57. 0 2
      dlibc/src/unix/header/sys_socket/constants.rs
  58. 2 6
      dlibc/src/unix/header/sys_socket/mod.rs
  59. 1 5
      dlibc/src/unix/header/sys_stat/mod.rs
  60. 1 4
      dlibc/src/unix/header/sys_statvfs/mod.rs
  61. 6 6
      dlibc/src/unix/header/sys_time/mod.rs
  62. 1 1
      dlibc/src/unix/header/sys_timeb/mod.rs
  63. 0 2
      dlibc/src/unix/header/sys_utsname/mod.rs
  64. 0 1
      dlibc/src/unix/header/sys_wait/mod.rs
  65. 2 2
      dlibc/src/unix/header/termios/mod.rs
  66. 2 5
      dlibc/src/unix/header/time/mod.rs
  67. 1 4
      dlibc/src/unix/header/unistd/brk.rs
  68. 1 1
      dlibc/src/unix/header/unistd/sysconf.rs
  69. 43 11
      dlibc/src/unix/header/wchar/mod.rs
  70. 7 2
      dlibc/src/unix/header/wchar/utf8.rs
  71. 0 2
      dlibc/src/unix/header/wctype/alpha.rs
  72. 0 2
      dlibc/src/unix/header/wctype/casecmp.rs
  73. 4 2
      dlibc/src/unix/header/wctype/mod.rs
  74. 0 2
      dlibc/src/unix/header/wctype/punct.rs
  75. 1 1
      dlibc/src/unix/ld_so/access.rs
  76. 8 8
      dlibc/src/unix/ld_so/dso.rs
  77. 2 2
      dlibc/src/unix/ld_so/linker.rs
  78. 2 2
      dlibc/src/unix/ld_so/start.rs
  79. 3 9
      dlibc/src/unix/ld_so/tcb.rs
  80. 1 1
      dlibc/src/unix/macros.rs
  81. 5 1
      dlibc/src/unix/mod.rs
  82. 7 3
      dlibc/src/unix/platform/dragonos/allocator/dragonos_malloc.rs
  83. 8 11
      dlibc/src/unix/platform/dragonos/mod.rs
  84. 1 2
      dlibc/src/unix/platform/dragonos/musl/b64/mod.rs
  85. 1 0
      dlibc/src/unix/platform/dragonos/musl/mod.rs
  86. 3 3
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/mod.rs
  87. 1 2
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal.rs
  88. 17 16
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_epoll.rs
  89. 37 44
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_socket.rs
  90. 3 7
      dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_trace.rs
  91. 18 16
      dlibc/src/unix/platform/mod.rs
  92. 8 4
      dlibc/src/unix/platform/rlb.rs
  93. 1 1
      dlibc/src/unix/sync/semaphore.rs
  94. 0 1
      src/lib.rs
  95. 1 2
      src/std/error.rs
  96. 1 0
      target.json

+ 6 - 2
.cargo/config.toml

@@ -1,2 +1,6 @@
-[alias]
-check = "check -Z build-std=core,alloc,compiler_builtins --target x86_64-unknown-dragonos"
+[build]
+target = "./target.json"
+
+[unstable]
+build-std = ["core", "compiler_builtins", "alloc"]
+build-std-features = ["compiler-builtins-mem"]

+ 2 - 3
.vscode/settings.json

@@ -4,7 +4,7 @@
     ],
     "rust-analyzer.check.overrideCommand": [
         "cargo",
-        "+nightly",
+        "+nightly-2023-08-15",
         "-Z",
         "build-std=core,alloc,compiler_builtins",
         "check",
@@ -13,6 +13,5 @@
         "--target",
         "target.json",
     ],
-
-    "rust-analyzer.cargo.target": "x86_64-unknown-dragonos",
+    // "rust-analyzer.cargo.target": "x86_64-unknown-dragonos",
 }

+ 1 - 1
Makefile

@@ -82,7 +82,7 @@ clean:
 	$(CARGO) clean
 
 check:
-	$(CARGO) check
+	$(CARGO) -Z build-std=core,alloc,compiler_builtins check --workspace --message-format=json --target target.json
 
 fmt:
 	$(CARGO) fmt

+ 76 - 52
dlibc/core_io/build.rs

@@ -3,79 +3,103 @@ extern crate rustc_version;
 use std::env;
 use std::fs::File;
 use std::io::Write;
+use std::ops::{Neg, Sub};
 use std::path::PathBuf;
-use std::ops::{Neg,Sub};
 
 /*
- * Let me explain this hack. For the sync shell script it's easiest if every 
- * line in mapping.rs looks exactly the same. This means that specifying an 
- * array literal is not possible. include!() can only expand to expressions, so 
+ * Let me explain this hack. For the sync shell script it's easiest if every
+ * line in mapping.rs looks exactly the same. This means that specifying an
+ * array literal is not possible. include!() can only expand to expressions, so
  * just specifying the contents of an array is also not possible.
  *
- * This leaves us with trying to find an expression in which every line looks 
- * the same. This can be done using the `-` operator. This can be a unary 
- * operator (first thing on the first line), or a binary operator (later 
- * lines). That is exactly what's going on here, and Neg and Sub simply build a 
+ * This leaves us with trying to find an expression in which every line looks
+ * the same. This can be done using the `-` operator. This can be a unary
+ * operator (first thing on the first line), or a binary operator (later
+ * lines). That is exactly what's going on here, and Neg and Sub simply build a
  * vector of the operangs.
  */
-struct Mapping(&'static str,&'static str);
+struct Mapping(&'static str, &'static str);
 
 impl Neg for Mapping {
-	type Output = Vec<Mapping>;
+    type Output = Vec<Mapping>;
     fn neg(self) -> Vec<Mapping> {
-		vec![self.into()]
-	}
+        vec![self.into()]
+    }
 }
 
 impl Sub<Mapping> for Vec<Mapping> {
-    type Output=Vec<Mapping>;
+    type Output = Vec<Mapping>;
     fn sub(mut self, rhs: Mapping) -> Vec<Mapping> {
-		self.push(rhs.into());
-		self
-	}
+        self.push(rhs.into());
+        self
+    }
 }
 
 fn main() {
-	let ver=rustc_version::version_meta();
+    let ver = rustc_version::version_meta();
 
-	let io_commit="b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d";
-	/*
-	let io_commit=match env::var("CORE_IO_COMMIT") {
-		Ok(c) => c,
-		Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"),
-		Err(env::VarError::NotPresent) => {
-			let mappings=include!("mapping.rs");
-			
-			let compiler=ver.commit_hash.expect("Couldn't determine compiler version");
-			mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned()
-		}
-	};
-	*/
+    let io_commit = "b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d";
+    /*
+    let io_commit=match env::var("CORE_IO_COMMIT") {
+        Ok(c) => c,
+        Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"),
+        Err(env::VarError::NotPresent) => {
+            let mappings=include!("mapping.rs");
 
-	if ver.commit_date.as_ref().map_or(true,|d| &**d>="2018-01-01") {
-		println!("cargo:rustc-cfg=core_memchr");
-	}
+            let compiler=ver.commit_hash.expect("Couldn't determine compiler version");
+            mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned()
+        }
+    };
+    */
 
-	if ver.commit_date.as_ref().map_or(true,|d| &**d>="2017-06-15") {
-		println!("cargo:rustc-cfg=no_collections");
-	}
+    if ver
+        .commit_date
+        .as_ref()
+        .map_or(true, |d| &**d >= "2018-01-01")
+    {
+        println!("cargo:rustc-cfg=core_memchr");
+    }
 
-	if ver.commit_date.as_ref().map_or(false,|d| &**d<"2016-12-15") {
-		println!("cargo:rustc-cfg=rustc_unicode");
-	} else if ver.commit_date.as_ref().map_or(false,|d| &**d<"2017-03-03") {
-		println!("cargo:rustc-cfg=std_unicode");
-	}
+    if ver
+        .commit_date
+        .as_ref()
+        .map_or(true, |d| &**d >= "2017-06-15")
+    {
+        println!("cargo:rustc-cfg=no_collections");
+    }
 
-	let mut dest_path=PathBuf::from(env::var_os("OUT_DIR").unwrap());
-	dest_path.push("io.rs");
-	let mut f=File::create(&dest_path).unwrap();
-	
-	let mut target_path=PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
-	target_path.push("src");
-	target_path.push(io_commit);
-	target_path.push("mod.rs");
+    if ver
+        .commit_date
+        .as_ref()
+        .map_or(false, |d| &**d < "2016-12-15")
+    {
+        println!("cargo:rustc-cfg=rustc_unicode");
+    } else if ver
+        .commit_date
+        .as_ref()
+        .map_or(false, |d| &**d < "2017-03-03")
+    {
+        println!("cargo:rustc-cfg=std_unicode");
+    }
 
-	f.write_all(br#"#[path=""#).unwrap();
-	f.write_all(target_path.into_os_string().into_string().unwrap().replace("\\", "\\\\").as_bytes()).unwrap();
-	f.write_all(br#""] mod io;"#).unwrap();
+    let mut dest_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
+    dest_path.push("io.rs");
+    let mut f = File::create(&dest_path).unwrap();
+
+    let mut target_path = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
+    target_path.push("src");
+    target_path.push(io_commit);
+    target_path.push("mod.rs");
+
+    f.write_all(br#"#[path=""#).unwrap();
+    f.write_all(
+        target_path
+            .into_os_string()
+            .into_string()
+            .unwrap()
+            .replace("\\", "\\\\")
+            .as_bytes(),
+    )
+    .unwrap();
+    f.write_all(br#""] mod io;"#).unwrap();
 }

+ 31 - 19
dlibc/core_io/src/lib.rs

@@ -2,48 +2,60 @@
 //! This is just a listing of the functionality available in this crate. See
 //! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html)
 //! for a full description of the functionality.
-#![allow(stable_features,unused_features)]
-#![feature(question_mark,copy_from_slice,
-	doc_notable_trait,try_from,str_internals,align_offset,slice_internals)]
-#![cfg_attr(feature="alloc",feature(alloc))]
+#![allow(stable_features, unused_features)]
+#![feature(
+    question_mark,
+    copy_from_slice,
+    doc_notable_trait,
+    try_from,
+    str_internals,
+    align_offset,
+    slice_internals
+)]
+#![cfg_attr(feature = "alloc", feature(alloc))]
 #![no_std]
 
-#[cfg_attr(feature="collections",macro_use)]
-#[cfg(all(feature="collections",not(no_collections)))] extern crate collections;
-#[cfg_attr(feature="collections",allow(unused_imports))]
-#[cfg_attr(feature="collections",macro_use)]
-#[cfg(all(feature="collections",no_collections))] extern crate alloc as collections;
-#[cfg(feature="alloc")] extern crate alloc;
+#[cfg(feature = "alloc")]
+extern crate alloc;
+#[cfg_attr(feature = "collections", allow(unused_imports))]
+#[cfg_attr(feature = "collections", macro_use)]
+#[cfg(all(feature = "collections", no_collections))]
+extern crate alloc as collections;
+#[cfg_attr(feature = "collections", macro_use)]
+#[cfg(all(feature = "collections", not(no_collections)))]
+extern crate collections;
 #[cfg(rustc_unicode)]
 extern crate rustc_unicode;
 #[cfg(std_unicode)]
 extern crate std_unicode;
 
-#[cfg(not(feature="collections"))]
+#[cfg(not(feature = "collections"))]
 pub type ErrorString = &'static str;
 
 // Provide Box::new wrapper
-#[cfg(not(feature="alloc"))]
+#[cfg(not(feature = "alloc"))]
 struct FakeBox<T>(core::marker::PhantomData<T>);
-#[cfg(not(feature="alloc"))]
+#[cfg(not(feature = "alloc"))]
 impl<T> FakeBox<T> {
-	fn new(val: T) -> T {
-		val
-	}
+    fn new(val: T) -> T {
+        val
+    }
 }
 
 // Needed for older compilers, to ignore vec!/format! macros in tests
-#[cfg(not(feature="collections"))]
+#[cfg(not(feature = "collections"))]
 #[allow(unused)]
 macro_rules! vec (
 	( $ elem : expr ; $ n : expr ) => { () };
 	( $ ( $ x : expr ) , * ) => { () };
 	( $ ( $ x : expr , ) * ) => { () };
 );
-#[cfg(not(feature="collections"))]
+#[cfg(not(feature = "collections"))]
 #[allow(unused)]
 macro_rules! format {
-	( $ ( $ arg : tt ) * ) => { () };
+    ( $ ( $ arg : tt ) * ) => {
+        ()
+    };
 }
 
 include!(concat!(env!("OUT_DIR"), "/io.rs"));

+ 100 - 71
dlibc/posix-regex/src/compile.rs

@@ -25,7 +25,7 @@ impl fmt::Debug for Range {
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum Collation {
     Char(u8),
-    Class(fn(u8) -> bool)
+    Class(fn(u8) -> bool),
 }
 impl Collation {
     /// Compare this collation to a character
@@ -33,7 +33,7 @@ impl Collation {
         match *self {
             Collation::Char(me) if insensitive => me & !32 == other & !32,
             Collation::Char(me) => me == other,
-            Collation::Class(f) => f(other)
+            Collation::Class(f) => f(other),
         }
     }
 }
@@ -48,15 +48,15 @@ pub enum Token {
     End,
     Group {
         id: usize,
-        branches: Vec<Vec<(Token, Range)>>
+        branches: Vec<Vec<(Token, Range)>>,
     },
     OneOf {
         invert: bool,
-        list: Vec<Collation>
+        list: Vec<Collation>,
     },
     Start,
     WordEnd,
-    WordStart
+    WordStart,
 }
 impl fmt::Debug for Token {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -70,7 +70,7 @@ impl fmt::Debug for Token {
             Token::OneOf { invert, ref list } => write!(f, "[invert: {}; {:?}]", invert, list),
             Token::Start => write!(f, "^"),
             Token::WordEnd => write!(f, ">"),
-            Token::WordStart => write!(f, "<")
+            Token::WordStart => write!(f, "<"),
         }
     }
 }
@@ -86,14 +86,14 @@ pub enum Error {
     UnclosedRepetition,
     UnexpectedToken(u8),
     UnknownClass(Vec<u8>),
-    UnknownCollation
+    UnknownCollation,
 }
 
 /// A regex builder struct
 pub struct PosixRegexBuilder<'a> {
     input: &'a [u8],
     classes: HashMap<&'a [u8], fn(u8) -> bool>,
-    group_id: usize
+    group_id: usize,
 }
 impl<'a> PosixRegexBuilder<'a> {
     /// Create a new instance that is ready to parse the regex `input`
@@ -101,7 +101,7 @@ impl<'a> PosixRegexBuilder<'a> {
         Self {
             input,
             classes: HashMap::new(),
-            group_id: 1
+            group_id: 1,
         }
     }
     /// Add a custom collation class, for use within square brackets (such as `[[:digit:]]`)
@@ -142,16 +142,22 @@ impl<'a> PosixRegexBuilder<'a> {
         let mut out: Option<u32> = None;
         while let Some(&c @ b'0'..=b'9') = self.input.first() {
             self.consume(1);
-            out = Some(out.unwrap_or(0)
-                .checked_mul(10)
-                .and_then(|out| out.checked_add((c - b'0') as u32))
-                .ok_or(Error::IntegerOverflow)?);
+            out = Some(
+                out.unwrap_or(0)
+                    .checked_mul(10)
+                    .and_then(|out| out.checked_add((c - b'0') as u32))
+                    .ok_or(Error::IntegerOverflow)?,
+            );
         }
         Ok(out)
     }
     fn next(&mut self) -> Result<u8, Error> {
-        self.input.first()
-            .map(|&c| { self.consume(1); c })
+        self.input
+            .first()
+            .map(|&c| {
+                self.consume(1);
+                c
+            })
             .ok_or(Error::EOF)
     }
     fn expect(&mut self, c: u8) -> Result<(), Error> {
@@ -171,12 +177,14 @@ impl<'a> PosixRegexBuilder<'a> {
                 b'^' => Token::Start,
                 b'$' => Token::End,
                 b'.' => Token::Any,
-                b'*' => if let Some(last) = chain.last_mut() {
-                    last.1 = Range(0, None);
-                    continue;
-                } else {
-                    return Err(Error::LeadingRepetition);
-                },
+                b'*' => {
+                    if let Some(last) = chain.last_mut() {
+                        last.1 = Range(0, None);
+                        continue;
+                    } else {
+                        return Err(Error::LeadingRepetition);
+                    }
+                }
                 b'[' => {
                     let mut list = Vec::new();
                     let invert = self.input.first() == Some(&b'^');
@@ -199,33 +207,41 @@ impl<'a> PosixRegexBuilder<'a> {
                                     c = self.next()?;
                                     self.expect(b'.')?;
                                     self.expect(b']')?;
-                                },
+                                }
                                 b'=' => {
                                     c = self.next()?;
                                     self.expect(b'=')?;
                                     self.expect(b']')?;
-                                },
+                                }
                                 b':' => {
-                                    let end = self.input.iter().position(|&c| c == b':').ok_or(Error::EOF)?;
+                                    let end = self
+                                        .input
+                                        .iter()
+                                        .position(|&c| c == b':')
+                                        .ok_or(Error::EOF)?;
                                     let key = &self.input[..end];
-                                    let class = *self.classes.get(key).ok_or_else(|| Error::UnknownClass(key.to_vec()))?;
+                                    let class = *self
+                                        .classes
+                                        .get(key)
+                                        .ok_or_else(|| Error::UnknownClass(key.to_vec()))?;
                                     self.consume(end + 1);
                                     self.expect(b']')?;
 
                                     list.push(Collation::Class(class));
                                     push = false;
-                                },
-                                _ => return Err(Error::UnknownCollation)
+                                }
+                                _ => return Err(Error::UnknownCollation),
                             }
                         }
 
                         if push {
                             list.push(Collation::Char(c));
 
-                            if self.input.first() == Some(&b'-') && self.input.get(1) != Some(&b']') {
+                            if self.input.first() == Some(&b'-') && self.input.get(1) != Some(&b']')
+                            {
                                 self.consume(1);
                                 let dest = self.next()?;
-                                for c in (c+1)..=dest {
+                                for c in (c + 1)..=dest {
                                     list.push(Collation::Char(c));
                                 }
                             }
@@ -237,20 +253,17 @@ impl<'a> PosixRegexBuilder<'a> {
                         }
                     }
 
-                    Token::OneOf {
-                        invert,
-                        list
-                    }
-                },
+                    Token::OneOf { invert, list }
+                }
                 b'\\' => match self.next()? {
                     b'(' => {
                         let id = self.group_id;
                         self.group_id += 1;
                         Token::Group {
                             id,
-                            branches: self.compile_tokens()?
+                            branches: self.compile_tokens()?,
                         }
-                    },
+                    }
                     b')' => {
                         alternatives.push(chain);
                         return Ok(alternatives);
@@ -259,51 +272,67 @@ impl<'a> PosixRegexBuilder<'a> {
                         alternatives.push(chain);
                         chain = Vec::new();
                         continue;
-                    },
+                    }
                     b'<' => Token::WordStart,
                     b'>' => Token::WordEnd,
-                    c@b'?' | c@b'+' => if let Some(last) = chain.last_mut() {
-                        last.1 = match c {
-                            b'?' => Range(0, Some(1)),
-                            b'+' => Range(1, None),
-                            _ => unreachable!("{}", c)
-                        };
-                        continue;
-                    } else {
-                        return Err(Error::LeadingRepetition);
-                    },
-                    b'{' => if let Some(last) = chain.last_mut() {
-                        let first = self.take_int()?.ok_or(Error::EmptyRepetition)?;
-                        let mut second = Some(first);
-                        if let Some(b',') = self.input.first() {
-                            self.consume(1);
-                            second = self.take_int()?;
-                        }
-                        if self.input.first() == Some(&b'}') {
-                            self.consume(1);
-                        } else if self.input.starts_with(br"\}") {
-                            self.consume(2);
+                    c @ b'?' | c @ b'+' => {
+                        if let Some(last) = chain.last_mut() {
+                            last.1 = match c {
+                                b'?' => Range(0, Some(1)),
+                                b'+' => Range(1, None),
+                                _ => unreachable!("{}", c),
+                            };
+                            continue;
                         } else {
-                            return Err(Error::UnclosedRepetition);
+                            return Err(Error::LeadingRepetition);
                         }
-                        if second.map(|second| first > second).unwrap_or(false) {
-                            return Err(Error::IllegalRange);
+                    }
+                    b'{' => {
+                        if let Some(last) = chain.last_mut() {
+                            let first = self.take_int()?.ok_or(Error::EmptyRepetition)?;
+                            let mut second = Some(first);
+                            if let Some(b',') = self.input.first() {
+                                self.consume(1);
+                                second = self.take_int()?;
+                            }
+                            if self.input.first() == Some(&b'}') {
+                                self.consume(1);
+                            } else if self.input.starts_with(br"\}") {
+                                self.consume(2);
+                            } else {
+                                return Err(Error::UnclosedRepetition);
+                            }
+                            if second.map(|second| first > second).unwrap_or(false) {
+                                return Err(Error::IllegalRange);
+                            }
+                            last.1 = Range(first, second);
+                            continue;
+                        } else {
+                            return Err(Error::LeadingRepetition);
                         }
-                        last.1 = Range(first, second);
-                        continue;
-                    } else {
-                        return Err(Error::LeadingRepetition);
+                    }
+                    b'a' => Token::OneOf {
+                        invert: false,
+                        list: vec![Collation::Class(ctype::is_alnum)],
+                    },
+                    b'd' => Token::OneOf {
+                        invert: false,
+                        list: vec![Collation::Class(ctype::is_digit)],
+                    },
+                    b's' => Token::OneOf {
+                        invert: false,
+                        list: vec![Collation::Class(ctype::is_space)],
+                    },
+                    b'S' => Token::OneOf {
+                        invert: true,
+                        list: vec![Collation::Class(ctype::is_space)],
                     },
-                    b'a' => Token::OneOf { invert: false, list: vec![Collation::Class(ctype::is_alnum)] },
-                    b'd' => Token::OneOf { invert: false, list: vec![Collation::Class(ctype::is_digit)] },
-                    b's' => Token::OneOf { invert: false, list: vec![Collation::Class(ctype::is_space)] },
-                    b'S' => Token::OneOf { invert: true,  list: vec![Collation::Class(ctype::is_space)] },
                     b'n' => Token::Char(b'\n'),
                     b'r' => Token::Char(b'\r'),
                     b't' => Token::Char(b'\t'),
-                    c => Token::Char(c)
+                    c => Token::Char(c),
                 },
-                c => Token::Char(c)
+                c => Token::Char(c),
             };
             chain.push((token, Range(1, Some(1))));
         }

+ 119 - 81
dlibc/posix-regex/src/matcher.rs

@@ -3,7 +3,7 @@
 #[cfg(feature = "no_std")]
 use std::prelude::*;
 
-use compile::{Token, Range};
+use compile::{Range, Token};
 use ctype;
 use std::borrow::Cow;
 use std::fmt;
@@ -16,7 +16,7 @@ pub struct PosixRegex<'a> {
     case_insensitive: bool,
     newline: bool,
     no_start: bool,
-    no_end: bool
+    no_end: bool,
 }
 impl<'a> PosixRegex<'a> {
     /// Create a new matcher instance from the specified alternations. This
@@ -28,7 +28,7 @@ impl<'a> PosixRegex<'a> {
             case_insensitive: false,
             newline: false,
             no_start: false,
-            no_end: false
+            no_end: false,
         }
     }
     /// Chainable function to enable/disable case insensitivity. Default: false.
@@ -72,9 +72,11 @@ impl<'a> PosixRegex<'a> {
         let mut matcher = PosixRegexMatcher {
             base: self,
             input,
-            offset: 0
+            offset: 0,
         };
-        let branches = self.branches.iter()
+        let branches = self
+            .branches
+            .iter()
             .filter_map(|tokens| Branch::new(true, tokens))
             .collect();
 
@@ -89,26 +91,34 @@ impl<'a> PosixRegex<'a> {
         }
     }
     /// Match any substrings in the string, but optionally no more than `max`
-    pub fn matches(&self, input: &[u8], mut max: Option<usize>) -> Vec<Box<[Option<(usize, usize)>]>> {
+    pub fn matches(
+        &self,
+        input: &[u8],
+        mut max: Option<usize>,
+    ) -> Vec<Box<[Option<(usize, usize)>]>> {
         let mut matcher = PosixRegexMatcher {
             base: self,
             input,
-            offset: 0
+            offset: 0,
         };
 
         let tokens = vec![
             (Token::InternalStart, Range(0, None)),
-            (Token::Group { id: 0, branches: self.branches.to_vec() }, Range(1, Some(1)))
-        ];
-        let branches = vec![
-            Branch::new(false, &tokens).unwrap()
+            (
+                Token::Group {
+                    id: 0,
+                    branches: self.branches.to_vec(),
+                },
+                Range(1, Some(1)),
+            ),
         ];
+        let branches = vec![Branch::new(false, &tokens).unwrap()];
 
         let mut matches = Vec::new();
         while max.map(|max| max > 0).unwrap_or(true) {
             match matcher.matches_exact(branches.clone()) {
                 Some(groups) => matches.push(groups),
-                None => break
+                None => break,
             }
             max = max.map(|max| max - 1);
         }
@@ -133,7 +143,7 @@ fn count_groups(tokens: &[(Token, Range)]) -> usize {
 struct Group {
     index: usize,
     variant: usize,
-    id: usize
+    id: usize,
 }
 
 #[derive(Clone)]
@@ -144,7 +154,7 @@ struct Branch<'a> {
     path: Box<[Group]>,
     prev: Box<[Option<(usize, usize)>]>,
 
-    parent: Option<Rc<Branch<'a>>>
+    parent: Option<Rc<Branch<'a>>>,
 }
 impl<'a> fmt::Debug for Branch<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -166,14 +176,14 @@ impl<'a> Branch<'a> {
             path: Box::new([]),
             prev: vec![None; if exact { 1 } else { 0 } + count_groups(tokens)].into_boxed_slice(),
 
-            parent: None
+            parent: None,
         })
     }
     fn group(
         path: Box<[Group]>,
         prev: Box<[Option<(usize, usize)>]>,
         tokens: &'a [(Token, Range)],
-        mut parent: Branch<'a>
+        mut parent: Branch<'a>,
     ) -> Option<Self> {
         if tokens.is_empty() {
             return None;
@@ -185,7 +195,7 @@ impl<'a> Branch<'a> {
             tokens,
             path,
             prev,
-            parent: Some(Rc::new(parent))
+            parent: Some(Rc::new(parent)),
         })
     }
     fn parent_tokens(&self) -> &[(Token, Range)] {
@@ -193,10 +203,10 @@ impl<'a> Branch<'a> {
 
         let len = self.path.len();
         if len > 0 {
-            for group in &self.path[..len-1] {
+            for group in &self.path[..len - 1] {
                 match tokens[group.index] {
                     (Token::Group { ref branches, .. }, _) => tokens = &branches[group.variant],
-                    _ => panic!("non-group index in path")
+                    _ => panic!("non-group index in path"),
                 }
             }
         }
@@ -209,7 +219,7 @@ impl<'a> Branch<'a> {
         if let Some(group) = self.path.last() {
             match tokens[group.index] {
                 (Token::Group { ref branches, .. }, _) => tokens = &branches[group.variant],
-                _ => panic!("non-group index in path")
+                _ => panic!("non-group index in path"),
             }
         }
 
@@ -256,14 +266,21 @@ impl<'a> Branch<'a> {
     fn add_repeats(&self, branches: &mut Vec<Branch<'a>>, offset: usize) {
         let mut branch = self;
         loop {
-            if let (Token::Group { id, branches: ref alternatives }, Range(_, max)) = *branch.get_token() {
+            if let (
+                Token::Group {
+                    id,
+                    branches: ref alternatives,
+                },
+                Range(_, max),
+            ) = *branch.get_token()
+            {
                 if max.map(|max| branch.repeated < max).unwrap_or(true) {
                     for alternative in 0..alternatives.len() {
                         let mut path = branch.path.to_vec();
                         path.push(Group {
                             variant: alternative,
                             index: branch.index,
-                            id
+                            id,
                         });
 
                         let mut prev = self.prev.clone();
@@ -273,7 +290,7 @@ impl<'a> Branch<'a> {
                             path.into_boxed_slice(),
                             prev,
                             branch.tokens,
-                            branch.clone()
+                            branch.clone(),
                         ) {
                             branches.push(group);
                         }
@@ -284,7 +301,7 @@ impl<'a> Branch<'a> {
 
             match branch.parent {
                 Some(ref new) => branch = new,
-                None => break
+                None => break,
             }
         }
     }
@@ -312,7 +329,7 @@ impl<'a> Branch<'a> {
             }
             match branch.next_branch() {
                 Some(next) => branch = Cow::Owned(next),
-                None => break
+                None => break,
             }
         }
         true
@@ -322,7 +339,7 @@ impl<'a> Branch<'a> {
 struct PosixRegexMatcher<'a> {
     base: &'a PosixRegex<'a>,
     input: &'a [u8],
-    offset: usize
+    offset: usize,
 }
 impl<'a> PosixRegexMatcher<'a> {
     fn expand<'b>(&mut self, branches: &mut [Branch<'b>]) -> Vec<Branch<'b>> {
@@ -333,25 +350,26 @@ impl<'a> PosixRegexMatcher<'a> {
 
             let (ref token, range) = *branch.get_token();
 
-            if let Token::Group { id, branches: ref inner } = *token {
+            if let Token::Group {
+                id,
+                branches: ref inner,
+            } = *token
+            {
                 for alternation in 0..inner.len() {
                     let mut path = Vec::with_capacity(branch.path.len() + 1);
                     path.extend_from_slice(&branch.path);
                     path.push(Group {
                         index: branch.index,
                         variant: alternation,
-                        id
+                        id,
                     });
 
                     let mut prev = branch.prev.clone();
                     prev[id].get_or_insert((0, 0)).0 = self.offset;
 
-                    if let Some(branch) = Branch::group(
-                        path.into(),
-                        prev,
-                        branch.tokens,
-                        branch.clone()
-                    ) {
+                    if let Some(branch) =
+                        Branch::group(path.into(), prev, branch.tokens, branch.clone())
+                    {
                         insert.push(branch);
                     }
                 }
@@ -372,11 +390,17 @@ impl<'a> PosixRegexMatcher<'a> {
         insert
     }
 
-    fn matches_exact(&mut self, mut branches: Vec<Branch>) -> Option<Box<[Option<(usize, usize)>]>> {
+    fn matches_exact(
+        &mut self,
+        mut branches: Vec<Branch>,
+    ) -> Option<Box<[Option<(usize, usize)>]>> {
         // Whether or not any branch, at any point, got fully explored. This
         // means at least one path of the regex successfully completed!
         let mut succeeded = None;
-        let mut prev = self.offset.checked_sub(1).and_then(|index| self.input.get(index).cloned());
+        let mut prev = self
+            .offset
+            .checked_sub(1)
+            .and_then(|index| self.input.get(index).cloned());
 
         loop {
             let next = self.input.get(self.offset).cloned();
@@ -394,9 +418,9 @@ impl<'a> PosixRegexMatcher<'a> {
                 if remove > 0 {
                     // Just like Rust's `retain` function, shift all elements I
                     // want to keep back and `truncate` when I'm done.
-                    branches.swap(index, index-remove);
+                    branches.swap(index, index - remove);
                 }
-                let branch = &mut branches[index-remove];
+                let branch = &mut branches[index - remove];
                 index += 1;
 
                 let (ref token, Range(_, mut max)) = *branch.get_token();
@@ -407,32 +431,36 @@ impl<'a> PosixRegexMatcher<'a> {
                 // Step 1: Handle zero-width stuff like ^ and \<
                 loop {
                     match token {
-                        Token::End |
-                        Token::Start |
-                        Token::WordEnd |
-                        Token::WordStart => {
-                            accepts = accepts && match token {
-                                Token::End =>
-                                    (!self.base.no_end && next.is_none())
-                                        || (self.base.newline && next == Some(b'\n')),
-                                Token::Start =>
-                                    (!self.base.no_start && self.offset == 0)
-                                        || (self.base.newline && prev == Some(b'\n')),
-                                Token::WordEnd => next.map(ctype::is_word_boundary).unwrap_or(true),
-                                Token::WordStart => prev.map(ctype::is_word_boundary).unwrap_or(true),
-                                _ => unreachable!()
-                            };
+                        Token::End | Token::Start | Token::WordEnd | Token::WordStart => {
+                            accepts = accepts
+                                && match token {
+                                    Token::End => {
+                                        (!self.base.no_end && next.is_none())
+                                            || (self.base.newline && next == Some(b'\n'))
+                                    }
+                                    Token::Start => {
+                                        (!self.base.no_start && self.offset == 0)
+                                            || (self.base.newline && prev == Some(b'\n'))
+                                    }
+                                    Token::WordEnd => {
+                                        next.map(ctype::is_word_boundary).unwrap_or(true)
+                                    }
+                                    Token::WordStart => {
+                                        prev.map(ctype::is_word_boundary).unwrap_or(true)
+                                    }
+                                    _ => unreachable!(),
+                                };
 
                             // Skip ahead to the next token.
                             match branch.next_branch() {
                                 Some(next) => *branch = next,
-                                None => break
+                                None => break,
                             }
                             let (ref new_token, Range(_, new_max)) = *branch.get_token();
                             token = new_token;
                             max = new_max;
-                        },
-                        _ => break
+                        }
+                        _ => break,
                     }
                 }
 
@@ -440,30 +468,39 @@ impl<'a> PosixRegexMatcher<'a> {
                 accepts = accepts && max.map(|max| branch.repeated < max).unwrap_or(true);
 
                 // Step 3: Check if the token matches
-                accepts = accepts && match *token {
-                    Token::InternalStart => next.is_some(),
-                    Token::Group { .. } => false, // <- content is already expanded and handled
-
-                    Token::Any => next.map(|c| !self.base.newline || c != b'\n').unwrap_or(false),
-                    Token::Char(c) => if self.base.case_insensitive {
-                        next.map(|c2| c & !32 == c2 & !32).unwrap_or(false)
-                    } else {
-                        next == Some(c)
-                    },
-                    Token::OneOf { invert, ref list } => if let Some(next) = next {
-                        (!invert || !self.base.newline || next != b'\n')
-                        && list.iter().any(|c| c.matches(next, self.base.case_insensitive)) == !invert
-                    } else { false },
-
-                    // These will only get called if they are encountered at
-                    // EOF (because next_branch returns None), for example
-                    // "abc\>" or "^". Then we simply want to return true as to
-                    // preserve the current `accepts` status.
-                    Token::End |
-                    Token::Start |
-                    Token::WordEnd |
-                    Token::WordStart => true
-                };
+                accepts = accepts
+                    && match *token {
+                        Token::InternalStart => next.is_some(),
+                        Token::Group { .. } => false, // <- content is already expanded and handled
+
+                        Token::Any => next
+                            .map(|c| !self.base.newline || c != b'\n')
+                            .unwrap_or(false),
+                        Token::Char(c) => {
+                            if self.base.case_insensitive {
+                                next.map(|c2| c & !32 == c2 & !32).unwrap_or(false)
+                            } else {
+                                next == Some(c)
+                            }
+                        }
+                        Token::OneOf { invert, ref list } => {
+                            if let Some(next) = next {
+                                (!invert || !self.base.newline || next != b'\n')
+                                    && list
+                                        .iter()
+                                        .any(|c| c.matches(next, self.base.case_insensitive))
+                                        == !invert
+                            } else {
+                                false
+                            }
+                        }
+
+                        // These will only get called if they are encountered at
+                        // EOF (because next_branch returns None), for example
+                        // "abc\>" or "^". Then we simply want to return true as to
+                        // preserve the current `accepts` status.
+                        Token::End | Token::Start | Token::WordEnd | Token::WordStart => true,
+                    };
 
                 if !accepts {
                     if branch.is_explored() {
@@ -480,7 +517,8 @@ impl<'a> PosixRegexMatcher<'a> {
 
             if branches.is_empty() ||
                     // The internal start thing is lazy, not greedy:
-                    (succeeded.is_some() && branches.iter().all(|t| t.get_token().0 == Token::InternalStart)) {
+                    (succeeded.is_some() && branches.iter().all(|t| t.get_token().0 == Token::InternalStart))
+            {
                 return succeeded.map(|branch| branch.prev);
             }
 

+ 8 - 12
dlibc/src/lib.rs

@@ -3,7 +3,7 @@
 //! [Documentation for other platforms][pd].
 //!
 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
-//! 
+//!
 
 #![feature(core_intrinsics)]
 #![feature(linkage)]
@@ -14,8 +14,6 @@
 #![feature(c_variadic)]
 #![feature(stmt_expr_attributes)]
 #![feature(lang_items)]
-
-
 #![crate_name = "dlibc"]
 #![crate_type = "staticlib"]
 #![allow(
@@ -49,13 +47,12 @@ extern crate alloc;
 extern crate core_io;
 #[macro_use]
 extern crate lazy_static;
-extern crate memchr;
-extern crate goblin;
-extern crate rand;
-extern crate posix_regex;
 extern crate cbitset;
+extern crate goblin;
+extern crate memchr;
 extern crate num_traits;
-
+extern crate posix_regex;
+extern crate rand;
 
 #[macro_use]
 mod macros;
@@ -127,12 +124,11 @@ pub use unix::*;
 extern crate dsc;
 #[cfg(target_os = "dragonos")]
 #[global_allocator]
-static ALLOCATOR: crate::unix::platform::allocator::Allocator = crate::unix::platform::allocator::ALLOCATOR;
+static ALLOCATOR: crate::unix::platform::allocator::Allocator =
+    crate::unix::platform::allocator::ALLOCATOR;
 #[cfg(target_os = "dragonos")]
 pub use crate::unix::macros::*;
 
-
-
 #[lang = "eh_personality"]
 extern "C" fn eh_personality() {}
 
@@ -146,4 +142,4 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
 
     // 结束程序,例如通过调用 `std::process::exit`
     crate::unix::platform::pal::exit(0);
-}                        
+}

+ 0 - 1
dlibc/src/unix/c_vec.rs

@@ -232,4 +232,3 @@ impl WriteByte for CVec<u8> {
         Ok(())
     }
 }
-

+ 4 - 4
dlibc/src/unix/fs.rs

@@ -1,13 +1,13 @@
+use crate::unix::platform;
 use crate::unix::{
+    c_str::CStr,
     header::{
         fcntl::O_CREAT,
         unistd::{SEEK_CUR, SEEK_END, SEEK_SET},
     },
     io,
-    c_str::CStr
 };
 use core::ops::Deref;
-use crate::unix::platform;
 pub struct File {
     pub fd: ::c_int,
     /// To avoid self referential FILE struct that needs both a reader and a writer,
@@ -71,7 +71,7 @@ impl File {
 
 impl io::Read for &File {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
-        match platform::pal::read(self.fd, buf.as_ptr() as *mut ::c_void,buf.len()) {
+        match platform::pal::read(self.fd, buf.as_ptr() as *mut ::c_void, buf.len()) {
             -1 => Err(io::last_os_error()),
             ok => Ok(ok as usize),
         }
@@ -80,7 +80,7 @@ impl io::Read for &File {
 
 impl io::Write for &File {
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
-        match platform::pal::write(self.fd, buf.as_ptr() as*const ::c_void,buf.len()) {
+        match platform::pal::write(self.fd, buf.as_ptr() as *const ::c_void, buf.len()) {
             -1 => Err(io::last_os_error()),
             ok => Ok(ok as usize),
         }

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

@@ -1,4 +1,4 @@
-use crate::unix::header::time::{sigevent};
+use crate::unix::header::time::sigevent;
 
 pub struct aiocb {
     pub aio_fildes: ::c_int,

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

@@ -7,7 +7,7 @@ pub const FE_TONEAREST: ::c_int = 0;
 pub type fexcept_t = u64;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct fenv_t {
     pub cw: u64,
 }

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

@@ -1,4 +1,3 @@
-
 #[repr(C)]
 pub struct user_regs_struct {
     pub regs: [::c_ulonglong; 31],

+ 7 - 3
dlibc/src/unix/header/arpa_inet/mod.rs

@@ -1,11 +1,11 @@
 //! arpa/inet implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xns/arpainet.h.html
 
+use crate::unix::c_str::*;
+use crate::unix::platform;
 use core::{
     ptr, slice,
     str::{self, FromStr},
 };
-use crate::unix::c_str::*;
-use crate::unix::platform;
 
 use crate::unix::header::{
     errno::*,
@@ -52,7 +52,11 @@ pub unsafe extern "C" fn inet_ntoa(addr: in_addr) -> *const ::c_char {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn inet_pton(domain: ::c_int, src: *const ::c_char, dest: *mut ::c_void) -> ::c_int {
+pub unsafe extern "C" fn inet_pton(
+    domain: ::c_int,
+    src: *const ::c_char,
+    dest: *mut ::c_void,
+) -> ::c_int {
     if domain != AF_INET {
         platform::errno = EAFNOSUPPORT;
         -1

+ 3 - 1
dlibc/src/unix/header/ctype/mod.rs

@@ -74,7 +74,9 @@ pub extern "C" fn isupper(c: ::c_int) -> ::c_int {
 
 #[no_mangle]
 pub extern "C" fn isxdigit(c: ::c_int) -> ::c_int {
-    ::c_int::from(isdigit(c) != 0 || (c | 32 >= ::c_int::from(b'a') && c | 32 <= ::c_int::from(b'f')))
+    ::c_int::from(
+        isdigit(c) != 0 || (c | 32 >= ::c_int::from(b'a') && c | 32 <= ::c_int::from(b'f')),
+    )
 }
 
 #[no_mangle]

+ 3 - 1
dlibc/src/unix/header/dirent/mod.rs

@@ -126,7 +126,9 @@ pub unsafe extern "C" fn scandir(
     dirp: *const ::c_char,
     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>,
+    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() {

+ 1 - 1
dlibc/src/unix/header/dl-tls/mod.rs

@@ -3,7 +3,7 @@
 use crate::ld_so::tcb::Tcb;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct dl_tls_index {
     pub ti_module: u64,
     pub ti_offset: u64,

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

@@ -1,11 +1,11 @@
 //! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html
 
+use crate::ld_so::tcb::Tcb;
+use crate::unix::c_str::*;
 use core::{
     ptr, str,
     sync::atomic::{AtomicUsize, Ordering},
 };
-use crate::unix::c_str::*;
-use crate::ld_so::tcb::Tcb;
 
 static ERROR_NOT_SUPPORTED: &'static CStr = c_str!("dlfcn not supported");
 

+ 30 - 31
dlibc/src/unix/header/elf/mod.rs

@@ -1,4 +1,3 @@
-
 pub type Elf32_Half = ::uint16_t;
 pub type Elf64_Half = ::uint16_t;
 
@@ -27,7 +26,7 @@ pub type Elf64_Versym = Elf64_Half;
 pub const EI_NIDENT: usize = 16;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Ehdr {
     pub e_ident: [::c_uchar; EI_NIDENT],
     pub e_type: Elf32_Half,
@@ -46,7 +45,7 @@ pub struct Elf32_Ehdr {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Ehdr {
     pub e_ident: [::c_uchar; EI_NIDENT],
     pub e_type: Elf64_Half,
@@ -198,7 +197,7 @@ pub const EV_CURRENT: usize = 1;
 pub const EV_NUM: usize = 2;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Shdr {
     pub sh_name: Elf32_Word,
     pub sh_type: Elf32_Word,
@@ -213,7 +212,7 @@ pub struct Elf32_Shdr {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Shdr {
     pub sh_name: Elf64_Word,
     pub sh_type: Elf64_Word,
@@ -293,7 +292,7 @@ pub const SHF_EXCLUDE: usize = 1 << 31;
 pub const GRP_COMDAT: usize = 0x1;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Sym {
     pub st_name: Elf32_Word,
     pub st_value: Elf32_Addr,
@@ -304,7 +303,7 @@ pub struct Elf32_Sym {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Sym {
     pub st_name: Elf64_Word,
     pub st_info: ::c_uchar,
@@ -315,14 +314,14 @@ pub struct Elf64_Sym {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Syminfo {
     pub si_boundto: Elf32_Half,
     pub si_flags: Elf32_Half,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Syminfo {
     pub si_boundto: Elf64_Half,
     pub si_flags: Elf64_Half,
@@ -369,21 +368,21 @@ pub const STV_HIDDEN: usize = 2;
 pub const STV_PROTECTED: usize = 3;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Rel {
     pub r_offset: Elf32_Addr,
     pub r_info: Elf32_Word,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Rel {
     pub r_offset: Elf64_Addr,
     pub r_info: Elf64_Xword,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Rela {
     pub r_offset: Elf32_Addr,
     pub r_info: Elf32_Word,
@@ -391,7 +390,7 @@ pub struct Elf32_Rela {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Rela {
     pub r_offset: Elf64_Addr,
     pub r_info: Elf64_Xword,
@@ -399,7 +398,7 @@ pub struct Elf64_Rela {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Phdr {
     pub p_type: Elf32_Word,
     pub p_offset: Elf32_Off,
@@ -412,7 +411,7 @@ pub struct Elf32_Phdr {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Phdr {
     pub p_type: Elf64_Word,
     pub p_flags: Elf64_Word,
@@ -495,28 +494,28 @@ pub const NT_METAG_TLS: usize = 0x502;
 pub const NT_VERSION: usize = 1;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub union Elf32_Dyn_Union {
     d_val: Elf32_Word,
     d_ptr: Elf32_Addr,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Dyn {
     pub d_tag: Elf32_Sword,
     pub d_un: Elf32_Dyn_Union,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub union Elf64_Dyn_Union {
     d_val: Elf64_Xword,
     d_ptr: Elf64_Addr,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Dyn {
     pub d_tag: Elf64_Sxword,
     pub d_un: Elf64_Dyn_Union,
@@ -636,7 +635,7 @@ pub const DF_P1_LAZYLOAD: usize = 0x00000001;
 pub const DF_P1_GROUPPERM: usize = 0x00000002;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Verdef {
     pub vd_version: Elf32_Half,
     pub vd_flags: Elf32_Half,
@@ -648,7 +647,7 @@ pub struct Elf32_Verdef {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Verdef {
     pub vd_version: Elf64_Half,
     pub vd_flags: Elf64_Half,
@@ -671,21 +670,21 @@ pub const VER_NDX_LORESERVE: usize = 0xff00;
 pub const VER_NDX_ELIMINATE: usize = 0xff01;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Verdaux {
     pub vda_name: Elf32_Word,
     pub vda_next: Elf32_Word,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Verdaux {
     pub vda_name: Elf64_Word,
     pub vda_next: Elf64_Word,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Verneed {
     pub vn_version: Elf32_Half,
     pub vn_cnt: Elf32_Half,
@@ -695,7 +694,7 @@ pub struct Elf32_Verneed {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Verneed {
     pub vn_version: Elf64_Half,
     pub vn_cnt: Elf64_Half,
@@ -709,7 +708,7 @@ pub const VER_NEED_CURRENT: usize = 1;
 pub const VER_NEED_NUM: usize = 2;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Vernaux {
     pub vna_hash: Elf64_Word,
     pub vna_flags: Elf64_Half,
@@ -719,13 +718,13 @@ pub struct Elf64_Vernaux {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub union A_UN {
     a_val: ::uint64_t,
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_auxv_t {
     pub a_type: ::uint64_t,
     pub a_un: A_UN,
@@ -767,7 +766,7 @@ pub const AT_L2_CACHESHAPE: usize = 36;
 pub const AT_L3_CACHESHAPE: usize = 37;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf32_Nhdr {
     pub n_namesz: Elf32_Word,
     pub n_descsz: Elf32_Word,
@@ -775,7 +774,7 @@ pub struct Elf32_Nhdr {
 }
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Nhdr {
     pub n_namesz: Elf64_Word,
     pub n_descsz: Elf64_Word,
@@ -799,7 +798,7 @@ pub const NT_GNU_BUILD_ID: usize = 3;
 pub const NT_GNU_GOLD_VERSION: usize = 4;
 
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct Elf64_Move {
     pub m_value: Elf64_Xword,
     pub m_info: Elf64_Xword,

+ 6 - 4
dlibc/src/unix/header/fcntl/mod.rs

@@ -1,7 +1,5 @@
 //! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html
 
-
-
 pub use self::platform::*;
 use crate::unix::platform;
 
@@ -10,7 +8,7 @@ pub unsafe extern "C" fn creat(path: *const ::c_char, mode: ::mode_t) -> ::c_int
     sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
 }
 #[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct flock {
     pub l_type: ::c_short,
     pub l_whence: ::c_short,
@@ -24,7 +22,11 @@ pub extern "C" fn sys_fcntl(fildes: ::c_int, cmd: ::c_int, arg: ::c_int) -> ::c_
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn sys_open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int {
+pub unsafe extern "C" fn sys_open(
+    path: *const ::c_char,
+    oflag: ::c_int,
+    mode: ::mode_t,
+) -> ::c_int {
     platform::pal::open(path, oflag, mode)
 }
 

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

@@ -3,7 +3,6 @@
 use alloc::{borrow::Cow, vec::Vec};
 use core::slice;
 
-
 use posix_regex::{
     compile::{Collation, Range, Token},
     PosixRegex,

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

@@ -1,9 +1,9 @@
 //! getopt implementation for relibc
 
 use crate::unix::header::{
-        stdio, string,
-        unistd::{optarg, opterr, optind, optopt},
-    };
+    stdio, string,
+    unistd::{optarg, opterr, optind, optopt},
+};
 use core::ptr;
 
 static mut CURRENT_OPT: *mut ::c_char = ptr::null_mut();

+ 0 - 2
dlibc/src/unix/header/grp/mod.rs

@@ -1,7 +1,5 @@
 //! grp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/grp.h.html
 
-
-
 #[repr(C)]
 pub struct group {
     pub gr_name: *mut ::c_char,

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

@@ -2,8 +2,6 @@
 
 use core::ptr;
 
-
-
 const EMPTY_PTR: *const ::c_char = "\0" as *const _ as *const ::c_char;
 // Can't use &str because of the mutability
 static mut C_LOCALE: [::c_char; 2] = [b'C' as ::c_char, 0];

+ 0 - 4
dlibc/src/unix/header/netdb/dns/mod.rs

@@ -16,10 +16,6 @@ use core::{slice, u16};
 mod answer;
 mod query;
 
-
-
-
-
 #[allow(non_camel_case_types)]
 #[derive(Copy, Clone, Debug, Default)]
 #[repr(packed)]

+ 1 - 1
dlibc/src/unix/header/netdb/dragonos.rs

@@ -1,10 +1,10 @@
+use alloc::string::String;
 use unix::{
     c_str::CString,
     fs::File,
     header::fcntl,
     io::{BufRead, BufReader},
 };
-use alloc::string::String;
 
 pub fn get_dns_server() -> String {
     let file = match File::open(&CString::new("/etc/resolv.conf").unwrap(), fcntl::O_RDONLY) {

+ 4 - 1
dlibc/src/unix/header/netdb/host.rs

@@ -81,7 +81,10 @@ pub unsafe extern "C" fn gethostent() -> *mut hostent {
     let addr = addr.assume_init();
 
     _HOST_ADDR_LIST = mem::transmute::<u32, [u8; 4]>(addr.s_addr);
-    HOST_ADDR_LIST = [_HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char, ptr::null_mut()];
+    HOST_ADDR_LIST = [
+        _HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char,
+        ptr::null_mut(),
+    ];
 
     HOST_ADDR = Some(addr);
 

+ 15 - 6
dlibc/src/unix/header/netdb/mod.rs

@@ -7,7 +7,6 @@ use core::{
     str::{self, FromStr},
 };
 
-use alloc::{borrow::ToOwned, boxed::Box, str::SplitWhitespace, vec::Vec};
 use crate::unix::header::{
     arpa_inet::{htons, inet_aton, ntohl},
     errno::*,
@@ -18,6 +17,7 @@ use crate::unix::header::{
     sys_socket::{constants::AF_INET, sa_family_t, socklen_t},
     unistd::SEEK_SET,
 };
+use alloc::{borrow::ToOwned, boxed::Box, str::SplitWhitespace, vec::Vec};
 
 use sockaddr;
 
@@ -88,8 +88,8 @@ pub struct addrinfo {
     ai_protocol: ::c_int,        /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
     ai_addrlen: ::size_t,        /* length of ai_addr */
     ai_canonname: *mut ::c_char, /* canonical name for hostname */
-    ai_addr: *mut sockaddr,    /* binary address */
-    ai_next: *mut addrinfo,    /* next structure in linked list */
+    ai_addr: *mut sockaddr,      /* binary address */
+    ai_next: *mut addrinfo,      /* next structure in linked list */
 }
 
 pub const AI_PASSIVE: ::c_int = 0x0001;
@@ -235,7 +235,10 @@ pub unsafe extern "C" fn gethostbyaddr(
     match lookup_addr(addr) {
         Ok(s) => {
             _HOST_ADDR_LIST = mem::transmute::<u32, [u8; 4]>(addr.s_addr);
-            HOST_ADDR_LIST = [_HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char, ptr::null_mut()];
+            HOST_ADDR_LIST = [
+                _HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char,
+                ptr::null_mut(),
+            ];
             let host_name = s[0].to_vec();
             HOST_NAME = Some(host_name);
             HOST_ENTRY = hostent {
@@ -326,7 +329,10 @@ pub unsafe extern "C" fn gethostbyname(name: *const ::c_char) -> *mut hostent {
     let host_name: Vec<u8> = name_cstr.to_bytes().to_vec();
     HOST_NAME = Some(host_name);
     _HOST_ADDR_LIST = mem::transmute::<u32, [u8; 4]>(host_addr.s_addr);
-    HOST_ADDR_LIST = [_HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char, ptr::null_mut()];
+    HOST_ADDR_LIST = [
+        _HOST_ADDR_LIST.as_mut_ptr() as *mut ::c_char,
+        ptr::null_mut(),
+    ];
     HOST_ADDR = Some(host_addr);
 
     //TODO actually get aliases
@@ -545,7 +551,10 @@ pub unsafe extern "C" fn getprotoent() -> *mut protoent {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn getservbyname(name: *const ::c_char, proto: *const ::c_char) -> *mut servent {
+pub unsafe extern "C" fn getservbyname(
+    name: *const ::c_char,
+    proto: *const ::c_char,
+) -> *mut servent {
     setservent(SERV_STAYOPEN);
     let mut p: *mut servent;
     if proto.is_null() {

+ 0 - 2
dlibc/src/unix/header/netinet_tcp/mod.rs

@@ -1,3 +1 @@
-
-
 pub const TCP_NODELAY: ::c_int = 1;

+ 3 - 4
dlibc/src/unix/header/poll/mod.rs

@@ -5,8 +5,7 @@ use core::{mem, slice};
 use crate::unix::{
     fs::File,
     header::sys_epoll::{
-        epoll_ctl, epoll_data, epoll_event, epoll_wait,
-        EPOLL_CLOEXEC, EPOLL_CTL_ADD,
+        epoll_ctl, epoll_data, epoll_event, epoll_wait, EPOLL_CLOEXEC, EPOLL_CTL_ADD,
     },
 };
 
@@ -45,7 +44,7 @@ pub fn poll_epoll(fds: &mut [pollfd], timeout: ::c_int) -> ::c_int {
     ];
 
     let ep = {
-        let epfd = unsafe{::epoll_create1(EPOLL_CLOEXEC)};
+        let epfd = unsafe { ::epoll_create1(EPOLL_CLOEXEC) };
         if epfd < 0 {
             return -1;
         }
@@ -69,7 +68,7 @@ pub fn poll_epoll(fds: &mut [pollfd], timeout: ::c_int) -> ::c_int {
 
         pfd.revents = 0;
 
-        if unsafe{epoll_ctl(*ep, EPOLL_CTL_ADD, pfd.fd, &mut event)} < 0 {
+        if unsafe { epoll_ctl(*ep, EPOLL_CTL_ADD, pfd.fd, &mut event) } < 0 {
             return -1;
         }
     }

+ 0 - 1
dlibc/src/unix/header/pwd/dragonos.rs

@@ -1,6 +1,5 @@
 use super::{parsed, passwd};
 
-
 pub fn split(line: &mut [u8]) -> Option<passwd> {
     let mut parts = line.split_mut(|&c| c == b'\0');
     Some(passwd {

+ 0 - 1
dlibc/src/unix/header/pwd/linux.rs

@@ -1,6 +1,5 @@
 use super::{parsed, passwd};
 
-
 pub fn split(line: &mut [u8]) -> Option<passwd> {
     let mut parts = line.split_mut(|&c| c == b'\0');
     Some(passwd {

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

@@ -22,7 +22,6 @@ mod dragonos;
 #[cfg(target_os = "redox")]
 mod redox;
 
-
 #[cfg(target_os = "linux")]
 use self::linux as sys;
 #[cfg(target_os = "redox")]

+ 0 - 1
dlibc/src/unix/header/pwd/redox.rs

@@ -1,6 +1,5 @@
 use super::{parsed, passwd};
 
-
 pub fn split(line: &mut [u8]) -> Option<passwd> {
     let mut parts = line.split_mut(|&c| c == b'\0');
     Some(passwd {

+ 5 - 1
dlibc/src/unix/header/regex/mod.rs

@@ -51,7 +51,11 @@ pub const REG_BADRPT: ::c_int = 14;
 
 #[no_mangle]
 #[linkage = "weak"] // redefined in GIT
-pub unsafe extern "C" fn regcomp(out: *mut regex_t, pat: *const ::c_char, cflags: ::c_int) -> ::c_int {
+pub unsafe extern "C" fn regcomp(
+    out: *mut regex_t,
+    pat: *const ::c_char,
+    cflags: ::c_int,
+) -> ::c_int {
     if cflags & REG_EXTENDED == REG_EXTENDED {
         return REG_ENOSYS;
     }

+ 0 - 2
dlibc/src/unix/header/semaphore/mod.rs

@@ -1,5 +1,3 @@
-
-
 #[repr(C)]
 #[derive(Copy)]
 pub union sem_t {

+ 0 - 2
dlibc/src/unix/header/stdio/constants.rs

@@ -1,5 +1,3 @@
-
-
 pub const EOF: ::c_int = -1;
 pub const BUFSIZ: ::c_int = 1024;
 

+ 2 - 6
dlibc/src/unix/header/stdio/helpers.rs

@@ -2,14 +2,10 @@ use alloc::boxed::Box;
 
 use super::{Buffer, FILE};
 use crate::unix::header::{errno, fcntl::*, string::strchr};
-use crate::unix::{
-    fs::File,
-    io::BufWriter,
-    sync::Mutex,
-};
+use crate::unix::{fs::File, io::BufWriter, sync::Mutex};
 use alloc::vec::Vec;
 
-use crate::unix::header::stdio::{F_APP,F_NORD,F_NOWR};
+use crate::unix::header::stdio::{F_APP, F_NORD, F_NOWR};
 use crate::unix::platform;
 
 /// Parse mode flags as a string and output a mode flags integer

+ 26 - 11
dlibc/src/unix/header/stdio/mod.rs

@@ -1,11 +1,15 @@
 //! stdio implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/stdio.h.html
-use WriteByte;
+use crate::unix::header::{
+    errno::{self, STR_ERROR},
+    fcntl, stdlib,
+    string::{self, strlen},
+};
+use crate::unix::platform;
 use alloc::{
     borrow::{Borrow, BorrowMut},
     boxed::Box,
     vec::Vec,
 };
-use crate::unix::platform;
 use core::{
     cmp,
     ffi::VaList as va_list,
@@ -14,11 +18,6 @@ use core::{
     ops::{Deref, DerefMut},
     ptr, slice, str,
 };
-use crate::unix::header::{
-    errno::{self, STR_ERROR},
-    fcntl, stdlib,
-    string::{self, strlen},
-};
 use unix::{
     c_str::CStr,
     c_vec::CVec,
@@ -26,6 +25,7 @@ use unix::{
     io::{self, BufRead, BufWriter, LineWriter, Read, Write},
     sync::Mutex,
 };
+use WriteByte;
 
 pub use self::constants::*;
 mod constants;
@@ -870,7 +870,10 @@ pub unsafe extern "C" fn popen(command: *const ::c_char, mode: *const ::c_char)
             ::close(pipes[1]);
         }
 
-        ::execv(shell as *const ::c_char, args.as_ptr() as *const *const ::c_char);
+        ::execv(
+            shell as *const ::c_char,
+            args.as_ptr() as *const *const ::c_char,
+        );
 
         stdlib::exit(127);
 
@@ -1119,7 +1122,11 @@ pub unsafe extern "C" fn ungetc(c: ::c_int, stream: *mut FILE) -> ::c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn vfprintf(file: *mut FILE, format: *const ::c_char, ap: va_list) -> ::c_int {
+pub unsafe extern "C" fn vfprintf(
+    file: *mut FILE,
+    format: *const ::c_char,
+    ap: va_list,
+) -> ::c_int {
     let mut file = (*file).lock();
     if let Err(_) = file.try_set_byte_orientation_unlocked() {
         return -1;
@@ -1162,7 +1169,11 @@ pub unsafe extern "C" fn vsnprintf(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn vsprintf(s: *mut ::c_char, format: *const ::c_char, ap: va_list) -> ::c_int {
+pub unsafe extern "C" fn vsprintf(
+    s: *mut ::c_char,
+    format: *const ::c_char,
+    ap: va_list,
+) -> ::c_int {
     printf::printf(&mut platform::UnsafeStringWriter(s as *mut u8), format, ap)
 }
 
@@ -1187,7 +1198,11 @@ pub unsafe extern "C" fn vscanf(format: *const ::c_char, ap: va_list) -> ::c_int
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn vsscanf(s: *const ::c_char, format: *const ::c_char, ap: va_list) -> ::c_int {
+pub unsafe extern "C" fn vsscanf(
+    s: *const ::c_char,
+    format: *const ::c_char,
+    ap: va_list,
+) -> ::c_int {
     let reader = (s as *const u8).into();
     scanf::scanf(reader, format, ap)
 }

+ 6 - 5
dlibc/src/unix/header/stdio/printf.rs

@@ -6,10 +6,7 @@ use alloc::{
 };
 use core::{char, cmp, f64, ffi::VaList, fmt, num::FpCategory, ops::Range, slice};
 
-use crate::unix::{
-    header::errno::EILSEQ,
-    platform,
-};
+use crate::unix::{header::errno::EILSEQ, platform};
 
 //  ____        _ _                 _       _
 // | __ )  ___ (_) | ___ _ __ _ __ | | __ _| |_ ___ _
@@ -608,7 +605,11 @@ impl Iterator for PrintfIter {
     }
 }
 
-unsafe fn inner_printf<W: Write>(w: W, format: *const ::c_char, mut ap: VaList) -> io::Result<::c_int> {
+unsafe fn inner_printf<W: Write>(
+    w: W,
+    format: *const ::c_char,
+    mut ap: VaList,
+) -> io::Result<::c_int> {
     let w = &mut platform::CountingWriter::new(w);
 
     let iterator = PrintfIter {

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

@@ -239,10 +239,10 @@ 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)

+ 0 - 2
dlibc/src/unix/header/stdlib/rand48.rs

@@ -1,7 +1,5 @@
 //! Helper functions for pseudorandom number generation using LCG, see https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/drand48.html
 
-
-
 /* The default element buffer for the linear congruential generator's
  * sequence. Implemented using a ::c_ushort array for consistency between
  * the drand48()/lrand48()/mrand48() and erand48()/nrand48()/jrand48()

+ 0 - 1
dlibc/src/unix/header/stdlib/random.rs

@@ -2,7 +2,6 @@
 /* Ported from musl's implementation (src/prng/random.c). Does not
  * currently implement locking, though. */
 
-
 use core::{convert::TryFrom, ptr};
 
 #[rustfmt::skip]

+ 11 - 4
dlibc/src/unix/header/stdlib/sort.rs

@@ -1,5 +1,3 @@
-
-
 pub fn introsort(
     base: *mut ::c_char,
     nel: ::size_t,
@@ -133,11 +131,20 @@ fn heap_sift_down(
         let first_child_ptr = unsafe { base.add(child * width) };
         let second_child_ptr = unsafe { base.add((child + 1) * width) };
 
-        if comp(swap_ptr as *const ::c_void, first_child_ptr as *const ::c_void) < 0 {
+        if comp(
+            swap_ptr as *const ::c_void,
+            first_child_ptr as *const ::c_void,
+        ) < 0
+        {
             swap_idx = child;
             swap_ptr = first_child_ptr;
         }
-        if child < end && comp(swap_ptr as *const ::c_void, second_child_ptr as *const ::c_void) < 0 {
+        if child < end
+            && comp(
+                swap_ptr as *const ::c_void,
+                second_child_ptr as *const ::c_void,
+            ) < 0
+        {
             swap_idx = child + 1;
             swap_ptr = second_child_ptr;
         }

+ 46 - 12
dlibc/src/unix/header/string/mod.rs

@@ -1,10 +1,10 @@
 //! string implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/string.h.html
 
-use core::{mem, ptr, slice, usize};
+use crate::unix::header::string::slice::memchr;
+use crate::unix::header::{errno::*, signal};
 use crate::unix::platform;
 use cbitset::BitSet256;
-use crate::unix::header::{errno::*, signal};
-use crate::unix::header::string::slice::memchr;
+use core::{mem, ptr, slice, usize};
 
 #[no_mangle]
 pub unsafe extern "C" fn memccpy(
@@ -71,7 +71,11 @@ pub unsafe extern "C" fn memcmp(s1: *const ::c_void, s2: *const ::c_void, n: ::s
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memcpy(s1: *mut ::c_void, s2: *const ::c_void, n: ::size_t) -> *mut ::c_void {
+pub unsafe extern "C" fn memcpy(
+    s1: *mut ::c_void,
+    s2: *const ::c_void,
+    n: ::size_t,
+) -> *mut ::c_void {
     let mut i = 0;
     while i + 7 < n {
         *(s1.add(i) as *mut u64) = *(s2.add(i) as *const u64);
@@ -85,7 +89,11 @@ pub unsafe extern "C" fn memcpy(s1: *mut ::c_void, s2: *const ::c_void, n: ::siz
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memmove(s1: *mut ::c_void, s2: *const ::c_void, n: ::size_t) -> *mut ::c_void {
+pub unsafe extern "C" fn memmove(
+    s1: *mut ::c_void,
+    s2: *const ::c_void,
+    n: ::size_t,
+) -> *mut ::c_void {
     if s2 < s1 as *const ::c_void {
         // copy from end
         let mut i = n;
@@ -241,7 +249,11 @@ pub unsafe extern "C" fn strerror(errnum: ::c_int) -> *mut ::c_char {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strerror_r(errnum: ::c_int, buf: *mut ::c_char, buflen: ::size_t) -> ::c_int {
+pub unsafe extern "C" fn strerror_r(
+    errnum: ::c_int,
+    buf: *mut ::c_char,
+    buflen: ::size_t,
+) -> ::c_int {
     let msg = strerror(errnum);
     let len = strlen(msg);
 
@@ -289,7 +301,11 @@ pub unsafe extern "C" fn strcat(s1: *mut ::c_char, s2: *const ::c_char) -> *mut
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strncat(s1: *mut ::c_char, s2: *const ::c_char, n: ::size_t) -> *mut ::c_char {
+pub unsafe extern "C" fn strncat(
+    s1: *mut ::c_char,
+    s2: *const ::c_char,
+    n: ::size_t,
+) -> *mut ::c_char {
     let len = strlen(s1 as *const ::c_char);
     let mut i = 0;
     while i < n {
@@ -322,7 +338,11 @@ pub unsafe extern "C" fn strncmp(s1: *const ::c_char, s2: *const ::c_char, n: ::
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strncpy(dst: *mut ::c_char, src: *const ::c_char, n: ::size_t) -> *mut ::c_char {
+pub unsafe extern "C" fn strncpy(
+    dst: *mut ::c_char,
+    src: *const ::c_char,
+    n: ::size_t,
+) -> *mut ::c_char {
     let mut i = 0;
 
     while *src.add(i) != 0 && i < n {
@@ -399,11 +419,17 @@ unsafe fn inner_strstr(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strstr(haystack: *const ::c_char, needle: *const ::c_char) -> *mut ::c_char {
+pub unsafe extern "C" fn strstr(
+    haystack: *const ::c_char,
+    needle: *const ::c_char,
+) -> *mut ::c_char {
     inner_strstr(haystack, needle, !0)
 }
 #[no_mangle]
-pub unsafe extern "C" fn strcasestr(haystack: *const ::c_char, needle: *const ::c_char) -> *mut ::c_char {
+pub unsafe extern "C" fn strcasestr(
+    haystack: *const ::c_char,
+    needle: *const ::c_char,
+) -> *mut ::c_char {
     inner_strstr(haystack, needle, !32)
 }
 
@@ -460,7 +486,11 @@ pub unsafe extern "C" fn strxfrm(s1: *mut ::c_char, s2: *const ::c_char, n: ::si
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strlcpy(dst: *mut ::c_char, src: *const ::c_char, n: ::size_t) -> ::size_t {
+pub unsafe extern "C" fn strlcpy(
+    dst: *mut ::c_char,
+    src: *const ::c_char,
+    n: ::size_t,
+) -> ::size_t {
     let mut i = 0;
 
     while *src.add(i) != 0 && i < n {
@@ -474,7 +504,11 @@ pub unsafe extern "C" fn strlcpy(dst: *mut ::c_char, src: *const ::c_char, n: ::
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strlcat(dst: *mut ::c_char, src: *const ::c_char, n: ::size_t) -> ::size_t {
+pub unsafe extern "C" fn strlcat(
+    dst: *mut ::c_char,
+    src: *const ::c_char,
+    n: ::size_t,
+) -> ::size_t {
     let len = strlen(dst) as isize;
     let d = dst.offset(len);
 

+ 5 - 1
dlibc/src/unix/header/strings/mod.rs

@@ -5,7 +5,11 @@ use core::{arch, ptr};
 use crate::unix::header::{ctype, string};
 
 #[no_mangle]
-pub unsafe extern "C" fn bcmp(first: *const ::c_void, second: *const ::c_void, n: ::size_t) -> ::c_int {
+pub unsafe extern "C" fn bcmp(
+    first: *const ::c_void,
+    second: *const ::c_void,
+    n: ::size_t,
+) -> ::c_int {
     string::memcmp(first, second, n)
 }
 

+ 0 - 2
dlibc/src/unix/header/sys_auxv/mod.rs

@@ -1,7 +1,5 @@
 //! sys/auxv.h implementation
 
-
-
 #[no_mangle]
 pub extern "C" fn getauxval(_t: ::c_ulong) -> ::c_ulong {
     0

+ 1 - 3
dlibc/src/unix/header/sys_epoll/mod.rs

@@ -2,8 +2,6 @@
 
 use core::ptr;
 
-
-
 use crate::unix::platform;
 
 pub use self::platform::*;
@@ -20,5 +18,5 @@ pub extern "C" fn epoll_wait(
     maxevents: ::c_int,
     timeout: ::c_int,
 ) -> ::c_int {
-    unsafe{epoll_pwait(epfd, events, maxevents, timeout, ptr::null())}
+    unsafe { epoll_pwait(epfd, events, maxevents, timeout, ptr::null()) }
 }

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

@@ -1,6 +1,5 @@
 //! sys/file.h implementation
 
-
 pub const LOCK_SH: usize = 1;
 pub const LOCK_EX: usize = 2;
 pub const LOCK_NB: usize = 4;

+ 0 - 1
dlibc/src/unix/header/sys_ioctl/linux.rs

@@ -1,4 +1,3 @@
-
 #[no_mangle]
 pub unsafe extern "C" fn ioctl(fd: ::c_int, request: ::c_ulong, out: *mut ::c_void) -> ::c_int {
     // TODO: Somehow support varargs to syscall??

+ 0 - 2
dlibc/src/unix/header/sys_ioctl/mod.rs

@@ -1,7 +1,5 @@
 //! ioctl implementation for linux
 
-
-
 // This is used from sgtty
 #[repr(C)]
 pub struct sgttyb {

+ 5 - 3
dlibc/src/unix/header/sys_mman/mod.rs

@@ -3,8 +3,6 @@ use crate::unix::{
     header::fcntl,
 };
 
-
-
 pub const MADV_NORMAL: ::c_int = 0;
 pub const MADV_RANDOM: ::c_int = 1;
 pub const MADV_SEQUENTIAL: ::c_int = 2;
@@ -107,7 +105,11 @@ unsafe fn shm_path(name: *const ::c_char) -> CString {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int {
+pub unsafe extern "C" fn shm_open(
+    name: *const ::c_char,
+    oflag: ::c_int,
+    mode: ::mode_t,
+) -> ::c_int {
     let path = shm_path(name);
     fcntl::sys_open(path.as_ptr(), oflag, mode)
 }

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

@@ -3,7 +3,6 @@ use crate::header::arch_aarch64_user::*;
 #[cfg(target_arch = "x86_64")]
 use crate::header::arch_x64_user::*;
 
-
 pub const ELF_PRARGSZ: ::size_t = 80;
 
 #[repr(C)]

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

@@ -1,7 +1,7 @@
 //! ptrace compatibility layer for Redox OS
 
-use core::ffi::VaList;
 use crate::unix::platform;
+use core::ffi::VaList;
 
 pub const PTRACE_TRACEME: ::c_int = 0;
 pub const PTRACE_PEEKTEXT: ::c_int = 1;

+ 0 - 3
dlibc/src/unix/header/sys_random/mod.rs

@@ -1,6 +1,3 @@
-
-
-
 pub const GRND_NONBLOCK: ::c_uint = 1;
 pub const GRND_RANDOM: ::c_uint = 2;
 

+ 4 - 6
dlibc/src/unix/header/sys_select/mod.rs

@@ -8,9 +8,7 @@ use crate::unix::{
     fs::File,
     header::{
         errno,
-        sys_epoll::{
-            epoll_create1, epoll_ctl, epoll_data, epoll_event, epoll_wait
-        },
+        sys_epoll::{epoll_create1, epoll_ctl, epoll_data, epoll_event, epoll_wait},
         sys_time::timeval,
     },
     platform,
@@ -39,7 +37,7 @@ pub fn select_epoll(
     };
 
     let ep = {
-        let epfd = unsafe{epoll_create1(::EPOLL_CLOEXEC)};
+        let epfd = unsafe { epoll_create1(::EPOLL_CLOEXEC) };
         if epfd < 0 {
             return -1;
         }
@@ -75,11 +73,11 @@ pub fn select_epoll(
 
         if events > 0 {
             let mut event = epoll_event {
-                events:events as u32,
+                events: events as u32,
                 data: epoll_data { fd },
                 ..Default::default()
             };
-            if unsafe{epoll_ctl(*ep, ::EPOLL_CTL_ADD, fd, &mut event)} < 0 {
+            if unsafe { epoll_ctl(*ep, ::EPOLL_CTL_ADD, fd, &mut event) } < 0 {
                 if unsafe { platform::errno == errno::EPERM } {
                     not_epoll += 1;
                 } else {

+ 0 - 2
dlibc/src/unix/header/sys_socket/constants.rs

@@ -1,5 +1,3 @@
-
-
 pub const SOCK_STREAM: ::c_int = 1;
 pub const SOCK_DGRAM: ::c_int = 2;
 pub const SOCK_NONBLOCK: ::c_int = 0o4_000;

+ 2 - 6
dlibc/src/unix/header/sys_socket/mod.rs

@@ -1,7 +1,7 @@
 //! socket implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html
 
-use core::ptr;
 use crate::unix::platform;
+use core::ptr;
 pub mod constants;
 
 use unix::platform::sockaddr;
@@ -23,11 +23,7 @@ pub unsafe extern "C" fn accept(
     )
 }
 
-pub unsafe fn bind(
-    socket: ::c_int,
-    address: *const sockaddr,
-    address_len: socklen_t,
-) -> ::c_int {
+pub unsafe fn bind(socket: ::c_int, address: *const sockaddr, address_len: socklen_t) -> ::c_int {
     trace_expr!(
         platform::pal::bind(socket, address, address_len),
         "bind({}, {:p}, {})",

+ 1 - 5
dlibc/src/unix/header/sys_stat/mod.rs

@@ -1,10 +1,6 @@
 //! ::stat implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html
 
-use crate::unix::{
-    header::fcntl::{O_NOFOLLOW, O_PATH},
-};
-
-
+use crate::unix::header::fcntl::{O_NOFOLLOW, O_PATH};
 
 use crate::unix::platform;
 

+ 1 - 4
dlibc/src/unix/header/sys_statvfs/mod.rs

@@ -1,9 +1,6 @@
 //! ::statvfs implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstatvfs.h.html
 
-use crate::unix::{
-    header::fcntl::O_PATH,
-    platform,
-};
+use crate::unix::{header::fcntl::O_PATH, platform};
 
 //pub const ST_RDONLY
 //pub const ST_NOSUID

+ 6 - 6
dlibc/src/unix/header/sys_time/mod.rs

@@ -1,12 +1,9 @@
 //! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
 
-use crate::unix::{
-    c_str::CStr,
-    platform,
-};
+use crate::unix::{c_str::CStr, platform};
 
-pub use timeval;
 pub use itimerval;
+pub use timeval;
 
 pub const ITIMER_REAL: ::c_int = 0;
 pub const ITIMER_VIRTUAL: ::c_int = 1;
@@ -41,7 +38,10 @@ pub struct fd_set {
 #[no_mangle]
 pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> ::c_int {
     #[cfg(target_os = "dragonos")]
-    crate::unix::platform::dragonos::pal::relibc_adapter::pal::gettimeofday(tp, tzp as *mut ::c_void)
+    crate::unix::platform::dragonos::pal::relibc_adapter::pal::gettimeofday(
+        tp,
+        tzp as *mut ::c_void,
+    )
 }
 
 #[no_mangle]

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

@@ -1,6 +1,6 @@
 //! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
 
-use crate::unix::header::sys_time::{gettimeofday ,timeval, timezone};
+use crate::unix::header::sys_time::{gettimeofday, timeval, timezone};
 
 #[repr(C)]
 #[derive(Default)]

+ 0 - 2
dlibc/src/unix/header/sys_utsname/mod.rs

@@ -1,7 +1,5 @@
 //! sys/utsname implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
 
-
-
 pub const UTSLENGTH: usize = 65;
 
 // #[no_mangle]

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

@@ -3,7 +3,6 @@
 
 //use header::sys_resource::rusage;
 
-
 pub const WNOHANG: ::c_int = 1;
 pub const WUNTRACED: ::c_int = 2;
 

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

@@ -1,6 +1,6 @@
 //! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html
 
-use crate::unix::header::{errno};
+use crate::unix::header::errno;
 
 pub type cc_t = u8;
 pub type speed_t = u32;
@@ -46,8 +46,8 @@ pub struct termios {
     c_cc: [cc_t; NCCS],
 }
 
-use {TCGETS,TCSETS,TCFLSH,TCSBRK};
 use unix::platform::ioctl;
+use {TCFLSH, TCGETS, TCSBRK, TCSETS};
 
 #[no_mangle]
 pub unsafe extern "C" fn tcgetattr(fd: ::c_int, out: *mut termios) -> ::c_int {

+ 2 - 5
dlibc/src/unix/header/time/mod.rs

@@ -2,10 +2,7 @@
 
 use core::convert::{TryFrom, TryInto};
 
-use crate::unix::{
-    header::errno::EOVERFLOW,
-    platform,
-};
+use crate::unix::{header::errno::EOVERFLOW, platform};
 
 pub use self::constants::*;
 use clock_gettime;
@@ -141,7 +138,7 @@ pub unsafe extern "C" fn asctime_r(tm: *const tm, buf: *mut ::c_char) -> *mut ::
 pub extern "C" fn clock() -> ::clock_t {
     let mut ts = core::mem::MaybeUninit::<::timespec>::uninit();
 
-    if unsafe{clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ts.as_mut_ptr())} != 0 {
+    if unsafe { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ts.as_mut_ptr()) } != 0 {
         return -1;
     }
     let ts = unsafe { ts.assume_init() };

+ 1 - 4
dlibc/src/unix/header/unistd/brk.rs

@@ -1,9 +1,6 @@
 use core::ptr;
 
-use crate::unix::{
-    header::errno::ENOMEM,
-    platform,
-};
+use crate::unix::{header::errno::ENOMEM, platform};
 
 static mut BRK: *mut ::c_void = ptr::null_mut();
 

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

@@ -1,6 +1,6 @@
+use crate::unix::header::errno;
 use core::convert::TryInto;
 use unix::platform;
-use crate::unix::header::errno;
 
 // POSIX.1 {
 pub const _SC_ARG_MAX: ::c_int = 0;

+ 43 - 11
dlibc/src/unix/header/wchar/mod.rs

@@ -1,10 +1,10 @@
 //! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wchar.h.html
 
-use core::{char, ffi::VaList as va_list, mem, ptr, slice, usize};
-use crate::unix::platform;
 use crate::unix::header::{
     ctype::isspace, errno::ERANGE, stdio::*, stdlib::MB_CUR_MAX, string, time::*, wctype::*,
 };
+use crate::unix::platform;
+use core::{char, ffi::VaList as va_list, mem, ptr, slice, usize};
 
 mod utf8;
 #[repr(C)]
@@ -38,7 +38,11 @@ pub unsafe extern "C" fn fgetwc(stream: *mut FILE) -> ::wint_t {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn fgetws(ws: *mut ::wchar_t, n: ::c_int, stream: *mut FILE) -> *mut ::wchar_t {
+pub unsafe extern "C" fn fgetws(
+    ws: *mut ::wchar_t,
+    n: ::c_int,
+    stream: *mut FILE,
+) -> *mut ::wchar_t {
     //TODO: lock
     let mut i = 0;
     while ((i + 1) as ::c_int) < n {
@@ -230,7 +234,11 @@ pub extern "C" fn swprintf(
 }
 
 // #[no_mangle]
-pub extern "C" fn swscanf(_s: *const ::wchar_t, _format: *const ::wchar_t, _ap: va_list) -> ::c_int {
+pub extern "C" fn swscanf(
+    _s: *const ::wchar_t,
+    _format: *const ::wchar_t,
+    _ap: va_list,
+) -> ::c_int {
     unimplemented!();
 }
 
@@ -240,7 +248,11 @@ pub extern "C" fn ungetwc(_wc: ::wint_t, _stream: *mut FILE) -> ::wint_t {
 }
 
 // #[no_mangle]
-pub extern "C" fn vfwprintf(_stream: *mut FILE, _format: *const ::wchar_t, _arg: va_list) -> ::c_int {
+pub extern "C" fn vfwprintf(
+    _stream: *mut FILE,
+    _format: *const ::wchar_t,
+    _arg: va_list,
+) -> ::c_int {
     unimplemented!();
 }
 
@@ -371,7 +383,11 @@ pub unsafe extern "C" fn wcsncat(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wcsncmp(ws1: *const ::wchar_t, ws2: *const ::wchar_t, n: ::size_t) -> ::c_int {
+pub unsafe extern "C" fn wcsncmp(
+    ws1: *const ::wchar_t,
+    ws2: *const ::wchar_t,
+    n: ::size_t,
+) -> ::c_int {
     for i in 0..n {
         let wc1 = *ws1.add(i);
         let wc2 = *ws2.add(i);
@@ -407,7 +423,10 @@ pub unsafe extern "C" fn wcsncpy(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wcspbrk(mut wcs: *const ::wchar_t, set: *const ::wchar_t) -> *mut ::wchar_t {
+pub unsafe extern "C" fn wcspbrk(
+    mut wcs: *const ::wchar_t,
+    set: *const ::wchar_t,
+) -> *mut ::wchar_t {
     wcs = wcs.add(wcscspn(wcs, set));
     if *wcs == 0 {
         ptr::null_mut()
@@ -673,7 +692,11 @@ pub extern "C" fn wcwidth(wc: ::wchar_t) -> ::c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wmemchr(ws: *const ::wchar_t, wc: ::wchar_t, n: ::size_t) -> *mut ::wchar_t {
+pub unsafe extern "C" fn wmemchr(
+    ws: *const ::wchar_t,
+    wc: ::wchar_t,
+    n: ::size_t,
+) -> *mut ::wchar_t {
     for i in 0..n {
         if *ws.add(i) == wc {
             return ws.add(i) as *mut ::wchar_t;
@@ -683,7 +706,11 @@ pub unsafe extern "C" fn wmemchr(ws: *const ::wchar_t, wc: ::wchar_t, n: ::size_
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wmemcmp(ws1: *const ::wchar_t, ws2: *const ::wchar_t, n: ::size_t) -> ::c_int {
+pub unsafe extern "C" fn wmemcmp(
+    ws1: *const ::wchar_t,
+    ws2: *const ::wchar_t,
+    n: ::size_t,
+) -> ::c_int {
     for i in 0..n {
         let wc1 = *ws1.add(i);
         let wc2 = *ws2.add(i);
@@ -754,14 +781,19 @@ pub extern "C" fn wcscasecmp(mut s1: *const ::wchar_t, mut s2: *const ::wchar_t)
 }
 
 #[no_mangle]
-pub extern "C" fn wcsncasecmp(mut s1: *const ::wchar_t, mut s2: *const ::wchar_t, n: ::size_t) -> ::c_int {
+pub extern "C" fn wcsncasecmp(
+    mut s1: *const ::wchar_t,
+    mut s2: *const ::wchar_t,
+    n: ::size_t,
+) -> ::c_int {
     if n == 0 {
         return 0;
     }
     unsafe {
         for _ in 0..n {
             if *s1 == 0 || *s2 == 0 || towlower(*s1 as ::wint_t) != towlower(*s2 as ::wint_t) {
-                return towlower(*s1 as ::wint_t).wrapping_sub(towlower(*s2 as ::wint_t)) as ::c_int;
+                return towlower(*s1 as ::wint_t).wrapping_sub(towlower(*s2 as ::wint_t))
+                    as ::c_int;
             }
             s1 = s1.add(1);
             s2 = s2.add(1);

+ 7 - 2
dlibc/src/unix/header/wchar/utf8.rs

@@ -3,9 +3,9 @@
 
 use core::{char, slice, str, usize};
 
+use super::mbstate_t;
 use crate::unix::header::errno;
 use crate::unix::platform;
-use super::mbstate_t;
 
 // Based on
 // https://github.com/rust-lang/rust/blob/f24ce9b/library/core/src/str/validations.rs#L232-L257,
@@ -38,7 +38,12 @@ fn utf8_char_width(b: u8) -> usize {
 }
 
 //It's guaranteed that we don't have any nullpointers here
-pub unsafe fn mbrtowc(pwc: *mut ::wchar_t, s: *const ::c_char, n: usize, _ps: *mut mbstate_t) -> usize {
+pub unsafe fn mbrtowc(
+    pwc: *mut ::wchar_t,
+    s: *const ::c_char,
+    n: usize,
+    _ps: *mut mbstate_t,
+) -> usize {
     let size = utf8_char_width(*s as u8);
     if size > n {
         platform::errno = errno::EILSEQ;

+ 0 - 2
dlibc/src/unix/header/wctype/alpha.rs

@@ -2,8 +2,6 @@
 // Licensed under the MIT license
 // Copyright 2005-2020 Rich Felker, et al.
 
-
-
 pub fn is(wc: usize) -> ::c_uchar {
     if wc < 0x20000 {
         return (table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;

+ 0 - 2
dlibc/src/unix/header/wctype/casecmp.rs

@@ -2,8 +2,6 @@
 // Licensed under the MIT license
 // Copyright 2005-2020 Rich Felker, et al.
 
-
-
 const tab: [::c_uchar; 2666] = [
     7, 8, 9, 10, 11, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 13, 6, 6, 14, 6, 6, 6, 6, 6, 6, 6, 6, 15,
     16, 17, 18, 6, 19, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 20, 21, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,

+ 4 - 2
dlibc/src/unix/header/wctype/mod.rs

@@ -1,7 +1,7 @@
 //! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wctype.h.html
 
 use self::casecmp::casemap;
-use crate::unix::{c_str::CStr, header::ctype,};
+use crate::unix::{c_str::CStr, header::ctype};
 
 mod alpha;
 mod casecmp;
@@ -165,7 +165,9 @@ pub extern "C" fn iswupper(wc: ::wint_t) -> ::c_int {
 
 #[no_mangle]
 pub extern "C" fn iswxdigit(wc: ::wint_t) -> ::c_int {
-    ::c_int::from(wc.wrapping_sub('0' as ::wint_t) < 10 || (wc | 32).wrapping_sub('a' as ::wint_t) < 6)
+    ::c_int::from(
+        wc.wrapping_sub('0' as ::wint_t) < 10 || (wc | 32).wrapping_sub('a' as ::wint_t) < 6,
+    )
 }
 
 #[no_mangle]

+ 0 - 2
dlibc/src/unix/header/wctype/punct.rs

@@ -2,8 +2,6 @@
 // Licensed under the MIT license
 // Copyright 2005-2020 Rich Felker, et al.
 
-
-
 pub fn is(wc: usize) -> ::c_uchar {
     if wc < 0x20000 {
         return (table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;

+ 1 - 1
dlibc/src/unix/ld_so/access.rs

@@ -1,9 +1,9 @@
 // Wrapper over the access syscall that doesn't touch errno variable,
 // Do not use outside of ld_so
 
+use crate::unix::c_str::CString;
 #[cfg(target_os = "redox")]
 use crate::unix::header::unistd::{F_OK, R_OK, W_OK, X_OK};
-use crate::unix::c_str::{CString};
 
 pub fn accessible(path: &str, mode: ::c_int) -> ::c_int {
     let path_c = CString::new(path.as_bytes()).unwrap(); /*.map_err(|err| {

+ 8 - 8
dlibc/src/unix/ld_so/dso.rs

@@ -1,11 +1,12 @@
-use errno;
 use super::{
     debug::{RTLDDebug, _r_debug},
     linker::Symbol,
     tcb::{round_up, Master},
 };
-use unix::header::{errno::STR_ERROR};
+use errno;
+use unix::header::errno::STR_ERROR;
 
+use crate::trace;
 use alloc::{
     collections::BTreeMap,
     string::{String, ToString},
@@ -35,14 +36,13 @@ use goblin::{
     elf::Elf,
     error::{Error, Result},
 };
-use PROT_READ;
-use PROT_WRITE;
-use MAP_FIXED_NOREPLACE;
-use MAP_ANONYMOUS;
-use MAP_PRIVATE;
 use mmap;
 use munmap;
-use crate::trace;
+use MAP_ANONYMOUS;
+use MAP_FIXED_NOREPLACE;
+use MAP_PRIVATE;
+use PROT_READ;
+use PROT_WRITE;
 
 /// Use to represent a library as well as all the symbols that is loaded withen it.
 #[derive(Default)]

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

@@ -29,15 +29,15 @@ use super::{
     ExpectTlsFree, PATH_SEP,
 };
 
-use O_RDONLY;
 use O_CLOEXEC;
+use O_RDONLY;
 
 use crate::trace;
 use PROT_EXEC;
 
+use mprotect;
 use PROT_READ;
 use PROT_WRITE;
-use mprotect;
 
 #[derive(Clone, Copy, Debug)]
 pub struct Symbol {

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

@@ -10,17 +10,17 @@ use alloc::{
 
 use unix::platform::allocator::new_mspace;
 
+use super::platform;
 use crate::eprintln;
 use crate::println;
-use super::platform;
 
 use unix::{
+    allocator::ALLOCATOR,
     c_str::CStr,
     header::unistd,
     platform::{get_auxv, get_auxvs},
     start::Stack,
     sync::mutex::Mutex,
-    allocator::ALLOCATOR,
 };
 
 use super::{access::accessible, debug::_r_debug, linker::Linker, tcb::Tcb, PATH_SEP};

+ 3 - 9
dlibc/src/unix/ld_so/tcb.rs

@@ -1,19 +1,13 @@
-
 use alloc::vec::Vec;
 use core::{arch::asm, mem, ptr, slice};
 use goblin::error::{Error, Result};
 
-
-
 use crate::unix::platform;
-use crate::unix::{
-    ld_so::linker::Linker,
-    sync::mutex::Mutex,
-};
-use PROT_READ;
-use PROT_WRITE;
+use crate::unix::{ld_so::linker::Linker, sync::mutex::Mutex};
 use MAP_ANONYMOUS;
 use MAP_PRIVATE;
+use PROT_READ;
+use PROT_WRITE;
 
 use crate::trace;
 

+ 1 - 1
dlibc/src/unix/macros.rs

@@ -143,7 +143,7 @@ macro_rules! strto_impl {
                 *$endptr = $s.offset(idx) as *mut _;
             }
         };
-        
+
         #[allow(unused_mut)]
         let mut invalid_input = || {
             ::errno = EINVAL;

+ 5 - 1
dlibc/src/unix/mod.rs

@@ -1391,7 +1391,11 @@ extern "C" {
     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 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;

+ 7 - 3
dlibc/src/unix/platform/dragonos/allocator/dragonos_malloc.rs

@@ -1,4 +1,8 @@
-use core::{alloc::GlobalAlloc, ptr::null_mut, sync::atomic::{AtomicUsize, Ordering}};
+use core::{
+    alloc::GlobalAlloc,
+    ptr::null_mut,
+    sync::atomic::{AtomicUsize, Ordering},
+};
 
 extern "C" {
     fn _dragonos_free(ptr: *mut ::c_void) -> *mut ::c_void;
@@ -6,7 +10,7 @@ extern "C" {
     fn _dragonos_chunk_length(ptr: *mut ::c_void) -> usize;
 }
 
-pub struct Allocator{
+pub struct Allocator {
     mstate: AtomicUsize,
 }
 
@@ -19,7 +23,7 @@ impl Allocator {
     }
 }
 
-pub const ALLOCATOR: Allocator = Allocator{
+pub const ALLOCATOR: Allocator = Allocator {
     mstate: AtomicUsize::new(0),
 };
 

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

@@ -140,7 +140,6 @@ pub static STR_ERROR: [&'static str; 132] = [
     "Unknown",
 ];
 
-
 pub type useconds_t = u32;
 pub type dev_t = u64;
 pub type socklen_t = u32;
@@ -1814,7 +1813,7 @@ pub const PF_MASKOS: u32 = 0x0ff00000;
 pub const PF_MASKPROC: u32 = 0xf0000000;
 
 // elf.h - Legal values for a_type (entry type).
-cfg_if!{
+cfg_if! {
     if #[cfg(target_os = "dragonos")]{
         pub const AT_NULL: usize = 0;
         pub const AT_IGNORE: usize = 1;
@@ -1876,14 +1875,13 @@ cfg_if!{
         pub const AT_HWCAP2: ::c_ulong = 26;
 
         pub const AT_EXECFN: ::c_ulong = 31;
-        
+
         // defined in arch/<arch>/include/uapi/asm/auxvec.h but has the same value
         // wherever it is defined.
         pub const AT_SYSINFO_EHDR: ::c_ulong = 33;
     }
 }
 
-
 pub const GLOB_ERR: ::c_int = 1 << 0;
 pub const GLOB_MARK: ::c_int = 1 << 1;
 pub const GLOB_NOSORT: ::c_int = 1 << 2;
@@ -5077,20 +5075,19 @@ cfg_if! {
 
 cfg_if! {
     if #[cfg(target_env = "uclibc")] {
-        mod uclibc;
-        pub use self::ucdlibc::*;
+        // mod uclibc;
+        // pub use self::ucdlibc::*;
+        unimplemented!();
     } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
         mod musl;
         pub use self::musl::*;
     } else if #[cfg(target_env = "gnu")] {
-        mod gnu;
-        pub use self::gnu::*;
+        // mod gnu;
+        // pub use self::gnu::*;
+        unimplemented!();
     }
 }
 
-pub mod musl;
-pub use self::musl::*;
-
 pub mod arch;
 pub use self::arch::*;
 

+ 1 - 2
dlibc/src/unix/platform/dragonos/musl/b64/mod.rs

@@ -2,9 +2,8 @@ pub type c_long = i64;
 pub type c_ulong = u64;
 pub type regoff_t = ::c_long;
 
-
 #[cfg(not(target_os = "dragonos"))]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct sigset_t {
     __val: [::c_ulong; 16],
 }

+ 1 - 0
dlibc/src/unix/platform/dragonos/musl/mod.rs

@@ -702,6 +702,7 @@ cfg_if! {
     }
 }
 
+#[allow(dead_code)]
 extern "C" {
     pub fn sendmmsg(
         sockfd: ::c_int,

+ 3 - 3
dlibc/src/unix/platform/dragonos/pal/relibc_adapter/mod.rs

@@ -1,11 +1,11 @@
 pub mod pal;
 pub mod pal_epoll;
-pub mod pal_socket;
 pub mod pal_signal;
+pub mod pal_socket;
 pub mod pal_trace;
 
 pub use self::pal::*;
 pub use self::pal_epoll::*;
-pub use self::pal_socket::*;
 pub use self::pal_signal::*;
-pub use self::pal_trace::*;
+pub use self::pal_socket::*;
+pub use self::pal_trace::*;

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

@@ -1,4 +1,3 @@
-
 use crate::unix::c_str::CStr;
 use crate::unix::platform::pal::e;
 use crate::unix::*;
@@ -318,7 +317,7 @@ pub extern "C" fn open(path: *const ::c_char, oflag: ::c_int, mode: mode_t) -> :
 
 #[no_mangle]
 pub extern "C" fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int {
-    e(unsafe { syscall!(SYS_PIPE, fds, flags )}) as ::c_int
+    e(unsafe { syscall!(SYS_PIPE, fds, flags) }) as ::c_int
 }
 
 #[no_mangle]

+ 17 - 16
dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_epoll.rs

@@ -1,24 +1,25 @@
-
-
-
 #[no_mangle]
-pub extern "C" fn epoll_create1(_flags: ::c_int) -> ::c_int{
-	unimplemented!()
+pub extern "C" fn epoll_create1(_flags: ::c_int) -> ::c_int {
+    unimplemented!()
 }
 
 #[no_mangle]
-pub extern "C" fn epoll_ctl(_epfd: ::c_int, _op: ::c_int, _fd: ::c_int, _event: *mut ::epoll_event)
-	-> ::c_int{
-	unimplemented!()
+pub extern "C" fn epoll_ctl(
+    _epfd: ::c_int,
+    _op: ::c_int,
+    _fd: ::c_int,
+    _event: *mut ::epoll_event,
+) -> ::c_int {
+    unimplemented!()
 }
 
 #[no_mangle]
 pub extern "C" fn epoll_pwait(
-	_epfd: ::c_int,
-	_events: *mut ::epoll_event,
-	_maxevents: ::c_int,
-	_timeout: ::c_int,
-	_sigmask: *const ::sigset_t,
-) -> ::c_int{
-	unimplemented!()
-}
+    _epfd: ::c_int,
+    _events: *mut ::epoll_event,
+    _maxevents: ::c_int,
+    _timeout: ::c_int,
+    _sigmask: *const ::sigset_t,
+) -> ::c_int {
+    unimplemented!()
+}

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

@@ -1,10 +1,14 @@
+use crate::unix::platform::pal::e;
 use crate::unix::*;
 use dsc::syscall;
-use crate::unix::platform::pal::{e};
 use sockaddr;
 #[no_mangle]
-pub unsafe extern "C" fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int{
-	e(syscall!(
+pub unsafe extern "C" fn accept(
+    socket: ::c_int,
+    address: *mut sockaddr,
+    address_len: *mut socklen_t,
+) -> ::c_int {
+    e(syscall!(
         SYS_ACCEPT,
         socket as usize,
         address as usize,
@@ -13,12 +17,20 @@ pub unsafe extern "C" fn accept(socket: ::c_int, address: *mut sockaddr, address
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int{
-	e(syscall!(SYS_BIND, socket, address, address_len)) as ::c_int
+pub unsafe extern "C" fn bind(
+    socket: ::c_int,
+    address: *const ::sockaddr,
+    address_len: ::socklen_t,
+) -> ::c_int {
+    e(syscall!(SYS_BIND, socket, address, address_len)) as ::c_int
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn connect(socket: ::c_int, address: *const sockaddr, address_len: socklen_t) -> ::c_int {
+pub unsafe extern "C" fn connect(
+    socket: ::c_int,
+    address: *const sockaddr,
+    address_len: socklen_t,
+) -> ::c_int {
     e(syscall!(SYS_CONNECT, socket, address, address_len)) as ::c_int
 }
 
@@ -67,22 +79,14 @@ pub extern "C" fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int {
 
 #[no_mangle]
 pub extern "C" fn recvfrom(
-	socket: ::c_int,
-	buf: *mut ::c_void,
-	len: ::size_t,
-	flags: ::c_int,
-	addr: *mut ::sockaddr,
-	addrlen: *mut ::socklen_t,
-) -> ::ssize_t{
-	e(unsafe{syscall!(
-        SYS_RECVFROM,
-        socket,
-        buf,
-        len,
-        flags,
-        addr,
-        addrlen
-    )}) as ssize_t
+    socket: ::c_int,
+    buf: *mut ::c_void,
+    len: ::size_t,
+    flags: ::c_int,
+    addr: *mut ::sockaddr,
+    addrlen: *mut ::socklen_t,
+) -> ::ssize_t {
+    e(unsafe { syscall!(SYS_RECVFROM, socket, buf, len, flags, addr, addrlen) }) as ssize_t
 }
 
 #[no_mangle]
@@ -93,10 +97,8 @@ pub extern "C" fn sendto(
     flags: ::c_int,
     addr: *const sockaddr,
     addrlen: socklen_t,
-) -> ::ssize_t{
-	e(unsafe{syscall!(
-        SYS_SENDTO, socket, buf, len, flags, addr, addrlen
-    )}) as ssize_t
+) -> ::ssize_t {
+    e(unsafe { syscall!(SYS_SENDTO, socket, buf, len, flags, addr, addrlen) }) as ssize_t
 }
 
 #[no_mangle]
@@ -106,27 +108,18 @@ pub extern "C" fn setsockopt(
     name: ::c_int,
     value: *const ::c_void,
     option_len: socklen_t,
-) -> ::c_int{
-	e(unsafe {
-        syscall!(
-            SYS_SETSOCKOPT,
-            socket,
-            level,
-            name,
-            value,
-            option_len
-        )
-    }) as ::c_int
+) -> ::c_int {
+    e(unsafe { syscall!(SYS_SETSOCKOPT, socket, level, name, value, option_len) }) as ::c_int
 }
 
 #[no_mangle]
-pub extern "C" fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int{
-	e(unsafe { syscall!(SYS_SHUTDOWN, socket, how) }) as ::c_int
+pub extern "C" fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int {
+    e(unsafe { syscall!(SYS_SHUTDOWN, socket, how) }) as ::c_int
 }
 
 #[no_mangle]
-pub extern "C" fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int{
-	e(unsafe{syscall!(SYS_SOCKET, domain, ty, protocol)}) as ::c_int
+pub extern "C" fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int {
+    e(unsafe { syscall!(SYS_SOCKET, domain, ty, protocol) }) as ::c_int
 }
 
 #[no_mangle]
@@ -135,6 +128,6 @@ pub extern "C" fn socketpair(
     _type_: ::c_int,
     _protocol: ::c_int,
     _socket_vector: *mut ::c_int,
-) -> ::c_int{
-	unimplemented!()
-}
+) -> ::c_int {
+    unimplemented!()
+}

+ 3 - 7
dlibc/src/unix/platform/dragonos/pal/relibc_adapter/pal_trace.rs

@@ -1,8 +1,4 @@
-
-
-
-
 #[no_mangle]
-pub extern "C" fn ptrace(_request: ::c_int) -> ::c_long{
-	unimplemented!()
-}
+pub extern "C" fn ptrace(_request: ::c_int) -> ::c_long {
+    unimplemented!()
+}

+ 18 - 16
dlibc/src/unix/platform/mod.rs

@@ -200,23 +200,23 @@ s! {
         pub msg_hdr: ::msghdr,
         pub msg_len: ::c_uint,
     }
-    
+
 }
 
-#[derive(Copy,Clone,Default)]
+#[derive(Copy, Clone, Default)]
 pub struct timeval {
     pub tv_sec: time_t,
     pub tv_usec: suseconds_t,
 }
 
 // <sys/time.h>
-#[derive(Copy,Clone,Default)]
+#[derive(Copy, Clone, Default)]
 pub struct itimerval {
     pub it_interval: ::timeval,
     pub it_value: ::timeval,
 }
 
-cfg_if!{
+cfg_if! {
     if #[cfg(target_os = "dragonos")]{
         #[derive(Copy,Clone)]
         pub union epoll_data {
@@ -247,9 +247,12 @@ cfg_if!{
             target_arch = "x86",
             not(target_env = "musl"),
             not(target_os = "android"),
-            not(target_os = "dragonos")),
-        target_arch = "x86_64"),
-    repr(packed))]
+            not(target_os = "dragonos")
+        ),
+        target_arch = "x86_64"
+    ),
+    repr(packed)
+)]
 pub struct epoll_event {
     pub events: u32,
     pub u64: u64,
@@ -1102,7 +1105,7 @@ pub const PATH_MAX: ::c_int = 4096;
 pub const UIO_MAXIOV: ::c_int = 1024;
 
 pub const FD_SETSIZE: usize = 1024;
-cfg_if!{
+cfg_if! {
     if #[cfg(not(target_os = "dragonos"))]{
         pub const EPOLLIN: ::c_int = 0x1;
         pub const EPOLLPRI: ::c_int = 0x2;
@@ -1945,11 +1948,11 @@ pub mod dragonos;
 #[cfg(target_os = "dragonos")]
 pub use self::dragonos::*;
 
-use unix::io::{self, Read, Write};
 use alloc::{boxed::Box, vec::Vec};
 use core::{fmt, ptr};
+use unix::io::{self, Read, Write};
 
-pub use self::allocator::{alloc,free,realloc,alloc_align};
+pub use self::allocator::{alloc, alloc_align, free, realloc};
 
 //#[cfg(all(not(feature = "ralloc"), target_os = "dragonos"))]
 #[path = "dragonos/allocator/dragonos_malloc.rs"]
@@ -2017,12 +2020,12 @@ impl<'a, W: WriteByte> WriteByte for &'a mut W {
     }
 }
 
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct FileWriter(pub ::c_int);
 
 impl FileWriter {
     pub fn write(&mut self, buf: &[u8]) -> isize {
-        self::write(self.0, buf.as_ptr() as *const ::c_void,buf.len())
+        self::write(self.0, buf.as_ptr() as *const ::c_void, buf.len())
     }
 }
 
@@ -2040,18 +2043,18 @@ impl WriteByte for FileWriter {
     }
 }
 
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
 pub struct FileReader(pub ::c_int);
 
 impl FileReader {
     pub fn read(&mut self, buf: &mut [u8]) -> isize {
-        self::read(self.0, buf.as_mut_ptr() as *mut ::c_void,buf.len())
+        self::read(self.0, buf.as_mut_ptr() as *mut ::c_void, buf.len())
     }
 }
 
 impl Read for FileReader {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
-        let i = self::read(self.0, buf.as_mut_ptr() as *mut ::c_void,buf.len());
+        let i = self::read(self.0, buf.as_mut_ptr() as *mut ::c_void, buf.len());
         if i >= 0 {
             Ok(i as usize)
         } else {
@@ -2236,4 +2239,3 @@ pub fn init(auxvs: Box<[[usize; 2]]>) {
 }
 #[cfg(not(target_os = "redox"))]
 pub fn init(_auxvs: Box<[[usize; 2]]>) {}
-

+ 8 - 4
dlibc/src/unix/platform/rlb.rs

@@ -1,6 +1,6 @@
-use alloc::vec::Vec;
-use crate::unix::platform;
 use crate::unix::header::unistd::SEEK_SET;
+use crate::unix::platform;
+use alloc::vec::Vec;
 /// Implements an `Iterator` which returns on either newline or EOF.
 #[derive(Clone)]
 pub struct RawLineBuffer {
@@ -56,7 +56,11 @@ impl RawLineBuffer {
                 self.buf.set_len(capacity);
             }
 
-            let read = platform::pal::read(self.fd, (&mut self.buf[len..]).as_ptr() as *mut ::c_void,(&mut self.buf[len..]).len());
+            let read = platform::pal::read(
+                self.fd,
+                (&mut self.buf[len..]).as_ptr() as *mut ::c_void,
+                (&mut self.buf[len..]).len(),
+            );
 
             let read_usize = read.max(0) as usize;
 
@@ -90,7 +94,7 @@ impl RawLineBuffer {
 
     /// Seek to a byte position in the file
     pub fn seek(&mut self, pos: usize) -> ::off_t {
-        let ret = unsafe{::lseek(self.fd, pos as ::off_t, SEEK_SET)};
+        let ret = unsafe { ::lseek(self.fd, pos as ::off_t, SEEK_SET) };
         if ret != !0 {
             self.read = pos;
         }

+ 1 - 1
dlibc/src/unix/sync/semaphore.rs

@@ -44,7 +44,7 @@ impl Semaphore {
             }
             if let Some(timeout) = timeout_opt {
                 let mut time = ::timespec::default();
-                unsafe{clock_gettime(::CLOCK_MONOTONIC, &mut time)};
+                unsafe { clock_gettime(::CLOCK_MONOTONIC, &mut time) };
                 if (time.tv_sec > timeout.tv_sec)
                     || (time.tv_sec == timeout.tv_sec && time.tv_nsec >= timeout.tv_nsec)
                 {

+ 0 - 1
src/lib.rs

@@ -12,7 +12,6 @@
 #![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)]

+ 1 - 2
src/std/error.rs

@@ -3,8 +3,7 @@
 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, Error};
 
 mod private {
     // This is a hack to prevent `type_id` from being overridden by `Error`

+ 1 - 0
target.json

@@ -8,6 +8,7 @@
     "target-family": [
         "unix"
     ],
+    "env": "musl",
     "target-c-int-width": "32",
     "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
     "disable-redzone": true,