zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 432b7685bfa840a459b492a37894f7ffed870c7e (tree)
parent e66f538972d1278ed95513aa1d97c196818a73c6
Author: kristopher tate <kris.tate+github@gmail.com>
Date:   Fri,  3 Aug 2018 01:59:59 +0900

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.
Diffstat:
Mstd/os/index.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 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),