{"thread":{"id":"63555","subject":"[PATCH] builtin/gc: correct physical memory detection for OpenBSD / NetBSD","startedAt":"2025-06-01T08:24:14Z","lastAt":"2025-06-01T08:24:14Z","messageCount":1,"participants":["Brad Smith"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"519336","messageId":"aDwOLPOa8JOgFJZg@humpty.home.comstyle.com","threadId":"63555","inReplyTo":null,"subject":"[PATCH] builtin/gc: correct physical memory detection for OpenBSD / NetBSD","fromName":"Brad Smith","fromEmail":"brad@comstyle.com","sentAt":"2025-06-01T08:24:12Z","receivedAt":"2025-06-01T08:24:14Z","isPatch":true,"sender":{"key":"brad@comstyle.com","avatar":"https://avatars.githubusercontent.com/u/1129902?v=4"},"body":"OpenBSD / NetBSD use HW_PHYSMEM64 to detect the amount of physical\nmemory in a system. HW_PHYSMEM will not provide the correct amount\non a system with >=4GB of memory.\n\nSigned-off-by: Brad Smith <brad@comstyle.com>\n---\n builtin/gc.c | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex e690453d4f..eacb445085 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -431,7 +431,7 @@ static uint64_t total_ram(void)\n \t\t\ttotal *= (uint64_t)si.mem_unit;\n \t\treturn total;\n \t}\n-#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))\n+#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64))\n \tint64_t physical_memory;\n \tint mib[2];\n \tsize_t length;\n@@ -439,6 +439,8 @@ static uint64_t total_ram(void)\n \tmib[0] = CTL_HW;\n # if defined(HW_MEMSIZE)\n \tmib[1] = HW_MEMSIZE;\n+# elif defined(HW_PHYSMEM64)\n+\tmib[1] = HW_PHYSMEM64;\n # else\n \tmib[1] = HW_PHYSMEM;\n # endif\n-- \n2.49.0\n\n"}]}