diff options
| author | David CARLIER <devnexen@gmail.com> | 2023-04-21 23:23:14 +0100 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-04-22 14:10:30 +0300 |
| commit | 29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38 (patch) | |
| tree | a7a147a241f9ade0338b67f49499cbf17e585da0 /lib/std/process.zig | |
| parent | bd801dc489ee4642050b1b6f11afb976c47425b8 (diff) | |
| download | zig-29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38.tar.gz zig-29bc6fc24288fe02b2a607f38dbdbb6f5d53ea38.zip | |
process: totalSystemMemory freebsd portage
Diffstat (limited to 'lib/std/process.zig')
| -rw-r--r-- | lib/std/process.zig | 9 |
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( |
