]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/gc: correct physical memory detection for OpenBSD / NetBSD
authorBrad Smith <brad@comstyle.com>
Sun, 1 Jun 2025 08:24:12 +0000 (04:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Jun 2025 02:01:07 +0000 (19:01 -0700)
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>
builtin/gc.c

index e33ba946e43602af5b1d48d57753e712f9439892..7dc94f243d7dc62059f025cc9495ca6491729698 100644 (file)
@@ -516,7 +516,7 @@ static uint64_t total_ram(void)
                        total *= (uint64_t)si.mem_unit;
                return total;
        }
-#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))
+#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64))
        int64_t physical_memory;
        int mib[2];
        size_t length;
@@ -524,6 +524,8 @@ static uint64_t total_ram(void)
        mib[0] = CTL_HW;
 # if defined(HW_MEMSIZE)
        mib[1] = HW_MEMSIZE;
+# elif defined(HW_PHYSMEM64)
+       mib[1] = HW_PHYSMEM64;
 # else
        mib[1] = HW_PHYSMEM;
 # endif