mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Add core/hyperthread count for Windows and Linux (#5216)
Add core/hyperthread count to `core:sys/info` for Windows and Linux. TODO: Linux RISCV, Linux ARM, Darwin, and the BSDs.
This commit is contained in:
@@ -40,9 +40,13 @@ CPU_Feature :: enum u64 {
|
||||
}
|
||||
|
||||
CPU_Features :: distinct bit_set[CPU_Feature; u64]
|
||||
|
||||
cpu_features: Maybe(CPU_Features)
|
||||
cpu_name: Maybe(string)
|
||||
CPU :: struct {
|
||||
name: Maybe(string),
|
||||
features: Maybe(CPU_Features),
|
||||
physical_cores: int,
|
||||
logical_cores: int,
|
||||
}
|
||||
cpu: CPU
|
||||
|
||||
@(private)
|
||||
cpu_name_buf: [128]byte
|
||||
@@ -53,7 +57,7 @@ init_cpu_name :: proc "contextless" () {
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
if unix.sysctlbyname("machdep.cpu.brand_string", &cpu_name_buf) {
|
||||
cpu_name = string(cstring(rawptr(&cpu_name_buf)))
|
||||
cpu.name = string(cstring(rawptr(&cpu_name_buf)))
|
||||
generic = false
|
||||
}
|
||||
}
|
||||
@@ -61,10 +65,10 @@ init_cpu_name :: proc "contextless" () {
|
||||
if generic {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
copy(cpu_name_buf[:], "ARM64")
|
||||
cpu_name = string(cpu_name_buf[:len("ARM64")])
|
||||
cpu.name = string(cpu_name_buf[:len("ARM64")])
|
||||
} else {
|
||||
copy(cpu_name_buf[:], "ARM")
|
||||
cpu_name = string(cpu_name_buf[:len("ARM")])
|
||||
cpu.name = string(cpu_name_buf[:len("ARM")])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user