commit 29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38 (tree)
parent bd801dc489ee4642050b1b6f11afb976c47425b8
Author: David CARLIER <devnexen@gmail.com>
Date: Fri, 21 Apr 2023 23:23:14 +0100
process: totalSystemMemory freebsd portage
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git 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(