authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2026-01-25 13:03:22-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2026-01-25 13:03:22-05:00
logf186809caf3a14cbfbe6778f946c8597ebe7d561
tree5770b34a1eb58734a9738a7c250fdf80cead9df1
parent8709f53d440ed8479f711d871a2d6c2c35dc1014
signaturelock-open Commit is signed but in an unrecognized format.

std: impl process.totalSystemMemory for netbsd


1 files changed, 6 insertions(+), 3 deletions(-)

lib/std/process.zig+6-3
......@@ -558,14 +558,17 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 {
558558 // Promote to u64 to avoid overflow on systems where info.totalram is a 32-bit usize
559559 return @as(u64, info.totalram) * info.mem_unit;
560560 },
561 .freebsd => {
561 .dragonfly, .freebsd, .netbsd => {
562 const name = if (native_os == .netbsd) "hw.physmem64" else "hw.physmem";
562563 var physmem: c_ulong = undefined;
563564 var len: usize = @sizeOf(c_ulong);
564 posix.sysctlbynameZ("hw.physmem", &physmem, &len, null, 0) catch |err| switch (err) {
565 posix.sysctlbynameZ(name, &physmem, &len, null, 0) catch |err| switch (err) {
566 error.PermissionDenied => unreachable, // only when setting values,
567 error.SystemResources => unreachable, // memory already on the stack
565568 error.UnknownName => unreachable,
566569 else => return error.UnknownTotalSystemMemory,
567570 };
568 return @as(u64, @intCast(physmem));
571 return @intCast(physmem);
569572 },
570573 // whole Darwin family
571574 .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {