diff options
| author | gnzlbg <gonzalobg88@gmail.com> | 2019-06-21 17:35:48 +0200 |
|---|---|---|
| committer | gnzlbg <gonzalobg88@gmail.com> | 2019-08-01 17:01:33 +0200 |
| commit | 74dc2b6f6fc80dcb0d394949b9d7010009fc4bed (patch) | |
| tree | c0cb56f35f8b3f3abe791a61136de948edca9e7e /src/libstd | |
| parent | 0b9d0b0ccb994274e8da7f010a09c681da38f745 (diff) | |
| download | rust-74dc2b6f6fc80dcb0d394949b9d7010009fc4bed.tar.gz rust-74dc2b6f6fc80dcb0d394949b9d7010009fc4bed.zip | |
Remove mach dependency
Diffstat (limited to 'src/libstd')
| -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 | 26 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index c953a53e0f9..5334c4dfc68 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -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'] } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 460d92d0519..8fd76eabe39 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -338,10 +338,6 @@ 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 b7d2c4562f7..02f377d55c9 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -137,9 +137,21 @@ mod inner { 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 @@ mod inner { 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 @@ mod inner { // ... 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 |
