diff options
| author | bors <bors@rust-lang.org> | 2019-08-02 07:45:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-02 07:45:05 +0000 |
| commit | fc3ef9698fa80aa2f4da6208b8295bc8fa48eec5 (patch) | |
| tree | ce7b01e1ef6144375c3ecfc95f738f1bcdfbac76 /src/libstd | |
| parent | 435236b8877cdb98c82eaebfb7887782277265c5 (diff) | |
| parent | 52caca0c45f5a2f19dc2b1af2e1fa86e2e0ad4be (diff) | |
| download | rust-fc3ef9698fa80aa2f4da6208b8295bc8fa48eec5.tar.gz rust-fc3ef9698fa80aa2f4da6208b8295bc8fa48eec5.zip | |
Auto merge of #61393 - gnzlbg:update_libc, r=gnzlbg
Update Cargo.lock
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/unix/time.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index e21c32cd91b..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 { libc::mach_absolute_time() } } + extern "C" { + fn mach_absolute_time() -> u64; + } + Instant { t: unsafe { mach_absolute_time() } } } pub const fn zero() -> Instant { @@ -230,8 +242,8 @@ 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_timebase_info { + static mut INFO: mach_timebase_info = mach_timebase_info { numer: 0, denom: 0, }; @@ -245,7 +257,12 @@ mod inner { // ... otherwise learn for ourselves ... let mut info = mem::zeroed(); - libc::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 |
