1 /* Copyright (C) 1991,93,95,96,97,99,2000,2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 #include <sys/param.h>
28 #include <sys/sysinfo.h>
29 #include <sys/types.h>
33 /* Get the value of the system variable NAME. */
59 return __getclktck ();
69 return __getdtablesize ();
79 return MAX (__tzname_max (), _POSIX_TZNAME_MAX
);
82 #ifdef _POSIX_JOB_CONTROL
89 #ifdef _POSIX_SAVED_IDS
95 case _SC_REALTIME_SIGNALS
:
96 #ifdef _POSIX_REALTIME_SIGNALS
102 case _SC_PRIORITY_SCHEDULING
:
103 #ifdef _POSIX_PRIORITY_SCHEDULING
116 case _SC_ASYNCHRONOUS_IO
:
117 #ifdef _POSIX_ASYNCHRONOUS_IO
123 case _SC_PRIORITIZED_IO
:
124 #ifdef _POSIX_PRIORITIZED_IO
130 case _SC_SYNCHRONIZED_IO
:
131 #ifdef _POSIX_SYNCHRONIZED_IO
144 case _SC_MAPPED_FILES
:
145 #ifdef _POSIX_MAPPED_FILES
152 #ifdef _POSIX_MEMLOCK
158 case _SC_MEMLOCK_RANGE
:
159 #ifdef _POSIX_MEMLOCK_RANGE
165 case _SC_MEMORY_PROTECTION
:
166 #ifdef _POSIX_MEMORY_PROTECTION
172 case _SC_MESSAGE_PASSING
:
173 #ifdef _POSIX_MESSAGE_PASSING
180 #ifdef _POSIX_SEMAPHORES
186 case _SC_SHARED_MEMORY_OBJECTS
:
187 #ifdef _POSIX_SHARED_MEMORY_OBJECTS
194 return _POSIX_VERSION
;
197 return __getpagesize ();
199 case _SC_AIO_LISTIO_MAX
:
200 #ifdef AIO_LISTIO_MAX
201 return AIO_LISTIO_MAX
;
213 case _SC_AIO_PRIO_DELTA_MAX
:
214 #ifdef AIO_PRIO_DELTA_MAX
215 return AIO_PRIO_DELTA_MAX
;
220 case _SC_DELAYTIMER_MAX
:
221 #ifdef DELAYTIMER_MAX
222 return DELAYTIMER_MAX
;
227 case _SC_MQ_OPEN_MAX
:
234 case _SC_MQ_PRIO_MAX
:
248 case _SC_SEM_NSEMS_MAX
:
250 return SEM_NSEMS_MAX
;
255 case _SC_SEM_VALUE_MAX
:
257 return SEM_VALUE_MAX
;
262 case _SC_SIGQUEUE_MAX
:
276 case _SC_BC_BASE_MAX
:
290 case _SC_BC_SCALE_MAX
:
297 case _SC_BC_STRING_MAX
:
299 return BC_STRING_MAX
;
304 case _SC_COLL_WEIGHTS_MAX
:
305 #ifdef COLL_WEIGHTS_MAX
306 return COLL_WEIGHTS_MAX
;
311 case _SC_EXPR_NEST_MAX
:
313 return EXPR_NEST_MAX
;
332 case _SC_CHARCLASS_NAME_MAX
:
333 #ifdef CHARCLASS_NAME_MAX
334 return CHARCLASS_NAME_MAX
;
347 #ifdef _POSIX_PII_XTI
354 #ifdef _POSIX_PII_SOCKET
360 case _SC_PII_INTERNET
:
361 #ifdef _POSIX_PII_INTERNET
368 #ifdef _POSIX_PII_OSI
395 case _SC_PII_INTERNET_STREAM
:
396 #ifdef _POSIX_PII_INTERNET_STREAM
402 case _SC_PII_INTERNET_DGRAM
:
403 #ifdef _POSIX_PII_INTERNET_DGRAM
409 case _SC_PII_OSI_COTS
:
410 #ifdef _POSIX_PII_OSI_COTS
416 case _SC_PII_OSI_CLTS
:
417 #ifdef _POSIX_PII_OSI_CLTS
424 #ifdef _POSIX_PII_OSI_M
438 return _POSIX2_VERSION
;
441 #ifdef _POSIX2_C_BIND
442 return _POSIX2_C_BIND
;
449 return _POSIX2_C_DEV
;
454 case _SC_2_C_VERSION
:
455 #ifdef _POSIX2_C_VERSION
456 return _POSIX2_C_VERSION
;
462 #ifdef _POSIX2_FORT_DEV
463 return _POSIX2_FORT_DEV
;
468 case _SC_2_LOCALEDEF
:
469 #ifdef _POSIX2_LOCALEDEF
470 return _POSIX2_LOCALEDEF
;
476 #ifdef _POSIX2_SW_DEV
477 return _POSIX2_SW_DEV
;
482 case _SC_2_CHAR_TERM
:
483 #ifdef _POSIX2_CHAR_TERM
484 return _POSIX2_CHAR_TERM
;
496 /* POSIX 1003.1c (POSIX Threads). */
498 #ifdef _POSIX_THREADS
504 case _SC_THREAD_SAFE_FUNCTIONS
:
505 #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
511 case _SC_GETGR_R_SIZE_MAX
:
512 #ifdef NSS_BUFLEN_GROUP
513 return NSS_BUFLEN_GROUP
;
518 case _SC_GETPW_R_SIZE_MAX
:
519 #ifdef NSS_BUFLEN_PASSWD
520 return NSS_BUFLEN_PASSWD
;
525 case _SC_LOGIN_NAME_MAX
:
526 #ifdef _POSIX_LOGIN_NAME_MAX
527 return _POSIX_LOGIN_NAME_MAX
;
532 case _SC_TTY_NAME_MAX
:
533 #ifdef _POSIX_TTY_NAME_MAX
534 return _POSIX_TTY_NAME_MAX
;
539 case _SC_THREAD_DESTRUCTOR_ITERATIONS
:
540 #ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
541 return _POSIX_THREAD_DESTRUCTOR_ITERATIONS
;
546 case _SC_THREAD_KEYS_MAX
:
547 #ifdef PTHREAD_KEYS_MAX
548 return PTHREAD_KEYS_MAX
;
553 case _SC_THREAD_STACK_MIN
:
554 #ifdef PTHREAD_STACK_MIN
555 return PTHREAD_STACK_MIN
;
560 case _SC_THREAD_THREADS_MAX
:
561 #ifdef PTHREAD_THREADS_MAX
562 return PTHREAD_THREADS_MAX
;
567 case _SC_THREAD_ATTR_STACKADDR
:
568 #ifdef _POSIX_THREAD_ATTR_STACKADDR
574 case _SC_THREAD_ATTR_STACKSIZE
:
575 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
581 case _SC_THREAD_PRIORITY_SCHEDULING
:
582 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
588 case _SC_THREAD_PRIO_INHERIT
:
589 #ifdef _POSIX_THREAD_PRIO_INHERIT
595 case _SC_THREAD_PRIO_PROTECT
:
596 #ifdef _POSIX_THREAD_PRIO_PROTECT
602 case _SC_THREAD_PROCESS_SHARED
:
603 #ifdef _POSIX_THREAD_PROCESS_SHARED
609 case _SC_NPROCESSORS_CONF
:
610 return __get_nprocs_conf ();
612 case _SC_NPROCESSORS_ONLN
:
613 return __get_nprocs ();
616 return __get_phys_pages ();
618 case _SC_AVPHYS_PAGES
:
619 return __get_avphys_pages ();
622 /* We have no limit since we use lists. */
626 /* We have no limit but since the return value might be used to
627 allocate a buffer we restrict the value. */
630 case _SC_XOPEN_VERSION
:
631 return _XOPEN_VERSION
;
633 case _SC_XOPEN_XCU_VERSION
:
634 return _XOPEN_XCU_VERSION
;
639 case _SC_XOPEN_CRYPT
:
646 case _SC_XOPEN_ENH_I18N
:
647 #ifdef _XOPEN_ENH_I18N
648 return _XOPEN_ENH_I18N
;
697 return sizeof (long int) * CHAR_BIT
;
700 return sizeof (int) * CHAR_BIT
;
709 return _POSIX_SSIZE_MAX
;
777 case _SC_XBS5_ILP32_OFF32
:
778 #ifdef _XBS5_ILP32_OFF32
779 return _XBS5_ILP32_OFF32
;
783 case _SC_XBS5_ILP32_OFFBIG
:
784 #ifdef _XBS5_ILP32_OFFBIG
785 return _XBS5_ILP32_OFFBIG
;
789 case _SC_XBS5_LP64_OFF64
:
790 #ifdef _XBS5_LP64_OFF64
791 return _XBS5_LP64_OFF64
;
795 case _SC_XBS5_LPBIG_OFFBIG
:
796 #ifdef _XBS5_LPBIG_OFFBIG
797 return _XBS5_LPBIG_OFFBIG
;
802 case _SC_V6_ILP32_OFF32
:
803 #ifdef _POSIX_V6_ILP32_OFF32
804 return _POSIX_V6_ILP32_OFF32
;
808 case _SC_V6_ILP32_OFFBIG
:
809 #ifdef _POSIX_V6_ILP32_OFFBIG
810 return _POSIX_V6_ILP32_OFFBIG
;
814 case _SC_V6_LP64_OFF64
:
815 #ifdef _POSIX_V6_LP64_OFF64
816 return _POSIX_V6_LP64_OFF64
;
820 case _SC_V6_LPBIG_OFFBIG
:
821 #ifdef _POSIX_V6_LPBIG_OFFBIG
822 return _POSIX_V6_LPBIG_OFFBIG
;
827 case _SC_XOPEN_LEGACY
:
828 return _XOPEN_LEGACY
;
830 case _SC_XOPEN_REALTIME
:
831 #ifdef _XOPEN_REALTIME
832 return _XOPEN_REALTIME
;
836 case _SC_XOPEN_REALTIME_THREADS
:
837 #ifdef _XOPEN_REALTIME_THREADS
838 return _XOPEN_REALTIME_THREADS
;
843 case _SC_ADVISORY_INFO
:
844 #ifdef _POSIX_ADVISORY_INFO
845 return _POSIX_ADVISORY_INFO
;
851 #ifdef _POSIX_BARRIERS
852 return _POSIX_BARRIERS
;
863 case _SC_C_LANG_SUPPORT
:
864 #ifdef _POSIX_C_LANG_SUPPORT
865 return _POSIX_C_LANG_SUPPORT
;
869 case _SC_C_LANG_SUPPORT_R
:
870 #ifdef _POSIX_C_LANG_SUPPORT_R
871 return _POSIX_C_LANG_SUPPORT_R
;
876 case _SC_CLOCK_SELECTION
:
877 #ifdef _POSIX_CLOCK_SELECTION
878 return _POSIX_CLOCK_SELECTION
;
884 #ifdef _POSIX_CPUTIME
885 return _POSIX_CPUTIME
;
891 #ifdef _POSIX_DEVICE_IO
892 return _POSIX_DEVICE_IO
;
896 case _SC_DEVICE_SPECIFIC
:
897 #ifdef _POSIX_DEVICE_SPCIFIC
898 return _POSIX_DEVICE_SPECIFIC
;
902 case _SC_DEVICE_SPECIFIC_R
:
903 #ifdef _POSIX_DEVICE_SPCIFIC_R
904 return _POSIX_DEVICE_SPECIFIC_R
;
910 #ifdef _POSIX_FD_MGMT
911 return _POSIX_FD_MGMT
;
929 case _SC_FILE_ATTRIBUTES
:
930 #ifdef _POSIX_FILE_ATTRIBUTES
931 return _POSIX_FILE_ATTRIBUTES
;
935 case _SC_FILE_LOCKING
:
936 #ifdef _POSIX_FILE_LOCKING
937 return _POSIX_FILE_LOCKING
;
941 case _SC_FILE_SYSTEM
:
942 #ifdef _POSIX_FILE_SYSTEM
943 return _POSIX_FILE_SYSTEM
;
948 case _SC_MONOTONIC_CLOCK
:
949 #ifdef _POSIX_MONOTONIC_CLOCK
950 return _POSIX_MONOTONIC_CLOCK
;
955 case _SC_MULTI_PROCESS
:
956 #ifdef _POSIX_MULTI_PROCESS
957 return _POSIX_MULTI_PROCESS
;
961 case _SC_SINGLE_PROCESS
:
962 #ifdef _POSIX_SINGLE_PROCESS
963 return _POSIX_SINGLE_PROCESS
;
969 #ifdef _POSIX_NETWORKING
970 return _POSIX_NETWORKING
;
975 case _SC_READER_WRITER_LOCKS
:
976 #ifdef _POSIX_READER_WRITER_LOCKS
977 return _POSIX_READER_WRITER_LOCKS
;
982 #ifdef _POSIX_SPIN_LOCKS
983 return _POSIX_SPIN_LOCKS
;
990 return _POSIX_REGEXP
;
994 case _SC_REGEX_VERSION
:
995 #ifdef _POSIX_REGEX_VERSION
996 return _POSIX_REGEX_VERSION
;
1003 return _POSIX_SHELL
;
1009 #ifdef _POSUX_SIGNALS
1010 return _POSIX_SIGNALS
;
1017 return _POSIX_SPAWN
;
1022 case _SC_SPORADIC_SERVER
:
1023 #ifdef _POSIX_SPORADIC_SERVER
1024 return _POSIX_SPORADIC_SERVER
;
1028 case _SC_THREAD_SPORADIC_SERVER
:
1029 #ifdef _POSIX_THREAD_SPORADIC_SERVER
1030 return _POSIX_THREAD_SPORADIC_SERVER
;
1035 case _SC_SYSTEM_DATABASE
:
1036 #ifdef _POSIX_SYSTEM_DATABASE
1037 return _POSIX_SYSTEM_DATABASE
;
1041 case _SC_SYSTEM_DATABASE_R
:
1042 #ifdef _POSIX_SYSTEM_DATABASE_R
1043 return _POSIX_SYSTEM_DATABASE_R
;
1048 case _SC_THREAD_CPUTIME
:
1049 #ifdef _POSIX_THREAD_CPUTIME
1050 return _POSIX_THREAD_CPUTIME
;
1056 #ifdef _POSIX_TIMEOUTS
1057 return _POSIX_TIMEOUTS
;
1062 case _SC_TYPED_MEMORY_OBJECTS
:
1063 #ifdef _POSIX_TYPED_MEMORY_OBJECTS
1064 return _POSIX_TYPED_MEMORY_OBJECTS
;
1069 case _SC_USER_GROUPS
:
1070 #ifdef _POSIX_USER_GROUPS
1071 return _POSIX_USER_GROUPS
;
1075 case _SC_USER_GROUPS_R
:
1076 #ifdef _POSIX_USER_GROUPS_R
1077 return _POSIX_USER_GROUPS_R
;
1088 case _SC_2_PBS_ACCOUNTING
:
1089 #ifdef _POSIX2_PBS_ACCOUNTING
1090 return _POSIX2_PBS_ACCOUNTING
;
1094 case _SC_2_PBS_CHECKPOINT
:
1095 #ifdef _POSIX2_PBS_CHECKPOINT
1096 return _POSIX2_PBS_CHECKPOINT
;
1100 case _SC_2_PBS_LOCATE
:
1101 #ifdef _POSIX2_PBS_LOCATE
1102 return _POSIX2_PBS_LOCATE
;
1106 case _SC_2_PBS_TRACK
:
1107 #ifdef _POSIX2_PBS_TRACK
1108 return _POSIX2_PBS_TRACK
;
1113 case _SC_SYMLOOP_MAX
:
1121 #ifdef _XOPEN_STREAMS
1122 return _XOPEN_STREAMS
;
1130 weak_alias (__sysconf
, sysconf
)