diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-09 18:16:16 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-09 18:16:16 +0100 |
| commit | ec05bb57dcde41428b27003dec674dcce87446af (patch) | |
| tree | b52ea3c2d5627f23cb4669e4db86fa48d75de9d0 /core | |
| parent | 7a7127aa13e86c29f2783e79732332edad8c514e (diff) | |
Implement `get_processor_core_count` without libc for Linux.
Diffstat (limited to 'core')
| -rw-r--r-- | core/os/process_linux.odin | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/os/process_linux.odin b/core/os/process_linux.odin index cfdb6774a..7f5608a51 100644 --- a/core/os/process_linux.odin +++ b/core/os/process_linux.odin @@ -57,8 +57,15 @@ _get_current_thread_id :: proc "contextless" () -> int { } @(private="package") -_get_processor_core_count :: proc() -> int { - return int(_unix_get_nprocs()) +_get_processor_core_count :: proc() -> (core_count: int) { + cpu_set: [128]u64 + + if err := linux.sched_getaffinity(0, size_of(cpu_set), &cpu_set); err != linux.Errno(-1) { + for set in cpu_set { + core_count += int(intrinsics.count_ones(set)) + } + } + return } @(private="package") |