From 432b7685bfa840a459b492a37894f7ffed870c7e Mon Sep 17 00:00:00 2001 From: kristopher tate Date: Fri, 3 Aug 2018 01:59:59 +0900 Subject: [PATCH] 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. --- std/os/index.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/os/index.zig b/std/os/index.zig index 77fd2a78ad..0a6f598a2e 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -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),