Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst RAM size will not change during installatio...



details:   https://anonhg.NetBSD.org/src/rev/5d7b40d7cfe5
branches:  trunk
changeset: 1022462:5d7b40d7cfe5
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 20 16:40:12 2021 +0000

description:
RAM size will not change during installation, do the sysctl() dance
only once.

diffstat:

 usr.sbin/sysinst/util.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (28 lines):

diff -r 5922f80393ef -r 5d7b40d7cfe5 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Tue Jul 20 11:39:16 2021 +0000
+++ b/usr.sbin/sysinst/util.c   Tue Jul 20 16:40:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.57 2021/01/31 22:45:47 rillig Exp $ */
+/*     $NetBSD: util.c,v 1.58 2021/07/20 16:40:12 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -264,11 +264,14 @@
 uint64_t
 get_ramsize(void)
 {
-       uint64_t ramsize;
-       size_t len = sizeof ramsize;
-       int mib[2] = {CTL_HW, HW_PHYSMEM64};
+       static uint64_t ramsize;
 
-       sysctl(mib, 2, &ramsize, &len, NULL, 0);
+       if (ramsize == 0) {
+               size_t len = sizeof ramsize;
+               int mib[2] = {CTL_HW, HW_PHYSMEM64};
+
+               sysctl(mib, 2, &ramsize, &len, NULL, 0);
+       }
 
        /* Find out how many Megs ... round up. */
        return (ramsize + MEG - 1) / MEG;



Home | Main Index | Thread Index | Old Index