update linux-arm to use the asm intrin for freq

This commit is contained in:
Colin Davidson
2025-07-28 16:32:10 -07:00
parent 76b00c046b
commit 1a9b128bfc
+5
View File
@@ -5,6 +5,10 @@ package time
import linux "core:sys/linux" import linux "core:sys/linux"
_get_tsc_frequency :: proc "contextless" () -> (u64, bool) { _get_tsc_frequency :: proc "contextless" () -> (u64, bool) {
if ODIN_ARCH == .arm64 {
freq = u64(intrinsics.arm64_read_cycle_counter_frequency())
return frequency, true
} else {
// Get the file descriptor for the perf mapping // Get the file descriptor for the perf mapping
perf_attr := linux.Perf_Event_Attr{} perf_attr := linux.Perf_Event_Attr{}
perf_attr.size = size_of(perf_attr) perf_attr.size = size_of(perf_attr)
@@ -31,3 +35,4 @@ _get_tsc_frequency :: proc "contextless" () -> (u64, bool) {
frequency := u64((u128(1_000_000_000) << u128(event_page.time_shift)) / u128(event_page.time_mult)) frequency := u64((u128(1_000_000_000) << u128(event_page.time_shift)) / u128(event_page.time_mult))
return frequency, true return frequency, true
} }
}