use the correct frequency for the arm tsc timer

This commit is contained in:
Colin Davidson
2025-07-28 15:10:42 -07:00
parent b88f9194d0
commit 1848e0df05
5 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -1,13 +1,14 @@
#+private
package time
import "base:intrinsics"
import "core:sys/unix"
_get_tsc_frequency :: proc "contextless" () -> (freq: u64, ok: bool) {
if ODIN_ARCH == .amd64 {
unix.sysctlbyname("machdep.tsc.frequency", &freq) or_return
} else if ODIN_ARCH == .arm64 {
unix.sysctlbyname("hw.tbfrequency", &freq) or_return
freq = u64(intrinsics.arm64_read_cycle_counter_frequency())
} else {
return
}