4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2013 Gary Mills
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 /* Copyright (c) 1988 AT&T */
30 /* All Rights Reserved */
32 /* sysconf(3C) - returns system configuration information */
34 #pragma weak _sysconf = sysconf
38 #include <sys/types.h>
40 #include <sys/sysconfig.h>
44 #include <nss_dbdefs.h>
50 /* from nss_common.c */
51 extern size_t _nss_get_bufsizes(int);
56 static int _pagesize
= 0;
58 static pid_t _maxpid
= 0;
59 static int _stackprot
= 0;
60 static int _ngroups_max
;
69 return ((long)ARG_MAX
);
73 _hz
= _sysconfig(_CONFIG_CLK_TCK
);
77 return ((long)_POSIX_JOB_CONTROL
);
80 return ((long)_POSIX_SAVED_IDS
);
83 return (_sysconfig(_CONFIG_CHILD_MAX
));
86 if (_ngroups_max
<= 0)
87 _ngroups_max
= _sysconfig(_CONFIG_NGROUPS
);
88 return (_ngroups_max
);
91 return (_sysconfig(_CONFIG_OPEN_FILES
));
94 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
101 _pagesize
= _sysconfig(_CONFIG_PAGESIZE
);
104 case _SC_XOPEN_VERSION
:
105 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
107 else if (__xpg4
== 0)
108 return (_sysconfig(_CONFIG_XOPEN_VER
));
112 case _SC_XOPEN_XCU_VERSION
:
113 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
119 * old value for pre XPG5 conformant systems to match
121 * XPG5 special cased with __sysconf_xpg5()
122 * new value for default and modern XPG systems.
126 (!(__xpg6
& _C99SUSv3_XPG6_sysconf_version
)))
127 return ((long)_PASS_MAX_XPG
);
129 return ((long)_PASS_MAX
);
131 case _SC_LOGNAME_MAX
:
132 return ((long)LOGNAME_MAX
);
135 return (_sysconfig(_CONFIG_OPEN_FILES
));
140 case _SC_NPROCESSORS_CONF
:
141 return (_sysconfig(_CONFIG_NPROC_CONF
));
143 case _SC_NPROCESSORS_ONLN
:
144 return (_sysconfig(_CONFIG_NPROC_ONLN
));
146 case _SC_NPROCESSORS_MAX
:
147 return (_sysconfig(_CONFIG_NPROC_MAX
));
151 _stackprot
= _sysconfig(_CONFIG_STACK_PROT
);
157 * Each of the following also have _POSIX_* symbols
158 * defined in <unistd.h>. Values here should align
159 * with values in the header. Up until the SUSv3 standard
160 * we defined these simply as 1. With the introduction
161 * of the new revision, these were changed to 200112L.
162 * The standard allows us to change the value, however,
163 * we have kept both values in case application programs
164 * are relying on the previous value even though an
165 * application doing so is technically wrong.
167 case _SC_ASYNCHRONOUS_IO
:
169 case _SC_MAPPED_FILES
:
171 case _SC_MEMLOCK_RANGE
:
172 case _SC_MEMORY_PROTECTION
:
173 case _SC_MESSAGE_PASSING
:
174 case _SC_PRIORITY_SCHEDULING
:
175 case _SC_REALTIME_SIGNALS
:
177 case _SC_SHARED_MEMORY_OBJECTS
:
178 case _SC_SYNCHRONIZED_IO
:
180 if (__xpg6
& _C99SUSv3_mode_ON
)
185 case _SC_PRIORITIZED_IO
:
186 #ifdef _POSIX_PRIORITIZED_IO
192 case _SC_AIO_LISTIO_MAX
:
193 return (_sysconfig(_CONFIG_AIO_LISTIO_MAX
));
196 return (_sysconfig(_CONFIG_AIO_MAX
));
198 case _SC_AIO_PRIO_DELTA_MAX
:
199 return (_sysconfig(_CONFIG_AIO_PRIO_DELTA_MAX
));
201 case _SC_DELAYTIMER_MAX
:
202 return (_sysconfig(_CONFIG_DELAYTIMER_MAX
));
204 case _SC_MQ_OPEN_MAX
:
205 return (_sysconfig(_CONFIG_MQ_OPEN_MAX
));
207 case _SC_MQ_PRIO_MAX
:
208 return (_sysconfig(_CONFIG_MQ_PRIO_MAX
));
211 return (_sysconfig(_CONFIG_RTSIG_MAX
));
213 case _SC_SEM_NSEMS_MAX
:
214 return (_sysconfig(_CONFIG_SEM_NSEMS_MAX
));
216 case _SC_SEM_VALUE_MAX
:
217 return (_sysconfig(_CONFIG_SEM_VALUE_MAX
));
219 case _SC_SIGQUEUE_MAX
:
220 return (_sysconfig(_CONFIG_SIGQUEUE_MAX
));
223 return (_sysconfig(_CONFIG_SIGRT_MAX
));
226 return (_sysconfig(_CONFIG_SIGRT_MIN
));
229 return (_sysconfig(_CONFIG_TIMER_MAX
));
232 return (_sysconfig(_CONFIG_PHYS_PAGES
));
234 case _SC_AVPHYS_PAGES
:
235 return (_sysconfig(_CONFIG_AVPHYS_PAGES
));
237 /* XPG4/POSIX.1-1990/POSIX.2-1992 names */
239 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
244 case _SC_2_CHAR_TERM
:
245 return ((long)_POSIX2_CHAR_TERM
);
248 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
253 case _SC_2_C_VERSION
:
254 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
263 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
268 case _SC_2_LOCALEDEF
:
269 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
275 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
281 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
287 if (__xpg6
& _C99SUSv3_XPG6_sysconf_version
)
292 case _SC_BC_BASE_MAX
:
293 return ((long)BC_BASE_MAX
);
296 return ((long)BC_DIM_MAX
);
298 case _SC_BC_SCALE_MAX
:
299 return ((long)BC_SCALE_MAX
);
301 case _SC_BC_STRING_MAX
:
302 return ((long)BC_STRING_MAX
);
304 case _SC_COLL_WEIGHTS_MAX
:
305 return ((long)COLL_WEIGHTS_MAX
);
307 case _SC_EXPR_NEST_MAX
:
308 return ((long)EXPR_NEST_MAX
);
311 return ((long)LINE_MAX
);
314 return ((long)RE_DUP_MAX
);
316 case _SC_XOPEN_CRYPT
:
319 case _SC_XOPEN_ENH_I18N
:
320 return ((long)_XOPEN_ENH_I18N
);
323 return ((long)_XOPEN_SHM
);
325 /* XPG4v2 (SUS) names */
329 case _SC_XOPEN_LEGACY
:
336 return ((long)IOV_MAX
);
339 return ((long)T_IOV_MAX
);
341 /* XPG5 (SUSv2) names */
342 case _SC_XOPEN_REALTIME
:
345 case _SC_XOPEN_REALTIME_THREADS
:
346 #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && \
347 defined(_POSIX_THREAD_PRIO_INHERIT) && \
348 defined(_POSIX_THREAD_PRIO_PROTECT)
354 case _SC_XBS5_ILP32_OFF32
:
357 case _SC_XBS5_ILP32_OFFBIG
:
360 case _SC_XBS5_LP64_OFF64
:
363 case _SC_XBS5_LPBIG_OFFBIG
:
367 case _SC_THREAD_DESTRUCTOR_ITERATIONS
:
370 case _SC_GETGR_R_SIZE_MAX
:
371 return ((long)_nss_get_bufsizes(_SC_GETGR_R_SIZE_MAX
));
373 case _SC_GETPW_R_SIZE_MAX
:
374 return ((long)NSS_BUFLEN_PASSWD
);
376 case _SC_LOGIN_NAME_MAX
:
377 return ((long)(LOGIN_NAME_MAX
));
379 case _SC_THREAD_KEYS_MAX
:
382 case _SC_THREAD_STACK_MIN
:
383 return ((long)thr_min_stack());
385 case _SC_THREAD_THREADS_MAX
:
388 case _SC_TTY_NAME_MAX
:
389 return ((long)TTYNAME_MAX
);
392 return ((long)_POSIX_BARRIERS
);
394 case _SC_CLOCK_SELECTION
:
395 return ((long)_POSIX_CLOCK_SELECTION
);
397 case _SC_MONOTONIC_CLOCK
:
398 return ((long)_POSIX_MONOTONIC_CLOCK
);
401 return ((long)_POSIX_SPAWN
);
404 return ((long)_POSIX_SPIN_LOCKS
);
407 case _SC_THREAD_ATTR_STACKADDR
:
408 case _SC_THREAD_ATTR_STACKSIZE
:
409 case _SC_THREAD_PRIORITY_SCHEDULING
:
410 case _SC_THREAD_PRIO_INHERIT
:
411 case _SC_THREAD_PRIO_PROTECT
:
412 case _SC_THREAD_PROCESS_SHARED
:
413 case _SC_THREAD_SAFE_FUNCTIONS
:
414 if (__xpg6
& _C99SUSv3_mode_ON
)
420 return ((long)_POSIX_TIMEOUTS
);
422 /* 1216676 - cache info */
423 case _SC_COHER_BLKSZ
:
424 return (_sysconfig(_CONFIG_COHERENCY
));
426 case _SC_SPLIT_CACHE
:
427 return (_sysconfig(_CONFIG_SPLIT_CACHE
));
430 return (_sysconfig(_CONFIG_ICACHESZ
));
433 return (_sysconfig(_CONFIG_DCACHESZ
));
435 case _SC_ICACHE_LINESZ
:
436 return (_sysconfig(_CONFIG_ICACHELINESZ
));
438 case _SC_DCACHE_LINESZ
:
439 return (_sysconfig(_CONFIG_DCACHELINESZ
));
441 case _SC_ICACHE_BLKSZ
:
442 return (_sysconfig(_CONFIG_ICACHEBLKSZ
));
444 case _SC_DCACHE_BLKSZ
:
445 return (_sysconfig(_CONFIG_DCACHEBLKSZ
));
447 case _SC_DCACHE_TBLKSZ
:
448 return (_sysconfig(_CONFIG_DCACHETBLKSZ
));
450 case _SC_ICACHE_ASSOC
:
451 return (_sysconfig(_CONFIG_ICACHE_ASSOC
));
453 case _SC_DCACHE_ASSOC
:
454 return (_sysconfig(_CONFIG_DCACHE_ASSOC
));
458 _maxpid
= _sysconfig(_CONFIG_MAXPID
);
462 return (_sysconfig(_CONFIG_CPUID_MAX
));
465 return (_sysconfig(_CONFIG_EPHID_MAX
));
467 /* UNIX 03 names - XPG6/SUSv3/POSIX.1-2001 */
470 return ((long)_POSIX_REGEXP
);
473 return ((long)_POSIX_SHELL
);
475 case _SC_ADVISORY_INFO
:
476 return ((long)_POSIX_ADVISORY_INFO
);
478 case _SC_HOST_NAME_MAX
:
479 return ((long)_POSIX_HOST_NAME_MAX
);
481 case _SC_READER_WRITER_LOCKS
:
482 return ((long)_POSIX_READER_WRITER_LOCKS
);
485 return ((long)_POSIX_IPV6
);
487 case _SC_RAW_SOCKETS
:
488 return ((long)_POSIX_RAW_SOCKETS
);
490 case _SC_XOPEN_STREAMS
:
491 return ((long)_XOPEN_STREAMS
);
493 case _SC_SYMLOOP_MAX
:
494 return (_sysconfig(_CONFIG_SYMLOOP_MAX
));
496 case _SC_V6_ILP32_OFF32
:
499 case _SC_V6_ILP32_OFFBIG
:
502 case _SC_V6_LP64_OFF64
:
505 case _SC_V6_LPBIG_OFFBIG
:
508 /* Unsupported UNIX 03 options */
510 case _SC_2_PBS_ACCOUNTING
:
511 case _SC_2_PBS_CHECKPOINT
:
512 case _SC_2_PBS_LOCATE
:
513 case _SC_2_PBS_MESSAGE
:
514 case _SC_2_PBS_TRACK
:
516 case _SC_SPORADIC_SERVER
:
517 case _SC_SS_REPL_MAX
:
518 case _SC_THREAD_CPUTIME
:
519 case _SC_THREAD_SPORADIC_SERVER
:
521 case _SC_TRACE_EVENT_FILTER
:
522 case _SC_TRACE_EVENT_NAME_MAX
:
523 case _SC_TRACE_INHERIT
:
525 case _SC_TRACE_NAME_MAX
:
526 case _SC_TRACE_SYS_MAX
:
527 case _SC_TRACE_USER_EVENT_MAX
:
528 case _SC_TYPED_MEMORY_OBJECTS
:
534 * UNIX 98 version of sysconf needed in order to set _XOPEN_VERSION to 500.
538 __sysconf_xpg5(int name
)
542 return (sysconf(name
));
543 case _SC_XOPEN_VERSION
:
546 return ((long)_PASS_MAX_XPG
);