]> git.lizzy.rs Git - rust.git/commitdiff
Remove mach dependency
authorgnzlbg <gonzalobg88@gmail.com>
Fri, 21 Jun 2019 15:35:48 +0000 (17:35 +0200)
committergnzlbg <gonzalobg88@gmail.com>
Thu, 1 Aug 2019 15:01:33 +0000 (17:01 +0200)
src/libstd/Cargo.toml
src/libstd/lib.rs
src/libstd/sys/unix/time.rs
src/tools/tidy/src/deps.rs

index c953a53e0f9dbd245ee5883333cc3ea86e978414..5334c4dfc68cc731f62f4170f1763ef0ac9b241b 100644 (file)
@@ -53,9 +53,6 @@ rustc_tsan = { path = "../librustc_tsan" }
 [target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
 dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
 
-[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
-mach = { version = "0.3.2", default-features = false, features = ['rustc-dep-of-std'] }
-
 [target.x86_64-fortanix-unknown-sgx.dependencies]
 fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
 
index 460d92d05196689c57c3d460e461411e0d10e375..8fd76eabe394371a0b569c496cf4031a6b876086 100644 (file)
 #[allow(unused_extern_crates)]
 extern crate libc;
 
-#[cfg(any(target_os = "macos", target_os = "ios"))]
-#[allow(unused_extern_crates)]
-extern crate mach;
-
 // We always need an unwinder currently for backtraces
 #[doc(masked)]
 #[allow(unused_extern_crates)]
index b7d2c4562f765d9109723c0420b1c19c26d01243..02f377d55c919de5ce58eaf0a42c69a6bccb40a5 100644 (file)
@@ -137,9 +137,21 @@ pub struct SystemTime {
         t: Timespec::zero(),
     };
 
+    #[repr(C)]
+    #[derive(Copy, Clone)]
+    struct mach_timebase_info {
+        numer: u32,
+        denom: u32,
+    }
+    type mach_timebase_info_t = *mut mach_timebase_info;
+    type kern_return_t = libc::c_int;
+
     impl Instant {
         pub fn now() -> Instant {
-            Instant { t: unsafe { mach::mach_time::mach_absolute_time() } }
+            extern "C" {
+                fn mach_absolute_time() -> u64;
+            }
+            Instant { t: unsafe { mach_absolute_time() } }
         }
 
         pub const fn zero() -> Instant {
@@ -230,9 +242,8 @@ fn checked_dur2intervals(dur: &Duration) -> Option<u64> {
         Some(mul_div_u64(nanos, info.denom as u64, info.numer as u64))
     }
 
-    fn info() -> mach::mach_time::mach_timebase_info {
-        static mut INFO: mach::mach_time::mach_timebase_info
-            = mach::mach_time::mach_timebase_info {
+    fn info() -> mach_timebase_info {
+        static mut INFO: mach_timebase_info = mach_timebase_info {
             numer: 0,
             denom: 0,
         };
@@ -246,7 +257,12 @@ fn info() -> mach::mach_time::mach_timebase_info {
 
             // ... otherwise learn for ourselves ...
             let mut info = mem::zeroed();
-            mach::mach_time::mach_timebase_info(&mut info);
+            extern "C" {
+                fn mach_timebase_info(info: mach_timebase_info_t)
+                                      -> kern_return_t;
+            }
+
+            mach_timebase_info(&mut info);
 
             // ... and attempt to be the one thread that stores it globally for
             // all other threads
index ca6cea9706680236d4fa88381b90ad7b10a6155d..ae255b9d03ca97295b6f8ced94079fd78a8205ed 100644 (file)
     "bytesize",           // Apache-2.0, cargo
     "im-rc",              // MPL-2.0+, cargo
     "adler32",            // BSD-3-Clause AND Zlib, cargo dep that isn't used
-    "fortanix-sgx-abi",   // MPL-2.0+, libstd but only for `sgx` target
     "constant_time_eq",   // CC0-1.0, rustfmt
     "utf8parse",          // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
     "vte",                // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
     "sized-chunks",       // MPL-2.0+, cargo via im-rc
+    // FIXME: this dependency violates the documentation comment above:
+    "fortanix-sgx-abi",   // MPL-2.0+, libstd but only for `sgx` target
 ];
 
 /// Which crates to check against the whitelist?