xref: /illumos-gate/usr/src/lib/libc/port/gen/sysconf.c (revision 4c46c814)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5f48205beScasper  * Common Development and Distribution License (the "License").
6f48205beScasper  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217257d1b4Sraf 
227c478bd9Sstevel@tonic-gate /*
230a1278f2SGary Mills  * Copyright (c) 2013 Gary Mills
240a1278f2SGary Mills  *
2567dbe2beSCasper H.S. Dik  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
30*4c46c814SRobert Mustacchi /*	  All Rights Reserved	*/
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /* sysconf(3C) - returns system configuration information */
337c478bd9Sstevel@tonic-gate 
347257d1b4Sraf #pragma weak _sysconf = sysconf
357c478bd9Sstevel@tonic-gate 
367257d1b4Sraf #include "lint.h"
377c478bd9Sstevel@tonic-gate #include <mtlib.h>
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <unistd.h>
407c478bd9Sstevel@tonic-gate #include <sys/sysconfig.h>
417c478bd9Sstevel@tonic-gate #include <limits.h>
427c478bd9Sstevel@tonic-gate #include <time.h>
437c478bd9Sstevel@tonic-gate #include <errno.h>
447c478bd9Sstevel@tonic-gate #include <nss_dbdefs.h>
457c478bd9Sstevel@tonic-gate #include <thread.h>
467c478bd9Sstevel@tonic-gate #include <xti.h>
477c478bd9Sstevel@tonic-gate #include "libc.h"
487c478bd9Sstevel@tonic-gate #include "xpg6.h"
497c478bd9Sstevel@tonic-gate 
506dd84139Sdjl /* from nss_common.c */
516dd84139Sdjl extern size_t _nss_get_bufsizes(int);
526dd84139Sdjl 
537c478bd9Sstevel@tonic-gate long
sysconf(int name)547c478bd9Sstevel@tonic-gate sysconf(int name)
557c478bd9Sstevel@tonic-gate {
567c478bd9Sstevel@tonic-gate 	static int _pagesize = 0;
577c478bd9Sstevel@tonic-gate 	static int _hz = 0;
587c478bd9Sstevel@tonic-gate 	static pid_t _maxpid = 0;
597c478bd9Sstevel@tonic-gate 	static int _stackprot = 0;
6067dbe2beSCasper H.S. Dik 	static int _ngroups_max;
617c478bd9Sstevel@tonic-gate 	extern int __xpg4;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 	switch (name) {
647c478bd9Sstevel@tonic-gate 		default:
657c478bd9Sstevel@tonic-gate 			errno = EINVAL;
667c478bd9Sstevel@tonic-gate 			return (-1L);
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 		case _SC_ARG_MAX:
697c478bd9Sstevel@tonic-gate 			return ((long)ARG_MAX);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 		case _SC_CLK_TCK:
727c478bd9Sstevel@tonic-gate 			if (_hz <= 0)
737c478bd9Sstevel@tonic-gate 				_hz = _sysconfig(_CONFIG_CLK_TCK);
747c478bd9Sstevel@tonic-gate 			return (_hz);
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate 		case _SC_JOB_CONTROL:
777c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_JOB_CONTROL);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 		case _SC_SAVED_IDS:
807c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_SAVED_IDS);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 		case _SC_CHILD_MAX:
837c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_CHILD_MAX));
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 		case _SC_NGROUPS_MAX:
8667dbe2beSCasper H.S. Dik 			if (_ngroups_max <= 0)
8767dbe2beSCasper H.S. Dik 				_ngroups_max = _sysconfig(_CONFIG_NGROUPS);
8867dbe2beSCasper H.S. Dik 			return (_ngroups_max);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 		case _SC_OPEN_MAX:
917c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_OPEN_FILES));
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 		case _SC_VERSION:
947c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
957c478bd9Sstevel@tonic-gate 				return (200112L);
967c478bd9Sstevel@tonic-gate 			else
977c478bd9Sstevel@tonic-gate 				return (199506L);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 		case _SC_PAGESIZE:
1007c478bd9Sstevel@tonic-gate 			if (_pagesize <= 0)
1017c478bd9Sstevel@tonic-gate 				_pagesize = _sysconfig(_CONFIG_PAGESIZE);
1027c478bd9Sstevel@tonic-gate 			return (_pagesize);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_VERSION:
1057c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
1067c478bd9Sstevel@tonic-gate 				return (600L);
1077c478bd9Sstevel@tonic-gate 			else if (__xpg4 == 0)
1087c478bd9Sstevel@tonic-gate 				return (_sysconfig(_CONFIG_XOPEN_VER));
1097c478bd9Sstevel@tonic-gate 			else
1107c478bd9Sstevel@tonic-gate 				return (4L);
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_XCU_VERSION:
1137c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
1147c478bd9Sstevel@tonic-gate 				return (600L);
1157c478bd9Sstevel@tonic-gate 			else
1167c478bd9Sstevel@tonic-gate 				return (4L);
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 		/*
1197c478bd9Sstevel@tonic-gate 		 * old value for pre XPG5 conformant systems to match
1207c478bd9Sstevel@tonic-gate 		 * getpass() length.
1217c478bd9Sstevel@tonic-gate 		 * XPG5 special cased with __sysconf_xpg5()
1227c478bd9Sstevel@tonic-gate 		 * new value for default and modern XPG systems.
1237c478bd9Sstevel@tonic-gate 		 */
1247c478bd9Sstevel@tonic-gate 		case _SC_PASS_MAX:
1257c478bd9Sstevel@tonic-gate 			if ((__xpg4 == 1) &&
1267c478bd9Sstevel@tonic-gate 			    (!(__xpg6 & _C99SUSv3_XPG6_sysconf_version)))
1277c478bd9Sstevel@tonic-gate 				return ((long)_PASS_MAX_XPG);
1287c478bd9Sstevel@tonic-gate 			else
1297c478bd9Sstevel@tonic-gate 				return ((long)_PASS_MAX);
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 		case _SC_LOGNAME_MAX:
1327c478bd9Sstevel@tonic-gate 			return ((long)LOGNAME_MAX);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 		case _SC_STREAM_MAX:
1357c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_OPEN_FILES));
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 		case _SC_TZNAME_MAX:
1387c478bd9Sstevel@tonic-gate 			return (-1L);
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 		case _SC_NPROCESSORS_CONF:
1417c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_CONF));
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 		case _SC_NPROCESSORS_ONLN:
1447c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_ONLN));
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate 		case _SC_NPROCESSORS_MAX:
1477c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_MAX));
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 		case _SC_STACK_PROT:
1507c478bd9Sstevel@tonic-gate 			if (_stackprot == 0)
1517c478bd9Sstevel@tonic-gate 				_stackprot = _sysconfig(_CONFIG_STACK_PROT);
1527c478bd9Sstevel@tonic-gate 			return (_stackprot);
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 		/* POSIX.4 names */
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 		/*
1577c478bd9Sstevel@tonic-gate 		 * Each of the following also have _POSIX_* symbols
1587c478bd9Sstevel@tonic-gate 		 * defined in <unistd.h>. Values here should align
1597c478bd9Sstevel@tonic-gate 		 * with values in the header. Up until the SUSv3 standard
1607c478bd9Sstevel@tonic-gate 		 * we defined these simply as 1. With the introduction
1617c478bd9Sstevel@tonic-gate 		 * of the new revision, these were changed to 200112L.
1627c478bd9Sstevel@tonic-gate 		 * The standard allows us to change the value, however,
1637c478bd9Sstevel@tonic-gate 		 * we have kept both values in case application programs
1647c478bd9Sstevel@tonic-gate 		 * are relying on the previous value even though an
1657c478bd9Sstevel@tonic-gate 		 * application doing so is technically wrong.
1667c478bd9Sstevel@tonic-gate 		 */
1677c478bd9Sstevel@tonic-gate 		case _SC_ASYNCHRONOUS_IO:
1687c478bd9Sstevel@tonic-gate 		case _SC_FSYNC:
1697c478bd9Sstevel@tonic-gate 		case _SC_MAPPED_FILES:
1707c478bd9Sstevel@tonic-gate 		case _SC_MEMLOCK:
1717c478bd9Sstevel@tonic-gate 		case _SC_MEMLOCK_RANGE:
1727c478bd9Sstevel@tonic-gate 		case _SC_MEMORY_PROTECTION:
1737c478bd9Sstevel@tonic-gate 		case _SC_MESSAGE_PASSING:
1747c478bd9Sstevel@tonic-gate 		case _SC_PRIORITY_SCHEDULING:
1757c478bd9Sstevel@tonic-gate 		case _SC_REALTIME_SIGNALS:
1767c478bd9Sstevel@tonic-gate 		case _SC_SEMAPHORES:
1777c478bd9Sstevel@tonic-gate 		case _SC_SHARED_MEMORY_OBJECTS:
1787c478bd9Sstevel@tonic-gate 		case _SC_SYNCHRONIZED_IO:
1797c478bd9Sstevel@tonic-gate 		case _SC_TIMERS:
1807c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_mode_ON)
1817c478bd9Sstevel@tonic-gate 				return (200112L);
1827c478bd9Sstevel@tonic-gate 			else
1837c478bd9Sstevel@tonic-gate 				return (1L);
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 		case _SC_PRIORITIZED_IO:
1867c478bd9Sstevel@tonic-gate #ifdef _POSIX_PRIORITIZED_IO
1877c478bd9Sstevel@tonic-gate 			return (1L);
1887c478bd9Sstevel@tonic-gate #else
1897c478bd9Sstevel@tonic-gate 			return (-1L);
1907c478bd9Sstevel@tonic-gate #endif
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 		case _SC_AIO_LISTIO_MAX:
1937c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_LISTIO_MAX));
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 		case _SC_AIO_MAX:
1967c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_MAX));
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 		case _SC_AIO_PRIO_DELTA_MAX:
1997c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_PRIO_DELTA_MAX));
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate 		case _SC_DELAYTIMER_MAX:
2027c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DELAYTIMER_MAX));
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate 		case _SC_MQ_OPEN_MAX:
2057c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_MQ_OPEN_MAX));
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 		case _SC_MQ_PRIO_MAX:
2087c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_MQ_PRIO_MAX));
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 		case _SC_RTSIG_MAX:
2117c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_RTSIG_MAX));
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 		case _SC_SEM_NSEMS_MAX:
2147c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SEM_NSEMS_MAX));
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 		case _SC_SEM_VALUE_MAX:
2177c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SEM_VALUE_MAX));
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 		case _SC_SIGQUEUE_MAX:
2207c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGQUEUE_MAX));
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 		case _SC_SIGRT_MAX:
2237c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGRT_MAX));
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate 		case _SC_SIGRT_MIN:
2267c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGRT_MIN));
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 		case _SC_TIMER_MAX:
2297c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_TIMER_MAX));
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 		case _SC_PHYS_PAGES:
2327c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_PHYS_PAGES));
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate 		case _SC_AVPHYS_PAGES:
2357c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AVPHYS_PAGES));
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 		/* XPG4/POSIX.1-1990/POSIX.2-1992 names */
2387c478bd9Sstevel@tonic-gate 		case _SC_2_C_BIND:
2391d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2401d4a595aSdamico 				return (200112L);
2411d4a595aSdamico 			else
2421d4a595aSdamico 				return (1L);
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 		case _SC_2_CHAR_TERM:
2457c478bd9Sstevel@tonic-gate 			return ((long)_POSIX2_CHAR_TERM);
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 		case _SC_2_C_DEV:
2481d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2491d4a595aSdamico 				return (200112L);
2501d4a595aSdamico 			else
2511d4a595aSdamico 				return (1L);
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate 		case _SC_2_C_VERSION:
2547c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2557c478bd9Sstevel@tonic-gate 				return (200112L);
2567c478bd9Sstevel@tonic-gate 			else
2577c478bd9Sstevel@tonic-gate 				return (199209L);
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate 		case _SC_2_FORT_DEV:
2607c478bd9Sstevel@tonic-gate 			return (-1L);
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 		case _SC_2_FORT_RUN:
2631d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2641d4a595aSdamico 				return (200112L);
2651d4a595aSdamico 			else
2661d4a595aSdamico 				return (1L);
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 		case _SC_2_LOCALEDEF:
2691d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2701d4a595aSdamico 				return (200112L);
2711d4a595aSdamico 			else
2721d4a595aSdamico 				return (1L);
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 		case _SC_2_SW_DEV:
2751d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2761d4a595aSdamico 				return (200112L);
2771d4a595aSdamico 			else
2781d4a595aSdamico 				return (1L);
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 		case _SC_2_UPE:
2811d4a595aSdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2821d4a595aSdamico 				return (200112L);
2831d4a595aSdamico 			else
2841d4a595aSdamico 				return (1L);
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate 		case _SC_2_VERSION:
2877c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2887c478bd9Sstevel@tonic-gate 				return (200112L);
2897c478bd9Sstevel@tonic-gate 			else
2907c478bd9Sstevel@tonic-gate 				return (199209L);
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 		case _SC_BC_BASE_MAX:
2937c478bd9Sstevel@tonic-gate 			return ((long)BC_BASE_MAX);
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 		case _SC_BC_DIM_MAX:
2967c478bd9Sstevel@tonic-gate 			return ((long)BC_DIM_MAX);
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate 		case _SC_BC_SCALE_MAX:
2997c478bd9Sstevel@tonic-gate 			return ((long)BC_SCALE_MAX);
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 		case _SC_BC_STRING_MAX:
3027c478bd9Sstevel@tonic-gate 			return ((long)BC_STRING_MAX);
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 		case _SC_COLL_WEIGHTS_MAX:
3057c478bd9Sstevel@tonic-gate 			return ((long)COLL_WEIGHTS_MAX);
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate 		case _SC_EXPR_NEST_MAX:
3087c478bd9Sstevel@tonic-gate 			return ((long)EXPR_NEST_MAX);
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 		case _SC_LINE_MAX:
3117c478bd9Sstevel@tonic-gate 			return ((long)LINE_MAX);
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 		case _SC_RE_DUP_MAX:
3147c478bd9Sstevel@tonic-gate 			return ((long)RE_DUP_MAX);
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_CRYPT:
3177c478bd9Sstevel@tonic-gate 			return (1L);
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_ENH_I18N:
3207c478bd9Sstevel@tonic-gate 			return ((long)_XOPEN_ENH_I18N);
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_SHM:
3237c478bd9Sstevel@tonic-gate 			return ((long)_XOPEN_SHM);
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 		/* XPG4v2 (SUS) names */
3267c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_UNIX:
3277c478bd9Sstevel@tonic-gate 			return (1L);
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_LEGACY:
3307c478bd9Sstevel@tonic-gate 			return (1L);
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate 		case _SC_ATEXIT_MAX:
3337c478bd9Sstevel@tonic-gate 			return (-1L);
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 		case _SC_IOV_MAX:
3367c478bd9Sstevel@tonic-gate 			return ((long)IOV_MAX);
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 		case _SC_T_IOV_MAX:
3397c478bd9Sstevel@tonic-gate 			return ((long)T_IOV_MAX);
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate 		/* XPG5 (SUSv2) names */
3427c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_REALTIME:
3437c478bd9Sstevel@tonic-gate 			return (1L);
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_REALTIME_THREADS:
3467c478bd9Sstevel@tonic-gate #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && \
3477c478bd9Sstevel@tonic-gate 	defined(_POSIX_THREAD_PRIO_INHERIT) && \
3487c478bd9Sstevel@tonic-gate 	defined(_POSIX_THREAD_PRIO_PROTECT)
3497c478bd9Sstevel@tonic-gate 			return (1L);
3507c478bd9Sstevel@tonic-gate #else
3517c478bd9Sstevel@tonic-gate 			return (-1L);
3527c478bd9Sstevel@tonic-gate #endif
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate 		case _SC_XBS5_ILP32_OFF32:
3557c478bd9Sstevel@tonic-gate 			return (1L);
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate 		case _SC_XBS5_ILP32_OFFBIG:
3587c478bd9Sstevel@tonic-gate 			return (1L);
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 		case _SC_XBS5_LP64_OFF64:
3617c478bd9Sstevel@tonic-gate 			return (1L);
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate 		case _SC_XBS5_LPBIG_OFFBIG:
3647c478bd9Sstevel@tonic-gate 			return (1L);
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 		/* POSIX.1c names */
3677c478bd9Sstevel@tonic-gate 		case _SC_THREAD_DESTRUCTOR_ITERATIONS:
3687c478bd9Sstevel@tonic-gate 			return (-1L);
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate 		case _SC_GETGR_R_SIZE_MAX:
3716dd84139Sdjl 			return ((long)_nss_get_bufsizes(_SC_GETGR_R_SIZE_MAX));
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate 		case _SC_GETPW_R_SIZE_MAX:
3747c478bd9Sstevel@tonic-gate 			return ((long)NSS_BUFLEN_PASSWD);
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 		case _SC_LOGIN_NAME_MAX:
3770a1278f2SGary Mills 			return ((long)(LOGIN_NAME_MAX));
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate 		case _SC_THREAD_KEYS_MAX:
3807c478bd9Sstevel@tonic-gate 			return (-1L);
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 		case _SC_THREAD_STACK_MIN:
3837257d1b4Sraf 			return ((long)thr_min_stack());
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 		case _SC_THREAD_THREADS_MAX:
3867c478bd9Sstevel@tonic-gate 			return (-1L);
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate 		case _SC_TTY_NAME_MAX:
3897c478bd9Sstevel@tonic-gate 			return ((long)TTYNAME_MAX);
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate 		case _SC_BARRIERS:
3927c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_BARRIERS);
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 		case _SC_CLOCK_SELECTION:
3957c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_CLOCK_SELECTION);
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 		case _SC_MONOTONIC_CLOCK:
3987c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_MONOTONIC_CLOCK);
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate 		case _SC_SPAWN:
4017c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_SPAWN);
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate 		case _SC_SPIN_LOCKS:
4047c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_SPIN_LOCKS);
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate 		case _SC_THREADS:
4077c478bd9Sstevel@tonic-gate 		case _SC_THREAD_ATTR_STACKADDR:
4087c478bd9Sstevel@tonic-gate 		case _SC_THREAD_ATTR_STACKSIZE:
4097c478bd9Sstevel@tonic-gate 		case _SC_THREAD_PRIORITY_SCHEDULING:
4107c478bd9Sstevel@tonic-gate 		case _SC_THREAD_PRIO_INHERIT:
4117c478bd9Sstevel@tonic-gate 		case _SC_THREAD_PRIO_PROTECT:
4127c478bd9Sstevel@tonic-gate 		case _SC_THREAD_PROCESS_SHARED:
4137c478bd9Sstevel@tonic-gate 		case _SC_THREAD_SAFE_FUNCTIONS:
4147c478bd9Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_mode_ON)
4157c478bd9Sstevel@tonic-gate 				return (200112L);
4167c478bd9Sstevel@tonic-gate 			else
4177c478bd9Sstevel@tonic-gate 				return (1L);
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 		case _SC_TIMEOUTS:
4207c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_TIMEOUTS);
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate 		/* 1216676 - cache info */
4237c478bd9Sstevel@tonic-gate 		case _SC_COHER_BLKSZ:
4247c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_COHERENCY));
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate 		case _SC_SPLIT_CACHE:
4277c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SPLIT_CACHE));
4287c478bd9Sstevel@tonic-gate 
4297c478bd9Sstevel@tonic-gate 		case _SC_ICACHE_SZ:
4307c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHESZ));
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate 		case _SC_DCACHE_SZ:
4337c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHESZ));
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate 		case _SC_ICACHE_LINESZ:
4367c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHELINESZ));
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate 		case _SC_DCACHE_LINESZ:
4397c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHELINESZ));
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate 		case _SC_ICACHE_BLKSZ:
4427c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHEBLKSZ));
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate 		case _SC_DCACHE_BLKSZ:
4457c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHEBLKSZ));
4467c478bd9Sstevel@tonic-gate 
4477c478bd9Sstevel@tonic-gate 		case _SC_DCACHE_TBLKSZ:
4487c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHETBLKSZ));
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate 		case _SC_ICACHE_ASSOC:
4517c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHE_ASSOC));
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate 		case _SC_DCACHE_ASSOC:
4547c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHE_ASSOC));
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate 		case _SC_MAXPID:
4577c478bd9Sstevel@tonic-gate 			if (_maxpid <= 0)
4587c478bd9Sstevel@tonic-gate 				_maxpid = _sysconfig(_CONFIG_MAXPID);
4597c478bd9Sstevel@tonic-gate 			return (_maxpid);
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate 		case _SC_CPUID_MAX:
4627c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_CPUID_MAX));
4637c478bd9Sstevel@tonic-gate 
464f48205beScasper 		case _SC_EPHID_MAX:
465f48205beScasper 			return (_sysconfig(_CONFIG_EPHID_MAX));
466f48205beScasper 
467*4c46c814SRobert Mustacchi 		case _SC_UADDR_MAX:
468*4c46c814SRobert Mustacchi 			return (_sysconfig(_CONFIG_UADDR_MAX));
469*4c46c814SRobert Mustacchi 
4707c478bd9Sstevel@tonic-gate 		/* UNIX 03 names - XPG6/SUSv3/POSIX.1-2001 */
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 		case _SC_REGEXP:
4737c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_REGEXP);
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate 		case _SC_SHELL:
4767c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_SHELL);
4777c478bd9Sstevel@tonic-gate 
478019c3c43Sraf 		case _SC_ADVISORY_INFO:
479019c3c43Sraf 			return ((long)_POSIX_ADVISORY_INFO);
480019c3c43Sraf 
4817c478bd9Sstevel@tonic-gate 		case _SC_HOST_NAME_MAX:
4827c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_HOST_NAME_MAX);
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate 		case _SC_READER_WRITER_LOCKS:
4857c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_READER_WRITER_LOCKS);
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate 		case _SC_IPV6:
4887c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_IPV6);
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate 		case _SC_RAW_SOCKETS:
4917c478bd9Sstevel@tonic-gate 			return ((long)_POSIX_RAW_SOCKETS);
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_STREAMS:
4947c478bd9Sstevel@tonic-gate 			return ((long)_XOPEN_STREAMS);
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate 		case _SC_SYMLOOP_MAX:
4977c478bd9Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SYMLOOP_MAX));
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate 		case _SC_V6_ILP32_OFF32:
5007c478bd9Sstevel@tonic-gate 			return (1L);
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate 		case _SC_V6_ILP32_OFFBIG:
5037c478bd9Sstevel@tonic-gate 			return (1L);
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate 		case _SC_V6_LP64_OFF64:
5067c478bd9Sstevel@tonic-gate 			return (1L);
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate 		case _SC_V6_LPBIG_OFFBIG:
5097c478bd9Sstevel@tonic-gate 			return (1L);
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 		/* Unsupported UNIX 03 options */
5127c478bd9Sstevel@tonic-gate 		case _SC_2_PBS:
5137c478bd9Sstevel@tonic-gate 		case _SC_2_PBS_ACCOUNTING:
5147c478bd9Sstevel@tonic-gate 		case _SC_2_PBS_CHECKPOINT:
5157c478bd9Sstevel@tonic-gate 		case _SC_2_PBS_LOCATE:
5167c478bd9Sstevel@tonic-gate 		case _SC_2_PBS_MESSAGE:
5177c478bd9Sstevel@tonic-gate 		case _SC_2_PBS_TRACK:
5187c478bd9Sstevel@tonic-gate 		case _SC_CPUTIME:
5197c478bd9Sstevel@tonic-gate 		case _SC_SPORADIC_SERVER:
5207c478bd9Sstevel@tonic-gate 		case _SC_SS_REPL_MAX:
5217c478bd9Sstevel@tonic-gate 		case _SC_THREAD_CPUTIME:
5227c478bd9Sstevel@tonic-gate 		case _SC_THREAD_SPORADIC_SERVER:
5237c478bd9Sstevel@tonic-gate 		case _SC_TRACE:
5247c478bd9Sstevel@tonic-gate 		case _SC_TRACE_EVENT_FILTER:
5257c478bd9Sstevel@tonic-gate 		case _SC_TRACE_EVENT_NAME_MAX:
5267c478bd9Sstevel@tonic-gate 		case _SC_TRACE_INHERIT:
5277c478bd9Sstevel@tonic-gate 		case _SC_TRACE_LOG:
5287c478bd9Sstevel@tonic-gate 		case _SC_TRACE_NAME_MAX:
5297c478bd9Sstevel@tonic-gate 		case _SC_TRACE_SYS_MAX:
5307c478bd9Sstevel@tonic-gate 		case _SC_TRACE_USER_EVENT_MAX:
5317c478bd9Sstevel@tonic-gate 		case _SC_TYPED_MEMORY_OBJECTS:
5327c478bd9Sstevel@tonic-gate 			return (-1L);
5337c478bd9Sstevel@tonic-gate 	}
5347c478bd9Sstevel@tonic-gate }
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate /*
5377c478bd9Sstevel@tonic-gate  * UNIX 98 version of sysconf needed in order to set _XOPEN_VERSION to 500.
5387c478bd9Sstevel@tonic-gate  */
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate long
__sysconf_xpg5(int name)5417c478bd9Sstevel@tonic-gate __sysconf_xpg5(int name)
5427c478bd9Sstevel@tonic-gate {
5437c478bd9Sstevel@tonic-gate 	switch (name) {
5447c478bd9Sstevel@tonic-gate 		default:
5457c478bd9Sstevel@tonic-gate 			return (sysconf(name));
5467c478bd9Sstevel@tonic-gate 		case _SC_XOPEN_VERSION:
5477c478bd9Sstevel@tonic-gate 			return (500L);
5487c478bd9Sstevel@tonic-gate 		case _SC_PASS_MAX:
5497c478bd9Sstevel@tonic-gate 			return ((long)_PASS_MAX_XPG);
5507c478bd9Sstevel@tonic-gate 	}
5517c478bd9Sstevel@tonic-gate }
552