Home | History | Annotate | Line # | Download | only in gen
sysconf.c revision 1.29.4.1
      1  1.29.4.1  wrstuden /*	$NetBSD: sysconf.c,v 1.29.4.1 2008/09/18 04:39:21 wrstuden Exp $	*/
      2       1.2       cgd 
      3       1.1       cgd /*-
      4       1.1       cgd  * Copyright (c) 1993
      5       1.1       cgd  *	The Regents of the University of California.  All rights reserved.
      6       1.1       cgd  *
      7       1.1       cgd  * This code is derived from software contributed to Berkeley by
      8       1.1       cgd  * Sean Eric Fagan of Cygnus Support.
      9       1.1       cgd  *
     10       1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11       1.1       cgd  * modification, are permitted provided that the following conditions
     12       1.1       cgd  * are met:
     13       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18      1.19       agc  * 3. Neither the name of the University nor the names of its contributors
     19       1.1       cgd  *    may be used to endorse or promote products derived from this software
     20       1.1       cgd  *    without specific prior written permission.
     21       1.1       cgd  *
     22       1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23       1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24       1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25       1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26       1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27       1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28       1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29       1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30       1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31       1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32       1.1       cgd  * SUCH DAMAGE.
     33       1.1       cgd  */
     34       1.1       cgd 
     35       1.4  christos #include <sys/cdefs.h>
     36       1.1       cgd #if defined(LIBC_SCCS) && !defined(lint)
     37       1.2       cgd #if 0
     38       1.1       cgd static char sccsid[] = "@(#)sysconf.c	8.2 (Berkeley) 3/20/94";
     39       1.2       cgd #else
     40  1.29.4.1  wrstuden __RCSID("$NetBSD: sysconf.c,v 1.29.4.1 2008/09/18 04:39:21 wrstuden Exp $");
     41       1.2       cgd #endif
     42       1.1       cgd #endif /* LIBC_SCCS and not lint */
     43       1.1       cgd 
     44       1.5       jtc #include "namespace.h"
     45       1.1       cgd #include <sys/param.h>
     46       1.1       cgd #include <sys/sysctl.h>
     47       1.1       cgd #include <sys/time.h>
     48       1.1       cgd #include <sys/resource.h>
     49       1.1       cgd 
     50       1.1       cgd #include <errno.h>
     51      1.21     lukem #include <limits.h>
     52       1.7    kleink #include <time.h>
     53       1.1       cgd #include <unistd.h>
     54  1.29.4.1  wrstuden #include <paths.h>
     55  1.29.4.1  wrstuden #include <pwd.h>
     56       1.5       jtc 
     57       1.5       jtc #ifdef __weak_alias
     58      1.13    kleink __weak_alias(sysconf,__sysconf)
     59       1.5       jtc #endif
     60       1.1       cgd 
     61       1.1       cgd /*
     62       1.1       cgd  * sysconf --
     63       1.1       cgd  *	get configurable system variables.
     64       1.1       cgd  *
     65       1.1       cgd  * XXX
     66       1.1       cgd  * POSIX 1003.1 (ISO/IEC 9945-1, 4.8.1.3) states that the variable values
     67       1.1       cgd  * not change during the lifetime of the calling process.  This would seem
     68       1.1       cgd  * to require that any change to system limits kill all running processes.
     69       1.1       cgd  * A workaround might be to cache the values when they are first retrieved
     70       1.1       cgd  * and then simply return the cached value on subsequent calls.  This is
     71       1.1       cgd  * less useful than returning up-to-date values, however.
     72       1.1       cgd  */
     73       1.1       cgd long
     74      1.23     rmind sysconf(int name)
     75       1.1       cgd {
     76       1.1       cgd 	struct rlimit rl;
     77       1.1       cgd 	size_t len;
     78      1.23     rmind 	int mib[CTL_MAXNAME], value;
     79      1.23     rmind 	unsigned int mib_len;
     80      1.15     perry 	struct clockinfo tmpclock;
     81      1.15     perry 	static int clk_tck;
     82       1.1       cgd 
     83       1.1       cgd 	len = sizeof(value);
     84       1.1       cgd 
     85      1.23     rmind 	/* Default length of the MIB */
     86      1.23     rmind 	mib_len = 2;
     87      1.23     rmind 
     88       1.1       cgd 	switch (name) {
     89      1.20     lukem 
     90       1.1       cgd /* 1003.1 */
     91       1.1       cgd 	case _SC_ARG_MAX:
     92       1.1       cgd 		mib[0] = CTL_KERN;
     93       1.1       cgd 		mib[1] = KERN_ARGMAX;
     94       1.1       cgd 		break;
     95       1.1       cgd 	case _SC_CHILD_MAX:
     96       1.6     perry 		return (getrlimit(RLIMIT_NPROC, &rl) ? -1 : (long)rl.rlim_cur);
     97      1.16     bjh21 	case _O_SC_CLK_TCK:
     98      1.16     bjh21 		/*
     99      1.16     bjh21 		 * For applications compiled when CLK_TCK was a compile-time
    100      1.16     bjh21 		 * constant.
    101      1.16     bjh21 		 */
    102      1.16     bjh21 		return 100;
    103       1.1       cgd 	case _SC_CLK_TCK:
    104      1.15     perry 		/*
    105      1.15     perry 		 * Has to be handled specially because it returns a
    106      1.15     perry 		 * struct clockinfo instead of an integer. Also, since
    107      1.15     perry 		 * this might be called often by some things that
    108      1.15     perry 		 * don't grok CLK_TCK can be a macro expanding to a
    109      1.15     perry 		 * function, cache the value.
    110      1.15     perry 		 */
    111      1.15     perry 		if (clk_tck == 0) {
    112      1.15     perry 			mib[0] = CTL_KERN;
    113      1.15     perry 			mib[1] = KERN_CLOCKRATE;
    114      1.15     perry 			len = sizeof(struct clockinfo);
    115      1.15     perry 			clk_tck = sysctl(mib, 2, &tmpclock, &len, NULL, 0)
    116      1.15     perry 			    == -1 ? -1 : tmpclock.hz;
    117      1.15     perry 		}
    118      1.15     perry 		return(clk_tck);
    119       1.1       cgd 	case _SC_JOB_CONTROL:
    120       1.1       cgd 		mib[0] = CTL_KERN;
    121       1.1       cgd 		mib[1] = KERN_JOB_CONTROL;
    122       1.1       cgd 		goto yesno;
    123       1.1       cgd 	case _SC_NGROUPS_MAX:
    124       1.1       cgd 		mib[0] = CTL_KERN;
    125       1.1       cgd 		mib[1] = KERN_NGROUPS;
    126       1.1       cgd 		break;
    127       1.1       cgd 	case _SC_OPEN_MAX:
    128       1.6     perry 		return (getrlimit(RLIMIT_NOFILE, &rl) ? -1 : (long)rl.rlim_cur);
    129       1.1       cgd 	case _SC_STREAM_MAX:
    130       1.1       cgd 		mib[0] = CTL_USER;
    131       1.1       cgd 		mib[1] = USER_STREAM_MAX;
    132       1.1       cgd 		break;
    133       1.1       cgd 	case _SC_TZNAME_MAX:
    134       1.1       cgd 		mib[0] = CTL_USER;
    135       1.1       cgd 		mib[1] = USER_TZNAME_MAX;
    136       1.1       cgd 		break;
    137       1.1       cgd 	case _SC_SAVED_IDS:
    138       1.1       cgd 		mib[0] = CTL_KERN;
    139       1.1       cgd 		mib[1] = KERN_SAVED_IDS;
    140       1.1       cgd 		goto yesno;
    141       1.1       cgd 	case _SC_VERSION:
    142       1.1       cgd 		mib[0] = CTL_KERN;
    143       1.1       cgd 		mib[1] = KERN_POSIX1;
    144       1.1       cgd 		break;
    145       1.1       cgd 
    146       1.8    kleink /* 1003.1b */
    147       1.8    kleink 	case _SC_PAGESIZE:
    148      1.28      yamt 		return _getpagesize();
    149       1.8    kleink 	case _SC_FSYNC:
    150       1.8    kleink 		mib[0] = CTL_KERN;
    151       1.8    kleink 		mib[1] = KERN_FSYNC;
    152       1.8    kleink 		goto yesno;
    153       1.9    kleink 	case _SC_SYNCHRONIZED_IO:
    154       1.9    kleink 		mib[0] = CTL_KERN;
    155       1.9    kleink 		mib[1] = KERN_SYNCHRONIZED_IO;
    156      1.10    kleink 		goto yesno;
    157      1.10    kleink 	case _SC_MAPPED_FILES:
    158      1.10    kleink 		mib[0] = CTL_KERN;
    159      1.10    kleink 		mib[1] = KERN_MAPPED_FILES;
    160      1.10    kleink 		goto yesno;
    161      1.10    kleink 	case _SC_MEMLOCK:
    162      1.10    kleink 		mib[0] = CTL_KERN;
    163      1.10    kleink 		mib[1] = KERN_MEMLOCK;
    164      1.10    kleink 		goto yesno;
    165      1.10    kleink 	case _SC_MEMLOCK_RANGE:
    166      1.10    kleink 		mib[0] = CTL_KERN;
    167      1.10    kleink 		mib[1] = KERN_MEMLOCK_RANGE;
    168      1.10    kleink 		goto yesno;
    169      1.10    kleink 	case _SC_MEMORY_PROTECTION:
    170      1.10    kleink 		mib[0] = CTL_KERN;
    171      1.10    kleink 		mib[1] = KERN_MEMORY_PROTECTION;
    172      1.14    kleink 		goto yesno;
    173      1.14    kleink 	case _SC_MONOTONIC_CLOCK:
    174      1.14    kleink 		mib[0] = CTL_KERN;
    175      1.14    kleink 		mib[1] = KERN_MONOTONIC_CLOCK;
    176       1.9    kleink 		goto yesno;
    177      1.18    kleink 	case _SC_SEMAPHORES:
    178      1.18    kleink 		mib[0] = CTL_KERN;
    179      1.18    kleink 		mib[1] = KERN_POSIX_SEMAPHORES;
    180      1.18    kleink 		goto yesno;
    181      1.18    kleink 	case _SC_TIMERS:
    182      1.18    kleink 		mib[0] = CTL_KERN;
    183      1.18    kleink 		mib[1] = KERN_POSIX_TIMERS;
    184      1.18    kleink 		goto yesno;
    185      1.11    kleink 
    186      1.11    kleink /* 1003.1c */
    187      1.11    kleink 	case _SC_LOGIN_NAME_MAX:
    188      1.11    kleink 		mib[0] = CTL_KERN;
    189      1.11    kleink 		mib[1] = KERN_LOGIN_NAME_MAX;
    190      1.11    kleink 		break;
    191      1.18    kleink 	case _SC_THREADS:
    192      1.18    kleink 		mib[0] = CTL_KERN;
    193      1.18    kleink 		mib[1] = KERN_POSIX_THREADS;
    194      1.18    kleink 		goto yesno;
    195      1.18    kleink 
    196      1.18    kleink /* 1003.1j */
    197      1.18    kleink 	case _SC_BARRIERS:
    198      1.18    kleink 		mib[0] = CTL_KERN;
    199      1.18    kleink 		mib[1] = KERN_POSIX_BARRIERS;
    200      1.18    kleink 		goto yesno;
    201      1.18    kleink 	case _SC_SPIN_LOCKS:
    202      1.18    kleink 		mib[0] = CTL_KERN;
    203      1.18    kleink 		mib[1] = KERN_POSIX_SPIN_LOCKS;
    204      1.18    kleink 		goto yesno;
    205      1.18    kleink 	/* Historical; Threads option in 1003.1-2001 */
    206      1.18    kleink 	case _SC_READER_WRITER_LOCKS:
    207      1.18    kleink 		mib[0] = CTL_KERN;
    208      1.18    kleink 		mib[1] = KERN_POSIX_READER_WRITER_LOCKS;
    209      1.18    kleink 		goto yesno;
    210       1.8    kleink 
    211       1.1       cgd /* 1003.2 */
    212       1.1       cgd 	case _SC_BC_BASE_MAX:
    213       1.1       cgd 		mib[0] = CTL_USER;
    214       1.1       cgd 		mib[1] = USER_BC_BASE_MAX;
    215       1.1       cgd 		break;
    216       1.1       cgd 	case _SC_BC_DIM_MAX:
    217       1.1       cgd 		mib[0] = CTL_USER;
    218       1.1       cgd 		mib[1] = USER_BC_DIM_MAX;
    219       1.1       cgd 		break;
    220       1.1       cgd 	case _SC_BC_SCALE_MAX:
    221       1.1       cgd 		mib[0] = CTL_USER;
    222       1.1       cgd 		mib[1] = USER_BC_SCALE_MAX;
    223       1.1       cgd 		break;
    224       1.1       cgd 	case _SC_BC_STRING_MAX:
    225       1.1       cgd 		mib[0] = CTL_USER;
    226       1.1       cgd 		mib[1] = USER_BC_STRING_MAX;
    227       1.1       cgd 		break;
    228       1.1       cgd 	case _SC_COLL_WEIGHTS_MAX:
    229       1.1       cgd 		mib[0] = CTL_USER;
    230       1.1       cgd 		mib[1] = USER_COLL_WEIGHTS_MAX;
    231       1.1       cgd 		break;
    232       1.1       cgd 	case _SC_EXPR_NEST_MAX:
    233       1.1       cgd 		mib[0] = CTL_USER;
    234       1.1       cgd 		mib[1] = USER_EXPR_NEST_MAX;
    235       1.1       cgd 		break;
    236       1.1       cgd 	case _SC_LINE_MAX:
    237       1.1       cgd 		mib[0] = CTL_USER;
    238       1.1       cgd 		mib[1] = USER_LINE_MAX;
    239       1.1       cgd 		break;
    240       1.1       cgd 	case _SC_RE_DUP_MAX:
    241       1.1       cgd 		mib[0] = CTL_USER;
    242       1.1       cgd 		mib[1] = USER_RE_DUP_MAX;
    243       1.1       cgd 		break;
    244       1.1       cgd 	case _SC_2_VERSION:
    245       1.1       cgd 		mib[0] = CTL_USER;
    246       1.1       cgd 		mib[1] = USER_POSIX2_VERSION;
    247       1.1       cgd 		break;
    248       1.1       cgd 	case _SC_2_C_BIND:
    249       1.1       cgd 		mib[0] = CTL_USER;
    250       1.1       cgd 		mib[1] = USER_POSIX2_C_BIND;
    251       1.1       cgd 		goto yesno;
    252       1.1       cgd 	case _SC_2_C_DEV:
    253       1.1       cgd 		mib[0] = CTL_USER;
    254       1.1       cgd 		mib[1] = USER_POSIX2_C_DEV;
    255       1.1       cgd 		goto yesno;
    256       1.1       cgd 	case _SC_2_CHAR_TERM:
    257       1.1       cgd 		mib[0] = CTL_USER;
    258       1.1       cgd 		mib[1] = USER_POSIX2_CHAR_TERM;
    259       1.1       cgd 		goto yesno;
    260       1.1       cgd 	case _SC_2_FORT_DEV:
    261       1.1       cgd 		mib[0] = CTL_USER;
    262       1.1       cgd 		mib[1] = USER_POSIX2_FORT_DEV;
    263       1.1       cgd 		goto yesno;
    264       1.1       cgd 	case _SC_2_FORT_RUN:
    265       1.1       cgd 		mib[0] = CTL_USER;
    266       1.1       cgd 		mib[1] = USER_POSIX2_FORT_RUN;
    267       1.1       cgd 		goto yesno;
    268       1.1       cgd 	case _SC_2_LOCALEDEF:
    269       1.1       cgd 		mib[0] = CTL_USER;
    270       1.1       cgd 		mib[1] = USER_POSIX2_LOCALEDEF;
    271       1.1       cgd 		goto yesno;
    272       1.1       cgd 	case _SC_2_SW_DEV:
    273       1.1       cgd 		mib[0] = CTL_USER;
    274       1.1       cgd 		mib[1] = USER_POSIX2_SW_DEV;
    275       1.1       cgd 		goto yesno;
    276       1.1       cgd 	case _SC_2_UPE:
    277       1.1       cgd 		mib[0] = CTL_USER;
    278       1.1       cgd 		mib[1] = USER_POSIX2_UPE;
    279       1.8    kleink 		goto yesno;
    280       1.8    kleink 
    281       1.8    kleink /* XPG 4.2 */
    282       1.9    kleink 	case _SC_IOV_MAX:
    283       1.9    kleink 		mib[0] = CTL_KERN;
    284       1.9    kleink 		mib[1] = KERN_IOV_MAX;
    285       1.9    kleink 		break;
    286       1.8    kleink 	case _SC_XOPEN_SHM:
    287       1.8    kleink 		mib[0] = CTL_KERN;
    288      1.22  christos 		mib[1] = KERN_SYSVIPC;
    289      1.22  christos 		mib[2] = KERN_SYSVIPC_SHM;
    290      1.23     rmind 		mib_len = 3;
    291      1.23     rmind 		goto yesno;
    292      1.17    kleink 
    293      1.17    kleink /* 1003.1-2001, XSI Option Group */
    294      1.23     rmind 	case _SC_AIO_LISTIO_MAX:
    295      1.23     rmind 		if (sysctlgetmibinfo("kern.aio_listio_max", &mib[0], &mib_len,
    296      1.23     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    297      1.23     rmind 			return -1;
    298      1.23     rmind 		break;
    299      1.23     rmind 	case _SC_AIO_MAX:
    300      1.23     rmind 		if (sysctlgetmibinfo("kern.aio_max", &mib[0], &mib_len,
    301      1.23     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    302      1.23     rmind 			return -1;
    303      1.23     rmind 		break;
    304      1.23     rmind 	case _SC_ASYNCHRONOUS_IO:
    305      1.23     rmind 		if (sysctlgetmibinfo("kern.posix_aio", &mib[0], &mib_len,
    306      1.23     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    307      1.23     rmind 			return -1;
    308      1.23     rmind 		goto yesno;
    309      1.24     rmind 	case _SC_MESSAGE_PASSING:
    310      1.24     rmind 		if (sysctlgetmibinfo("kern.posix_msg", &mib[0], &mib_len,
    311      1.24     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    312      1.24     rmind 			return -1;
    313      1.24     rmind 		goto yesno;
    314      1.24     rmind 	case _SC_MQ_OPEN_MAX:
    315      1.29     njoly 		if (sysctlgetmibinfo("kern.mqueue.mq_open_max", &mib[0],
    316      1.29     njoly 		    &mib_len, NULL, NULL, NULL, SYSCTL_VERSION))
    317      1.24     rmind 			return -1;
    318      1.24     rmind 		break;
    319      1.24     rmind 	case _SC_MQ_PRIO_MAX:
    320      1.29     njoly 		if (sysctlgetmibinfo("kern.mqueue.mq_prio_max", &mib[0],
    321      1.29     njoly 		    &mib_len, NULL, NULL, NULL, SYSCTL_VERSION))
    322      1.24     rmind 			return -1;
    323      1.24     rmind 		break;
    324      1.26     rmind 	case _SC_PRIORITY_SCHEDULING:
    325      1.26     rmind 		if (sysctlgetmibinfo("kern.posix_sched", &mib[0], &mib_len,
    326      1.26     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    327      1.26     rmind 			return -1;
    328      1.26     rmind 		goto yesno;
    329      1.17    kleink 	case _SC_ATEXIT_MAX:
    330      1.17    kleink 		mib[0] = CTL_USER;
    331      1.17    kleink 		mib[1] = USER_ATEXIT_MAX;
    332      1.17    kleink 		break;
    333      1.17    kleink 
    334      1.20     lukem /* 1003.1-2001, TSF */
    335      1.20     lukem 	case _SC_GETGR_R_SIZE_MAX:
    336      1.20     lukem 		return _GETGR_R_SIZE_MAX;
    337      1.20     lukem 	case _SC_GETPW_R_SIZE_MAX:
    338      1.20     lukem 		return _GETPW_R_SIZE_MAX;
    339      1.20     lukem 
    340  1.29.4.1  wrstuden /* Unsorted */
    341  1.29.4.1  wrstuden 	case _SC_HOST_NAME_MAX:
    342  1.29.4.1  wrstuden 		return MAXHOSTNAMELEN;
    343  1.29.4.1  wrstuden 	case _SC_PASS_MAX:
    344  1.29.4.1  wrstuden 		return _PASSWORD_LEN;
    345  1.29.4.1  wrstuden 	case _SC_REGEXP:
    346  1.29.4.1  wrstuden 		return _POSIX_REGEXP;
    347  1.29.4.1  wrstuden 	case _SC_SHELL:
    348  1.29.4.1  wrstuden 		return _POSIX_SHELL;
    349  1.29.4.1  wrstuden 	case _SC_SYMLOOP_MAX:
    350  1.29.4.1  wrstuden 		return MAXSYMLINKS;
    351  1.29.4.1  wrstuden 
    352      1.23     rmind yesno:		if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1)
    353       1.1       cgd 			return (-1);
    354       1.1       cgd 		if (value == 0)
    355       1.1       cgd 			return (-1);
    356       1.1       cgd 		return (value);
    357      1.25        ad 
    358      1.25        ad /* Extensions */
    359      1.25        ad 	case _SC_NPROCESSORS_CONF:
    360      1.25        ad 		mib[0] = CTL_HW;
    361      1.25        ad 		mib[1] = HW_NCPU;
    362      1.25        ad 		break;
    363      1.25        ad 	case _SC_NPROCESSORS_ONLN:
    364      1.25        ad 		mib[0] = CTL_HW;
    365      1.25        ad 		mib[1] = HW_NCPUONLINE;
    366      1.25        ad 		break;
    367      1.25        ad 
    368      1.26     rmind /* Native */
    369      1.26     rmind 	case _SC_SCHED_RT_TS:
    370      1.27     rmind 		if (sysctlgetmibinfo("kern.sched.rtts", &mib[0], &mib_len,
    371      1.26     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    372      1.26     rmind 			return -1;
    373      1.26     rmind 		break;
    374      1.26     rmind 	case _SC_SCHED_PRI_MIN:
    375      1.26     rmind 		if (sysctlgetmibinfo("kern.sched.pri_min", &mib[0], &mib_len,
    376      1.26     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    377      1.26     rmind 			return -1;
    378      1.26     rmind 		break;
    379      1.26     rmind 	case _SC_SCHED_PRI_MAX:
    380      1.26     rmind 		if (sysctlgetmibinfo("kern.sched.pri_max", &mib[0], &mib_len,
    381      1.26     rmind 		    NULL, NULL, NULL, SYSCTL_VERSION))
    382      1.26     rmind 			return -1;
    383      1.26     rmind 		break;
    384  1.29.4.1  wrstuden 	case _SC_THREAD_DESTRUCTOR_ITERATIONS:
    385  1.29.4.1  wrstuden 		return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
    386  1.29.4.1  wrstuden 	case _SC_THREAD_KEYS_MAX:
    387  1.29.4.1  wrstuden 		return _POSIX_THREAD_KEYS_MAX;
    388  1.29.4.1  wrstuden 	case _SC_THREAD_STACK_MIN:
    389  1.29.4.1  wrstuden 		return _getpagesize();
    390  1.29.4.1  wrstuden 	case _SC_THREAD_THREADS_MAX:
    391  1.29.4.1  wrstuden 		if (sysctlgetmibinfo("kern.maxproc", &mib[0], &mib_len,
    392  1.29.4.1  wrstuden 		    NULL, NULL, NULL, SYSCTL_VERSION))	/* XXX */
    393  1.29.4.1  wrstuden 			return -1;
    394  1.29.4.1  wrstuden 		goto yesno;
    395  1.29.4.1  wrstuden 	case _SC_THREAD_ATTR_STACKADDR:
    396  1.29.4.1  wrstuden 		return _POSIX_THREAD_ATTR_STACKADDR;
    397  1.29.4.1  wrstuden 	case _SC_THREAD_ATTR_STACKSIZE:
    398  1.29.4.1  wrstuden 		return _POSIX_THREAD_ATTR_STACKSIZE;
    399  1.29.4.1  wrstuden 	case _SC_THREAD_SAFE_FUNCTIONS:
    400  1.29.4.1  wrstuden 		return _POSIX_THREAD_SAFE_FUNCTIONS;
    401  1.29.4.1  wrstuden 	case _SC_THREAD_PRIORITY_SCHEDULING:
    402  1.29.4.1  wrstuden 	case _SC_THREAD_PRIO_INHERIT:
    403  1.29.4.1  wrstuden 	case _SC_THREAD_PRIO_PROTECT:
    404  1.29.4.1  wrstuden 	case _SC_THREAD_PROCESS_SHARED:
    405  1.29.4.1  wrstuden 		return -1;
    406  1.29.4.1  wrstuden 	case _SC_TTY_NAME_MAX:
    407  1.29.4.1  wrstuden 		return pathconf(_PATH_DEV, _PC_NAME_MAX);
    408       1.1       cgd 	default:
    409       1.1       cgd 		errno = EINVAL;
    410       1.1       cgd 		return (-1);
    411       1.1       cgd 	}
    412      1.23     rmind 	return (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1 ? -1 : value);
    413       1.1       cgd }
    414