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