浏览代码

fix frequency grab

Colin Davidson 3 月之前
父节点
当前提交
b1ed22d84f
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 2 2
      core/sys/darwin/mach_darwin.odin
  2. 7 1
      core/time/tsc_darwin.odin

+ 2 - 2
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,

+ 7 - 1
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
 }