From d4a7e4ca5d14b8d05665024d20a53c276e9a0977 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Mon, 1 Jun 1998 20:58:03 +0000 Subject: 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 --- lib/libc/gen/sysconf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 7f142541c26a..2298bb1907a6 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -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: -- cgit v1.3