Skip to content

Commit 74dc2b6

Browse files
committed
Remove mach dependency
1 parent 0b9d0b0 commit 74dc2b6

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

src/libstd/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ 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-
5956
[target.x86_64-fortanix-unknown-sgx.dependencies]
6057
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
6158

src/libstd/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ 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-
345341
// We always need an unwinder currently for backtraces
346342
#[doc(masked)]
347343
#[allow(unused_extern_crates)]

src/libstd/sys/unix/time.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,21 @@ mod inner {
137137
t: Timespec::zero(),
138138
};
139139

140+
#[repr(C)]
141+
#[derive(Copy, Clone)]
142+
struct mach_timebase_info {
143+
numer: u32,
144+
denom: u32,
145+
}
146+
type mach_timebase_info_t = *mut mach_timebase_info;
147+
type kern_return_t = libc::c_int;
148+
140149
impl Instant {
141150
pub fn now() -> Instant {
142-
Instant { t: unsafe { mach::mach_time::mach_absolute_time() } }
151+
extern "C" {
152+
fn mach_absolute_time() -> u64;
153+
}
154+
Instant { t: unsafe { mach_absolute_time() } }
143155
}
144156

145157
pub const fn zero() -> Instant {
@@ -230,9 +242,8 @@ mod inner {
230242
Some(mul_div_u64(nanos, info.denom as u64, info.numer as u64))
231243
}
232244

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 {
245+
fn info() -> mach_timebase_info {
246+
static mut INFO: mach_timebase_info = mach_timebase_info {
236247
numer: 0,
237248
denom: 0,
238249
};
@@ -246,7 +257,12 @@ mod inner {
246257

247258
// ... otherwise learn for ourselves ...
248259
let mut info = mem::zeroed();
249-
mach::mach_time::mach_timebase_info(&mut info);
260+
extern "C" {
261+
fn mach_timebase_info(info: mach_timebase_info_t)
262+
-> kern_return_t;
263+
}
264+
265+
mach_timebase_info(&mut info);
250266

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

src/tools/tidy/src/deps.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ const EXCEPTIONS: &[&str] = &[
4848
"bytesize", // Apache-2.0, cargo
4949
"im-rc", // MPL-2.0+, cargo
5050
"adler32", // BSD-3-Clause AND Zlib, cargo dep that isn't used
51-
"fortanix-sgx-abi", // MPL-2.0+, libstd but only for `sgx` target
5251
"constant_time_eq", // CC0-1.0, rustfmt
5352
"utf8parse", // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
5453
"vte", // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
5554
"sized-chunks", // MPL-2.0+, cargo via im-rc
55+
// FIXME: this dependency violates the documentation comment above:
56+
"fortanix-sgx-abi", // MPL-2.0+, libstd but only for `sgx` target
5657
];
5758

5859
/// Which crates to check against the whitelist?

0 commit comments

Comments
 (0)