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