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

@@ -36,3 +36,14 @@ fn sys_mono_now_darwin() u64 {
}
return (tm - start_time) * time_base.numer / time_base.denom
}
// NB: vpc_now_darwin is used by `v -profile` .
// It should NOT call *any other v function*, just C functions and casts.
[inline]
fn vpc_now_darwin() u64 {
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
}