mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
add get core count
This commit is contained in:
+23
-1
@@ -126,6 +126,28 @@ get_page_size :: proc() -> int {
|
||||
return page_size
|
||||
}
|
||||
|
||||
get_processor_thread_count :: proc() -> int {
|
||||
length : c.int = 0
|
||||
result := windows.GetLogicalProcessorInformation(nil, &length)
|
||||
|
||||
thread_count := 0
|
||||
if !result && win32.GetLastError() == 122 && length > 0 {
|
||||
processors := make([]windows.SYSTEM_LOGICAL_PROCESSOR_INFORMATION, length, context.temp_allocator)
|
||||
|
||||
result = windows.GetLogicalProcessorInformation(&processors[0], &length)
|
||||
if result {
|
||||
core_count := 0
|
||||
for processor in processors {
|
||||
if processor.Relationship == windows.RelationProcessorCore {
|
||||
thread := intrinsics.count_ones(processor.ProcessorMask)
|
||||
thread_count += thread
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return thread_count
|
||||
}
|
||||
|
||||
|
||||
exit :: proc "contextless" (code: int) -> ! {
|
||||
@@ -214,4 +236,4 @@ is_windows_10 :: proc() -> bool {
|
||||
is_windows_11 :: proc() -> bool {
|
||||
osvi := get_windows_version_w()
|
||||
return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber >= WINDOWS_11_BUILD_CUTOFF)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user