]> git.lizzy.rs Git - rust.git/commitdiff
Update libc and use the Mach kernel APIs via the mach crate instead.
authorgnzlbg <gonzalobg88@gmail.com>
Fri, 31 May 2019 11:50:30 +0000 (13:50 +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

index 5334c4dfc68cc731f62f4170f1763ef0ac9b241b..c953a53e0f9dbd245ee5883333cc3ea86e978414 100644 (file)
@@ -53,6 +53,9 @@ 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 8fd76eabe394371a0b569c496cf4031a6b876086..460d92d05196689c57c3d460e461411e0d10e375 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 e21c32cd91b1e6bd8bc734ef4d4f9c705ec3381d..b7d2c4562f765d9109723c0420b1c19c26d01243 100644 (file)
@@ -139,7 +139,7 @@ pub struct SystemTime {
 
     impl Instant {
         pub fn now() -> Instant {
-            Instant { t: unsafe { libc::mach_absolute_time() } }
+            Instant { t: unsafe { mach::mach_time::mach_absolute_time() } }
         }
 
         pub const fn zero() -> Instant {
@@ -230,8 +230,9 @@ fn checked_dur2intervals(dur: &Duration) -> Option<u64> {
         Some(mul_div_u64(nanos, info.denom as u64, info.numer as u64))
     }
 
-    fn info() -> libc::mach_timebase_info {
-        static mut INFO: libc::mach_timebase_info = libc::mach_timebase_info {
+    fn info() -> mach::mach_time::mach_timebase_info {
+        static mut INFO: mach::mach_time::mach_timebase_info
+            = mach::mach_time::mach_timebase_info {
             numer: 0,
             denom: 0,
         };
@@ -245,7 +246,7 @@ fn info() -> libc::mach_timebase_info {
 
             // ... otherwise learn for ourselves ...
             let mut info = mem::zeroed();
-            libc::mach_timebase_info(&mut info);
+            mach::mach_time::mach_timebase_info(&mut info);
 
             // ... and attempt to be the one thread that stores it globally for
             // all other threads