From b1ed22d84f2aae617c90c60701e9f25345cab980 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Sun, 8 Jun 2025 16:16:34 -0700 Subject: [PATCH] fix frequency grab --- core/sys/darwin/mach_darwin.odin | 4 ++-- core/time/tsc_darwin.odin | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/sys/darwin/mach_darwin.odin b/core/sys/darwin/mach_darwin.odin index 01affa6e8..2c8f38002 100644 --- a/core/sys/darwin/mach_darwin.odin +++ b/core/sys/darwin/mach_darwin.odin @@ -123,7 +123,7 @@ x86_thread_state32_t :: struct { } X86_THREAD_STATE32_COUNT :: size_of(x86_thread_state32_t) / size_of(u32) -x86_thread_state64_t :: struct { +x86_thread_state64_t :: struct #packed { rax: u64, rbx: u64, rcx: u64, @@ -148,7 +148,7 @@ x86_thread_state64_t :: struct { } X86_THREAD_STATE64_COUNT :: size_of(x86_thread_state64_t) / size_of(u32) -arm_thread_state64_t :: struct { +arm_thread_state64_t :: struct #packed { x: [29]u64, fp: u64, lr: u64, diff --git a/core/time/tsc_darwin.odin b/core/time/tsc_darwin.odin index 3726cff49..1210992a6 100644 --- a/core/time/tsc_darwin.odin +++ b/core/time/tsc_darwin.odin @@ -4,7 +4,13 @@ package time import "core:sys/unix" _get_tsc_frequency :: proc "contextless" () -> (freq: u64, ok: bool) { - unix.sysctlbyname("machdep.tsc.frequency", &freq) or_return + if ODIN_ARCH == .amd64 { + unix.sysctlbyname("machdep.tsc.frequency", &freq) or_return + } else if ODIN_ARCH == .arm64 { + unix.sysctlbyname("hw.tbfrequency", &freq) or_return + } else { + return + } ok = true return }