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 < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-10  |  3.7 KB  |  200 lines

  1. /* Copyright (C) 1991, 1993 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 <stddef.h>
  24. #include <stdio.h>
  25. #include <time.h>
  26. #include <sys/param.h>
  27.  
  28. /* Get the value of the system variable NAME.  */
  29. long int
  30. DEFUN(__sysconf, (name), int name)
  31. {
  32.   switch (name)
  33.     {
  34.     default:
  35.       errno = EINVAL;
  36.       return -1;
  37.  
  38.     case _SC_ARG_MAX:
  39. #ifdef    ARG_MAX
  40.       return ARG_MAX;
  41. #else
  42.       return -1;
  43. #endif
  44.  
  45.     case _SC_CHILD_MAX:
  46. #ifdef    CHILD_MAX
  47.       return CHILD_MAX;
  48. #else
  49.       return -1;
  50. #endif
  51.  
  52.     case _SC_CLK_TCK:
  53.       return CLK_TCK;
  54.  
  55.     case _SC_NGROUPS_MAX:
  56. #ifdef    NGROUPS_MAX
  57.       return NGROUPS_MAX;
  58. #else
  59.       return -1;
  60. #endif
  61.  
  62.     case _SC_OPEN_MAX:
  63.       return OPEN_MAX;
  64.  
  65.     case _SC_STREAM_MAX:
  66.       return STREAM_MAX;
  67.  
  68.     case _SC_TZNAME_MAX:
  69. #ifdef __linux__
  70.       return TZNAME_MAX;
  71. #else
  72.       return __tzname_max ();
  73. #endif
  74.  
  75.     case _SC_JOB_CONTROL:
  76. #ifdef    _POSIX_JOB_CONTROL
  77.       return 1;
  78. #else
  79.       return -1;
  80. #endif
  81.     case _SC_SAVED_IDS:
  82. #ifdef    _POSIX_SAVED_IDS
  83.       return 1;
  84. #else
  85.       return -1;
  86. #endif
  87.     case _SC_VERSION:
  88.       return _POSIX_VERSION;
  89.  
  90.     case _SC_PAGESIZE:
  91. #ifdef  EXEC_PAGESIZE
  92.       return EXEC_PAGESIZE;
  93. #else   /* No EXEC_PAGESIZE.  */
  94. #ifdef  NBPG
  95. #ifndef CLSIZE
  96. #define CLSIZE  1
  97. #endif  /* No CLSIZE.  */
  98.       return NBPG * CLSIZE;
  99. #else   /* No NBPG.  */
  100.       return NBPC;
  101. #endif  /* NBPG.  */
  102. #endif  /* EXEC_PAGESIZE.  */
  103.  
  104.     case _SC_BC_BASE_MAX:
  105. #ifdef    BC_BASE_MAX
  106.       return BC_BASE_MAX;
  107. #else
  108.       return -1;
  109. #endif
  110.  
  111.     case _SC_BC_DIM_MAX:
  112. #ifdef    BC_DIM_MAX
  113.       return BC_DIM_MAX;
  114. #else
  115.       return -1;
  116. #endif
  117.  
  118.     case _SC_BC_SCALE_MAX:
  119. #ifdef    BC_SCALE_MAX
  120.       return BC_SCALE_MAX;
  121. #else
  122.       return -1;
  123. #endif
  124.  
  125.     case _SC_BC_STRING_MAX:
  126. #ifdef    BC_STRING_MAX
  127.       return BC_STRING_MAX;
  128. #else
  129.       return -1;
  130. #endif
  131.  
  132.     case _SC_EQUIV_CLASS_MAX:
  133. #ifdef    EQUIV_CLASS_MAX
  134.       return EQUIV_CLASS_MAX;
  135. #else
  136.       return -1;
  137. #endif
  138.  
  139.     case _SC_EXPR_NEST_MAX:
  140. #ifdef    EXPR_NEST_MAX
  141.       return EXPR_NEST_MAX;
  142. #else
  143.       return -1;
  144. #endif
  145.  
  146.     case _SC_LINE_MAX:
  147. #ifdef    LINE_MAX
  148.       return LINE_MAX;
  149. #else
  150.       return -1;
  151. #endif
  152.  
  153.     case _SC_RE_DUP_MAX:
  154. #ifdef    RE_DUP_MAX
  155.       return RE_DUP_MAX;
  156. #else
  157.       return -1;
  158. #endif
  159.  
  160.  
  161.     case _SC_2_VERSION:
  162.       /* This is actually supposed to return the version
  163.      of the 1003.2 utilities on the system {POSIX2_VERSION}.  */
  164.       return _POSIX2_C_VERSION;
  165.  
  166.     case _SC_2_C_BIND:
  167. #ifdef    _POSIX2_C_BIND
  168.       return _POSIX2_C_BIND;
  169. #else
  170.       return -1;
  171. #endif
  172.  
  173.     case _SC_2_C_DEV:
  174. #ifdef    _POSIX2_C_DEV
  175.       return _POSIX2_C_DEV;
  176. #else
  177.       return -1;
  178. #endif
  179.  
  180.     case _SC_2_FORT_DEV:
  181. #ifdef    _POSIX2_FORT_DEV
  182.       return _POSIX2_FORT_DEV;
  183. #else
  184.       return -1;
  185. #endif
  186.  
  187.     case _SC_2_SW_DEV:
  188. #ifdef    _POSIX2_SW_DEV
  189.       return _POSIX2_SW_DEV;
  190. #else
  191.       return -1;
  192. #endif
  193.     }
  194. }
  195.  
  196. #include <gnu-stabs.h>
  197. #ifdef weak_alias
  198. weak_alias (__sysconf, sysconf);
  199. #endif
  200.