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