home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / __sysconf.c.old < prev    next >
Encoding:
Text File  |  1994-08-30  |  3.7 KB  |  212 lines

  1. /* Copyright (C) 1991 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 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.  
  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. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <ansidecl.h>
  20. #include <errno.h>
  21. #include <limits.h>
  22. #include <unistd.h>
  23. #include <time.h>
  24.  
  25. /* Get the value of the system variable NAME.  */
  26. long int
  27. DEFUN(__sysconf, (name), int name)
  28. {
  29.   switch (name)
  30.     {
  31.     default:
  32.       errno = EINVAL;
  33.       return -1;
  34.  
  35.     case _SC_ARG_MAX:
  36. #ifdef    ARG_MAX
  37.       return ARG_MAX;
  38. #else
  39.       return -1;
  40. #endif
  41.  
  42.     case _SC_CHILD_MAX:
  43. #ifdef    CHILD_MAX
  44.       return CHILD_MAX;
  45. #else
  46.       return -1;
  47. #endif
  48.  
  49.     case _SC_CLK_TCK:
  50.       return CLK_TCK;
  51.  
  52.     case _SC_NGROUPS_MAX:
  53. #ifdef    NGROUPS_MAX
  54.       return NGROUPS_MAX;
  55. #else
  56.       return -1;
  57. #endif
  58.  
  59.     case _SC_OPEN_MAX:
  60.       return OPEN_MAX;
  61.  
  62.     case _SC_STREAM_MAX:
  63.       return STREAM_MAX;
  64.  
  65.     case _SC_TZNAME_MAX:
  66. #ifdef linux
  67.       return TZNAME_MAX;
  68. #else
  69.       return __tzname_max ();
  70. #endif
  71.  
  72.     case _SC_JOB_CONTROL:
  73. #ifdef    _POSIX_JOB_CONTROL
  74.       return 1;
  75. #else
  76.       return -1;
  77. #endif
  78.     case _SC_SAVED_IDS:
  79. #ifdef    _POSIX_SAVED_IDS
  80.       return 1;
  81. #else
  82.       return -1;
  83. #endif
  84.     case _SC_VERSION:
  85.       return _POSIX_VERSION;
  86.  
  87. #ifdef _SC_BC_BASE_MAX
  88.     case _SC_BC_BASE_MAX:
  89. #ifdef    BC_BASE_MAX
  90.       return BC_BASE_MAX;
  91. #else
  92.       return -1;
  93. #endif
  94. #endif
  95.  
  96. #ifdef _SC_BC_DIM_MAX
  97.     case _SC_BC_DIM_MAX:
  98. #ifdef    BC_DIM_MAX
  99.       return BC_DIM_MAX;
  100. #else
  101.       return -1;
  102. #endif
  103. #endif
  104.  
  105. #ifdef _SC_BC_SCALE_MAX
  106.     case _SC_BC_SCALE_MAX
  107. #ifdef    BC_SCALE_MAX
  108.       return BC_SCALE_MAX;
  109. #else
  110.       return -1;
  111. #endif
  112. #endif
  113.  
  114. #ifdef _SC_BC_STRING_MAX
  115.     case _SC_BC_STRING_MAX:
  116. #ifdef    BC_STRING_MAX
  117.       return BC_STRING_MAX;
  118. #else
  119.       return -1;
  120. #endif
  121. #endif
  122.  
  123. #ifdef _SC_EQUIV_CLASS_MAX
  124.     case _SC_EQUIV_CLASS_MAX:
  125. #ifdef    EQUIV_CLASS_MAX
  126.       return EQUIV_CLASS_MAX;
  127. #else
  128.       return -1;
  129. #endif
  130. #endif
  131.  
  132. #ifdef _SC_EXPR_NEST_MAX
  133.     case _SC_EXPR_NEST_MAX:
  134. #ifdef    EXPR_NEST_MAX
  135.       return EXPR_NEST_MAX;
  136. #else
  137.       return -1;
  138. #endif
  139. #endif
  140.  
  141. #ifdef _SC_LINE_MAX
  142.     case _SC_LINE_MAX:
  143. #ifdef    LINE_MAX
  144.       return LINE_MAX;
  145. #else
  146.       return -1;
  147. #endif
  148. #endif
  149.  
  150. #ifdef _SC_RE_DUP_MAX
  151.     case _SC_RE_DUP_MAX:
  152. #ifdef    RE_DUP_MAX
  153.       return RE_DUP_MAX;
  154. #else
  155.       return -1;
  156. #endif
  157. #endif
  158.  
  159. #ifdef _SC_2_VERSION
  160.     case _SC_2_VERSION:
  161.       /* This is actually supposed to return the version
  162.      of the 1003.2 utilities on the system {POSIX2_VERSION}.  */
  163. #ifdef    _POSIX2_C_VERSION
  164.       return _POSIX2_C_VERSION;
  165. #else
  166.       return -1;
  167. #endif
  168. #endif
  169.  
  170. #ifdef _SC_2_C_BIND
  171.     case _SC_2_C_BIND:
  172. #ifdef    _POSIX2_C_BIND
  173.       return _POSIX2_C_BIND;
  174. #else
  175.       return -1;
  176. #endif
  177. #endif
  178.  
  179. #ifdef _SC_2_C_DEV
  180.     case _SC_2_C_DEV:
  181. #ifdef    _POSIX2_C_DEV
  182.       return _POSIX2_C_DEV;
  183. #else
  184.       return -1;
  185. #endif
  186. #endif
  187.  
  188. #ifdef _SC_2_FORT_DEV
  189.     case _SC_2_FORT_DEV:
  190. #ifdef    _POSIX2_FORT_DEV
  191.       return _POSIX2_FORT_DEV;
  192. #else
  193.       return -1;
  194. #endif
  195. #endif
  196.  
  197. #ifdef _SC_2_SW_DEV
  198.     case _SC_2_SW_DEV:
  199. #ifdef    _POSIX2_SW_DEV
  200.       return _POSIX2_SW_DEV;
  201. #else
  202.       return -1;
  203. #endif
  204. #endif
  205.     }
  206. }
  207.  
  208. #include <gnu-stabs.h>
  209. #ifdef weak_alias
  210. weak_alias (__sysconf, sysconf);
  211. #endif
  212.