Add a trivial mechanism for returning a useful default value if one is

available and the kernel MIB setting is zero.

Return the result from getpagesize() if the p1003_1b.pagesize MIB
value is zero.

Suggested by:		Joerg Schilling <schilling@fokus.gmd.de>
This commit is contained in:
msmith 1998-06-01 20:58:03 +00:00
parent 5c6ec72d16
commit 09e640d1b3

View File

@ -67,8 +67,10 @@ sysconf(name)
struct rlimit rl;
size_t len;
int mib[2], value;
long defaultresult;
len = sizeof(value);
defaultresult = -1;
switch (name) {
/* 1003.1 */
@ -257,6 +259,7 @@ sysconf(name)
mib[1] = CTL_P1003_1B_MQ_OPEN_MAX;
goto yesno;
case _SC_PAGESIZE:
defaultresult = getpagesize();
mib[0] = CTL_P1003_1B;
mib[1] = CTL_P1003_1B_PAGESIZE;
goto yesno;
@ -285,7 +288,7 @@ sysconf(name)
yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
return (-1);
if (value == 0)
return (-1);
return (defaultresult);
return (value);
break;
default: