AArch64: Update relocations for ILP32
[glibc.git] / sysdeps / posix / sysconf.c
blobe815cd5ff1365cb48a5e033c3bf24d763b976cf3
1 /* Copyright (C) 1991-2014 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, see
16 <http://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <limits.h>
20 #include <grp.h>
21 #include <pwd.h>
22 #include <stddef.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <time.h>
27 #include <unistd.h>
28 #include <sys/param.h>
29 #include <sys/stat.h>
30 #include <sys/sysinfo.h>
31 #include <sys/types.h>
32 #include <regex.h>
35 #define NEED_CHECK_SPEC \
36 (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
37 || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \
38 || !defined _POSIX_V6_ILP32_OFF32 || !defined _POSIX_V6_ILP32_OFFBIG \
39 || !defined _POSIX_V6_LP64_OFF64 || !defined _POSIX_V6_LPBIG_OFFBIG \
40 || !defined _POSIX_V7_ILP32_OFF32 || !defined _POSIX_V7_ILP32_OFFBIG \
41 || !defined _POSIX_V7_LP64_OFF64 || !defined _POSIX_V7_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 #define START_ENV_GROUP(VERSION) \
794 /* Empty. */
796 #define END_ENV_GROUP(VERSION) \
797 /* Empty. */
799 #define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
800 case _SC_##SC_PREFIX##_##SUFFIX: \
801 return _##ENV_PREFIX##_##SUFFIX;
803 #define KNOWN_PRESENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
804 case _SC_##SC_PREFIX##_##SUFFIX: \
805 return _##ENV_PREFIX##_##SUFFIX;
807 #define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
808 case _SC_##SC_PREFIX##_##SUFFIX: \
809 return __sysconf_check_spec (#SUFFIX);
811 #include <posix/posix-envs.def>
813 #undef START_ENV_GROUP
814 #undef END_ENV_GROUP
815 #undef KNOWN_ABSENT_ENVIRONMENT
816 #undef KNOWN_PRESENT_ENVIRONMENT
817 #undef UNKNOWN_ENVIRONMENT
819 case _SC_XOPEN_LEGACY:
820 return _XOPEN_LEGACY;
822 case _SC_XOPEN_REALTIME:
823 #ifdef _XOPEN_REALTIME
824 return _XOPEN_REALTIME;
825 #else
826 return -1;
827 #endif
828 case _SC_XOPEN_REALTIME_THREADS:
829 #ifdef _XOPEN_REALTIME_THREADS
830 return _XOPEN_REALTIME_THREADS;
831 #else
832 return -1;
833 #endif
835 case _SC_ADVISORY_INFO:
836 #if _POSIX_ADVISORY_INFO > 0
837 return _POSIX_ADVISORY_INFO;
838 #else
839 return -1;
840 #endif
842 case _SC_BARRIERS:
843 #if _POSIX_BARRIERS > 0
844 return _POSIX_BARRIERS;
845 #else
846 return -1;
847 #endif
849 case _SC_BASE:
850 #if _POSIX_BASE > 0
851 return _POSIX_BASE;
852 #else
853 return -1;
854 #endif
855 case _SC_C_LANG_SUPPORT:
856 #if _POSIX_C_LANG_SUPPORT > 0
857 return _POSIX_C_LANG_SUPPORT;
858 #else
859 return -1;
860 #endif
861 case _SC_C_LANG_SUPPORT_R:
862 #if _POSIX_C_LANG_SUPPORT_R > 0
863 return _POSIX_C_LANG_SUPPORT_R;
864 #else
865 return -1;
866 #endif
868 case _SC_CLOCK_SELECTION:
869 #if _POSIX_CLOCK_SELECTION > 0
870 return _POSIX_CLOCK_SELECTION;
871 #else
872 return -1;
873 #endif
875 case _SC_CPUTIME:
876 #if _POSIX_CPUTIME > 0
877 return _POSIX_CPUTIME;
878 #else
879 return -1;
880 #endif
882 case _SC_DEVICE_IO:
883 #if _POSIX_DEVICE_IO > 0
884 return _POSIX_DEVICE_IO;
885 #else
886 return -1;
887 #endif
888 case _SC_DEVICE_SPECIFIC:
889 #if _POSIX_DEVICE_SPECIFIC > 0
890 return _POSIX_DEVICE_SPECIFIC;
891 #else
892 return -1;
893 #endif
894 case _SC_DEVICE_SPECIFIC_R:
895 #if _POSIX_DEVICE_SPECIFIC_R > 0
896 return _POSIX_DEVICE_SPECIFIC_R;
897 #else
898 return -1;
899 #endif
901 case _SC_FD_MGMT:
902 #if _POSIX_FD_MGMT > 0
903 return _POSIX_FD_MGMT;
904 #else
905 return -1;
906 #endif
908 case _SC_FIFO:
909 #if _POSIX_FIFO > 0
910 return _POSIX_FIFO;
911 #else
912 return -1;
913 #endif
914 case _SC_PIPE:
915 #if _POSIX_PIPE > 0
916 return _POSIX_PIPE;
917 #else
918 return -1;
919 #endif
921 case _SC_FILE_ATTRIBUTES:
922 #if _POSIX_FILE_ATTRIBUTES > 0
923 return _POSIX_FILE_ATTRIBUTES;
924 #else
925 return -1;
926 #endif
927 case _SC_FILE_LOCKING:
928 #if _POSIX_FILE_LOCKING > 0
929 return _POSIX_FILE_LOCKING;
930 #else
931 return -1;
932 #endif
933 case _SC_FILE_SYSTEM:
934 #if _POSIX_FILE_SYSTEM > 0
935 return _POSIX_FILE_SYSTEM;
936 #else
937 return -1;
938 #endif
940 case _SC_MONOTONIC_CLOCK:
941 #if _POSIX_MONOTONIC_CLOCK
942 return _POSIX_MONOTONIC_CLOCK;
943 #else
944 return -1;
945 #endif
947 case _SC_MULTI_PROCESS:
948 #if _POSIX_MULTI_PROCESS > 0
949 return _POSIX_MULTI_PROCESS;
950 #else
951 return -1;
952 #endif
953 case _SC_SINGLE_PROCESS:
954 #if _POSIX_SINGLE_PROCESS > 0
955 return _POSIX_SINGLE_PROCESS;
956 #else
957 return -1;
958 #endif
960 case _SC_NETWORKING:
961 #if _POSIX_NETWORKING > 0
962 return _POSIX_NETWORKING;
963 #else
964 return -1;
965 #endif
967 case _SC_READER_WRITER_LOCKS:
968 #if _POSIX_READER_WRITER_LOCKS > 0
969 return _POSIX_READER_WRITER_LOCKS;
970 #else
971 return -1;
972 #endif
973 case _SC_SPIN_LOCKS:
974 #if _POSIX_SPIN_LOCKS > 0
975 return _POSIX_SPIN_LOCKS;
976 #else
977 return -1;
978 #endif
980 case _SC_REGEXP:
981 #if _POSIX_REGEXP > 0
982 return _POSIX_REGEXP;
983 #else
984 return -1;
985 #endif
986 /* _REGEX_VERSION has been removed with IEEE Std 1003.1-2001/Cor 2-2004,
987 item XSH/TC2/D6/137. */
988 case _SC_REGEX_VERSION:
989 return -1;
991 case _SC_SHELL:
992 #if _POSIX_SHELL > 0
993 return _POSIX_SHELL;
994 #else
995 return -1;
996 #endif
998 case _SC_SIGNALS:
999 #ifdef _POSIX_SIGNALS
1000 return _POSIX_SIGNALS;
1001 #else
1002 return -1;
1003 #endif
1005 case _SC_SPAWN:
1006 #if _POSIX_SPAWN > 0
1007 return _POSIX_SPAWN;
1008 #else
1009 return -1;
1010 #endif
1012 case _SC_SPORADIC_SERVER:
1013 #if _POSIX_SPORADIC_SERVER > 0
1014 return _POSIX_SPORADIC_SERVER;
1015 #else
1016 return -1;
1017 #endif
1018 case _SC_THREAD_SPORADIC_SERVER:
1019 #if _POSIX_THREAD_SPORADIC_SERVER > 0
1020 return _POSIX_THREAD_SPORADIC_SERVER;
1021 #else
1022 return -1;
1023 #endif
1025 case _SC_SYSTEM_DATABASE:
1026 #if _POSIX_SYSTEM_DATABASE > 0
1027 return _POSIX_SYSTEM_DATABASE;
1028 #else
1029 return -1;
1030 #endif
1031 case _SC_SYSTEM_DATABASE_R:
1032 #if _POSIX_SYSTEM_DATABASE_R > 0
1033 return _POSIX_SYSTEM_DATABASE_R;
1034 #else
1035 return -1;
1036 #endif
1038 case _SC_THREAD_CPUTIME:
1039 #if _POSIX_THREAD_CPUTIME > 0
1040 return _POSIX_THREAD_CPUTIME;
1041 #else
1042 return -1;
1043 #endif
1045 case _SC_TIMEOUTS:
1046 #if _POSIX_TIMEOUTS > 0
1047 return _POSIX_TIMEOUTS;
1048 #else
1049 return -1;
1050 #endif
1052 case _SC_TYPED_MEMORY_OBJECTS:
1053 #if _POSIX_TYPED_MEMORY_OBJECTS > 0
1054 return _POSIX_TYPED_MEMORY_OBJECTS;
1055 #else
1056 return -1;
1057 #endif
1059 case _SC_USER_GROUPS:
1060 #if _POSIX_USER_GROUPS > 0
1061 return _POSIX_USER_GROUPS;
1062 #else
1063 return -1;
1064 #endif
1065 case _SC_USER_GROUPS_R:
1066 #if _POSIX_USER_GROUPS_R > 0
1067 return _POSIX_USER_GROUPS_R;
1068 #else
1069 return -1;
1070 #endif
1072 case _SC_2_PBS:
1073 #ifdef _POSIX2_PBS
1074 return _POSIX2_PBS;
1075 #else
1076 return -1;
1077 #endif
1078 case _SC_2_PBS_ACCOUNTING:
1079 #ifdef _POSIX2_PBS_ACCOUNTING
1080 return _POSIX2_PBS_ACCOUNTING;
1081 #else
1082 return -1;
1083 #endif
1084 case _SC_2_PBS_CHECKPOINT:
1085 #ifdef _POSIX2_PBS_CHECKPOINT
1086 return _POSIX2_PBS_CHECKPOINT;
1087 #else
1088 return -1;
1089 #endif
1090 case _SC_2_PBS_LOCATE:
1091 #ifdef _POSIX2_PBS_LOCATE
1092 return _POSIX2_PBS_LOCATE;
1093 #else
1094 return -1;
1095 #endif
1096 case _SC_2_PBS_MESSAGE:
1097 #ifdef _POSIX2_PBS_MESSAGE
1098 return _POSIX2_PBS_MESSAGE;
1099 #else
1100 return -1;
1101 #endif
1102 case _SC_2_PBS_TRACK:
1103 #ifdef _POSIX2_PBS_TRACK
1104 return _POSIX2_PBS_TRACK;
1105 #else
1106 return -1;
1107 #endif
1109 case _SC_SYMLOOP_MAX:
1110 #ifdef SYMLOOP_MAX
1111 return SYMLOOP_MAX;
1112 #else
1113 return -1;
1114 #endif
1116 case _SC_STREAMS:
1117 #ifdef _XOPEN_STREAMS
1118 return _XOPEN_STREAMS;
1119 #else
1120 return -1;
1121 #endif
1123 case _SC_HOST_NAME_MAX:
1124 #ifdef HOST_NAME_MAX
1125 return HOST_NAME_MAX;
1126 #else
1127 return -1;
1128 #endif
1130 case _SC_TRACE:
1131 #if _POSIX_TRACE > 0
1132 return _POSIX_TRACE;
1133 #else
1134 return -1;
1135 #endif
1136 case _SC_TRACE_EVENT_FILTER:
1137 #if _POSIX_TRACE_EVENT_FILTER > 0
1138 return _POSIX_TRACE_EVENT_FILTER;
1139 #else
1140 return -1;
1141 #endif
1142 case _SC_TRACE_INHERIT:
1143 #if _POSIX_TRACE_INHERIT > 0
1144 return _POSIX_TRACE_INHERIT;
1145 #else
1146 return -1;
1147 #endif
1148 case _SC_TRACE_LOG:
1149 #if _POSIX_TRACE_LOG > 0
1150 return _POSIX_TRACE_LOG;
1151 #else
1152 return -1;
1153 #endif
1155 case _SC_TRACE_EVENT_NAME_MAX:
1156 case _SC_TRACE_NAME_MAX:
1157 case _SC_TRACE_SYS_MAX:
1158 case _SC_TRACE_USER_EVENT_MAX:
1159 /* No support for tracing. */
1161 case _SC_XOPEN_STREAMS:
1162 /* No support for STREAMS. */
1163 return -1;
1165 case _SC_LEVEL1_ICACHE_SIZE:
1166 case _SC_LEVEL1_ICACHE_ASSOC:
1167 case _SC_LEVEL1_ICACHE_LINESIZE:
1168 case _SC_LEVEL1_DCACHE_SIZE:
1169 case _SC_LEVEL1_DCACHE_ASSOC:
1170 case _SC_LEVEL1_DCACHE_LINESIZE:
1171 case _SC_LEVEL2_CACHE_SIZE:
1172 case _SC_LEVEL2_CACHE_ASSOC:
1173 case _SC_LEVEL2_CACHE_LINESIZE:
1174 case _SC_LEVEL3_CACHE_SIZE:
1175 case _SC_LEVEL3_CACHE_ASSOC:
1176 case _SC_LEVEL3_CACHE_LINESIZE:
1177 case _SC_LEVEL4_CACHE_SIZE:
1178 case _SC_LEVEL4_CACHE_ASSOC:
1179 case _SC_LEVEL4_CACHE_LINESIZE:
1180 /* In general we cannot determine these values. Therefore we
1181 return zero which indicates that no information is
1182 available. */
1183 return 0;
1185 case _SC_IPV6:
1186 #if _POSIX_IPV6 > 0
1187 return _POSIX_IPV6;
1188 #else
1189 return -1;
1190 #endif
1192 case _SC_RAW_SOCKETS:
1193 #if _POSIX_RAW_SOCKETS > 0
1194 return _POSIX_RAW_SOCKETS;
1195 #else
1196 return -1;
1197 #endif
1201 #undef __sysconf
1202 weak_alias (__sysconf, sysconf)
1203 libc_hidden_def (__sysconf)
1205 #if NEED_CHECK_SPEC
1206 static long int
1207 __sysconf_check_spec (const char *spec)
1209 int save_errno = errno;
1211 const char *getconf_dir = __libc_secure_getenv ("GETCONF_DIR") ?: GETCONF_DIR;
1212 size_t getconf_dirlen = strlen (getconf_dir);
1213 size_t speclen = strlen (spec);
1215 char name[getconf_dirlen + sizeof ("/POSIX_V6_") + speclen];
1216 memcpy (mempcpy (mempcpy (name, getconf_dir, getconf_dirlen),
1217 "/POSIX_V6_", sizeof ("/POSIX_V6_") - 1),
1218 spec, speclen + 1);
1220 struct stat64 st;
1221 long int ret = __xstat64 (_STAT_VER, name, &st) >= 0 ? 1 : -1;
1223 __set_errno (save_errno);
1224 return ret;
1226 #endif