Mon Mar 18 22:54:32 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
[glibc.git] / sysdeps / unix / sysv / linux / sysconf.c
blob447cfd46ae836915b82308035b4f9fc411c055f4
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 size_t EXFUN(__getpagesize, (NOARGS));
29 /* Get the value of the system variable NAME. */
30 long int
31 DEFUN(__sysconf, (name), int name)
33 switch (name)
35 default:
36 errno = EINVAL;
37 return -1;
39 case _SC_ARG_MAX:
40 #ifdef ARG_MAX
41 return ARG_MAX;
42 #else
43 return -1;
44 #endif
46 case _SC_CHILD_MAX:
47 #ifdef CHILD_MAX
48 return CHILD_MAX;
49 #else
50 return -1;
51 #endif
53 case _SC_CLK_TCK:
54 #ifdef CLK_TCK
55 return CLK_TCK;
56 #else
57 return 60;
58 #endif
60 case _SC_NGROUPS_MAX:
61 #ifdef NGROUPS_MAX
62 return NGROUPS_MAX;
63 #else
64 return -1;
65 #endif
67 case _SC_OPEN_MAX:
68 return OPEN_MAX;
70 case _SC_STREAM_MAX:
71 #ifdef STREAM_MAX
72 return STREAM_MAX;
73 #else
74 return FOPEN_MAX;
75 #endif
77 case _SC_TZNAME_MAX:
78 return __tzname_max ();
80 case _SC_JOB_CONTROL:
81 #ifdef _POSIX_JOB_CONTROL
82 return 1;
83 #else
84 return -1;
85 #endif
86 case _SC_SAVED_IDS:
87 #ifdef _POSIX_SAVED_IDS
88 return 1;
89 #else
90 return -1;
91 #endif
92 case _SC_VERSION:
93 return _POSIX_VERSION;
95 case _SC_PAGESIZE:
96 return __getpagesize ();
98 case _SC_BC_BASE_MAX:
99 #ifdef BC_BASE_MAX
100 return BC_BASE_MAX;
101 #else
102 return -1;
103 #endif
105 case _SC_BC_DIM_MAX:
106 #ifdef BC_DIM_MAX
107 return BC_DIM_MAX;
108 #else
109 return -1;
110 #endif
112 case _SC_BC_SCALE_MAX:
113 #ifdef BC_SCALE_MAX
114 return BC_SCALE_MAX;
115 #else
116 return -1;
117 #endif
119 case _SC_BC_STRING_MAX:
120 #ifdef BC_STRING_MAX
121 return BC_STRING_MAX;
122 #else
123 return -1;
124 #endif
126 case _SC_EQUIV_CLASS_MAX:
127 #ifdef EQUIV_CLASS_MAX
128 return EQUIV_CLASS_MAX;
129 #else
130 return -1;
131 #endif
133 case _SC_EXPR_NEST_MAX:
134 #ifdef EXPR_NEST_MAX
135 return EXPR_NEST_MAX;
136 #else
137 return -1;
138 #endif
140 case _SC_LINE_MAX:
141 #ifdef LINE_MAX
142 return LINE_MAX;
143 #else
144 return -1;
145 #endif
147 case _SC_RE_DUP_MAX:
148 #ifdef RE_DUP_MAX
149 return RE_DUP_MAX;
150 #else
151 return -1;
152 #endif
155 case _SC_2_VERSION:
156 /* This is actually supposed to return the version
157 of the 1003.2 utilities on the system {POSIX2_VERSION}. */
158 return _POSIX2_C_VERSION;
160 case _SC_2_C_BIND:
161 #ifdef _POSIX2_C_BIND
162 return _POSIX2_C_BIND;
163 #else
164 return -1;
165 #endif
167 case _SC_2_C_DEV:
168 #ifdef _POSIX2_C_DEV
169 return _POSIX2_C_DEV;
170 #else
171 return -1;
172 #endif
174 case _SC_2_FORT_DEV:
175 #ifdef _POSIX2_FORT_DEV
176 return _POSIX2_FORT_DEV;
177 #else
178 return -1;
179 #endif
181 case _SC_2_LOCALEDEF:
182 #ifdef _POSIX2_LOCALEDEF
183 return _POSIX2_LOCALEDEF;
184 #else
185 return -1;
186 #endif
188 case _SC_2_SW_DEV:
189 #ifdef _POSIX2_SW_DEV
190 return _POSIX2_SW_DEV;
191 #else
192 return -1;
193 #endif
197 weak_alias (__sysconf, sysconf)