sysconf.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. /* Copyright (C) 1991, 93, 95, 96, 97, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 02111-1307, USA. */
  15. #define _XOPEN_SOURCE 500
  16. #include <features.h>
  17. #include <errno.h>
  18. #include <limits.h>
  19. #include <grp.h>
  20. #include <pwd.h>
  21. #include <stddef.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <time.h>
  25. #include <unistd.h>
  26. #include <sys/syscall.h>
  27. #include <sys/sysinfo.h>
  28. #include <sys/types.h>
  29. #ifdef __UCLIBC_HAS_REGEX__
  30. #include <regex.h>
  31. #endif
  32. /* libc_hidden_proto(sysconf) */
  33. /* libc_hidden_proto(getpagesize) */
  34. /* libc_hidden_proto(getdtablesize) */
  35. #ifndef __UCLIBC_CLK_TCK_CONST
  36. #error __UCLIBC_CLK_TCK_CONST not defined!
  37. #endif
  38. /***********************************************************************/
  39. /*
  40. * Manuel Novoa III Jan 2001
  41. *
  42. * On i386, the switch-based implementation generates 796 bytes of code.
  43. * However, many of the return values are repeats. By collecting these
  44. * repeats and moving to a table-based implementation, we generate 283
  45. * bytes on i386 (-Os -fomit-frame-pointer).
  46. */
  47. #ifdef _UCLIBC_GENERATE_SYSCONF_ARCH
  48. /*
  49. * Set some errno's so the auto-gen code knows what it is dealing with.
  50. * 1) ENOSYS signifies that we're returning a default value.
  51. * This is just extra info for development.
  52. * 2) EISNAM signifies that the value returned varies at runtime.
  53. *
  54. * Option: GETPAGESIZE_IS_DYNAMIC
  55. * The current implementation of getpagesize in uClibc returns
  56. * a constant. The pagesize on the target arch should not vary,
  57. * so it should be safe to set this as 0.
  58. */
  59. #define RETURN_NEG_1 __set_errno(ENOSYS); return -1
  60. #define RETURN_FUNCTION(f) __set_errno(EISNAM); return (long int) #f
  61. #define GETPAGESIZE_IS_DYNAMIC 0
  62. #else
  63. #define RETURN_NEG_1 return -1
  64. #define RETURN_FUNCTION(f) return f;
  65. #endif /* _UCLIBC_GENERATE_SYSCONF_ARCH */
  66. /* Get the value of the system variable NAME. */
  67. long int sysconf(int name)
  68. {
  69. switch (name)
  70. {
  71. default:
  72. __set_errno(EINVAL);
  73. return -1;
  74. case _SC_ARG_MAX:
  75. #ifdef ARG_MAX
  76. return ARG_MAX;
  77. #else
  78. RETURN_NEG_1;
  79. #endif
  80. case _SC_CHILD_MAX:
  81. #ifdef CHILD_MAX
  82. return CHILD_MAX;
  83. #else
  84. RETURN_NEG_1;
  85. #endif
  86. case _SC_CLK_TCK:
  87. /* Can't use CLK_TCK here since that calls __sysconf(_SC_CLK_TCK) */
  88. return __UCLIBC_CLK_TCK_CONST;
  89. case _SC_NGROUPS_MAX:
  90. #ifdef NGROUPS_MAX
  91. return NGROUPS_MAX;
  92. #else
  93. RETURN_NEG_1;
  94. #endif
  95. case _SC_OPEN_MAX:
  96. RETURN_FUNCTION(getdtablesize());
  97. case _SC_STREAM_MAX:
  98. #ifdef STREAM_MAX
  99. return STREAM_MAX;
  100. #else
  101. return FOPEN_MAX;
  102. #endif
  103. case _SC_TZNAME_MAX:
  104. return _POSIX_TZNAME_MAX;
  105. case _SC_JOB_CONTROL:
  106. #ifdef _POSIX_JOB_CONTROL
  107. return 1;
  108. #else
  109. RETURN_NEG_1;
  110. #endif
  111. case _SC_SAVED_IDS:
  112. #ifdef _POSIX_SAVED_IDS
  113. return 1;
  114. #else
  115. RETURN_NEG_1;
  116. #endif
  117. case _SC_REALTIME_SIGNALS:
  118. #ifdef _POSIX_REALTIME_SIGNALS
  119. return 1;
  120. #else
  121. RETURN_NEG_1;
  122. #endif
  123. case _SC_PRIORITY_SCHEDULING:
  124. #ifdef _POSIX_PRIORITY_SCHEDULING
  125. return 1;
  126. #else
  127. RETURN_NEG_1;
  128. #endif
  129. case _SC_TIMERS:
  130. #ifdef _POSIX_TIMERS
  131. return 1;
  132. #else
  133. RETURN_NEG_1;
  134. #endif
  135. case _SC_ASYNCHRONOUS_IO:
  136. #ifdef _POSIX_ASYNCHRONOUS_IO
  137. return 1;
  138. #else
  139. RETURN_NEG_1;
  140. #endif
  141. case _SC_PRIORITIZED_IO:
  142. #ifdef _POSIX_PRIORITIZED_IO
  143. return 1;
  144. #else
  145. RETURN_NEG_1;
  146. #endif
  147. case _SC_SYNCHRONIZED_IO:
  148. #ifdef _POSIX_SYNCHRONIZED_IO
  149. return 1;
  150. #else
  151. RETURN_NEG_1;
  152. #endif
  153. case _SC_FSYNC:
  154. #ifdef _POSIX_FSYNC
  155. return 1;
  156. #else
  157. RETURN_NEG_1;
  158. #endif
  159. case _SC_MAPPED_FILES:
  160. #ifdef _POSIX_MAPPED_FILES
  161. return 1;
  162. #else
  163. RETURN_NEG_1;
  164. #endif
  165. case _SC_MEMLOCK:
  166. #ifdef _POSIX_MEMLOCK
  167. return 1;
  168. #else
  169. RETURN_NEG_1;
  170. #endif
  171. case _SC_MEMLOCK_RANGE:
  172. #ifdef _POSIX_MEMLOCK_RANGE
  173. return 1;
  174. #else
  175. RETURN_NEG_1;
  176. #endif
  177. case _SC_MEMORY_PROTECTION:
  178. #ifdef _POSIX_MEMORY_PROTECTION
  179. return 1;
  180. #else
  181. RETURN_NEG_1;
  182. #endif
  183. case _SC_MESSAGE_PASSING:
  184. #ifdef _POSIX_MESSAGE_PASSING
  185. return 1;
  186. #else
  187. RETURN_NEG_1;
  188. #endif
  189. case _SC_SEMAPHORES:
  190. #ifdef _POSIX_SEMAPHORES
  191. return 1;
  192. #else
  193. RETURN_NEG_1;
  194. #endif
  195. case _SC_SHARED_MEMORY_OBJECTS:
  196. #ifdef _POSIX_SHARED_MEMORY_OBJECTS
  197. return 1;
  198. #else
  199. RETURN_NEG_1;
  200. #endif
  201. case _SC_VERSION:
  202. return _POSIX_VERSION;
  203. case _SC_PAGESIZE:
  204. #if defined(GETPAGESIZE_IS_DYNAMIC) && (GETPAGESIZE_IS_DYNAMIC == 1)
  205. RETURN_FUNCTION(getpagesize());
  206. #else
  207. return getpagesize(); /* note: currently this is not dynamic */
  208. #endif
  209. case _SC_AIO_LISTIO_MAX:
  210. #ifdef AIO_LISTIO_MAX
  211. return AIO_LISTIO_MAX;
  212. #else
  213. RETURN_NEG_1;
  214. #endif
  215. case _SC_AIO_MAX:
  216. #ifdef AIO_MAX
  217. return AIO_MAX;
  218. #else
  219. RETURN_NEG_1;
  220. #endif
  221. case _SC_AIO_PRIO_DELTA_MAX:
  222. #ifdef AIO_PRIO_DELTA_MAX
  223. return AIO_PRIO_DELTA_MAX;
  224. #else
  225. RETURN_NEG_1;
  226. #endif
  227. case _SC_DELAYTIMER_MAX:
  228. #ifdef DELAYTIMER_MAX
  229. return DELAYTIMER_MAX;
  230. #else
  231. RETURN_NEG_1;
  232. #endif
  233. case _SC_MQ_OPEN_MAX:
  234. #ifdef MQ_OPEN_MAX
  235. return MQ_OPEN_MAX;
  236. #else
  237. RETURN_NEG_1;
  238. #endif
  239. case _SC_MQ_PRIO_MAX:
  240. #ifdef MQ_PRIO_MAX
  241. return MQ_PRIO_MAX;
  242. #else
  243. RETURN_NEG_1;
  244. #endif
  245. case _SC_RTSIG_MAX:
  246. #ifdef RTSIG_MAX
  247. return RTSIG_MAX;
  248. #else
  249. RETURN_NEG_1;
  250. #endif
  251. case _SC_SEM_NSEMS_MAX:
  252. #ifdef SEM_NSEMS_MAX
  253. return SEM_NSEMS_MAX;
  254. #else
  255. RETURN_NEG_1;
  256. #endif
  257. case _SC_SEM_VALUE_MAX:
  258. #ifdef SEM_VALUE_MAX
  259. return SEM_VALUE_MAX;
  260. #else
  261. RETURN_NEG_1;
  262. #endif
  263. case _SC_SIGQUEUE_MAX:
  264. #ifdef SIGQUEUE_MAX
  265. return SIGQUEUE_MAX;
  266. #else
  267. RETURN_NEG_1;
  268. #endif
  269. case _SC_TIMER_MAX:
  270. #ifdef TIMER_MAX
  271. return TIMER_MAX;
  272. #else
  273. RETURN_NEG_1;
  274. #endif
  275. case _SC_BC_BASE_MAX:
  276. #ifdef BC_BASE_MAX
  277. return BC_BASE_MAX;
  278. #else
  279. RETURN_NEG_1;
  280. #endif
  281. case _SC_BC_DIM_MAX:
  282. #ifdef BC_DIM_MAX
  283. return BC_DIM_MAX;
  284. #else
  285. RETURN_NEG_1;
  286. #endif
  287. case _SC_BC_SCALE_MAX:
  288. #ifdef BC_SCALE_MAX
  289. return BC_SCALE_MAX;
  290. #else
  291. RETURN_NEG_1;
  292. #endif
  293. case _SC_BC_STRING_MAX:
  294. #ifdef BC_STRING_MAX
  295. return BC_STRING_MAX;
  296. #else
  297. RETURN_NEG_1;
  298. #endif
  299. case _SC_COLL_WEIGHTS_MAX:
  300. #ifdef COLL_WEIGHTS_MAX
  301. return COLL_WEIGHTS_MAX;
  302. #else
  303. RETURN_NEG_1;
  304. #endif
  305. case _SC_EQUIV_CLASS_MAX:
  306. #ifdef EQUIV_CLASS_MAX
  307. return EQUIV_CLASS_MAX;
  308. #else
  309. RETURN_NEG_1;
  310. #endif
  311. case _SC_EXPR_NEST_MAX:
  312. #ifdef EXPR_NEST_MAX
  313. return EXPR_NEST_MAX;
  314. #else
  315. RETURN_NEG_1;
  316. #endif
  317. case _SC_LINE_MAX:
  318. #ifdef LINE_MAX
  319. return LINE_MAX;
  320. #else
  321. RETURN_NEG_1;
  322. #endif
  323. case _SC_RE_DUP_MAX:
  324. #ifdef RE_DUP_MAX
  325. return RE_DUP_MAX;
  326. #else
  327. RETURN_NEG_1;
  328. #endif
  329. case _SC_CHARCLASS_NAME_MAX:
  330. #ifdef CHARCLASS_NAME_MAX
  331. return CHARCLASS_NAME_MAX;
  332. #else
  333. RETURN_NEG_1;
  334. #endif
  335. case _SC_PII:
  336. #ifdef _POSIX_PII
  337. return 1;
  338. #else
  339. RETURN_NEG_1;
  340. #endif
  341. case _SC_PII_XTI:
  342. #ifdef _POSIX_PII_XTI
  343. return 1;
  344. #else
  345. RETURN_NEG_1;
  346. #endif
  347. case _SC_PII_SOCKET:
  348. #ifdef _POSIX_PII_SOCKET
  349. return 1;
  350. #else
  351. RETURN_NEG_1;
  352. #endif
  353. case _SC_PII_INTERNET:
  354. #ifdef _POSIX_PII_INTERNET
  355. return 1;
  356. #else
  357. RETURN_NEG_1;
  358. #endif
  359. case _SC_PII_OSI:
  360. #ifdef _POSIX_PII_OSI
  361. return 1;
  362. #else
  363. RETURN_NEG_1;
  364. #endif
  365. case _SC_POLL:
  366. #ifdef _POSIX_POLL
  367. return 1;
  368. #else
  369. RETURN_NEG_1;
  370. #endif
  371. case _SC_SELECT:
  372. #ifdef _POSIX_SELECT
  373. return 1;
  374. #else
  375. RETURN_NEG_1;
  376. #endif
  377. case _SC_UIO_MAXIOV:
  378. #ifdef UIO_MAXIOV
  379. return UIO_MAXIOV;
  380. #else
  381. RETURN_NEG_1;
  382. #endif
  383. case _SC_PII_INTERNET_STREAM:
  384. #ifdef _POSIX_PII_INTERNET_STREAM
  385. return 1;
  386. #else
  387. RETURN_NEG_1;
  388. #endif
  389. case _SC_PII_INTERNET_DGRAM:
  390. #ifdef _POSIX_PII_INTERNET_DGRAM
  391. return 1;
  392. #else
  393. RETURN_NEG_1;
  394. #endif
  395. case _SC_PII_OSI_COTS:
  396. #ifdef _POSIX_PII_OSI_COTS
  397. return 1;
  398. #else
  399. RETURN_NEG_1;
  400. #endif
  401. case _SC_PII_OSI_CLTS:
  402. #ifdef _POSIX_PII_OSI_CLTS
  403. return 1;
  404. #else
  405. RETURN_NEG_1;
  406. #endif
  407. case _SC_PII_OSI_M:
  408. #ifdef _POSIX_PII_OSI_M
  409. return 1;
  410. #else
  411. RETURN_NEG_1;
  412. #endif
  413. case _SC_T_IOV_MAX:
  414. #ifdef _T_IOV_MAX
  415. return _T_IOV_MAX;
  416. #else
  417. RETURN_NEG_1;
  418. #endif
  419. case _SC_2_VERSION:
  420. return _POSIX2_VERSION;
  421. case _SC_2_C_BIND:
  422. #ifdef _POSIX2_C_BIND
  423. return _POSIX2_C_BIND;
  424. #else
  425. RETURN_NEG_1;
  426. #endif
  427. case _SC_2_C_DEV:
  428. #ifdef _POSIX2_C_DEV
  429. return _POSIX2_C_DEV;
  430. #else
  431. RETURN_NEG_1;
  432. #endif
  433. case _SC_2_C_VERSION:
  434. #ifdef _POSIX2_C_VERSION
  435. return _POSIX2_C_VERSION;
  436. #else
  437. RETURN_NEG_1;
  438. #endif
  439. case _SC_2_FORT_DEV:
  440. #ifdef _POSIX2_FORT_DEV
  441. return _POSIX2_FORT_DEV;
  442. #else
  443. RETURN_NEG_1;
  444. #endif
  445. case _SC_2_FORT_RUN:
  446. #ifdef _POSIX2_FORT_RUN
  447. return _POSIX2_FORT_RUN;
  448. #else
  449. RETURN_NEG_1;
  450. #endif
  451. case _SC_2_LOCALEDEF:
  452. #ifdef _POSIX2_LOCALEDEF
  453. return _POSIX2_LOCALEDEF;
  454. #else
  455. RETURN_NEG_1;
  456. #endif
  457. case _SC_2_SW_DEV:
  458. #ifdef _POSIX2_SW_DEV
  459. return _POSIX2_SW_DEV;
  460. #else
  461. RETURN_NEG_1;
  462. #endif
  463. case _SC_2_CHAR_TERM:
  464. #ifdef _POSIX2_CHAR_TERM
  465. return _POSIX2_CHAR_TERM;
  466. #else
  467. RETURN_NEG_1;
  468. #endif
  469. case _SC_2_UPE:
  470. #ifdef _POSIX2_UPE
  471. return _POSIX2_UPE;
  472. #else
  473. RETURN_NEG_1;
  474. #endif
  475. /* POSIX 1003.1c (POSIX Threads). */
  476. case _SC_THREADS:
  477. #ifdef __UCLIBC_HAS_THREADS__
  478. return 1;
  479. #else
  480. RETURN_NEG_1;
  481. #endif
  482. case _SC_THREAD_SAFE_FUNCTIONS:
  483. #ifdef __UCLIBC_HAS_THREADS__
  484. return 1;
  485. #else
  486. RETURN_NEG_1;
  487. #endif
  488. /* If you change these, also change libc/pwd_grp/pwd_grp.c to match */
  489. case _SC_GETGR_R_SIZE_MAX:
  490. return __UCLIBC_GRP_BUFFER_SIZE__;
  491. case _SC_GETPW_R_SIZE_MAX:
  492. return __UCLIBC_PWD_BUFFER_SIZE__;
  493. /* getlogin() is a worthless interface. In uClibc we let the user specify
  494. * whatever they want via the LOGNAME environment variable, or we return NULL
  495. * if getenv() fails to find anything. So this is merely how large a env
  496. * variable can be. Lets use 256 */
  497. case _SC_LOGIN_NAME_MAX:
  498. return 256;
  499. /* If you change this, also change _SC_TTY_NAME_MAX in libc/unistd/sysconf.c */
  500. #define TTYNAME_BUFLEN 32
  501. case _SC_TTY_NAME_MAX:
  502. return TTYNAME_BUFLEN;
  503. case _SC_THREAD_DESTRUCTOR_ITERATIONS:
  504. #ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
  505. return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
  506. #else
  507. RETURN_NEG_1;
  508. #endif
  509. case _SC_THREAD_KEYS_MAX:
  510. #ifdef PTHREAD_KEYS_MAX
  511. return PTHREAD_KEYS_MAX;
  512. #else
  513. RETURN_NEG_1;
  514. #endif
  515. case _SC_THREAD_STACK_MIN:
  516. #ifdef PTHREAD_STACK_MIN
  517. return PTHREAD_STACK_MIN;
  518. #else
  519. RETURN_NEG_1;
  520. #endif
  521. case _SC_THREAD_THREADS_MAX:
  522. #ifdef PTHREAD_THREADS_MAX
  523. return PTHREAD_THREADS_MAX;
  524. #else
  525. RETURN_NEG_1;
  526. #endif
  527. case _SC_THREAD_ATTR_STACKADDR:
  528. #ifdef _POSIX_THREAD_ATTR_STACKADDR
  529. return 1;
  530. #else
  531. RETURN_NEG_1;
  532. #endif
  533. case _SC_THREAD_ATTR_STACKSIZE:
  534. #ifdef _POSIX_THREAD_ATTR_STACKSIZE
  535. return 1;
  536. #else
  537. RETURN_NEG_1;
  538. #endif
  539. case _SC_THREAD_PRIORITY_SCHEDULING:
  540. #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
  541. return 1;
  542. #else
  543. RETURN_NEG_1;
  544. #endif
  545. case _SC_THREAD_PRIO_INHERIT:
  546. #ifdef _POSIX_THREAD_PRIO_INHERIT
  547. return 1;
  548. #else
  549. RETURN_NEG_1;
  550. #endif
  551. case _SC_THREAD_PRIO_PROTECT:
  552. #ifdef _POSIX_THREAD_PRIO_PROTECT
  553. return 1;
  554. #else
  555. RETURN_NEG_1;
  556. #endif
  557. case _SC_THREAD_PROCESS_SHARED:
  558. #ifdef _POSIX_THREAD_PROCESS_SHARED
  559. return 1;
  560. #else
  561. RETURN_NEG_1;
  562. #endif
  563. case _SC_NPROCESSORS_CONF:
  564. #if 0
  565. RETURN_FUNCTION(get_nprocs_conf());
  566. #else
  567. /* this is a hack. for now always claim we have exactly one cpu */
  568. return 1;
  569. #endif
  570. case _SC_NPROCESSORS_ONLN:
  571. #if 0
  572. RETURN_FUNCTION(get_nprocs());
  573. #else
  574. /* this is a hack. for now always claim we have exactly one cpu */
  575. return 1;
  576. #endif
  577. case _SC_PHYS_PAGES:
  578. #if 0
  579. RETURN_FUNCTION(get_phys_pages());
  580. #else
  581. RETURN_NEG_1;
  582. #endif
  583. case _SC_AVPHYS_PAGES:
  584. #if 0
  585. RETURN_FUNCTION(get_avphys_pages());
  586. #else
  587. RETURN_NEG_1;
  588. #endif
  589. case _SC_ATEXIT_MAX:
  590. return __UCLIBC_MAX_ATEXIT;
  591. case _SC_PASS_MAX:
  592. /* We have no limit but since the return value might be used to
  593. allocate a buffer we restrict the value. */
  594. return BUFSIZ;
  595. case _SC_XOPEN_VERSION:
  596. return _XOPEN_VERSION;
  597. case _SC_XOPEN_XCU_VERSION:
  598. return _XOPEN_XCU_VERSION;
  599. case _SC_XOPEN_UNIX:
  600. return _XOPEN_UNIX;
  601. case _SC_XOPEN_CRYPT:
  602. #ifdef _XOPEN_CRYPT
  603. return _XOPEN_CRYPT;
  604. #else
  605. RETURN_NEG_1;
  606. #endif
  607. case _SC_XOPEN_ENH_I18N:
  608. #ifdef _XOPEN_ENH_I18N
  609. return _XOPEN_ENH_I18N;
  610. #else
  611. RETURN_NEG_1;
  612. #endif
  613. case _SC_XOPEN_SHM:
  614. #ifdef _XOPEN_SHM
  615. return _XOPEN_SHM;
  616. #else
  617. RETURN_NEG_1;
  618. #endif
  619. case _SC_XOPEN_XPG2:
  620. #ifdef _XOPEN_XPG2
  621. return _XOPEN_XPG2;
  622. #else
  623. RETURN_NEG_1;
  624. #endif
  625. case _SC_XOPEN_XPG3:
  626. #ifdef _XOPEN_XPG3
  627. return _XOPEN_XPG3;
  628. #else
  629. RETURN_NEG_1;
  630. #endif
  631. case _SC_XOPEN_XPG4:
  632. #ifdef _XOPEN_XPG4
  633. return _XOPEN_XPG4;
  634. #else
  635. RETURN_NEG_1;
  636. #endif
  637. case _SC_CHAR_BIT:
  638. return CHAR_BIT;
  639. case _SC_CHAR_MAX:
  640. return CHAR_MAX;
  641. case _SC_CHAR_MIN:
  642. return CHAR_MIN;
  643. case _SC_INT_MAX:
  644. return INT_MAX;
  645. case _SC_INT_MIN:
  646. return INT_MIN;
  647. case _SC_LONG_BIT:
  648. return sizeof (long int) * CHAR_BIT;
  649. case _SC_WORD_BIT:
  650. return sizeof (int) * CHAR_BIT;
  651. case _SC_MB_LEN_MAX:
  652. return MB_LEN_MAX;
  653. case _SC_NZERO:
  654. return NZERO;
  655. case _SC_SSIZE_MAX:
  656. return _POSIX_SSIZE_MAX;
  657. case _SC_SCHAR_MAX:
  658. return SCHAR_MAX;
  659. case _SC_SCHAR_MIN:
  660. return SCHAR_MIN;
  661. case _SC_SHRT_MAX:
  662. return SHRT_MAX;
  663. case _SC_SHRT_MIN:
  664. return SHRT_MIN;
  665. case _SC_UCHAR_MAX:
  666. return UCHAR_MAX;
  667. case _SC_UINT_MAX:
  668. return UINT_MAX;
  669. case _SC_ULONG_MAX:
  670. return ULONG_MAX;
  671. case _SC_USHRT_MAX:
  672. return USHRT_MAX;
  673. case _SC_NL_ARGMAX:
  674. #ifdef NL_ARGMAX
  675. return NL_ARGMAX;
  676. #else
  677. RETURN_NEG_1;
  678. #endif
  679. case _SC_NL_LANGMAX:
  680. #ifdef NL_LANGMAX
  681. return NL_LANGMAX;
  682. #else
  683. RETURN_NEG_1;
  684. #endif
  685. case _SC_NL_MSGMAX:
  686. #ifdef NL_MSGMAX
  687. return NL_MSGMAX;
  688. #else
  689. RETURN_NEG_1;
  690. #endif
  691. case _SC_NL_NMAX:
  692. #ifdef NL_NMAX
  693. return NL_NMAX;
  694. #else
  695. RETURN_NEG_1;
  696. #endif
  697. case _SC_NL_SETMAX:
  698. #ifdef NL_SETMAX
  699. return NL_SETMAX;
  700. #else
  701. RETURN_NEG_1;
  702. #endif
  703. case _SC_NL_TEXTMAX:
  704. #ifdef NL_TEXTMAX
  705. return NL_TEXTMAX;
  706. #else
  707. RETURN_NEG_1;
  708. #endif
  709. case _SC_XBS5_ILP32_OFF32:
  710. #ifdef _XBS5_ILP32_OFF32
  711. return _XBS5_ILP32_OFF32;
  712. #else
  713. RETURN_NEG_1;
  714. #endif
  715. case _SC_XBS5_ILP32_OFFBIG:
  716. #ifdef _XBS5_ILP32_OFFBIG
  717. return _XBS5_ILP32_OFFBIG;
  718. #else
  719. RETURN_NEG_1;
  720. #endif
  721. case _SC_XBS5_LP64_OFF64:
  722. #ifdef _XBS5_LP64_OFF64
  723. return _XBS5_LP64_OFF64;
  724. #else
  725. RETURN_NEG_1;
  726. #endif
  727. case _SC_XBS5_LPBIG_OFFBIG:
  728. #ifdef _XBS5_LPBIG_OFFBIG
  729. return _XBS5_LPBIG_OFFBIG;
  730. #else
  731. RETURN_NEG_1;
  732. #endif
  733. case _SC_XOPEN_LEGACY:
  734. return _XOPEN_LEGACY;
  735. case _SC_XOPEN_REALTIME:
  736. #ifdef _XOPEN_REALTIME
  737. return _XOPEN_REALTIME;
  738. #else
  739. RETURN_NEG_1;
  740. #endif
  741. case _SC_XOPEN_REALTIME_THREADS:
  742. #ifdef _XOPEN_REALTIME_THREADS
  743. return _XOPEN_REALTIME_THREADS;
  744. #else
  745. RETURN_NEG_1;
  746. #endif
  747. case _SC_MONOTONIC_CLOCK:
  748. #if defined __UCLIBC_HAS_REALTIME__ && defined __NR_clock_getres
  749. /* Check using the clock_getres system call. */
  750. if (clock_getres(CLOCK_MONOTONIC, NULL) >= 0)
  751. return _POSIX_VERSION;
  752. #endif
  753. RETURN_NEG_1;
  754. }
  755. }
  756. libc_hidden_def(sysconf)