From: Brad Smith <brad@comstyle.com>
To: git@vger.kernel.org
Subject: [PATCH] builtin/gc: correct physical memory detection for OpenBSD / NetBSD
Date: Sun, 1 Jun 2025 04:24:12 -0400 [thread overview]
Message-ID: <aDwOLPOa8JOgFJZg@humpty.home.comstyle.com> (raw)
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
next reply other threads:[~2025-06-01 8:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-01 8:24 Brad Smith [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-06-02 1:34 [PATCH] builtin/gc: correct physical memory detection for OpenBSD / NetBSD Collin Funk
2025-06-02 2:00 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aDwOLPOa8JOgFJZg@humpty.home.comstyle.com \
--to=brad@comstyle.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).