Add support for _SC_PHYS_PAGES, which is not standard, but can be found in
Solaris and Linux.
This commit is contained in:
parent
1080ddcf3f
commit
fbddb38d93
@ -167,6 +167,19 @@ otherwise \-1.
|
|||||||
Return 1 if the system supports the User Portability Utilities Option,
|
Return 1 if the system supports the User Portability Utilities Option,
|
||||||
otherwise \-1.
|
otherwise \-1.
|
||||||
.El
|
.El
|
||||||
|
.Pp
|
||||||
|
These values also exist, but may not be standard:
|
||||||
|
.Pp
|
||||||
|
.Bl -tag -width 6n
|
||||||
|
.Pp
|
||||||
|
.It Li _SC_PHYS_PAGES
|
||||||
|
The number of pages of physical memory.
|
||||||
|
Note that it is possible that the product of this value and the value of
|
||||||
|
.Li _SC_PAGESIZE
|
||||||
|
will overflow a
|
||||||
|
.Vt long
|
||||||
|
in some configurations on a 32bit machine.
|
||||||
|
.El
|
||||||
.Sh RETURN VALUES
|
.Sh RETURN VALUES
|
||||||
If the call to
|
If the call to
|
||||||
.Fn sysconf
|
.Fn sysconf
|
||||||
|
@ -79,9 +79,11 @@ sysconf(name)
|
|||||||
int mib[2], sverrno, value;
|
int mib[2], sverrno, value;
|
||||||
long defaultresult;
|
long defaultresult;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
const char *sname;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
defaultresult = -1;
|
defaultresult = -1;
|
||||||
|
sname = NULL;
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case _SC_ARG_MAX:
|
case _SC_ARG_MAX:
|
||||||
@ -574,9 +576,20 @@ yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
|
|||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case _SC_PHYS_PAGES:
|
||||||
|
sname = "hw.availpages";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (-1);
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user