git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] builtin/gc: correct physical memory detection for OpenBSD / NetBSD

From
Brad Smith <brad@comstyle.com>
Date
Jun 1, 2025, 08:24 UTC
Message-ID
<aDwOLPOa8JOgFJZg@humpty.home.comstyle.com>

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>
---
 builtin/gc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index e690453d4f..eacb445085 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -431,7 +431,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;
@@ -439,6 +439,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
-- 
2.49.0
Message 1 of 1 in “builtin/gc: correct physical memory detection for OpenBSD / NetBSD”
  1. builtin/gc: correct physical memory detection for OpenBSD / NetBSDBrad Smith, Jun 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.