1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: add specialized vpc_now_darwin to fix -os cross

This commit is contained in:
Delyan Angelov
2020-05-05 17:19:25 +03:00
parent dd2a1455dc
commit ddb5a8e6e4
3 changed files with 18 additions and 14 deletions

View File

@ -43,15 +43,7 @@ fn sys_mono_now() u64 {
// It should NOT call *any other v function*, just C functions and casts.
[inline]
fn vpc_now() u64 {
$if macos {
tm := C.mach_absolute_time()
if time_base.denom == 0 {
C.mach_timebase_info(&time_base)
}
return (tm - start_time) * time_base.numer / time_base.denom
} $else {
ts := C.timespec{}
C.clock_gettime(C.CLOCK_MONOTONIC, &ts)
return u64(ts.tv_sec) * 1_000_000_000 + u64(ts.tv_nsec)
}
ts := C.timespec{}
C.clock_gettime(C.CLOCK_MONOTONIC, &ts)
return u64(ts.tv_sec) * 1_000_000_000 + u64(ts.tv_nsec)
}