Skip to content

Commit 9ea83f9

Browse files
committed
Update libc and use the Mach kernel APIs via the mach crate instead.
1 parent a17951c commit 9ea83f9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/libstd/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ rustc_tsan = { path = "../librustc_tsan" }
5353
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
5454
dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
5555

56+
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
57+
mach = { version = "0.3.2", default-features = false, features = ['rustc-dep-of-std'] }
58+
5659
[target.x86_64-fortanix-unknown-sgx.dependencies]
5760
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
5861

src/libstd/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ extern crate alloc as alloc_crate;
338338
#[allow(unused_extern_crates)]
339339
extern crate libc;
340340

341+
#[cfg(any(target_os = "macos", target_os = "ios"))]
342+
#[allow(unused_extern_crates)]
343+
extern crate mach;
344+
341345
// We always need an unwinder currently for backtraces
342346
#[doc(masked)]
343347
#[allow(unused_extern_crates)]

src/libstd/sys/unix/time.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod inner {
139139

140140
impl Instant {
141141
pub fn now() -> Instant {
142-
Instant { t: unsafe { libc::mach_absolute_time() } }
142+
Instant { t: unsafe { mach::mach_time::mach_absolute_time() } }
143143
}
144144

145145
pub const fn zero() -> Instant {
@@ -230,8 +230,9 @@ mod inner {
230230
Some(mul_div_u64(nanos, info.denom as u64, info.numer as u64))
231231
}
232232

233-
fn info() -> libc::mach_timebase_info {
234-
static mut INFO: libc::mach_timebase_info = libc::mach_timebase_info {
233+
fn info() -> mach::mach_time::mach_timebase_info {
234+
static mut INFO: mach::mach_time::mach_timebase_info
235+
= mach::mach_time::mach_timebase_info {
235236
numer: 0,
236237
denom: 0,
237238
};
@@ -245,7 +246,7 @@ mod inner {
245246

246247
// ... otherwise learn for ourselves ...
247248
let mut info = mem::zeroed();
248-
libc::mach_timebase_info(&mut info);
249+
mach::mach_time::mach_timebase_info(&mut info);
249250

250251
// ... and attempt to be the one thread that stores it globally for
251252
// all other threads

0 commit comments

Comments
 (0)