diff options
author | msmith <msmith@FreeBSD.org> | 1998-06-01 20:58:03 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-06-01 20:58:03 +0000 |
commit | 09e640d1b3c288bbe44660999cd6d6cb6c98dfbd (patch) | |
tree | c1118f2f428b6bb10567fc8f028af1b31bec8e42 /lib | |
parent | 5c6ec72d1613409295be390d76fb691885845f85 (diff) | |
download | FreeBSD-src-09e640d1b3c288bbe44660999cd6d6cb6c98dfbd.zip FreeBSD-src-09e640d1b3c288bbe44660999cd6d6cb6c98dfbd.tar.gz |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/sysconf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 7f14254..2298bb1 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: |