Skip to content

Commit 448c8bf

Browse files
committed
Fix libtime
1 parent ad83352 commit 448c8bf

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/libtime/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod rustrt {
4747
}
4848
}
4949

50-
#[cfg(unix, not(target_os = "macos"), not(target_os = "ios"))]
50+
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios")))]
5151
mod imp {
5252
use libc::{c_int, timespec};
5353

@@ -61,8 +61,7 @@ mod imp {
6161
}
6262

6363
}
64-
#[cfg(target_os = "macos")]
65-
#[cfg(target_os = "ios")]
64+
#[cfg(any(target_os = "macos", target_os = "ios"))]
6665
mod imp {
6766
use libc::{timeval, timezone, c_int, mach_timebase_info};
6867

@@ -150,16 +149,15 @@ pub fn get_time() -> Timespec {
150149
((ns_since_1970 % 1000000) * 1000) as i32)
151150
}
152151

153-
#[cfg(target_os = "macos")]
154-
#[cfg(target_os = "ios")]
152+
#[cfg(any(target_os = "macos", target_os = "ios"))]
155153
unsafe fn os_get_time() -> (i64, i32) {
156154
use std::ptr;
157155
let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 };
158156
imp::gettimeofday(&mut tv, ptr::null_mut());
159157
(tv.tv_sec as i64, tv.tv_usec * 1000)
160158
}
161159

162-
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(windows))]
160+
#[cfg(not(any(target_os = "macos", target_os = "ios", windows)))]
163161
unsafe fn os_get_time() -> (i64, i32) {
164162
let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 };
165163
imp::clock_gettime(libc::CLOCK_REALTIME, &mut tv);
@@ -190,8 +188,7 @@ pub fn precise_time_ns() -> u64 {
190188
return (ticks as u64 * 1000000000) / (ticks_per_s as u64);
191189
}
192190

193-
#[cfg(target_os = "macos")]
194-
#[cfg(target_os = "ios")]
191+
#[cfg(any(target_os = "macos", target_os = "ios"))]
195192
fn os_precise_time_ns() -> u64 {
196193
static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0,
197194
denom: 0 };
@@ -205,7 +202,7 @@ pub fn precise_time_ns() -> u64 {
205202
}
206203
}
207204

208-
#[cfg(not(windows), not(target_os = "macos"), not(target_os = "ios"))]
205+
#[cfg(not(any(windows, target_os = "macos", target_os = "ios")))]
209206
fn os_precise_time_ns() -> u64 {
210207
let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 };
211208
unsafe {

0 commit comments

Comments
 (0)