Module Name:    src
Committed By:   riz
Date:           Wed Nov 28 21:38:13 UTC 2012

Modified Files:
        src/lib/libc/gen [netbsd-6]: sysconf.3 sysconf.c
        src/sys/sys [netbsd-6]: unistd.h

Log Message:
Pull up following revision(s) (requested by christos in ticket #720):
        sys/sys/unistd.h: revision 1.54
        lib/libc/gen/sysconf.3: revision 1.41
        lib/libc/gen/sysconf.c: revision 1.35
add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.40.4.1 src/lib/libc/gen/sysconf.3
cvs rdiff -u -r1.33.22.1 -r1.33.22.2 src/lib/libc/gen/sysconf.c
cvs rdiff -u -r1.52.18.1 -r1.52.18.2 src/sys/sys/unistd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/sysconf.3
diff -u src/lib/libc/gen/sysconf.3:1.40 src/lib/libc/gen/sysconf.3:1.40.4.1
--- src/lib/libc/gen/sysconf.3:1.40	Tue Aug 23 17:28:34 2011
+++ src/lib/libc/gen/sysconf.3	Wed Nov 28 21:38:12 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysconf.3,v 1.40 2011/08/23 17:28:34 jmcneill Exp $
+.\"	$NetBSD: sysconf.3,v 1.40.4.1 2012/11/28 21:38:12 riz 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 @@ and
 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

Index: src/lib/libc/gen/sysconf.c
diff -u src/lib/libc/gen/sysconf.c:1.33.22.1 src/lib/libc/gen/sysconf.c:1.33.22.2
--- src/lib/libc/gen/sysconf.c:1.33.22.1	Thu Aug  9 06:49:23 2012
+++ src/lib/libc/gen/sysconf.c	Wed Nov 28 21:38:13 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysconf.c,v 1.33.22.1 2012/08/09 06:49:23 jdc Exp $	*/
+/*	$NetBSD: sysconf.c,v 1.33.22.2 2012/11/28 21:38:13 riz 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.33.22.1 2012/08/09 06:49:23 jdc Exp $");
+__RCSID("$NetBSD: sysconf.c,v 1.33.22.2 2012/11/28 21:38:13 riz Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -75,6 +75,7 @@ sysconf(int name)
 {
 	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 @@ yesno:		if (sysctl(mib, mib_len, &value,
 		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,

Index: src/sys/sys/unistd.h
diff -u src/sys/sys/unistd.h:1.52.18.1 src/sys/sys/unistd.h:1.52.18.2
--- src/sys/sys/unistd.h:1.52.18.1	Thu Aug  9 06:49:23 2012
+++ src/sys/sys/unistd.h	Wed Nov 28 21:38:12 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: unistd.h,v 1.52.18.1 2012/08/09 06:49:23 jdc Exp $	*/
+/*	$NetBSD: unistd.h,v 1.52.18.2 2012/11/28 21:38:12 riz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -306,6 +306,9 @@
 /* This is implemented */
 #define	_SC_SPAWN			86
 
+/* Extensions found in Solaris and Linux. */
+#define	_SC_PHYS_PAGES		121
+
 #ifdef _NETBSD_SOURCE
 /* Commonly provided sysconf() extensions */
 #define	_SC_NPROCESSORS_CONF	1001

Reply via email to