Skip to content

Commit

Permalink
Update libc and use the Mach kernel APIs via the mach crate instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Aug 1, 2019
1 parent a17951c commit 9ea83f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/libstd/Cargo.toml
Expand Up @@ -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'] }

Expand Down
4 changes: 4 additions & 0 deletions src/libstd/lib.rs
Expand Up @@ -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)]
Expand Down
9 changes: 5 additions & 4 deletions src/libstd/sys/unix/time.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
};
Expand All @@ -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
Expand Down

0 comments on commit 9ea83f9

Please sign in to comment.