1 /* Copyright (C) 1991,1993,1995-1997,1999-2003,2004
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 #include <sys/param.h>
29 #include <sys/sysinfo.h>
30 #include <sys/types.h>
34 /* Get the value of the system variable NAME. */
41 /* Also add obsolete or unnecessarily added constants here. */
42 case _SC_EQUIV_CLASS_MAX
:
62 return __getclktck ();
72 return __getdtablesize ();
82 return MAX (__tzname_max (), _POSIX_TZNAME_MAX
);
85 #ifdef _POSIX_JOB_CONTROL
92 #ifdef _POSIX_SAVED_IDS
98 case _SC_REALTIME_SIGNALS
:
99 #ifdef _POSIX_REALTIME_SIGNALS
100 return _POSIX_REALTIME_SIGNALS
;
105 case _SC_PRIORITY_SCHEDULING
:
106 #ifdef _POSIX_PRIORITY_SCHEDULING
107 return _POSIX_PRIORITY_SCHEDULING
;
114 return _POSIX_TIMERS
;
119 case _SC_ASYNCHRONOUS_IO
:
120 #ifdef _POSIX_ASYNCHRONOUS_IO
121 return _POSIX_ASYNCHRONOUS_IO
;
126 case _SC_PRIORITIZED_IO
:
127 #ifdef _POSIX_PRIORITIZED_IO
128 return _POSIX_PRIORITIZED_IO
;
133 case _SC_SYNCHRONIZED_IO
:
134 #ifdef _POSIX_SYNCHRONIZED_IO
135 return _POSIX_SYNCHRONIZED_IO
;
147 case _SC_MAPPED_FILES
:
148 #ifdef _POSIX_MAPPED_FILES
149 return _POSIX_MAPPED_FILES
;
155 #ifdef _POSIX_MEMLOCK
156 return _POSIX_MEMLOCK
;
161 case _SC_MEMLOCK_RANGE
:
162 #ifdef _POSIX_MEMLOCK_RANGE
163 return _POSIX_MEMLOCK_RANGE
;
168 case _SC_MEMORY_PROTECTION
:
169 #ifdef _POSIX_MEMORY_PROTECTION
170 return _POSIX_MEMORY_PROTECTION
;
175 case _SC_MESSAGE_PASSING
:
176 #ifdef _POSIX_MESSAGE_PASSING
177 return _POSIX_MESSAGE_PASSING
;
183 #ifdef _POSIX_SEMAPHORES
184 return _POSIX_SEMAPHORES
;
189 case _SC_SHARED_MEMORY_OBJECTS
:
190 #ifdef _POSIX_SHARED_MEMORY_OBJECTS
191 return _POSIX_SHARED_MEMORY_OBJECTS
;
197 return _POSIX_VERSION
;
200 return __getpagesize ();
202 case _SC_AIO_LISTIO_MAX
:
203 #ifdef AIO_LISTIO_MAX
204 return AIO_LISTIO_MAX
;
216 case _SC_AIO_PRIO_DELTA_MAX
:
217 #ifdef AIO_PRIO_DELTA_MAX
218 return AIO_PRIO_DELTA_MAX
;
223 case _SC_DELAYTIMER_MAX
:
224 #ifdef DELAYTIMER_MAX
225 return DELAYTIMER_MAX
;
230 case _SC_MQ_OPEN_MAX
:
237 case _SC_MQ_PRIO_MAX
:
251 case _SC_SEM_NSEMS_MAX
:
253 return SEM_NSEMS_MAX
;
258 case _SC_SEM_VALUE_MAX
:
260 return SEM_VALUE_MAX
;
265 case _SC_SIGQUEUE_MAX
:
279 case _SC_BC_BASE_MAX
:
293 case _SC_BC_SCALE_MAX
:
300 case _SC_BC_STRING_MAX
:
302 return BC_STRING_MAX
;
307 case _SC_COLL_WEIGHTS_MAX
:
308 #ifdef COLL_WEIGHTS_MAX
309 return COLL_WEIGHTS_MAX
;
314 case _SC_EXPR_NEST_MAX
:
316 return EXPR_NEST_MAX
;
335 case _SC_CHARCLASS_NAME_MAX
:
336 #ifdef CHARCLASS_NAME_MAX
337 return CHARCLASS_NAME_MAX
;
350 #ifdef _POSIX_PII_XTI
357 #ifdef _POSIX_PII_SOCKET
363 case _SC_PII_INTERNET
:
364 #ifdef _POSIX_PII_INTERNET
371 #ifdef _POSIX_PII_OSI
391 /* The same as _SC_IOV_MAX. */
399 case _SC_PII_INTERNET_STREAM
:
400 #ifdef _POSIX_PII_INTERNET_STREAM
406 case _SC_PII_INTERNET_DGRAM
:
407 #ifdef _POSIX_PII_INTERNET_DGRAM
413 case _SC_PII_OSI_COTS
:
414 #ifdef _POSIX_PII_OSI_COTS
420 case _SC_PII_OSI_CLTS
:
421 #ifdef _POSIX_PII_OSI_CLTS
428 #ifdef _POSIX_PII_OSI_M
442 return _POSIX2_VERSION
;
445 #ifdef _POSIX2_C_BIND
446 return _POSIX2_C_BIND
;
453 return _POSIX2_C_DEV
;
458 case _SC_2_C_VERSION
:
459 #ifdef _POSIX2_C_VERSION
460 return _POSIX2_C_VERSION
;
466 #ifdef _POSIX2_FORT_DEV
467 return _POSIX2_FORT_DEV
;
473 #ifdef _POSIX2_FORT_RUN
474 return _POSIX2_FORT_RUN
;
479 case _SC_2_LOCALEDEF
:
480 #ifdef _POSIX2_LOCALEDEF
481 return _POSIX2_LOCALEDEF
;
487 #ifdef _POSIX2_SW_DEV
488 return _POSIX2_SW_DEV
;
493 case _SC_2_CHAR_TERM
:
494 #ifdef _POSIX2_CHAR_TERM
495 return _POSIX2_CHAR_TERM
;
507 /* POSIX 1003.1c (POSIX Threads). */
509 #ifdef _POSIX_THREADS
510 return _POSIX_THREADS
;
515 case _SC_THREAD_SAFE_FUNCTIONS
:
516 #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
517 return _POSIX_THREAD_SAFE_FUNCTIONS
;
522 case _SC_GETGR_R_SIZE_MAX
:
523 return NSS_BUFLEN_GROUP
;
525 case _SC_GETPW_R_SIZE_MAX
:
526 return NSS_BUFLEN_PASSWD
;
528 case _SC_LOGIN_NAME_MAX
:
529 #ifdef LOGIN_NAME_MAX
530 return LOGIN_NAME_MAX
;
535 case _SC_TTY_NAME_MAX
:
542 case _SC_THREAD_DESTRUCTOR_ITERATIONS
:
543 #ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
544 return _POSIX_THREAD_DESTRUCTOR_ITERATIONS
;
549 case _SC_THREAD_KEYS_MAX
:
550 #ifdef PTHREAD_KEYS_MAX
551 return PTHREAD_KEYS_MAX
;
556 case _SC_THREAD_STACK_MIN
:
557 #ifdef PTHREAD_STACK_MIN
558 return PTHREAD_STACK_MIN
;
563 case _SC_THREAD_THREADS_MAX
:
564 #ifdef PTHREAD_THREADS_MAX
565 return PTHREAD_THREADS_MAX
;
570 case _SC_THREAD_ATTR_STACKADDR
:
571 #ifdef _POSIX_THREAD_ATTR_STACKADDR
572 return _POSIX_THREAD_ATTR_STACKADDR
;
577 case _SC_THREAD_ATTR_STACKSIZE
:
578 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
579 return _POSIX_THREAD_ATTR_STACKSIZE
;
584 case _SC_THREAD_PRIORITY_SCHEDULING
:
585 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
586 return _POSIX_THREAD_PRIORITY_SCHEDULING
;
591 case _SC_THREAD_PRIO_INHERIT
:
592 #ifdef _POSIX_THREAD_PRIO_INHERIT
593 return _POSIX_THREAD_PRIO_INHERIT
;
598 case _SC_THREAD_PRIO_PROTECT
:
599 #ifdef _POSIX_THREAD_PRIO_PROTECT
600 return _POSIX_THREAD_PRIO_PROTECT
;
605 case _SC_THREAD_PROCESS_SHARED
:
606 #ifdef _POSIX_THREAD_PROCESS_SHARED
607 return _POSIX_THREAD_PROCESS_SHARED
;
612 case _SC_NPROCESSORS_CONF
:
613 return __get_nprocs_conf ();
615 case _SC_NPROCESSORS_ONLN
:
616 return __get_nprocs ();
619 return __get_phys_pages ();
621 case _SC_AVPHYS_PAGES
:
622 return __get_avphys_pages ();
625 /* We have no limit since we use lists. */
629 /* We have no limit but since the return value might be used to
630 allocate a buffer we restrict the value. */
633 case _SC_XOPEN_VERSION
:
634 return _XOPEN_VERSION
;
636 case _SC_XOPEN_XCU_VERSION
:
637 return _XOPEN_XCU_VERSION
;
642 case _SC_XOPEN_CRYPT
:
649 case _SC_XOPEN_ENH_I18N
:
650 #ifdef _XOPEN_ENH_I18N
651 return _XOPEN_ENH_I18N
;
700 return sizeof (long int) * CHAR_BIT
;
703 return sizeof (int) * CHAR_BIT
;
712 return _POSIX_SSIZE_MAX
;
780 case _SC_XBS5_ILP32_OFF32
:
781 #ifdef _XBS5_ILP32_OFF32
782 return _XBS5_ILP32_OFF32
;
786 case _SC_XBS5_ILP32_OFFBIG
:
787 #ifdef _XBS5_ILP32_OFFBIG
788 return _XBS5_ILP32_OFFBIG
;
792 case _SC_XBS5_LP64_OFF64
:
793 #ifdef _XBS5_LP64_OFF64
794 return _XBS5_LP64_OFF64
;
798 case _SC_XBS5_LPBIG_OFFBIG
:
799 #ifdef _XBS5_LPBIG_OFFBIG
800 return _XBS5_LPBIG_OFFBIG
;
805 case _SC_V6_ILP32_OFF32
:
806 #ifdef _POSIX_V6_ILP32_OFF32
807 return _POSIX_V6_ILP32_OFF32
;
811 case _SC_V6_ILP32_OFFBIG
:
812 #ifdef _POSIX_V6_ILP32_OFFBIG
813 return _POSIX_V6_ILP32_OFFBIG
;
817 case _SC_V6_LP64_OFF64
:
818 #ifdef _POSIX_V6_LP64_OFF64
819 return _POSIX_V6_LP64_OFF64
;
823 case _SC_V6_LPBIG_OFFBIG
:
824 #ifdef _POSIX_V6_LPBIG_OFFBIG
825 return _POSIX_V6_LPBIG_OFFBIG
;
830 case _SC_XOPEN_LEGACY
:
831 return _XOPEN_LEGACY
;
833 case _SC_XOPEN_REALTIME
:
834 #ifdef _XOPEN_REALTIME
835 return _XOPEN_REALTIME
;
839 case _SC_XOPEN_REALTIME_THREADS
:
840 #ifdef _XOPEN_REALTIME_THREADS
841 return _XOPEN_REALTIME_THREADS
;
846 case _SC_ADVISORY_INFO
:
847 #ifdef _POSIX_ADVISORY_INFO
848 return _POSIX_ADVISORY_INFO
;
854 #ifdef _POSIX_BARRIERS
855 return _POSIX_BARRIERS
;
866 case _SC_C_LANG_SUPPORT
:
867 #ifdef _POSIX_C_LANG_SUPPORT
868 return _POSIX_C_LANG_SUPPORT
;
872 case _SC_C_LANG_SUPPORT_R
:
873 #ifdef _POSIX_C_LANG_SUPPORT_R
874 return _POSIX_C_LANG_SUPPORT_R
;
879 case _SC_CLOCK_SELECTION
:
880 #ifdef _POSIX_CLOCK_SELECTION
881 return _POSIX_CLOCK_SELECTION
;
887 #ifdef _POSIX_CPUTIME
888 return _POSIX_CPUTIME
;
894 #ifdef _POSIX_DEVICE_IO
895 return _POSIX_DEVICE_IO
;
899 case _SC_DEVICE_SPECIFIC
:
900 #ifdef _POSIX_DEVICE_SPCIFIC
901 return _POSIX_DEVICE_SPECIFIC
;
905 case _SC_DEVICE_SPECIFIC_R
:
906 #ifdef _POSIX_DEVICE_SPCIFIC_R
907 return _POSIX_DEVICE_SPECIFIC_R
;
913 #ifdef _POSIX_FD_MGMT
914 return _POSIX_FD_MGMT
;
932 case _SC_FILE_ATTRIBUTES
:
933 #ifdef _POSIX_FILE_ATTRIBUTES
934 return _POSIX_FILE_ATTRIBUTES
;
938 case _SC_FILE_LOCKING
:
939 #ifdef _POSIX_FILE_LOCKING
940 return _POSIX_FILE_LOCKING
;
944 case _SC_FILE_SYSTEM
:
945 #ifdef _POSIX_FILE_SYSTEM
946 return _POSIX_FILE_SYSTEM
;
951 case _SC_MONOTONIC_CLOCK
:
952 #if _POSIX_MONOTONIC_CLOCK
953 return _POSIX_MONOTONIC_CLOCK
;
958 case _SC_MULTI_PROCESS
:
959 #ifdef _POSIX_MULTI_PROCESS
960 return _POSIX_MULTI_PROCESS
;
964 case _SC_SINGLE_PROCESS
:
965 #ifdef _POSIX_SINGLE_PROCESS
966 return _POSIX_SINGLE_PROCESS
;
972 #ifdef _POSIX_NETWORKING
973 return _POSIX_NETWORKING
;
978 case _SC_READER_WRITER_LOCKS
:
979 #ifdef _POSIX_READER_WRITER_LOCKS
980 return _POSIX_READER_WRITER_LOCKS
;
985 #ifdef _POSIX_SPIN_LOCKS
986 return _POSIX_SPIN_LOCKS
;
993 return _POSIX_REGEXP
;
997 case _SC_REGEX_VERSION
:
998 #ifdef _POSIX_REGEX_VERSION
999 return _POSIX_REGEX_VERSION
;
1006 return _POSIX_SHELL
;
1012 #ifdef _POSUX_SIGNALS
1013 return _POSIX_SIGNALS
;
1020 return _POSIX_SPAWN
;
1025 case _SC_SPORADIC_SERVER
:
1026 #ifdef _POSIX_SPORADIC_SERVER
1027 return _POSIX_SPORADIC_SERVER
;
1031 case _SC_THREAD_SPORADIC_SERVER
:
1032 #ifdef _POSIX_THREAD_SPORADIC_SERVER
1033 return _POSIX_THREAD_SPORADIC_SERVER
;
1038 case _SC_SYSTEM_DATABASE
:
1039 #ifdef _POSIX_SYSTEM_DATABASE
1040 return _POSIX_SYSTEM_DATABASE
;
1044 case _SC_SYSTEM_DATABASE_R
:
1045 #ifdef _POSIX_SYSTEM_DATABASE_R
1046 return _POSIX_SYSTEM_DATABASE_R
;
1051 case _SC_THREAD_CPUTIME
:
1052 #ifdef _POSIX_THREAD_CPUTIME
1053 return _POSIX_THREAD_CPUTIME
;
1059 #ifdef _POSIX_TIMEOUTS
1060 return _POSIX_TIMEOUTS
;
1065 case _SC_TYPED_MEMORY_OBJECTS
:
1066 #ifdef _POSIX_TYPED_MEMORY_OBJECTS
1067 return _POSIX_TYPED_MEMORY_OBJECTS
;
1072 case _SC_USER_GROUPS
:
1073 #ifdef _POSIX_USER_GROUPS
1074 return _POSIX_USER_GROUPS
;
1078 case _SC_USER_GROUPS_R
:
1079 #ifdef _POSIX_USER_GROUPS_R
1080 return _POSIX_USER_GROUPS_R
;
1091 case _SC_2_PBS_ACCOUNTING
:
1092 #ifdef _POSIX2_PBS_ACCOUNTING
1093 return _POSIX2_PBS_ACCOUNTING
;
1097 case _SC_2_PBS_CHECKPOINT
:
1098 #ifdef _POSIX2_PBS_CHECKPOINT
1099 return _POSIX2_PBS_CHECKPOINT
;
1103 case _SC_2_PBS_LOCATE
:
1104 #ifdef _POSIX2_PBS_LOCATE
1105 return _POSIX2_PBS_LOCATE
;
1109 case _SC_2_PBS_MESSAGE
:
1110 #ifdef _POSIX2_PBS_MESSAGE
1111 return _POSIX2_PBS_MESSAGE
;
1115 case _SC_2_PBS_TRACK
:
1116 #ifdef _POSIX2_PBS_TRACK
1117 return _POSIX2_PBS_TRACK
;
1122 case _SC_SYMLOOP_MAX
:
1130 #ifdef _XOPEN_STREAMS
1131 return _XOPEN_STREAMS
;
1136 case _SC_HOST_NAME_MAX
:
1137 #ifdef HOST_NAME_MAX
1138 return HOST_NAME_MAX
;
1145 return _POSIX_TRACE
;
1149 case _SC_TRACE_EVENT_FILTER
:
1150 #ifdef _POSIX_TRACE_EVENT_FILTER
1151 return _POSIX_TRACE_EVENT_FILTER
;
1155 case _SC_TRACE_INHERIT
:
1156 #ifdef _POSIX_TRACE_INHERIT
1157 return _POSIX_TRACE_INHERIT
;
1162 #ifdef _POSIX_TRACE_LOG
1163 return _POSIX_TRACE_LOG
;
1168 case _SC_LEVEL1_ICACHE_SIZE
:
1169 case _SC_LEVEL1_ICACHE_ASSOC
:
1170 case _SC_LEVEL1_ICACHE_LINESIZE
:
1171 case _SC_LEVEL1_DCACHE_SIZE
:
1172 case _SC_LEVEL1_DCACHE_ASSOC
:
1173 case _SC_LEVEL1_DCACHE_LINESIZE
:
1174 case _SC_LEVEL2_CACHE_SIZE
:
1175 case _SC_LEVEL2_CACHE_ASSOC
:
1176 case _SC_LEVEL2_CACHE_LINESIZE
:
1177 case _SC_LEVEL3_CACHE_SIZE
:
1178 case _SC_LEVEL3_CACHE_ASSOC
:
1179 case _SC_LEVEL3_CACHE_LINESIZE
:
1180 case _SC_LEVEL4_CACHE_SIZE
:
1181 case _SC_LEVEL4_CACHE_ASSOC
:
1182 /* In general we cannot determine these values. Therefore we
1183 return zero which indicates that no information is
1190 weak_alias (__sysconf
, sysconf
)
1191 libc_hidden_def (__sysconf
)