sysconf.c 17 KB

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