builtin/gc: correct physical memory detection for OpenBSD / NetBSD
OpenBSD / NetBSD use HW_PHYSMEM64 to detect the amount of physical memory in a system. HW_PHYSMEM will not provide the correct amount on a system with >=4GB of memory. Signed-off-by: Brad Smith <brad@comstyle.com> Reviewed-by: Collin Funk <collin.funk1@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brad Smith committed
Jun 1, 2025 at 04:24 UTC
35c1d592cd11429e402501df3ad68bcd0fb86bef
1 file changed
+3
-1
builtin/gc.c
+3
-1
@@ -516,7 +516,7 @@ static uint64_t total_ram(void)
516
total *= (uint64_t)si.mem_unit;
517
return total;
518
}
519
-#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))
519
+#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64))
520
int64_t physical_memory;
521
int mib[2];
522
size_t length;
@@ -524,6 +524,8 @@ static uint64_t total_ram(void)
524
mib[0] = CTL_HW;
525
# if defined(HW_MEMSIZE)
526
mib[1] = HW_MEMSIZE;
527
+# elif defined(HW_PHYSMEM64)
528
+ mib[1] = HW_PHYSMEM64;
529
# else
530
mib[1] = HW_PHYSMEM;
531
# endif