From 384137d4e9958044e200f42ac346130bca20b36c Mon Sep 17 00:00:00 2001 From: Andreas T Jonsson Date: Mon, 22 Apr 2024 10:15:52 +0200 Subject: [PATCH] Use PHYSMEM64 on NetBSD I realize we should use PHYSMEM64 on NetBSD. So we can not share code with FreeBSD. --- src/bug_report.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bug_report.cpp b/src/bug_report.cpp index 2262779c1..0ec383b44 100644 --- a/src/bug_report.cpp +++ b/src/bug_report.cpp @@ -250,6 +250,14 @@ gb_internal void report_ram_info() { if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1)); } + #elif defined(GB_SYSTEM_NETBSD) + uint64_t ram_amount; + size_t val_size = sizeof(ram_amount); + + int mibs[] = { CTL_HW, HW_PHYSMEM64 }; + if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { + gb_printf("%lu MiB\n", ram_amount / gb_megabytes(1)); + } #elif defined(GB_SYSTEM_OPENBSD) uint64_t ram_amount; size_t val_size = sizeof(ram_amount); @@ -258,7 +266,7 @@ gb_internal void report_ram_info() { if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1)); } - #elif defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_NETBSD) + #elif defined(GB_SYSTEM_FREEBSD) uint64_t ram_amount; size_t val_size = sizeof(ram_amount);