Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen Add _SC_PHYS_PAGES



details:   https://anonhg.NetBSD.org/src/rev/c40d0e6b90fb
branches:  trunk
changeset: 782438:c40d0e6b90fb
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Nov 02 21:43:07 2012 +0000

description:
Add _SC_PHYS_PAGES

diffstat:

 lib/libc/gen/sysconf.3 |   8 ++++++--
 lib/libc/gen/sysconf.c |  13 +++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diffs (70 lines):

diff -r ffe274b48b21 -r c40d0e6b90fb lib/libc/gen/sysconf.3
--- a/lib/libc/gen/sysconf.3    Fri Nov 02 21:41:26 2012 +0000
+++ b/lib/libc/gen/sysconf.3    Fri Nov 02 21:43:07 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sysconf.3,v 1.40 2011/08/23 17:28:34 jmcneill Exp $
+.\"    $NetBSD: sysconf.3,v 1.41 2012/11/02 21:44:52 christos Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)sysconf.3   8.3 (Berkeley) 4/19/94
 .\"
-.Dd August 23, 2011
+.Dd November 2, 2012
 .Dt SYSCONF 3
 .Os
 .Sh NAME
@@ -282,6 +282,10 @@
 The number of processors configured.
 .It Li _SC_NPROCESSORS_ONLN
 The number of processors online (capable of running processes).
+.It Li _SC_PHYS_PAGES
+The amount of physical memory on the system in 
+.Li _SC_PAGESIZE
+bytes.
 .El
 .Sh RETURN VALUES
 If the call to
diff -r ffe274b48b21 -r c40d0e6b90fb lib/libc/gen/sysconf.c
--- a/lib/libc/gen/sysconf.c    Fri Nov 02 21:41:26 2012 +0000
+++ b/lib/libc/gen/sysconf.c    Fri Nov 02 21:43:07 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysconf.c,v 1.34 2012/08/01 15:24:22 martin Exp $      */
+/*     $NetBSD: sysconf.c,v 1.35 2012/11/02 21:43:07 christos Exp $    */
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)sysconf.c  8.2 (Berkeley) 3/20/94";
 #else
-__RCSID("$NetBSD: sysconf.c,v 1.34 2012/08/01 15:24:22 martin Exp $");
+__RCSID("$NetBSD: sysconf.c,v 1.35 2012/11/02 21:43:07 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -75,6 +75,7 @@
 {
        struct rlimit rl;
        size_t len;
+       uint64_t mem;
        int mib[CTL_MAXNAME], value;
        unsigned int mib_len;
        struct clockinfo tmpclock;
@@ -367,6 +368,14 @@
                mib[1] = HW_NCPUONLINE;
                break;
 
+/* Linux/Solaris */
+       case _SC_PHYS_PAGES:
+               len = sizeof(mem);
+               mib[0] = CTL_HW;
+               mib[1] = HW_PHYSMEM64;
+               return sysctl(mib, 2, &mem, &len, NULL, 0) == -1 ? -1 : 
+                   (long)(mem / _getpagesize()); 
+
 /* Native */
        case _SC_SCHED_RT_TS:
                if (sysctlgetmibinfo("kern.sched.rtts", &mib[0], &mib_len,



Home | Main Index | Thread Index | Old Index