block all x86 tsc functions in when block

This commit is contained in:
Colin Davidson
2023-02-21 06:28:55 -08:00
parent 7322b63991
commit 1fc3a25f47
3 changed files with 50 additions and 44 deletions
+10 -8
View File
@@ -9,13 +9,15 @@ foreign libc {
@(link_name="sysctlbyname") _sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int ---
}
_x86_get_tsc_frequency :: proc "contextless" () -> (u64, bool) {
tmp_freq : u64 = 0
tmp_size : i64 = size_of(tmp_freq)
ret := _sysctlbyname("machdep.tsc.frequency", &tmp_freq, &tmp_size, nil, 0)
if ret < 0 {
return 0, false
}
when ODIN_ARCH == .amd64 {
_x86_get_tsc_frequency :: proc "contextless" () -> (u64, bool) {
tmp_freq : u64 = 0
tmp_size : i64 = size_of(tmp_freq)
ret := _sysctlbyname("machdep.tsc.frequency", &tmp_freq, &tmp_size, nil, 0)
if ret < 0 {
return 0, false
}
return tmp_freq, true
return tmp_freq, true
}
}