aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-04-25 20:03:53 +0200
committerGitHub <noreply@github.com>2023-04-25 20:03:53 +0200
commit015ea6fd6c0c0deacb42de237f737d208737e3ac (patch)
tree33f5e2d3acacc24e63f259ce5485fee28243ed44 /lib/std/process.zig
parenta260fa8bf22b952e96b08c3f206756e1784ce870 (diff)
parent8d88dcdc61c61e3410138f4402482131f5074a80 (diff)
downloadzig-015ea6fd6c0c0deacb42de237f737d208737e3ac.tar.gz
zig-015ea6fd6c0c0deacb42de237f737d208737e3ac.zip
Merge branch 'master' into autodoc-pkg-mod
Diffstat (limited to 'lib/std/process.zig')
-rw-r--r--lib/std/process.zig14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig
index 578efa62c4..56e3708f3b 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -818,7 +818,8 @@ pub const ArgIterator = struct {
}
};
-/// Use argsWithAllocator() for cross-platform code
+/// Holds the command-line arguments, with the program name as the first entry.
+/// Use argsWithAllocator() for cross-platform code.
pub fn args() ArgIterator {
return ArgIterator.init();
}
@@ -1162,12 +1163,17 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize {
.linux => {
return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory;
},
- .freebsd => {
+ .freebsd, .netbsd, .openbsd, .dragonfly, .macos => {
var physmem: c_ulong = undefined;
var len: usize = @sizeOf(c_ulong);
- os.sysctlbynameZ("hw.physmem", &physmem, &len, null, 0) catch |err| switch (err) {
+ const name = switch (builtin.os.tag) {
+ .macos => "hw.memsize",
+ .netbsd => "hw.physmem64",
+ else => "hw.physmem",
+ };
+ os.sysctlbynameZ(name, &physmem, &len, null, 0) catch |err| switch (err) {
error.NameTooLong, error.UnknownName => unreachable,
- else => |e| return e,
+ else => return error.UnknownTotalSystemMemory,
};
return @intCast(usize, physmem);
},