Commit 29bc6fc242

David CARLIER <devnexen@gmail.com>
2023-04-22 00:23:14
process: totalSystemMemory freebsd portage
1 parent bd801dc
Changed files (1)
lib
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(