Implement os.cpus for Darwin (OS X) (#2115)

* adding experimental Mac implementation os os.cpus

* Simplify cpus interfaces

* remove support for osx 10

* Refactor os.cpus implementation

This commit substantially refactors how the Linux and Darwin implementations of
 `os.cpus`.  The goal is to avoid unnecessary copying and allow broader latitude
 in responding to errors per implementation.

* improved comments

* ensure no buffer overrun

* use PROCESSOR_CPU_LOAD_INFO_COUNT; not sure if this is correct

* oh teh noes

* use sliceTo instead of span

* cpu_ticks are uints
This commit is contained in:
Justin Whear
2023-02-24 12:24:04 -08:00
committed by GitHub
parent 1c531472c9
commit f0e5d54579
3 changed files with 172 additions and 73 deletions

View File

@@ -170,11 +170,7 @@ pub fn build(b: *Build) !void {
if (std.mem.eql(u8, os_tagname, "macos")) {
os_tagname = "darwin";
if (arch.isAARCH64()) {
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
} else if (arch.isX86()) {
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 10, .minor = 14, .patch = 0 } };
}
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
} else if (target.isLinux()) {
target.setGnuLibCVersion(2, 27, 0);
}