diff options
| author | gnzlbg <gonzalobg88@gmail.com> | 2019-05-31 13:50:30 +0200 |
|---|---|---|
| committer | gnzlbg <gonzalobg88@gmail.com> | 2019-08-01 17:01:33 +0200 |
| commit | 9ea83f9732d7a15467bed88d4a996487713c70d4 (patch) | |
| tree | fdaab0409c46af0fce7d76aa81b6fe62281f03ed /src | |
| parent | a17951c4f80eb5208030f91fdb4ae93919fa6b12 (diff) | |
| download | rust-9ea83f9732d7a15467bed88d4a996487713c70d4.tar.gz rust-9ea83f9732d7a15467bed88d4a996487713c70d4.zip | |
Update libc and use the Mach kernel APIs via the mach crate instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/Cargo.toml | 3 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/time.rs | 9 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5334c4dfc68..c953a53e0f9 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -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'] } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8fd76eabe39..460d92d0519 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -338,6 +338,10 @@ extern crate alloc as alloc_crate; #[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)] diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index e21c32cd91b..b7d2c4562f7 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -139,7 +139,7 @@ mod inner { 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 @@ mod inner { 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 @@ mod inner { // ... 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 |
