* locales/cs_SR: Removed.
[glibc.git] / sysdeps / posix / sysconf.c
blob0c0d7d141880867678060e28cd5740e8157c8f26
1 /* Copyright (C) 1991,1993,1995-1997,1999-2003,2004,2006
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
18 02111-1307 USA. */
20 #include <errno.h>
21 #include <limits.h>
22 #include <grp.h>
23 #include <pwd.h>
24 #include <stddef.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <time.h>
29 #include <unistd.h>
30 #include <sys/param.h>
31 #include <sys/stat.h>
32 #include <sys/sysinfo.h>
33 #include <sys/types.h>
34 #include <regex.h>
37 #define NEED_CHECK_SPEC \
38 (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
39 || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \
40 || !defined _POSIX_V6_ILP32_OFF32 || !defined _POSIX_V6_ILP32_OFFBIG \
41 || !defined _POSIX_V6_LP64_OFF64 || !defined _POSIX_V6_LPBIG_OFFBIG)
42 #if NEED_CHECK_SPEC
43 static long int __sysconf_check_spec (const char *spec);
44 #endif
47 /* Get the value of the system variable NAME. */
48 long int
49 __sysconf (name)
50 int name;
52 switch (name)
54 /* Also add obsolete or unnecessarily added constants here. */
55 case _SC_EQUIV_CLASS_MAX:
56 default:
57 __set_errno (EINVAL);
58 return -1;
60 case _SC_ARG_MAX:
61 #ifdef ARG_MAX
62 return ARG_MAX;
63 #else
64 return -1;
65 #endif
67 case _SC_CHILD_MAX:
68 #ifdef CHILD_MAX
69 return CHILD_MAX;
70 #else
71 return __get_child_max ();
72 #endif
74 case _SC_CLK_TCK:
75 return __getclktck ();
77 case _SC_NGROUPS_MAX:
78 #ifdef NGROUPS_MAX
79 return NGROUPS_MAX;
80 #else
81 return -1;
82 #endif
84 case _SC_OPEN_MAX:
85 return __getdtablesize ();
87 case _SC_STREAM_MAX:
88 #ifdef STREAM_MAX
89 return STREAM_MAX;
90 #else
91 return FOPEN_MAX;
92 #endif
94 case _SC_TZNAME_MAX:
95 return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
97 case _SC_JOB_CONTROL:
98 #if _POSIX_JOB_CONTROL > 0
99 return _POSIX_JOB_CONTROL;
100 #else
101 return -1;
102 #endif
104 case _SC_SAVED_IDS:
105 #if _POSIX_SAVED_IDS > 0
106 return 1;
107 #else
108 return -1;
109 #endif
111 case _SC_REALTIME_SIGNALS:
112 #if _POSIX_REALTIME_SIGNALS > 0
113 return _POSIX_REALTIME_SIGNALS;
114 #else
115 return -1;
116 #endif
118 case _SC_PRIORITY_SCHEDULING:
119 #if _POSIX_PRIORITY_SCHEDULING > 0
120 return _POSIX_PRIORITY_SCHEDULING;
121 #else
122 return -1;
123 #endif
125 case _SC_TIMERS:
126 #if _POSIX_TIMERS > 0
127 return _POSIX_TIMERS;
128 #else
129 return -1;
130 #endif
132 case _SC_ASYNCHRONOUS_IO:
133 #if _POSIX_ASYNCHRONOUS_IO > 0
134 return _POSIX_ASYNCHRONOUS_IO;
135 #else
136 return -1;
137 #endif
139 case _SC_PRIORITIZED_IO:
140 #if _POSIX_PRIORITIZED_IO > 0
141 return _POSIX_PRIORITIZED_IO;
142 #else
143 return -1;
144 #endif
146 case _SC_SYNCHRONIZED_IO:
147 #if _POSIX_SYNCHRONIZED_IO > 0
148 return _POSIX_SYNCHRONIZED_IO;
149 #else
150 return -1;
151 #endif
153 case _SC_FSYNC:
154 #if _POSIX_FSYNC > 0
155 return _POSIX_FSYNC;
156 #else
157 return -1;
158 #endif
160 case _SC_MAPPED_FILES:
161 #if _POSIX_MAPPED_FILES > 0
162 return _POSIX_MAPPED_FILES;
163 #else
164 return -1;
165 #endif
167 case _SC_MEMLOCK:
168 #if _POSIX_MEMLOCK > 0
169 return _POSIX_MEMLOCK;
170 #else
171 return -1;
172 #endif
174 case _SC_MEMLOCK_RANGE:
175 #if _POSIX_MEMLOCK_RANGE > 0
176 return _POSIX_MEMLOCK_RANGE;
177 #else
178 return -1;
179 #endif
181 case _SC_MEMORY_PROTECTION:
182 #if _POSIX_MEMORY_PROTECTION > 0
183 return _POSIX_MEMORY_PROTECTION;
184 #else
185 return -1;
186 #endif
188 case _SC_MESSAGE_PASSING:
189 #if _POSIX_MESSAGE_PASSING > 0
190 return _POSIX_MESSAGE_PASSING;
191 #else
192 return -1;
193 #endif
195 case _SC_SEMAPHORES:
196 #if _POSIX_SEMAPHORES > 0
197 return _POSIX_SEMAPHORES;
198 #else
199 return -1;
200 #endif
202 case _SC_SHARED_MEMORY_OBJECTS:
203 #if _POSIX_SHARED_MEMORY_OBJECTS > 0
204 return _POSIX_SHARED_MEMORY_OBJECTS;
205 #else
206 return -1;
207 #endif
209 case _SC_VERSION:
210 return _POSIX_VERSION;
212 case _SC_PAGESIZE:
213 return __getpagesize ();
215 case _SC_AIO_LISTIO_MAX:
216 #ifdef AIO_LISTIO_MAX
217 return AIO_LISTIO_MAX;
218 #else
219 return -1;
220 #endif
222 case _SC_AIO_MAX:
223 #ifdef AIO_MAX
224 return AIO_MAX;
225 #else
226 return -1;
227 #endif
229 case _SC_AIO_PRIO_DELTA_MAX:
230 #ifdef AIO_PRIO_DELTA_MAX
231 return AIO_PRIO_DELTA_MAX;
232 #else
233 return -1;
234 #endif
236 case _SC_DELAYTIMER_MAX:
237 #ifdef DELAYTIMER_MAX
238 return DELAYTIMER_MAX;
239 #else
240 return -1;
241 #endif
243 case _SC_MQ_OPEN_MAX:
244 #ifdef MQ_OPEN_MAX
245 return MQ_OPEN_MAX;
246 #else
247 return -1;
248 #endif
250 case _SC_MQ_PRIO_MAX:
251 #ifdef MQ_PRIO_MAX
252 return MQ_PRIO_MAX;
253 #else
254 return -1;
255 #endif
257 case _SC_RTSIG_MAX:
258 #ifdef RTSIG_MAX
259 return RTSIG_MAX;
260 #else
261 return -1;
262 #endif
264 case _SC_SEM_NSEMS_MAX:
265 #ifdef SEM_NSEMS_MAX
266 return SEM_NSEMS_MAX;
267 #else
268 return -1;
269 #endif
271 case _SC_SEM_VALUE_MAX:
272 #ifdef SEM_VALUE_MAX
273 return SEM_VALUE_MAX;
274 #else
275 return -1;
276 #endif
278 case _SC_SIGQUEUE_MAX:
279 #ifdef SIGQUEUE_MAX
280 return SIGQUEUE_MAX;
281 #else
282 return -1;
283 #endif
285 case _SC_TIMER_MAX:
286 #ifdef TIMER_MAX
287 return TIMER_MAX;
288 #else
289 return -1;
290 #endif
292 case _SC_BC_BASE_MAX:
293 #ifdef BC_BASE_MAX
294 return BC_BASE_MAX;
295 #else
296 return -1;
297 #endif
299 case _SC_BC_DIM_MAX:
300 #ifdef BC_DIM_MAX
301 return BC_DIM_MAX;
302 #else
303 return -1;
304 #endif
306 case _SC_BC_SCALE_MAX:
307 #ifdef BC_SCALE_MAX
308 return BC_SCALE_MAX;
309 #else
310 return -1;
311 #endif
313 case _SC_BC_STRING_MAX:
314 #ifdef BC_STRING_MAX
315 return BC_STRING_MAX;
316 #else
317 return -1;
318 #endif
320 case _SC_COLL_WEIGHTS_MAX:
321 #ifdef COLL_WEIGHTS_MAX
322 return COLL_WEIGHTS_MAX;
323 #else
324 return -1;
325 #endif
327 case _SC_EXPR_NEST_MAX:
328 #ifdef EXPR_NEST_MAX
329 return EXPR_NEST_MAX;
330 #else
331 return -1;
332 #endif
334 case _SC_LINE_MAX:
335 #ifdef LINE_MAX
336 return LINE_MAX;
337 #else
338 return -1;
339 #endif
341 case _SC_RE_DUP_MAX:
342 #ifdef RE_DUP_MAX
343 return RE_DUP_MAX;
344 #else
345 return -1;
346 #endif
348 case _SC_CHARCLASS_NAME_MAX:
349 #ifdef CHARCLASS_NAME_MAX
350 return CHARCLASS_NAME_MAX;
351 #else
352 return -1;
353 #endif
355 case _SC_PII:
356 #if _POSIX_PII > 0
357 return 1;
358 #else
359 return -1;
360 #endif
362 case _SC_PII_XTI:
363 #if _POSIX_PII_XTI > 0
364 return 1;
365 #else
366 return -1;
367 #endif
369 case _SC_PII_SOCKET:
370 #if _POSIX_PII_SOCKET > 0
371 return 1;
372 #else
373 return -1;
374 #endif
376 case _SC_PII_INTERNET:
377 #if _POSIX_PII_INTERNET > 0
378 return 1;
379 #else
380 return -1;
381 #endif
383 case _SC_PII_OSI:
384 #if _POSIX_PII_OSI > 0
385 return 1;
386 #else
387 return -1;
388 #endif
390 case _SC_POLL:
391 #if _POSIX_POLL > 0
392 return 1;
393 #else
394 return -1;
395 #endif
397 case _SC_SELECT:
398 #if _POSIX_SELECT > 0
399 return 1;
400 #else
401 return -1;
402 #endif
404 /* The same as _SC_IOV_MAX. */
405 case _SC_UIO_MAXIOV:
406 #ifdef UIO_MAXIOV
407 return UIO_MAXIOV;
408 #else
409 return -1;
410 #endif
412 case _SC_PII_INTERNET_STREAM:
413 #if _POSIX_PII_INTERNET_STREAM > 0
414 return 1;
415 #else
416 return -1;
417 #endif
419 case _SC_PII_INTERNET_DGRAM:
420 #if _POSIX_PII_INTERNET_DGRAM > 0
421 return 1;
422 #else
423 return -1;
424 #endif
426 case _SC_PII_OSI_COTS:
427 #if _POSIX_PII_OSI_COTS > 0
428 return 1;
429 #else
430 return -1;
431 #endif
433 case _SC_PII_OSI_CLTS:
434 #if _POSIX_PII_OSI_CLTS > 0
435 return 1;
436 #else
437 return -1;
438 #endif
440 case _SC_PII_OSI_M:
441 #if _POSIX_PII_OSI_M > 0
442 return 1;
443 #else
444 return -1;
445 #endif
447 case _SC_T_IOV_MAX:
448 #ifdef _T_IOV_MAX
449 return _T_IOV_MAX;
450 #else
451 return -1;
452 #endif
454 case _SC_2_VERSION:
455 return _POSIX2_VERSION;
457 case _SC_2_C_BIND:
458 #ifdef _POSIX2_C_BIND
459 return _POSIX2_C_BIND;
460 #else
461 return -1;
462 #endif
464 case _SC_2_C_DEV:
465 #ifdef _POSIX2_C_DEV
466 return _POSIX2_C_DEV;
467 #else
468 return -1;
469 #endif
471 case _SC_2_C_VERSION:
472 #ifdef _POSIX2_C_VERSION
473 return _POSIX2_C_VERSION;
474 #else
475 return -1;
476 #endif
478 case _SC_2_FORT_DEV:
479 #ifdef _POSIX2_FORT_DEV
480 return _POSIX2_FORT_DEV;
481 #else
482 return -1;
483 #endif
485 case _SC_2_FORT_RUN:
486 #ifdef _POSIX2_FORT_RUN
487 return _POSIX2_FORT_RUN;
488 #else
489 return -1;
490 #endif
492 case _SC_2_LOCALEDEF:
493 #ifdef _POSIX2_LOCALEDEF
494 return _POSIX2_LOCALEDEF;
495 #else
496 return -1;
497 #endif
499 case _SC_2_SW_DEV:
500 #ifdef _POSIX2_SW_DEV
501 return _POSIX2_SW_DEV;
502 #else
503 return -1;
504 #endif
506 case _SC_2_CHAR_TERM:
507 #ifdef _POSIX2_CHAR_TERM
508 return _POSIX2_CHAR_TERM;
509 #else
510 return -1;
511 #endif
513 case _SC_2_UPE:
514 #ifdef _POSIX2_UPE
515 return _POSIX2_UPE;
516 #else
517 return -1;
518 #endif
520 /* POSIX 1003.1c (POSIX Threads). */
521 case _SC_THREADS:
522 #if _POSIX_THREADS > 0
523 return _POSIX_THREADS;
524 #else
525 return -1;
526 #endif
528 case _SC_THREAD_SAFE_FUNCTIONS:
529 #if _POSIX_THREAD_SAFE_FUNCTIONS > 0
530 return _POSIX_THREAD_SAFE_FUNCTIONS;
531 #else
532 return -1;
533 #endif
535 case _SC_GETGR_R_SIZE_MAX:
536 return NSS_BUFLEN_GROUP;
538 case _SC_GETPW_R_SIZE_MAX:
539 return NSS_BUFLEN_PASSWD;
541 case _SC_LOGIN_NAME_MAX:
542 #ifdef LOGIN_NAME_MAX
543 return LOGIN_NAME_MAX;
544 #else
545 return -1;
546 #endif
548 case _SC_TTY_NAME_MAX:
549 #ifdef TTY_NAME_MAX
550 return TTY_NAME_MAX;
551 #else
552 return -1;
553 #endif
555 case _SC_THREAD_DESTRUCTOR_ITERATIONS:
556 #if _POSIX_THREAD_DESTRUCTOR_ITERATIONS > 0
557 return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
558 #else
559 return -1;
560 #endif
562 case _SC_THREAD_KEYS_MAX:
563 #ifdef PTHREAD_KEYS_MAX
564 return PTHREAD_KEYS_MAX;
565 #else
566 return -1;
567 #endif
569 case _SC_THREAD_STACK_MIN:
570 #ifdef PTHREAD_STACK_MIN
571 return PTHREAD_STACK_MIN;
572 #else
573 return -1;
574 #endif
576 case _SC_THREAD_THREADS_MAX:
577 #ifdef PTHREAD_THREADS_MAX
578 return PTHREAD_THREADS_MAX;
579 #else
580 return -1;
581 #endif
583 case _SC_THREAD_ATTR_STACKADDR:
584 #if _POSIX_THREAD_ATTR_STACKADDR > 0
585 return _POSIX_THREAD_ATTR_STACKADDR;
586 #else
587 return -1;
588 #endif
590 case _SC_THREAD_ATTR_STACKSIZE:
591 #if _POSIX_THREAD_ATTR_STACKSIZE > 0
592 return _POSIX_THREAD_ATTR_STACKSIZE;
593 #else
594 return -1;
595 #endif
597 case _SC_THREAD_PRIORITY_SCHEDULING:
598 #if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
599 return _POSIX_THREAD_PRIORITY_SCHEDULING;
600 #else
601 return -1;
602 #endif
604 case _SC_THREAD_PRIO_INHERIT:
605 #if _POSIX_THREAD_PRIO_INHERIT > 0
606 return _POSIX_THREAD_PRIO_INHERIT;
607 #else
608 return -1;
609 #endif
611 case _SC_THREAD_PRIO_PROTECT:
612 #if _POSIX_THREAD_PRIO_PROTECT > 0
613 return _POSIX_THREAD_PRIO_PROTECT;
614 #else
615 return -1;
616 #endif
618 case _SC_THREAD_PROCESS_SHARED:
619 #if _POSIX_THREAD_PROCESS_SHARED > 0
620 return _POSIX_THREAD_PROCESS_SHARED;
621 #else
622 return -1;
623 #endif
625 case _SC_NPROCESSORS_CONF:
626 return __get_nprocs_conf ();
628 case _SC_NPROCESSORS_ONLN:
629 return __get_nprocs ();
631 case _SC_PHYS_PAGES:
632 return __get_phys_pages ();
634 case _SC_AVPHYS_PAGES:
635 return __get_avphys_pages ();
637 case _SC_ATEXIT_MAX:
638 /* We have no limit since we use lists. */
639 return INT_MAX;
641 case _SC_PASS_MAX:
642 /* We have no limit but since the return value might be used to
643 allocate a buffer we restrict the value. */
644 return BUFSIZ;
646 case _SC_XOPEN_VERSION:
647 return _XOPEN_VERSION;
649 case _SC_XOPEN_XCU_VERSION:
650 return _XOPEN_XCU_VERSION;
652 case _SC_XOPEN_UNIX:
653 return _XOPEN_UNIX;
655 case _SC_XOPEN_CRYPT:
656 #ifdef _XOPEN_CRYPT
657 return _XOPEN_CRYPT;
658 #else
659 return -1;
660 #endif
662 case _SC_XOPEN_ENH_I18N:
663 #ifdef _XOPEN_ENH_I18N
664 return _XOPEN_ENH_I18N;
665 #else
666 return -1;
667 #endif
669 case _SC_XOPEN_SHM:
670 #ifdef _XOPEN_SHM
671 return _XOPEN_SHM;
672 #else
673 return -1;
674 #endif
676 case _SC_XOPEN_XPG2:
677 #ifdef _XOPEN_XPG2
678 return _XOPEN_XPG2;
679 #else
680 return -1;
681 #endif
683 case _SC_XOPEN_XPG3:
684 #ifdef _XOPEN_XPG3
685 return _XOPEN_XPG3;
686 #else
687 return -1;
688 #endif
690 case _SC_XOPEN_XPG4:
691 #ifdef _XOPEN_XPG4
692 return _XOPEN_XPG4;
693 #else
694 return -1;
695 #endif
697 case _SC_CHAR_BIT:
698 return CHAR_BIT;
700 case _SC_CHAR_MAX:
701 return CHAR_MAX;
703 case _SC_CHAR_MIN:
704 return CHAR_MIN;
706 case _SC_INT_MAX:
707 return INT_MAX;
709 case _SC_INT_MIN:
710 return INT_MIN;
712 case _SC_LONG_BIT:
713 return sizeof (long int) * CHAR_BIT;
715 case _SC_WORD_BIT:
716 return sizeof (int) * CHAR_BIT;
718 case _SC_MB_LEN_MAX:
719 return MB_LEN_MAX;
721 case _SC_NZERO:
722 return NZERO;
724 case _SC_SSIZE_MAX:
725 return _POSIX_SSIZE_MAX;
727 case _SC_SCHAR_MAX:
728 return SCHAR_MAX;
730 case _SC_SCHAR_MIN:
731 return SCHAR_MIN;
733 case _SC_SHRT_MAX:
734 return SHRT_MAX;
736 case _SC_SHRT_MIN:
737 return SHRT_MIN;
739 case _SC_UCHAR_MAX:
740 return UCHAR_MAX;
742 case _SC_UINT_MAX:
743 return UINT_MAX;
745 case _SC_ULONG_MAX:
746 return ULONG_MAX;
748 case _SC_USHRT_MAX:
749 return USHRT_MAX;
751 case _SC_NL_ARGMAX:
752 #ifdef NL_ARGMAX
753 return NL_ARGMAX;
754 #else
755 return -1;
756 #endif
758 case _SC_NL_LANGMAX:
759 #ifdef NL_LANGMAX
760 return NL_LANGMAX;
761 #else
762 return -1;
763 #endif
765 case _SC_NL_MSGMAX:
766 #ifdef NL_MSGMAX
767 return NL_MSGMAX;
768 #else
769 return -1;
770 #endif
772 case _SC_NL_NMAX:
773 #ifdef NL_NMAX
774 return NL_NMAX;
775 #else
776 return -1;
777 #endif
779 case _SC_NL_SETMAX:
780 #ifdef NL_SETMAX
781 return NL_SETMAX;
782 #else
783 return -1;
784 #endif
786 case _SC_NL_TEXTMAX:
787 #ifdef NL_TEXTMAX
788 return NL_TEXTMAX;
789 #else
790 return -1;
791 #endif
793 case _SC_XBS5_ILP32_OFF32:
794 #ifdef _XBS5_ILP32_OFF32
795 return _XBS5_ILP32_OFF32;
796 #else
797 return __sysconf_check_spec ("ILP32_OFF32");
798 #endif
799 case _SC_XBS5_ILP32_OFFBIG:
800 #ifdef _XBS5_ILP32_OFFBIG
801 return _XBS5_ILP32_OFFBIG;
802 #else
803 return __sysconf_check_spec ("ILP32_OFFBIG");
804 #endif
805 case _SC_XBS5_LP64_OFF64:
806 #ifdef _XBS5_LP64_OFF64
807 return _XBS5_LP64_OFF64;
808 #else
809 return __sysconf_check_spec ("LP64_OFF64");
810 #endif
811 case _SC_XBS5_LPBIG_OFFBIG:
812 #ifdef _XBS5_LPBIG_OFFBIG
813 return _XBS5_LPBIG_OFFBIG;
814 #else
815 return __sysconf_check_spec ("LPBIG_OFFBIG");
816 #endif
818 case _SC_V6_ILP32_OFF32:
819 #ifdef _POSIX_V6_ILP32_OFF32
820 return _POSIX_V6_ILP32_OFF32;
821 #else
822 return __sysconf_check_spec ("ILP32_OFF32");
823 #endif
824 case _SC_V6_ILP32_OFFBIG:
825 #ifdef _POSIX_V6_ILP32_OFFBIG
826 return _POSIX_V6_ILP32_OFFBIG;
827 #else
828 return __sysconf_check_spec ("ILP32_OFFBIG");
829 #endif
830 case _SC_V6_LP64_OFF64:
831 #ifdef _POSIX_V6_LP64_OFF64
832 return _POSIX_V6_LP64_OFF64;
833 #else
834 return __sysconf_check_spec ("LP64_OFF64");
835 #endif
836 case _SC_V6_LPBIG_OFFBIG:
837 #ifdef _POSIX_V6_LPBIG_OFFBIG
838 return _POSIX_V6_LPBIG_OFFBIG;
839 #else
840 return __sysconf_check_spec ("LPBIG_OFFBIG");
841 #endif
843 case _SC_XOPEN_LEGACY:
844 return _XOPEN_LEGACY;
846 case _SC_XOPEN_REALTIME:
847 #ifdef _XOPEN_REALTIME
848 return _XOPEN_REALTIME;
849 #else
850 return -1;
851 #endif
852 case _SC_XOPEN_REALTIME_THREADS:
853 #ifdef _XOPEN_REALTIME_THREADS
854 return _XOPEN_REALTIME_THREADS;
855 #else
856 return -1;
857 #endif
859 case _SC_ADVISORY_INFO:
860 #if _POSIX_ADVISORY_INFO > 0
861 return _POSIX_ADVISORY_INFO;
862 #else
863 return -1;
864 #endif
866 case _SC_BARRIERS:
867 #if _POSIX_BARRIERS > 0
868 return _POSIX_BARRIERS;
869 #else
870 return -1;
871 #endif
873 case _SC_BASE:
874 #if _POSIX_BASE > 0
875 return _POSIX_BASE;
876 #else
877 return -1;
878 #endif
879 case _SC_C_LANG_SUPPORT:
880 #if _POSIX_C_LANG_SUPPORT > 0
881 return _POSIX_C_LANG_SUPPORT;
882 #else
883 return -1;
884 #endif
885 case _SC_C_LANG_SUPPORT_R:
886 #if _POSIX_C_LANG_SUPPORT_R > 0
887 return _POSIX_C_LANG_SUPPORT_R;
888 #else
889 return -1;
890 #endif
892 case _SC_CLOCK_SELECTION:
893 #if _POSIX_CLOCK_SELECTION > 0
894 return _POSIX_CLOCK_SELECTION;
895 #else
896 return -1;
897 #endif
899 case _SC_CPUTIME:
900 #if _POSIX_CPUTIME > 0
901 return _POSIX_CPUTIME;
902 #else
903 return -1;
904 #endif
906 case _SC_DEVICE_IO:
907 #if _POSIX_DEVICE_IO > 0
908 return _POSIX_DEVICE_IO;
909 #else
910 return -1;
911 #endif
912 case _SC_DEVICE_SPECIFIC:
913 #if _POSIX_DEVICE_SPCIFIC > 0
914 return _POSIX_DEVICE_SPECIFIC;
915 #else
916 return -1;
917 #endif
918 case _SC_DEVICE_SPECIFIC_R:
919 #if _POSIX_DEVICE_SPCIFIC_R > 0
920 return _POSIX_DEVICE_SPECIFIC_R;
921 #else
922 return -1;
923 #endif
925 case _SC_FD_MGMT:
926 #if _POSIX_FD_MGMT > 0
927 return _POSIX_FD_MGMT;
928 #else
929 return -1;
930 #endif
932 case _SC_FIFO:
933 #if _POSIX_FIFO > 0
934 return _POSIX_FIFO;
935 #else
936 return -1;
937 #endif
938 case _SC_PIPE:
939 #if _POSIX_PIPE > 0
940 return _POSIX_PIPE;
941 #else
942 return -1;
943 #endif
945 case _SC_FILE_ATTRIBUTES:
946 #if _POSIX_FILE_ATTRIBUTES > 0
947 return _POSIX_FILE_ATTRIBUTES;
948 #else
949 return -1;
950 #endif
951 case _SC_FILE_LOCKING:
952 #if _POSIX_FILE_LOCKING > 0
953 return _POSIX_FILE_LOCKING;
954 #else
955 return -1;
956 #endif
957 case _SC_FILE_SYSTEM:
958 #if _POSIX_FILE_SYSTEM > 0
959 return _POSIX_FILE_SYSTEM;
960 #else
961 return -1;
962 #endif
964 case _SC_MONOTONIC_CLOCK:
965 #if _POSIX_MONOTONIC_CLOCK
966 return _POSIX_MONOTONIC_CLOCK;
967 #else
968 return -1;
969 #endif
971 case _SC_MULTI_PROCESS:
972 #if _POSIX_MULTI_PROCESS > 0
973 return _POSIX_MULTI_PROCESS;
974 #else
975 return -1;
976 #endif
977 case _SC_SINGLE_PROCESS:
978 #if _POSIX_SINGLE_PROCESS > 0
979 return _POSIX_SINGLE_PROCESS;
980 #else
981 return -1;
982 #endif
984 case _SC_NETWORKING:
985 #if _POSIX_NETWORKING > 0
986 return _POSIX_NETWORKING;
987 #else
988 return -1;
989 #endif
991 case _SC_READER_WRITER_LOCKS:
992 #if _POSIX_READER_WRITER_LOCKS > 0
993 return _POSIX_READER_WRITER_LOCKS;
994 #else
995 return -1;
996 #endif
997 case _SC_SPIN_LOCKS:
998 #if _POSIX_SPIN_LOCKS > 0
999 return _POSIX_SPIN_LOCKS;
1000 #else
1001 return -1;
1002 #endif
1004 case _SC_REGEXP:
1005 #if _POSIX_REGEXP > 0
1006 return _POSIX_REGEXP;
1007 #else
1008 return -1;
1009 #endif
1010 case _SC_REGEX_VERSION:
1011 #if _POSIX_REGEX_VERSION > 0
1012 return _POSIX_REGEX_VERSION;
1013 #else
1014 return -1;
1015 #endif
1017 case _SC_SHELL:
1018 #if _POSIX_SHELL > 0
1019 return _POSIX_SHELL;
1020 #else
1021 return -1;
1022 #endif
1024 case _SC_SIGNALS:
1025 #ifdef _POSUX_SIGNALS
1026 return _POSIX_SIGNALS;
1027 #else
1028 return -1;
1029 #endif
1031 case _SC_SPAWN:
1032 #if _POSIX_SPAWN > 0
1033 return _POSIX_SPAWN;
1034 #else
1035 return -1;
1036 #endif
1038 case _SC_SPORADIC_SERVER:
1039 #if _POSIX_SPORADIC_SERVER > 0
1040 return _POSIX_SPORADIC_SERVER;
1041 #else
1042 return -1;
1043 #endif
1044 case _SC_THREAD_SPORADIC_SERVER:
1045 #if _POSIX_THREAD_SPORADIC_SERVER > 0
1046 return _POSIX_THREAD_SPORADIC_SERVER;
1047 #else
1048 return -1;
1049 #endif
1051 case _SC_SYSTEM_DATABASE:
1052 #if _POSIX_SYSTEM_DATABASE > 0
1053 return _POSIX_SYSTEM_DATABASE;
1054 #else
1055 return -1;
1056 #endif
1057 case _SC_SYSTEM_DATABASE_R:
1058 #if _POSIX_SYSTEM_DATABASE_R > 0
1059 return _POSIX_SYSTEM_DATABASE_R;
1060 #else
1061 return -1;
1062 #endif
1064 case _SC_THREAD_CPUTIME:
1065 #if _POSIX_THREAD_CPUTIME > 0
1066 return _POSIX_THREAD_CPUTIME;
1067 #else
1068 return -1;
1069 #endif
1071 case _SC_TIMEOUTS:
1072 #if _POSIX_TIMEOUTS > 0
1073 return _POSIX_TIMEOUTS;
1074 #else
1075 return -1;
1076 #endif
1078 case _SC_TYPED_MEMORY_OBJECTS:
1079 #if _POSIX_TYPED_MEMORY_OBJECTS > 0
1080 return _POSIX_TYPED_MEMORY_OBJECTS;
1081 #else
1082 return -1;
1083 #endif
1085 case _SC_USER_GROUPS:
1086 #if _POSIX_USER_GROUPS > 0
1087 return _POSIX_USER_GROUPS;
1088 #else
1089 return -1;
1090 #endif
1091 case _SC_USER_GROUPS_R:
1092 #if _POSIX_USER_GROUPS_R > 0
1093 return _POSIX_USER_GROUPS_R;
1094 #else
1095 return -1;
1096 #endif
1098 case _SC_2_PBS:
1099 #ifdef _POSIX2_PBS
1100 return _POSIX2_PBS;
1101 #else
1102 return -1;
1103 #endif
1104 case _SC_2_PBS_ACCOUNTING:
1105 #ifdef _POSIX2_PBS_ACCOUNTING
1106 return _POSIX2_PBS_ACCOUNTING;
1107 #else
1108 return -1;
1109 #endif
1110 case _SC_2_PBS_CHECKPOINT:
1111 #ifdef _POSIX2_PBS_CHECKPOINT
1112 return _POSIX2_PBS_CHECKPOINT;
1113 #else
1114 return -1;
1115 #endif
1116 case _SC_2_PBS_LOCATE:
1117 #ifdef _POSIX2_PBS_LOCATE
1118 return _POSIX2_PBS_LOCATE;
1119 #else
1120 return -1;
1121 #endif
1122 case _SC_2_PBS_MESSAGE:
1123 #ifdef _POSIX2_PBS_MESSAGE
1124 return _POSIX2_PBS_MESSAGE;
1125 #else
1126 return -1;
1127 #endif
1128 case _SC_2_PBS_TRACK:
1129 #ifdef _POSIX2_PBS_TRACK
1130 return _POSIX2_PBS_TRACK;
1131 #else
1132 return -1;
1133 #endif
1135 case _SC_SYMLOOP_MAX:
1136 #ifdef SYMLOOP_MAX
1137 return SYMLOOP_MAX;
1138 #else
1139 return -1;
1140 #endif
1142 case _SC_STREAMS:
1143 #ifdef _XOPEN_STREAMS
1144 return _XOPEN_STREAMS;
1145 #else
1146 return -1;
1147 #endif
1149 case _SC_HOST_NAME_MAX:
1150 #ifdef HOST_NAME_MAX
1151 return HOST_NAME_MAX;
1152 #else
1153 return -1;
1154 #endif
1156 case _SC_TRACE:
1157 #if _POSIX_TRACE > 0
1158 return _POSIX_TRACE;
1159 #else
1160 return -1;
1161 #endif
1162 case _SC_TRACE_EVENT_FILTER:
1163 #if _POSIX_TRACE_EVENT_FILTER > 0
1164 return _POSIX_TRACE_EVENT_FILTER;
1165 #else
1166 return -1;
1167 #endif
1168 case _SC_TRACE_INHERIT:
1169 #if _POSIX_TRACE_INHERIT > 0
1170 return _POSIX_TRACE_INHERIT;
1171 #else
1172 return -1;
1173 #endif
1174 case _SC_TRACE_LOG:
1175 #if _POSIX_TRACE_LOG > 0
1176 return _POSIX_TRACE_LOG;
1177 #else
1178 return -1;
1179 #endif
1181 case _SC_LEVEL1_ICACHE_SIZE:
1182 case _SC_LEVEL1_ICACHE_ASSOC:
1183 case _SC_LEVEL1_ICACHE_LINESIZE:
1184 case _SC_LEVEL1_DCACHE_SIZE:
1185 case _SC_LEVEL1_DCACHE_ASSOC:
1186 case _SC_LEVEL1_DCACHE_LINESIZE:
1187 case _SC_LEVEL2_CACHE_SIZE:
1188 case _SC_LEVEL2_CACHE_ASSOC:
1189 case _SC_LEVEL2_CACHE_LINESIZE:
1190 case _SC_LEVEL3_CACHE_SIZE:
1191 case _SC_LEVEL3_CACHE_ASSOC:
1192 case _SC_LEVEL3_CACHE_LINESIZE:
1193 case _SC_LEVEL4_CACHE_SIZE:
1194 case _SC_LEVEL4_CACHE_ASSOC:
1195 /* In general we cannot determine these values. Therefore we
1196 return zero which indicates that no information is
1197 available. */
1198 return 0;
1200 case _SC_IPV6:
1201 #if _POSIX_IPV6 > 0
1202 return _POSIX_IPV6;
1203 #else
1204 return -1;
1205 #endif
1207 case _SC_RAW_SOCKETS:
1208 #if _POSIX_RAW_SOCKETS > 0
1209 return _POSIX_RAW_SOCKETS;
1210 #else
1211 return -1;
1212 #endif
1216 #undef __sysconf
1217 weak_alias (__sysconf, sysconf)
1218 libc_hidden_def (__sysconf)
1220 #if NEED_CHECK_SPEC
1221 static long int
1222 __sysconf_check_spec (const char *spec)
1224 int save_errno = errno;
1226 const char *getconf_dir = __secure_getenv ("GETCONF_DIR") ?: GETCONF_DIR;
1227 size_t getconf_dirlen = strlen (getconf_dir);
1228 size_t speclen = strlen (spec);
1230 char name[getconf_dirlen + sizeof ("/POSIX_V6_") + speclen];
1231 memcpy (mempcpy (mempcpy (name, getconf_dir, getconf_dirlen),
1232 "/POSIX_V6_", sizeof ("/POSIX_V6_") - 1),
1233 spec, speclen + 1);
1235 struct stat64 st;
1236 long int ret = __xstat64 (_STAT_VER, name, &st) >= 0 ? 1 : -1;
1238 __set_errno (save_errno);
1239 return ret;
1241 #endif