sysconf.c 16 KB

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