mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
std/os/index.zig: use "hw.logicalcpu" instead of "hw.ncpu" in macOS; (#1317)
Tracking Issue #1252 ; hw.ncpu was deprecated in macOS. Among 4 new options available (hw.{physicalcpu, physicalcpu_max, logicalcpu, logicalcpu_max}), hw.logicalcpu was chosen because it actually reflects the number of logical cores the OS sees.
This commit is contained in:
parent
e66f538972
commit
432b7685bf
@ -2790,7 +2790,7 @@ pub fn cpuCount(fallback_allocator: *mem.Allocator) CpuCountError!usize {
|
||||
builtin.Os.macosx => {
|
||||
var count: c_int = undefined;
|
||||
var count_len: usize = @sizeOf(c_int);
|
||||
const rc = posix.sysctlbyname(c"hw.ncpu", @ptrCast(*c_void, &count), &count_len, null, 0);
|
||||
const rc = posix.sysctlbyname(c"hw.logicalcpu", @ptrCast(*c_void, &count), &count_len, null, 0);
|
||||
const err = posix.getErrno(rc);
|
||||
switch (err) {
|
||||
0 => return @intCast(usize, count),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user