| ... | @@ -1753,7 +1753,8 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { | ... | @@ -1753,7 +1753,8 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { |
| 1753 | if (std.os.linux.E.init(result) != .SUCCESS) { | 1753 | if (std.os.linux.E.init(result) != .SUCCESS) { |
| 1754 | return error.UnknownTotalSystemMemory; | 1754 | return error.UnknownTotalSystemMemory; |
| 1755 | } | 1755 | } |
| 1756 | return info.totalram * info.mem_unit; | 1756 | // Promote to u64 to avoid overflow on systems where info.totalram is a 32-bit usize |
| | 1757 | return @as(u64, info.totalram) * info.mem_unit; |
| 1757 | }, | 1758 | }, |
| 1758 | .freebsd => { | 1759 | .freebsd => { |
| 1759 | var physmem: c_ulong = undefined; | 1760 | var physmem: c_ulong = undefined; |