Wed Aug 9 14:25:35 1995 Miles Bader <miles@geech.gnu.ai.mit.edu>
[glibc.git] / sysdeps / posix / sysconf.c
blob7f4fbb7261da2928477ee584095e15d2b953dfb4
1 /* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
2 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.
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.
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. */
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>
27 extern int EXFUN(__getdtablesize, (NOARGS));
28 extern size_t EXFUN(__getpagesize, (NOARGS));
30 /* Get the value of the system variable NAME. */
31 long int
32 DEFUN(__sysconf, (name), int name)
34 switch (name)
36 default:
37 errno = EINVAL;
38 return -1;
40 case _SC_ARG_MAX:
41 #ifdef ARG_MAX
42 return ARG_MAX;
43 #else
44 return -1;
45 #endif
47 case _SC_CHILD_MAX:
48 #ifdef CHILD_MAX
49 return CHILD_MAX;
50 #else
51 return -1;
52 #endif
54 case _SC_CLK_TCK:
55 return 60;
57 case _SC_NGROUPS_MAX:
58 #ifdef NGROUPS_MAX
59 return NGROUPS_MAX;
60 #else
61 return -1;
62 #endif
64 case _SC_OPEN_MAX:
65 return __getdtablesize ();
67 case _SC_STREAM_MAX:
68 return FOPEN_MAX;
70 case _SC_TZNAME_MAX:
71 return __tzname_max ();
73 case _SC_JOB_CONTROL:
74 #ifdef _POSIX_JOB_CONTROL
75 return 1;
76 #else
77 return -1;
78 #endif
79 case _SC_SAVED_IDS:
80 #ifdef _POSIX_SAVED_IDS
81 return 1;
82 #else
83 return -1;
84 #endif
85 case _SC_VERSION:
86 return _POSIX_VERSION;
88 case _SC_PAGESIZE:
89 return __getpagesize ();
91 case _SC_BC_BASE_MAX:
92 #ifdef BC_BASE_MAX
93 return BC_BASE_MAX;
94 #else
95 return -1;
96 #endif
98 case _SC_BC_DIM_MAX:
99 #ifdef BC_DIM_MAX
100 return BC_DIM_MAX;
101 #else
102 return -1;
103 #endif
105 case _SC_BC_SCALE_MAX:
106 #ifdef BC_SCALE_MAX
107 return BC_SCALE_MAX;
108 #else
109 return -1;
110 #endif
112 case _SC_BC_STRING_MAX:
113 #ifdef BC_STRING_MAX
114 return BC_STRING_MAX;
115 #else
116 return -1;
117 #endif
119 case _SC_EQUIV_CLASS_MAX:
120 #ifdef EQUIV_CLASS_MAX
121 return EQUIV_CLASS_MAX;
122 #else
123 return -1;
124 #endif
126 case _SC_EXPR_NEST_MAX:
127 #ifdef EXPR_NEST_MAX
128 return EXPR_NEST_MAX;
129 #else
130 return -1;
131 #endif
133 case _SC_LINE_MAX:
134 #ifdef LINE_MAX
135 return LINE_MAX;
136 #else
137 return -1;
138 #endif
140 case _SC_RE_DUP_MAX:
141 #ifdef RE_DUP_MAX
142 return RE_DUP_MAX;
143 #else
144 return -1;
145 #endif
148 case _SC_2_VERSION:
149 /* This is actually supposed to return the version
150 of the 1003.2 utilities on the system {POSIX2_VERSION}. */
151 return _POSIX2_C_VERSION;
153 case _SC_2_C_BIND:
154 #ifdef _POSIX2_C_BIND
155 return _POSIX2_C_BIND;
156 #else
157 return -1;
158 #endif
160 case _SC_2_C_DEV:
161 #ifdef _POSIX2_C_DEV
162 return _POSIX2_C_DEV;
163 #else
164 return -1;
165 #endif
167 case _SC_2_FORT_DEV:
168 #ifdef _POSIX2_FORT_DEV
169 return _POSIX2_FORT_DEV;
170 #else
171 return -1;
172 #endif
174 case _SC_2_SW_DEV:
175 #ifdef _POSIX2_SW_DEV
176 return _POSIX2_SW_DEV;
177 #else
178 return -1;
179 #endif
183 weak_alias (__sysconf, sysconf)