From 5c07cc94205d347625397ea0dec09414dc6a2c6b Mon Sep 17 00:00:00 2001 From: millert Date: Fri, 7 May 2004 18:39:19 +0000 Subject: Implement _SC_SEM_NSEMS_MAX and _SC_SEM_VALUE_MAX. Based on a diff from Jean-Gérard Pailloncy. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/libc/gen/sysconf.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/libc/gen/sysconf.c') diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index b19485e1911..399690c2b54 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -31,10 +31,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: sysconf.c,v 1.5 2003/06/02 20:18:35 millert Exp $"; +static char rcsid[] = "$OpenBSD: sysconf.c,v 1.6 2004/05/07 18:39:19 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include +#include #include #include #include @@ -60,9 +61,10 @@ sysconf(name) { struct rlimit rl; size_t len; - int mib[2], value; + int mib[3], value, namelen; len = sizeof(value); + namelen = 2; switch (name) { /* 1003.1 */ @@ -186,15 +188,23 @@ sysconf(name) mib[0] = CTL_KERN; mib[1] = KERN_SYSVSHM; -yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1) +yesno: if (sysctl(mib, namelen, &value, &len, NULL, 0) == -1) return (-1); if (value == 0) return (-1); return (value); break; + case _SC_SEM_NSEMS_MAX: + case _SC_SEM_VALUE_MAX: + mib[0] = CTL_KERN; + mib[1] = KERN_SEMINFO; + mib[2] = name = _SC_SEM_NSEMS_MAX ? + KERN_SEMINFO_SEMMNS : KERN_SEMINFO_SEMVMX; + namelen = 3; + break; default: errno = EINVAL; return (-1); } - return (sysctl(mib, 2, &value, &len, NULL, 0) == -1 ? -1 : value); + return (sysctl(mib, namelen, &value, &len, NULL, 0) == -1 ? -1 : value); } -- cgit v1.2.3-59-g8ed1b