aboutsummaryrefslogtreecommitdiff
path: root/core/time/tsc_darwin.odin
blob: 6688ae7d815291591b068fa9304b86a6e6246608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//+private
//+build darwin
package time

import "core:c"

foreign import libc "system:System.framework"
foreign libc {
	@(link_name="sysctlbyname") _sysctlbyname    :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int ---
}

_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
}