diff options
author | pjd <pjd@FreeBSD.org> | 2006-12-14 14:32:59 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-12-14 14:32:59 +0000 |
commit | fbddb38d93f7f55ac59ae27f0c7235ad0b91230b (patch) | |
tree | 7dd5bd6d8ca8b631897e42ed10264ce3f7b2f2ce /lib/libc/gen/sysconf.c | |
parent | 1080ddcf3fee611977f5beb4fc1be5240e1c234b (diff) | |
download | FreeBSD-src-fbddb38d93f7f55ac59ae27f0c7235ad0b91230b.zip FreeBSD-src-fbddb38d93f7f55ac59ae27f0c7235ad0b91230b.tar.gz |
Add support for _SC_PHYS_PAGES, which is not standard, but can be found in
Solaris and Linux.
Diffstat (limited to 'lib/libc/gen/sysconf.c')
-rw-r--r-- | lib/libc/gen/sysconf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 27729a6..fc844cc 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -79,9 +79,11 @@ sysconf(name) int mib[2], sverrno, value; long defaultresult; const char *path; + const char *sname; len = sizeof(value); defaultresult = -1; + sname = NULL; switch (name) { case _SC_ARG_MAX: @@ -574,9 +576,20 @@ yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1) mib[1] = HW_NCPU; break; + case _SC_PHYS_PAGES: + sname = "hw.availpages"; + break; + default: errno = EINVAL; return (-1); } - return (sysctl(mib, 2, &value, &len, NULL, 0) == -1 ? -1 : value); + if (sname == NULL) { + if (sysctl(mib, 2, &value, &len, NULL, 0) == -1) + value = -1; + } else { + if (sysctlbyname(sname, &value, &len, NULL, 0) == -1) + value = -1; + } + return (value); } |