xref: /onnv-gate/usr/src/lib/libc/port/gen/sysconf.c (revision 6812:febeba71273d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54321Scasper  * Common Development and Distribution License (the "License").
64321Scasper  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*6812Sraf 
220Sstevel@tonic-gate /*
236279Sdjl  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
30*6812Sraf #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /* sysconf(3C) - returns system configuration information */
330Sstevel@tonic-gate 
34*6812Sraf #pragma weak _sysconf = sysconf
350Sstevel@tonic-gate 
36*6812Sraf #include "lint.h"
370Sstevel@tonic-gate #include <mtlib.h>
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include <unistd.h>
400Sstevel@tonic-gate #include <sys/sysconfig.h>
410Sstevel@tonic-gate #include <limits.h>
420Sstevel@tonic-gate #include <time.h>
430Sstevel@tonic-gate #include <errno.h>
440Sstevel@tonic-gate #include <nss_dbdefs.h>
450Sstevel@tonic-gate #include <thread.h>
460Sstevel@tonic-gate #include <xti.h>
470Sstevel@tonic-gate #include "libc.h"
480Sstevel@tonic-gate #include "xpg6.h"
490Sstevel@tonic-gate 
506279Sdjl /* from nss_common.c */
516279Sdjl extern size_t _nss_get_bufsizes(int);
526279Sdjl 
530Sstevel@tonic-gate long
540Sstevel@tonic-gate sysconf(int name)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	static int _pagesize = 0;
570Sstevel@tonic-gate 	static int _hz = 0;
580Sstevel@tonic-gate 	static pid_t _maxpid = 0;
590Sstevel@tonic-gate 	static int _stackprot = 0;
600Sstevel@tonic-gate 	extern int __xpg4;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	switch (name) {
630Sstevel@tonic-gate 		default:
640Sstevel@tonic-gate 			errno = EINVAL;
650Sstevel@tonic-gate 			return (-1L);
660Sstevel@tonic-gate 
670Sstevel@tonic-gate 		case _SC_ARG_MAX:
680Sstevel@tonic-gate 			return ((long)ARG_MAX);
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 		case _SC_CLK_TCK:
710Sstevel@tonic-gate 			if (_hz <= 0)
720Sstevel@tonic-gate 				_hz = _sysconfig(_CONFIG_CLK_TCK);
730Sstevel@tonic-gate 			return (_hz);
740Sstevel@tonic-gate 
750Sstevel@tonic-gate 		case _SC_JOB_CONTROL:
760Sstevel@tonic-gate 			return ((long)_POSIX_JOB_CONTROL);
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 		case _SC_SAVED_IDS:
790Sstevel@tonic-gate 			return ((long)_POSIX_SAVED_IDS);
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 		case _SC_CHILD_MAX:
820Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_CHILD_MAX));
830Sstevel@tonic-gate 
840Sstevel@tonic-gate 		case _SC_NGROUPS_MAX:
850Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NGROUPS));
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 		case _SC_OPEN_MAX:
880Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_OPEN_FILES));
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 		case _SC_VERSION:
910Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
920Sstevel@tonic-gate 				return (200112L);
930Sstevel@tonic-gate 			else
940Sstevel@tonic-gate 				return (199506L);
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 		case _SC_PAGESIZE:
970Sstevel@tonic-gate 			if (_pagesize <= 0)
980Sstevel@tonic-gate 				_pagesize = _sysconfig(_CONFIG_PAGESIZE);
990Sstevel@tonic-gate 			return (_pagesize);
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 		case _SC_XOPEN_VERSION:
1020Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
1030Sstevel@tonic-gate 				return (600L);
1040Sstevel@tonic-gate 			else if (__xpg4 == 0)
1050Sstevel@tonic-gate 				return (_sysconfig(_CONFIG_XOPEN_VER));
1060Sstevel@tonic-gate 			else
1070Sstevel@tonic-gate 				return (4L);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 		case _SC_XOPEN_XCU_VERSION:
1100Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
1110Sstevel@tonic-gate 				return (600L);
1120Sstevel@tonic-gate 			else
1130Sstevel@tonic-gate 				return (4L);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 		/*
1160Sstevel@tonic-gate 		 * old value for pre XPG5 conformant systems to match
1170Sstevel@tonic-gate 		 * getpass() length.
1180Sstevel@tonic-gate 		 * XPG5 special cased with __sysconf_xpg5()
1190Sstevel@tonic-gate 		 * new value for default and modern XPG systems.
1200Sstevel@tonic-gate 		 */
1210Sstevel@tonic-gate 		case _SC_PASS_MAX:
1220Sstevel@tonic-gate 			if ((__xpg4 == 1) &&
1230Sstevel@tonic-gate 			    (!(__xpg6 & _C99SUSv3_XPG6_sysconf_version)))
1240Sstevel@tonic-gate 				return ((long)_PASS_MAX_XPG);
1250Sstevel@tonic-gate 			else
1260Sstevel@tonic-gate 				return ((long)_PASS_MAX);
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate 		case _SC_LOGNAME_MAX:
1290Sstevel@tonic-gate 			return ((long)LOGNAME_MAX);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 		case _SC_STREAM_MAX:
1320Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_OPEN_FILES));
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 		case _SC_TZNAME_MAX:
1350Sstevel@tonic-gate 			return (-1L);
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 		case _SC_NPROCESSORS_CONF:
1380Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_CONF));
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate 		case _SC_NPROCESSORS_ONLN:
1410Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_ONLN));
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 		case _SC_NPROCESSORS_MAX:
1440Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_NPROC_MAX));
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate 		case _SC_STACK_PROT:
1470Sstevel@tonic-gate 			if (_stackprot == 0)
1480Sstevel@tonic-gate 				_stackprot = _sysconfig(_CONFIG_STACK_PROT);
1490Sstevel@tonic-gate 			return (_stackprot);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 		/* POSIX.4 names */
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate 		/*
1540Sstevel@tonic-gate 		 * Each of the following also have _POSIX_* symbols
1550Sstevel@tonic-gate 		 * defined in <unistd.h>. Values here should align
1560Sstevel@tonic-gate 		 * with values in the header. Up until the SUSv3 standard
1570Sstevel@tonic-gate 		 * we defined these simply as 1. With the introduction
1580Sstevel@tonic-gate 		 * of the new revision, these were changed to 200112L.
1590Sstevel@tonic-gate 		 * The standard allows us to change the value, however,
1600Sstevel@tonic-gate 		 * we have kept both values in case application programs
1610Sstevel@tonic-gate 		 * are relying on the previous value even though an
1620Sstevel@tonic-gate 		 * application doing so is technically wrong.
1630Sstevel@tonic-gate 		 */
1640Sstevel@tonic-gate 		case _SC_ASYNCHRONOUS_IO:
1650Sstevel@tonic-gate 		case _SC_FSYNC:
1660Sstevel@tonic-gate 		case _SC_MAPPED_FILES:
1670Sstevel@tonic-gate 		case _SC_MEMLOCK:
1680Sstevel@tonic-gate 		case _SC_MEMLOCK_RANGE:
1690Sstevel@tonic-gate 		case _SC_MEMORY_PROTECTION:
1700Sstevel@tonic-gate 		case _SC_MESSAGE_PASSING:
1710Sstevel@tonic-gate 		case _SC_PRIORITY_SCHEDULING:
1720Sstevel@tonic-gate 		case _SC_REALTIME_SIGNALS:
1730Sstevel@tonic-gate 		case _SC_SEMAPHORES:
1740Sstevel@tonic-gate 		case _SC_SHARED_MEMORY_OBJECTS:
1750Sstevel@tonic-gate 		case _SC_SYNCHRONIZED_IO:
1760Sstevel@tonic-gate 		case _SC_TIMERS:
1770Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_mode_ON)
1780Sstevel@tonic-gate 				return (200112L);
1790Sstevel@tonic-gate 			else
1800Sstevel@tonic-gate 				return (1L);
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate 		case _SC_PRIORITIZED_IO:
1830Sstevel@tonic-gate #ifdef _POSIX_PRIORITIZED_IO
1840Sstevel@tonic-gate 			return (1L);
1850Sstevel@tonic-gate #else
1860Sstevel@tonic-gate 			return (-1L);
1870Sstevel@tonic-gate #endif
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate 		case _SC_AIO_LISTIO_MAX:
1900Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_LISTIO_MAX));
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate 		case _SC_AIO_MAX:
1930Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_MAX));
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate 		case _SC_AIO_PRIO_DELTA_MAX:
1960Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AIO_PRIO_DELTA_MAX));
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate 		case _SC_DELAYTIMER_MAX:
1990Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DELAYTIMER_MAX));
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate 		case _SC_MQ_OPEN_MAX:
2020Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_MQ_OPEN_MAX));
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 		case _SC_MQ_PRIO_MAX:
2050Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_MQ_PRIO_MAX));
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate 		case _SC_RTSIG_MAX:
2080Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_RTSIG_MAX));
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate 		case _SC_SEM_NSEMS_MAX:
2110Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SEM_NSEMS_MAX));
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate 		case _SC_SEM_VALUE_MAX:
2140Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SEM_VALUE_MAX));
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate 		case _SC_SIGQUEUE_MAX:
2170Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGQUEUE_MAX));
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate 		case _SC_SIGRT_MAX:
2200Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGRT_MAX));
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate 		case _SC_SIGRT_MIN:
2230Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SIGRT_MIN));
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 		case _SC_TIMER_MAX:
2260Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_TIMER_MAX));
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate 		case _SC_PHYS_PAGES:
2290Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_PHYS_PAGES));
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 		case _SC_AVPHYS_PAGES:
2320Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_AVPHYS_PAGES));
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate 		/* XPG4/POSIX.1-1990/POSIX.2-1992 names */
2350Sstevel@tonic-gate 		case _SC_2_C_BIND:
2364917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2374917Sdamico 				return (200112L);
2384917Sdamico 			else
2394917Sdamico 				return (1L);
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate 		case _SC_2_CHAR_TERM:
2420Sstevel@tonic-gate 			return ((long)_POSIX2_CHAR_TERM);
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate 		case _SC_2_C_DEV:
2454917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2464917Sdamico 				return (200112L);
2474917Sdamico 			else
2484917Sdamico 				return (1L);
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate 		case _SC_2_C_VERSION:
2510Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2520Sstevel@tonic-gate 				return (200112L);
2530Sstevel@tonic-gate 			else
2540Sstevel@tonic-gate 				return (199209L);
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate 		case _SC_2_FORT_DEV:
2570Sstevel@tonic-gate 			return (-1L);
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate 		case _SC_2_FORT_RUN:
2604917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2614917Sdamico 				return (200112L);
2624917Sdamico 			else
2634917Sdamico 				return (1L);
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate 		case _SC_2_LOCALEDEF:
2664917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2674917Sdamico 				return (200112L);
2684917Sdamico 			else
2694917Sdamico 				return (1L);
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate 		case _SC_2_SW_DEV:
2724917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2734917Sdamico 				return (200112L);
2744917Sdamico 			else
2754917Sdamico 				return (1L);
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate 		case _SC_2_UPE:
2784917Sdamico 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2794917Sdamico 				return (200112L);
2804917Sdamico 			else
2814917Sdamico 				return (1L);
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate 		case _SC_2_VERSION:
2840Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
2850Sstevel@tonic-gate 				return (200112L);
2860Sstevel@tonic-gate 			else
2870Sstevel@tonic-gate 				return (199209L);
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate 		case _SC_BC_BASE_MAX:
2900Sstevel@tonic-gate 			return ((long)BC_BASE_MAX);
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate 		case _SC_BC_DIM_MAX:
2930Sstevel@tonic-gate 			return ((long)BC_DIM_MAX);
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 		case _SC_BC_SCALE_MAX:
2960Sstevel@tonic-gate 			return ((long)BC_SCALE_MAX);
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate 		case _SC_BC_STRING_MAX:
2990Sstevel@tonic-gate 			return ((long)BC_STRING_MAX);
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate 		case _SC_COLL_WEIGHTS_MAX:
3020Sstevel@tonic-gate 			return ((long)COLL_WEIGHTS_MAX);
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate 		case _SC_EXPR_NEST_MAX:
3050Sstevel@tonic-gate 			return ((long)EXPR_NEST_MAX);
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 		case _SC_LINE_MAX:
3080Sstevel@tonic-gate 			return ((long)LINE_MAX);
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 		case _SC_RE_DUP_MAX:
3110Sstevel@tonic-gate 			return ((long)RE_DUP_MAX);
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate 		case _SC_XOPEN_CRYPT:
3140Sstevel@tonic-gate 			return (1L);
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate 		case _SC_XOPEN_ENH_I18N:
3170Sstevel@tonic-gate 			return ((long)_XOPEN_ENH_I18N);
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate 		case _SC_XOPEN_SHM:
3200Sstevel@tonic-gate 			return ((long)_XOPEN_SHM);
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 		/* XPG4v2 (SUS) names */
3230Sstevel@tonic-gate 		case _SC_XOPEN_UNIX:
3240Sstevel@tonic-gate 			return (1L);
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate 		case _SC_XOPEN_LEGACY:
3270Sstevel@tonic-gate 			return (1L);
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate 		case _SC_ATEXIT_MAX:
3300Sstevel@tonic-gate 			return (-1L);
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 		case _SC_IOV_MAX:
3330Sstevel@tonic-gate 			return ((long)IOV_MAX);
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 		case _SC_T_IOV_MAX:
3360Sstevel@tonic-gate 			return ((long)T_IOV_MAX);
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate 		/* XPG5 (SUSv2) names */
3390Sstevel@tonic-gate 		case _SC_XOPEN_REALTIME:
3400Sstevel@tonic-gate 			return (1L);
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate 		case _SC_XOPEN_REALTIME_THREADS:
3430Sstevel@tonic-gate #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && \
3440Sstevel@tonic-gate 	defined(_POSIX_THREAD_PRIO_INHERIT) && \
3450Sstevel@tonic-gate 	defined(_POSIX_THREAD_PRIO_PROTECT)
3460Sstevel@tonic-gate 			return (1L);
3470Sstevel@tonic-gate #else
3480Sstevel@tonic-gate 			return (-1L);
3490Sstevel@tonic-gate #endif
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate 		case _SC_XBS5_ILP32_OFF32:
3520Sstevel@tonic-gate 			return (1L);
3530Sstevel@tonic-gate 
3540Sstevel@tonic-gate 		case _SC_XBS5_ILP32_OFFBIG:
3550Sstevel@tonic-gate 			return (1L);
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 		case _SC_XBS5_LP64_OFF64:
3580Sstevel@tonic-gate 			return (1L);
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate 		case _SC_XBS5_LPBIG_OFFBIG:
3610Sstevel@tonic-gate 			return (1L);
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate 		/* POSIX.1c names */
3640Sstevel@tonic-gate 		case _SC_THREAD_DESTRUCTOR_ITERATIONS:
3650Sstevel@tonic-gate 			return (-1L);
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 		case _SC_GETGR_R_SIZE_MAX:
3686279Sdjl 			return ((long)_nss_get_bufsizes(_SC_GETGR_R_SIZE_MAX));
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate 		case _SC_GETPW_R_SIZE_MAX:
3710Sstevel@tonic-gate 			return ((long)NSS_BUFLEN_PASSWD);
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate 		case _SC_LOGIN_NAME_MAX:
3740Sstevel@tonic-gate 			return ((long)(LOGNAME_MAX + 1));
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate 		case _SC_THREAD_KEYS_MAX:
3770Sstevel@tonic-gate 			return (-1L);
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate 		case _SC_THREAD_STACK_MIN:
380*6812Sraf 			return ((long)thr_min_stack());
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 		case _SC_THREAD_THREADS_MAX:
3830Sstevel@tonic-gate 			return (-1L);
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 		case _SC_TTY_NAME_MAX:
3860Sstevel@tonic-gate 			return ((long)TTYNAME_MAX);
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate 		case _SC_BARRIERS:
3890Sstevel@tonic-gate 			return ((long)_POSIX_BARRIERS);
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 		case _SC_CLOCK_SELECTION:
3920Sstevel@tonic-gate 			return ((long)_POSIX_CLOCK_SELECTION);
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate 		case _SC_MONOTONIC_CLOCK:
3950Sstevel@tonic-gate 			return ((long)_POSIX_MONOTONIC_CLOCK);
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate 		case _SC_SPAWN:
3980Sstevel@tonic-gate 			return ((long)_POSIX_SPAWN);
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate 		case _SC_SPIN_LOCKS:
4010Sstevel@tonic-gate 			return ((long)_POSIX_SPIN_LOCKS);
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate 		case _SC_THREADS:
4040Sstevel@tonic-gate 		case _SC_THREAD_ATTR_STACKADDR:
4050Sstevel@tonic-gate 		case _SC_THREAD_ATTR_STACKSIZE:
4060Sstevel@tonic-gate 		case _SC_THREAD_PRIORITY_SCHEDULING:
4070Sstevel@tonic-gate 		case _SC_THREAD_PRIO_INHERIT:
4080Sstevel@tonic-gate 		case _SC_THREAD_PRIO_PROTECT:
4090Sstevel@tonic-gate 		case _SC_THREAD_PROCESS_SHARED:
4100Sstevel@tonic-gate 		case _SC_THREAD_SAFE_FUNCTIONS:
4110Sstevel@tonic-gate 			if (__xpg6 & _C99SUSv3_mode_ON)
4120Sstevel@tonic-gate 				return (200112L);
4130Sstevel@tonic-gate 			else
4140Sstevel@tonic-gate 				return (1L);
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate 		case _SC_TIMEOUTS:
4170Sstevel@tonic-gate 			return ((long)_POSIX_TIMEOUTS);
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate 		/* 1216676 - cache info */
4200Sstevel@tonic-gate 		case _SC_COHER_BLKSZ:
4210Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_COHERENCY));
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate 		case _SC_SPLIT_CACHE:
4240Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SPLIT_CACHE));
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate 		case _SC_ICACHE_SZ:
4270Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHESZ));
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate 		case _SC_DCACHE_SZ:
4300Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHESZ));
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate 		case _SC_ICACHE_LINESZ:
4330Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHELINESZ));
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate 		case _SC_DCACHE_LINESZ:
4360Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHELINESZ));
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 		case _SC_ICACHE_BLKSZ:
4390Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHEBLKSZ));
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate 		case _SC_DCACHE_BLKSZ:
4420Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHEBLKSZ));
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate 		case _SC_DCACHE_TBLKSZ:
4450Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHETBLKSZ));
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate 		case _SC_ICACHE_ASSOC:
4480Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_ICACHE_ASSOC));
4490Sstevel@tonic-gate 
4500Sstevel@tonic-gate 		case _SC_DCACHE_ASSOC:
4510Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_DCACHE_ASSOC));
4520Sstevel@tonic-gate 
4530Sstevel@tonic-gate 		case _SC_MAXPID:
4540Sstevel@tonic-gate 			if (_maxpid <= 0)
4550Sstevel@tonic-gate 				_maxpid = _sysconfig(_CONFIG_MAXPID);
4560Sstevel@tonic-gate 			return (_maxpid);
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate 		case _SC_CPUID_MAX:
4590Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_CPUID_MAX));
4600Sstevel@tonic-gate 
4614321Scasper 		case _SC_EPHID_MAX:
4624321Scasper 			return (_sysconfig(_CONFIG_EPHID_MAX));
4634321Scasper 
4640Sstevel@tonic-gate 		/* UNIX 03 names - XPG6/SUSv3/POSIX.1-2001 */
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate 		case _SC_REGEXP:
4670Sstevel@tonic-gate 			return ((long)_POSIX_REGEXP);
4680Sstevel@tonic-gate 
4690Sstevel@tonic-gate 		case _SC_SHELL:
4700Sstevel@tonic-gate 			return ((long)_POSIX_SHELL);
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate 		case _SC_HOST_NAME_MAX:
4730Sstevel@tonic-gate 			return ((long)_POSIX_HOST_NAME_MAX);
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate 		case _SC_READER_WRITER_LOCKS:
4760Sstevel@tonic-gate 			return ((long)_POSIX_READER_WRITER_LOCKS);
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate 		case _SC_IPV6:
4790Sstevel@tonic-gate 			return ((long)_POSIX_IPV6);
4800Sstevel@tonic-gate 
4810Sstevel@tonic-gate 		case _SC_RAW_SOCKETS:
4820Sstevel@tonic-gate 			return ((long)_POSIX_RAW_SOCKETS);
4830Sstevel@tonic-gate 
4840Sstevel@tonic-gate 		case _SC_XOPEN_STREAMS:
4850Sstevel@tonic-gate 			return ((long)_XOPEN_STREAMS);
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate 		case _SC_SYMLOOP_MAX:
4880Sstevel@tonic-gate 			return (_sysconfig(_CONFIG_SYMLOOP_MAX));
4890Sstevel@tonic-gate 
4900Sstevel@tonic-gate 		case _SC_V6_ILP32_OFF32:
4910Sstevel@tonic-gate 			return (1L);
4920Sstevel@tonic-gate 
4930Sstevel@tonic-gate 		case _SC_V6_ILP32_OFFBIG:
4940Sstevel@tonic-gate 			return (1L);
4950Sstevel@tonic-gate 
4960Sstevel@tonic-gate 		case _SC_V6_LP64_OFF64:
4970Sstevel@tonic-gate 			return (1L);
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate 		case _SC_V6_LPBIG_OFFBIG:
5000Sstevel@tonic-gate 			return (1L);
5010Sstevel@tonic-gate 
5020Sstevel@tonic-gate 		/* Unsupported UNIX 03 options */
5030Sstevel@tonic-gate 		case _SC_2_PBS:
5040Sstevel@tonic-gate 		case _SC_2_PBS_ACCOUNTING:
5050Sstevel@tonic-gate 		case _SC_2_PBS_CHECKPOINT:
5060Sstevel@tonic-gate 		case _SC_2_PBS_LOCATE:
5070Sstevel@tonic-gate 		case _SC_2_PBS_MESSAGE:
5080Sstevel@tonic-gate 		case _SC_2_PBS_TRACK:
5090Sstevel@tonic-gate 		case _SC_ADVISORY_INFO:
5100Sstevel@tonic-gate 		case _SC_CPUTIME:
5110Sstevel@tonic-gate 		case _SC_SPORADIC_SERVER:
5120Sstevel@tonic-gate 		case _SC_SS_REPL_MAX:
5130Sstevel@tonic-gate 		case _SC_THREAD_CPUTIME:
5140Sstevel@tonic-gate 		case _SC_THREAD_SPORADIC_SERVER:
5150Sstevel@tonic-gate 		case _SC_TRACE:
5160Sstevel@tonic-gate 		case _SC_TRACE_EVENT_FILTER:
5170Sstevel@tonic-gate 		case _SC_TRACE_EVENT_NAME_MAX:
5180Sstevel@tonic-gate 		case _SC_TRACE_INHERIT:
5190Sstevel@tonic-gate 		case _SC_TRACE_LOG:
5200Sstevel@tonic-gate 		case _SC_TRACE_NAME_MAX:
5210Sstevel@tonic-gate 		case _SC_TRACE_SYS_MAX:
5220Sstevel@tonic-gate 		case _SC_TRACE_USER_EVENT_MAX:
5230Sstevel@tonic-gate 		case _SC_TYPED_MEMORY_OBJECTS:
5240Sstevel@tonic-gate 			return (-1L);
5250Sstevel@tonic-gate 	}
5260Sstevel@tonic-gate }
5270Sstevel@tonic-gate 
5280Sstevel@tonic-gate /*
5290Sstevel@tonic-gate  * UNIX 98 version of sysconf needed in order to set _XOPEN_VERSION to 500.
5300Sstevel@tonic-gate  */
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate long
5330Sstevel@tonic-gate __sysconf_xpg5(int name)
5340Sstevel@tonic-gate {
5350Sstevel@tonic-gate 	switch (name) {
5360Sstevel@tonic-gate 		default:
5370Sstevel@tonic-gate 			return (sysconf(name));
5380Sstevel@tonic-gate 		case _SC_XOPEN_VERSION:
5390Sstevel@tonic-gate 			return (500L);
5400Sstevel@tonic-gate 		case _SC_PASS_MAX:
5410Sstevel@tonic-gate 			return ((long)_PASS_MAX_XPG);
5420Sstevel@tonic-gate 	}
5430Sstevel@tonic-gate }
544