sysconf.c revision 1.44 1 1.44 simonb /* $NetBSD: sysconf.c,v 1.44 2023/10/25 08:19:34 simonb 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.44 simonb __RCSID("$NetBSD: sysconf.c,v 1.44 2023/10/25 08:19:34 simonb 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.44 simonb #include <uvm/uvm_extern.h>
50 1.1 cgd
51 1.1 cgd #include <errno.h>
52 1.21 lukem #include <limits.h>
53 1.7 kleink #include <time.h>
54 1.1 cgd #include <unistd.h>
55 1.32 ad #include <paths.h>
56 1.33 matt #include <pwd.h>
57 1.5 jtc
58 1.5 jtc #ifdef __weak_alias
59 1.13 kleink __weak_alias(sysconf,__sysconf)
60 1.5 jtc #endif
61 1.1 cgd
62 1.1 cgd /*
63 1.1 cgd * sysconf --
64 1.1 cgd * get configurable system variables.
65 1.1 cgd *
66 1.1 cgd * XXX
67 1.1 cgd * POSIX 1003.1 (ISO/IEC 9945-1, 4.8.1.3) states that the variable values
68 1.1 cgd * not change during the lifetime of the calling process. This would seem
69 1.1 cgd * to require that any change to system limits kill all running processes.
70 1.1 cgd * A workaround might be to cache the values when they are first retrieved
71 1.1 cgd * and then simply return the cached value on subsequent calls. This is
72 1.1 cgd * less useful than returning up-to-date values, however.
73 1.1 cgd */
74 1.1 cgd long
75 1.23 rmind sysconf(int name)
76 1.1 cgd {
77 1.1 cgd struct rlimit rl;
78 1.1 cgd size_t len;
79 1.35 christos uint64_t mem;
80 1.23 rmind int mib[CTL_MAXNAME], value;
81 1.23 rmind unsigned int mib_len;
82 1.15 perry struct clockinfo tmpclock;
83 1.44 simonb struct uvmexp_sysctl uvmexp;
84 1.15 perry static int clk_tck;
85 1.1 cgd
86 1.1 cgd len = sizeof(value);
87 1.1 cgd
88 1.23 rmind /* Default length of the MIB */
89 1.23 rmind mib_len = 2;
90 1.23 rmind
91 1.1 cgd switch (name) {
92 1.20 lukem
93 1.1 cgd /* 1003.1 */
94 1.1 cgd case _SC_ARG_MAX:
95 1.1 cgd mib[0] = CTL_KERN;
96 1.1 cgd mib[1] = KERN_ARGMAX;
97 1.1 cgd break;
98 1.1 cgd case _SC_CHILD_MAX:
99 1.6 perry return (getrlimit(RLIMIT_NPROC, &rl) ? -1 : (long)rl.rlim_cur);
100 1.16 bjh21 case _O_SC_CLK_TCK:
101 1.16 bjh21 /*
102 1.16 bjh21 * For applications compiled when CLK_TCK was a compile-time
103 1.16 bjh21 * constant.
104 1.16 bjh21 */
105 1.16 bjh21 return 100;
106 1.1 cgd case _SC_CLK_TCK:
107 1.15 perry /*
108 1.15 perry * Has to be handled specially because it returns a
109 1.15 perry * struct clockinfo instead of an integer. Also, since
110 1.15 perry * this might be called often by some things that
111 1.15 perry * don't grok CLK_TCK can be a macro expanding to a
112 1.15 perry * function, cache the value.
113 1.15 perry */
114 1.15 perry if (clk_tck == 0) {
115 1.15 perry mib[0] = CTL_KERN;
116 1.15 perry mib[1] = KERN_CLOCKRATE;
117 1.15 perry len = sizeof(struct clockinfo);
118 1.15 perry clk_tck = sysctl(mib, 2, &tmpclock, &len, NULL, 0)
119 1.15 perry == -1 ? -1 : tmpclock.hz;
120 1.15 perry }
121 1.15 perry return(clk_tck);
122 1.1 cgd case _SC_JOB_CONTROL:
123 1.1 cgd mib[0] = CTL_KERN;
124 1.1 cgd mib[1] = KERN_JOB_CONTROL;
125 1.1 cgd goto yesno;
126 1.1 cgd case _SC_NGROUPS_MAX:
127 1.1 cgd mib[0] = CTL_KERN;
128 1.1 cgd mib[1] = KERN_NGROUPS;
129 1.1 cgd break;
130 1.1 cgd case _SC_OPEN_MAX:
131 1.6 perry return (getrlimit(RLIMIT_NOFILE, &rl) ? -1 : (long)rl.rlim_cur);
132 1.1 cgd case _SC_STREAM_MAX:
133 1.1 cgd mib[0] = CTL_USER;
134 1.1 cgd mib[1] = USER_STREAM_MAX;
135 1.1 cgd break;
136 1.1 cgd case _SC_TZNAME_MAX:
137 1.1 cgd mib[0] = CTL_USER;
138 1.1 cgd mib[1] = USER_TZNAME_MAX;
139 1.1 cgd break;
140 1.1 cgd case _SC_SAVED_IDS:
141 1.1 cgd mib[0] = CTL_KERN;
142 1.1 cgd mib[1] = KERN_SAVED_IDS;
143 1.1 cgd goto yesno;
144 1.1 cgd case _SC_VERSION:
145 1.1 cgd mib[0] = CTL_KERN;
146 1.1 cgd mib[1] = KERN_POSIX1;
147 1.1 cgd break;
148 1.1 cgd
149 1.8 kleink /* 1003.1b */
150 1.8 kleink case _SC_PAGESIZE:
151 1.28 yamt return _getpagesize();
152 1.8 kleink case _SC_FSYNC:
153 1.8 kleink mib[0] = CTL_KERN;
154 1.8 kleink mib[1] = KERN_FSYNC;
155 1.8 kleink goto yesno;
156 1.9 kleink case _SC_SYNCHRONIZED_IO:
157 1.9 kleink mib[0] = CTL_KERN;
158 1.9 kleink mib[1] = KERN_SYNCHRONIZED_IO;
159 1.10 kleink goto yesno;
160 1.10 kleink case _SC_MAPPED_FILES:
161 1.10 kleink mib[0] = CTL_KERN;
162 1.10 kleink mib[1] = KERN_MAPPED_FILES;
163 1.10 kleink goto yesno;
164 1.10 kleink case _SC_MEMLOCK:
165 1.10 kleink mib[0] = CTL_KERN;
166 1.10 kleink mib[1] = KERN_MEMLOCK;
167 1.10 kleink goto yesno;
168 1.10 kleink case _SC_MEMLOCK_RANGE:
169 1.10 kleink mib[0] = CTL_KERN;
170 1.10 kleink mib[1] = KERN_MEMLOCK_RANGE;
171 1.10 kleink goto yesno;
172 1.10 kleink case _SC_MEMORY_PROTECTION:
173 1.10 kleink mib[0] = CTL_KERN;
174 1.10 kleink mib[1] = KERN_MEMORY_PROTECTION;
175 1.14 kleink goto yesno;
176 1.14 kleink case _SC_MONOTONIC_CLOCK:
177 1.14 kleink mib[0] = CTL_KERN;
178 1.14 kleink mib[1] = KERN_MONOTONIC_CLOCK;
179 1.9 kleink goto yesno;
180 1.18 kleink case _SC_SEMAPHORES:
181 1.18 kleink mib[0] = CTL_KERN;
182 1.18 kleink mib[1] = KERN_POSIX_SEMAPHORES;
183 1.18 kleink goto yesno;
184 1.18 kleink case _SC_TIMERS:
185 1.18 kleink mib[0] = CTL_KERN;
186 1.18 kleink mib[1] = KERN_POSIX_TIMERS;
187 1.18 kleink goto yesno;
188 1.11 kleink
189 1.11 kleink /* 1003.1c */
190 1.11 kleink case _SC_LOGIN_NAME_MAX:
191 1.11 kleink mib[0] = CTL_KERN;
192 1.11 kleink mib[1] = KERN_LOGIN_NAME_MAX;
193 1.11 kleink break;
194 1.18 kleink case _SC_THREADS:
195 1.18 kleink mib[0] = CTL_KERN;
196 1.18 kleink mib[1] = KERN_POSIX_THREADS;
197 1.18 kleink goto yesno;
198 1.18 kleink
199 1.18 kleink /* 1003.1j */
200 1.18 kleink case _SC_BARRIERS:
201 1.18 kleink mib[0] = CTL_KERN;
202 1.18 kleink mib[1] = KERN_POSIX_BARRIERS;
203 1.18 kleink goto yesno;
204 1.18 kleink case _SC_SPIN_LOCKS:
205 1.18 kleink mib[0] = CTL_KERN;
206 1.18 kleink mib[1] = KERN_POSIX_SPIN_LOCKS;
207 1.18 kleink goto yesno;
208 1.18 kleink /* Historical; Threads option in 1003.1-2001 */
209 1.18 kleink case _SC_READER_WRITER_LOCKS:
210 1.18 kleink mib[0] = CTL_KERN;
211 1.18 kleink mib[1] = KERN_POSIX_READER_WRITER_LOCKS;
212 1.18 kleink goto yesno;
213 1.8 kleink
214 1.1 cgd /* 1003.2 */
215 1.1 cgd case _SC_BC_BASE_MAX:
216 1.1 cgd mib[0] = CTL_USER;
217 1.1 cgd mib[1] = USER_BC_BASE_MAX;
218 1.1 cgd break;
219 1.1 cgd case _SC_BC_DIM_MAX:
220 1.1 cgd mib[0] = CTL_USER;
221 1.1 cgd mib[1] = USER_BC_DIM_MAX;
222 1.1 cgd break;
223 1.1 cgd case _SC_BC_SCALE_MAX:
224 1.1 cgd mib[0] = CTL_USER;
225 1.1 cgd mib[1] = USER_BC_SCALE_MAX;
226 1.1 cgd break;
227 1.1 cgd case _SC_BC_STRING_MAX:
228 1.1 cgd mib[0] = CTL_USER;
229 1.1 cgd mib[1] = USER_BC_STRING_MAX;
230 1.1 cgd break;
231 1.1 cgd case _SC_COLL_WEIGHTS_MAX:
232 1.1 cgd mib[0] = CTL_USER;
233 1.1 cgd mib[1] = USER_COLL_WEIGHTS_MAX;
234 1.1 cgd break;
235 1.1 cgd case _SC_EXPR_NEST_MAX:
236 1.1 cgd mib[0] = CTL_USER;
237 1.1 cgd mib[1] = USER_EXPR_NEST_MAX;
238 1.1 cgd break;
239 1.1 cgd case _SC_LINE_MAX:
240 1.1 cgd mib[0] = CTL_USER;
241 1.1 cgd mib[1] = USER_LINE_MAX;
242 1.1 cgd break;
243 1.1 cgd case _SC_RE_DUP_MAX:
244 1.1 cgd mib[0] = CTL_USER;
245 1.1 cgd mib[1] = USER_RE_DUP_MAX;
246 1.1 cgd break;
247 1.1 cgd case _SC_2_VERSION:
248 1.1 cgd mib[0] = CTL_USER;
249 1.1 cgd mib[1] = USER_POSIX2_VERSION;
250 1.1 cgd break;
251 1.1 cgd case _SC_2_C_BIND:
252 1.1 cgd mib[0] = CTL_USER;
253 1.1 cgd mib[1] = USER_POSIX2_C_BIND;
254 1.1 cgd goto yesno;
255 1.1 cgd case _SC_2_C_DEV:
256 1.1 cgd mib[0] = CTL_USER;
257 1.1 cgd mib[1] = USER_POSIX2_C_DEV;
258 1.1 cgd goto yesno;
259 1.1 cgd case _SC_2_CHAR_TERM:
260 1.1 cgd mib[0] = CTL_USER;
261 1.1 cgd mib[1] = USER_POSIX2_CHAR_TERM;
262 1.1 cgd goto yesno;
263 1.1 cgd case _SC_2_FORT_DEV:
264 1.1 cgd mib[0] = CTL_USER;
265 1.1 cgd mib[1] = USER_POSIX2_FORT_DEV;
266 1.1 cgd goto yesno;
267 1.1 cgd case _SC_2_FORT_RUN:
268 1.1 cgd mib[0] = CTL_USER;
269 1.1 cgd mib[1] = USER_POSIX2_FORT_RUN;
270 1.1 cgd goto yesno;
271 1.1 cgd case _SC_2_LOCALEDEF:
272 1.1 cgd mib[0] = CTL_USER;
273 1.1 cgd mib[1] = USER_POSIX2_LOCALEDEF;
274 1.1 cgd goto yesno;
275 1.1 cgd case _SC_2_SW_DEV:
276 1.1 cgd mib[0] = CTL_USER;
277 1.1 cgd mib[1] = USER_POSIX2_SW_DEV;
278 1.1 cgd goto yesno;
279 1.1 cgd case _SC_2_UPE:
280 1.1 cgd mib[0] = CTL_USER;
281 1.1 cgd mib[1] = USER_POSIX2_UPE;
282 1.8 kleink goto yesno;
283 1.8 kleink
284 1.8 kleink /* XPG 4.2 */
285 1.9 kleink case _SC_IOV_MAX:
286 1.9 kleink mib[0] = CTL_KERN;
287 1.9 kleink mib[1] = KERN_IOV_MAX;
288 1.9 kleink break;
289 1.8 kleink case _SC_XOPEN_SHM:
290 1.8 kleink mib[0] = CTL_KERN;
291 1.22 christos mib[1] = KERN_SYSVIPC;
292 1.22 christos mib[2] = KERN_SYSVIPC_SHM;
293 1.23 rmind mib_len = 3;
294 1.23 rmind goto yesno;
295 1.17 kleink
296 1.17 kleink /* 1003.1-2001, XSI Option Group */
297 1.23 rmind case _SC_AIO_LISTIO_MAX:
298 1.23 rmind if (sysctlgetmibinfo("kern.aio_listio_max", &mib[0], &mib_len,
299 1.23 rmind NULL, NULL, NULL, SYSCTL_VERSION))
300 1.23 rmind return -1;
301 1.23 rmind break;
302 1.23 rmind case _SC_AIO_MAX:
303 1.23 rmind if (sysctlgetmibinfo("kern.aio_max", &mib[0], &mib_len,
304 1.23 rmind NULL, NULL, NULL, SYSCTL_VERSION))
305 1.23 rmind return -1;
306 1.23 rmind break;
307 1.23 rmind case _SC_ASYNCHRONOUS_IO:
308 1.23 rmind if (sysctlgetmibinfo("kern.posix_aio", &mib[0], &mib_len,
309 1.23 rmind NULL, NULL, NULL, SYSCTL_VERSION))
310 1.23 rmind return -1;
311 1.23 rmind goto yesno;
312 1.24 rmind case _SC_MESSAGE_PASSING:
313 1.24 rmind if (sysctlgetmibinfo("kern.posix_msg", &mib[0], &mib_len,
314 1.24 rmind NULL, NULL, NULL, SYSCTL_VERSION))
315 1.24 rmind return -1;
316 1.24 rmind goto yesno;
317 1.24 rmind case _SC_MQ_OPEN_MAX:
318 1.29 njoly if (sysctlgetmibinfo("kern.mqueue.mq_open_max", &mib[0],
319 1.29 njoly &mib_len, NULL, NULL, NULL, SYSCTL_VERSION))
320 1.24 rmind return -1;
321 1.24 rmind break;
322 1.24 rmind case _SC_MQ_PRIO_MAX:
323 1.29 njoly if (sysctlgetmibinfo("kern.mqueue.mq_prio_max", &mib[0],
324 1.29 njoly &mib_len, NULL, NULL, NULL, SYSCTL_VERSION))
325 1.24 rmind return -1;
326 1.24 rmind break;
327 1.26 rmind case _SC_PRIORITY_SCHEDULING:
328 1.26 rmind if (sysctlgetmibinfo("kern.posix_sched", &mib[0], &mib_len,
329 1.26 rmind NULL, NULL, NULL, SYSCTL_VERSION))
330 1.26 rmind return -1;
331 1.26 rmind goto yesno;
332 1.17 kleink case _SC_ATEXIT_MAX:
333 1.17 kleink mib[0] = CTL_USER;
334 1.17 kleink mib[1] = USER_ATEXIT_MAX;
335 1.17 kleink break;
336 1.17 kleink
337 1.20 lukem /* 1003.1-2001, TSF */
338 1.20 lukem case _SC_GETGR_R_SIZE_MAX:
339 1.20 lukem return _GETGR_R_SIZE_MAX;
340 1.20 lukem case _SC_GETPW_R_SIZE_MAX:
341 1.20 lukem return _GETPW_R_SIZE_MAX;
342 1.20 lukem
343 1.33 matt /* Unsorted */
344 1.42 maya case _SC_RTSIG_MAX:
345 1.42 maya return SIGRTMAX - SIGRTMIN;
346 1.33 matt case _SC_HOST_NAME_MAX:
347 1.33 matt return MAXHOSTNAMELEN;
348 1.33 matt case _SC_PASS_MAX:
349 1.33 matt return _PASSWORD_LEN;
350 1.33 matt case _SC_REGEXP:
351 1.33 matt return _POSIX_REGEXP;
352 1.36 rmind case _SC_SHARED_MEMORY_OBJECTS:
353 1.36 rmind return _POSIX_SHARED_MEMORY_OBJECTS;
354 1.33 matt case _SC_SHELL:
355 1.33 matt return _POSIX_SHELL;
356 1.34 martin case _SC_SPAWN:
357 1.34 martin return _POSIX_SPAWN;
358 1.33 matt case _SC_SYMLOOP_MAX:
359 1.33 matt return MAXSYMLINKS;
360 1.33 matt
361 1.23 rmind yesno: if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1)
362 1.1 cgd return (-1);
363 1.1 cgd if (value == 0)
364 1.1 cgd return (-1);
365 1.1 cgd return (value);
366 1.25 ad
367 1.25 ad /* Extensions */
368 1.25 ad case _SC_NPROCESSORS_CONF:
369 1.25 ad mib[0] = CTL_HW;
370 1.25 ad mib[1] = HW_NCPU;
371 1.25 ad break;
372 1.25 ad case _SC_NPROCESSORS_ONLN:
373 1.25 ad mib[0] = CTL_HW;
374 1.25 ad mib[1] = HW_NCPUONLINE;
375 1.25 ad break;
376 1.25 ad
377 1.35 christos /* Linux/Solaris */
378 1.35 christos case _SC_PHYS_PAGES:
379 1.35 christos len = sizeof(mem);
380 1.35 christos mib[0] = CTL_HW;
381 1.35 christos mib[1] = HW_PHYSMEM64;
382 1.35 christos return sysctl(mib, 2, &mem, &len, NULL, 0) == -1 ? -1 :
383 1.35 christos (long)(mem / _getpagesize());
384 1.35 christos
385 1.44 simonb case _SC_AVPHYS_PAGES:
386 1.44 simonb len = sizeof(uvmexp);
387 1.44 simonb mib[0] = CTL_VM;
388 1.44 simonb mib[1] = VM_UVMEXP2;
389 1.44 simonb return sysctl(mib, 2, &uvmexp, &len, NULL, 0) == -1 ? -1 :
390 1.44 simonb (long)(uvmexp.free);
391 1.44 simonb
392 1.26 rmind /* Native */
393 1.26 rmind case _SC_SCHED_RT_TS:
394 1.27 rmind if (sysctlgetmibinfo("kern.sched.rtts", &mib[0], &mib_len,
395 1.26 rmind NULL, NULL, NULL, SYSCTL_VERSION))
396 1.26 rmind return -1;
397 1.26 rmind break;
398 1.26 rmind case _SC_SCHED_PRI_MIN:
399 1.26 rmind if (sysctlgetmibinfo("kern.sched.pri_min", &mib[0], &mib_len,
400 1.26 rmind NULL, NULL, NULL, SYSCTL_VERSION))
401 1.26 rmind return -1;
402 1.26 rmind break;
403 1.26 rmind case _SC_SCHED_PRI_MAX:
404 1.26 rmind if (sysctlgetmibinfo("kern.sched.pri_max", &mib[0], &mib_len,
405 1.26 rmind NULL, NULL, NULL, SYSCTL_VERSION))
406 1.26 rmind return -1;
407 1.26 rmind break;
408 1.30 ad case _SC_THREAD_DESTRUCTOR_ITERATIONS:
409 1.30 ad return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
410 1.30 ad case _SC_THREAD_KEYS_MAX:
411 1.30 ad return _POSIX_THREAD_KEYS_MAX;
412 1.30 ad case _SC_THREAD_STACK_MIN:
413 1.30 ad return _getpagesize();
414 1.30 ad case _SC_THREAD_THREADS_MAX:
415 1.30 ad if (sysctlgetmibinfo("kern.maxproc", &mib[0], &mib_len,
416 1.30 ad NULL, NULL, NULL, SYSCTL_VERSION)) /* XXX */
417 1.30 ad return -1;
418 1.30 ad goto yesno;
419 1.30 ad case _SC_THREAD_ATTR_STACKADDR:
420 1.30 ad return _POSIX_THREAD_ATTR_STACKADDR;
421 1.30 ad case _SC_THREAD_ATTR_STACKSIZE:
422 1.30 ad return _POSIX_THREAD_ATTR_STACKSIZE;
423 1.30 ad case _SC_THREAD_SAFE_FUNCTIONS:
424 1.30 ad return _POSIX_THREAD_SAFE_FUNCTIONS;
425 1.40 christos case _SC_THREAD_PRIO_PROTECT:
426 1.40 christos return _POSIX_THREAD_PRIO_PROTECT;
427 1.30 ad case _SC_THREAD_PRIORITY_SCHEDULING:
428 1.30 ad case _SC_THREAD_PRIO_INHERIT:
429 1.30 ad case _SC_THREAD_PROCESS_SHARED:
430 1.31 ad return -1;
431 1.32 ad case _SC_TTY_NAME_MAX:
432 1.32 ad return pathconf(_PATH_DEV, _PC_NAME_MAX);
433 1.37 christos case _SC_TIMER_MAX:
434 1.37 christos return _POSIX_TIMER_MAX;
435 1.38 christos case _SC_SEM_NSEMS_MAX:
436 1.43 joerg return LONG_MAX;
437 1.39 christos case _SC_CPUTIME:
438 1.39 christos return _POSIX_CPUTIME;
439 1.39 christos case _SC_THREAD_CPUTIME:
440 1.39 christos return _POSIX_THREAD_CPUTIME;
441 1.39 christos case _SC_DELAYTIMER_MAX:
442 1.39 christos return _POSIX_DELAYTIMER_MAX;
443 1.41 christos case _SC_SIGQUEUE_MAX:
444 1.41 christos return _POSIX_SIGQUEUE_MAX;
445 1.41 christos case _SC_REALTIME_SIGNALS:
446 1.41 christos return 200112L;
447 1.1 cgd default:
448 1.1 cgd errno = EINVAL;
449 1.1 cgd return (-1);
450 1.1 cgd }
451 1.23 rmind return (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1 ? -1 : value);
452 1.1 cgd }
453