sysconf.c 16 KB

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