aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2023-04-21 23:23:14 +0100
committerVeikka Tuominen <git@vexu.eu>2023-04-22 14:10:30 +0300
commit29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38 (patch)
treea7a147a241f9ade0338b67f49499cbf17e585da0 /lib/std/process.zig
parentbd801dc489ee4642050b1b6f11afb976c47425b8 (diff)
downloadzig-29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38.tar.gz
zig-29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38.zip
process: totalSystemMemory freebsd portage
Diffstat (limited to 'lib/std/process.zig')
-rw-r--r--lib/std/process.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig
index c2d5b8a000..578efa62c4 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -1162,6 +1162,15 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize {
.linux => {
return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory;
},
+ .freebsd => {
+ var physmem: c_ulong = undefined;
+ var len: usize = @sizeOf(c_ulong);
+ os.sysctlbynameZ("hw.physmem", &physmem, &len, null, 0) catch |err| switch (err) {
+ error.NameTooLong, error.UnknownName => unreachable,
+ else => |e| return e,
+ };
+ return @intCast(usize, physmem);
+ },
.windows => {
var sbi: std.os.windows.SYSTEM_BASIC_INFORMATION = undefined;
const rc = std.os.windows.ntdll.NtQuerySystemInformation(