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