]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/generic/sysconf.c
Update.
[thirdparty/glibc.git] / sysdeps / generic / sysconf.c
CommitLineData
a20d8dbe 1/* Copyright (C) 1991,1993,1995-1997,2001,2002 Free Software Foundation, Inc.
b5791037 2 This file is part of the GNU C Library.
28f540f4 3
b5791037 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
28f540f4 8
b5791037
UD
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
41bdb6e2 12 Lesser General Public License for more details.
28f540f4 13
41bdb6e2
AJ
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
28f540f4 18
28f540f4 19#include <errno.h>
845dcb57 20#include <stdio.h>
28f540f4
RM
21#include <unistd.h>
22#include <time.h>
23#include <limits.h>
9cddf9de 24#include <sys/param.h>
845dcb57 25#include <sys/sysinfo.h>
28f540f4
RM
26
27
28/* Get the value of the system variable NAME. */
29long int
036cc82f
RM
30__sysconf (name)
31 int name;
28f540f4
RM
32{
33 switch (name)
34 {
35 default:
c4029823 36 __set_errno (EINVAL);
28f540f4
RM
37 return -1;
38
39 case _SC_TZNAME_MAX:
9cddf9de 40 return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
28f540f4 41
036cc82f
RM
42 case _SC_CHARCLASS_NAME_MAX:
43#ifdef CHARCLASS_NAME_MAX
44 return CHARCLASS_NAME_MAX;
45#else
46 return -1;
47#endif
48
49 case _SC_COLL_WEIGHTS_MAX:
50#ifdef COLL_WEIGHTS_MAX
51 return COLL_WEIGHTS_MAX;
52#else
53 return -1;
54#endif
55
56 case _SC_EQUIV_CLASS_MAX:
57#ifdef EQUIV_CLASS_MAX
58 return EQUIV_CLASS_MAX;
59#else
60 return -1;
61#endif
62
63 case _SC_2_LOCALEDEF:
64#ifdef _POSIX2_LOCALEDEF
65 return _POSIX2_LOCALEDEF;
66#else
67 return -1;
68#endif
69
845dcb57
UD
70 case _SC_NPROCESSORS_CONF:
71 return __get_nprocs_conf ();
72
73 case _SC_NPROCESSORS_ONLN:
74 return __get_nprocs ();
75
76 case _SC_PHYS_PAGES:
77 return __get_phys_pages ();
78
79 case _SC_AVPHYS_PAGES:
80 return __get_avphys_pages ();
81
82 case _SC_ATEXIT_MAX:
83 /* We have no limit since we use lists. */
84 return INT_MAX;
85
86 case _SC_PASS_MAX:
87 /* We have no limit but since the return value might be used to
88 allocate a buffer we restrict the value. */
89 return BUFSIZ;
90
b5791037
UD
91 case _SC_CHAR_BIT:
92 return CHAR_BIT;
93
94 case _SC_CHAR_MAX:
95 return CHAR_MAX;
96
97 case _SC_CHAR_MIN:
98 return CHAR_MIN;
99
100 case _SC_INT_MAX:
101 return INT_MAX;
102
103 case _SC_INT_MIN:
104 return INT_MIN;
105
106 case _SC_LONG_BIT:
107 return sizeof (long int) * CHAR_BIT;
108
109 case _SC_WORD_BIT:
110 return sizeof (int) * CHAR_BIT;
111
112 case _SC_MB_LEN_MAX:
113 return MB_LEN_MAX;
114
115 case _SC_NZERO:
116 return NZERO;
117
118 case _SC_SSIZE_MAX:
119 return _POSIX_SSIZE_MAX;
120
121 case _SC_SCHAR_MAX:
122 return SCHAR_MAX;
123
124 case _SC_SCHAR_MIN:
125 return SCHAR_MIN;
126
127 case _SC_SHRT_MAX:
128 return SHRT_MAX;
129
130 case _SC_SHRT_MIN:
131 return SHRT_MIN;
132
133 case _SC_UCHAR_MAX:
134 return UCHAR_MAX;
135
136 case _SC_UINT_MAX:
137 return UINT_MAX;
138
139 case _SC_ULONG_MAX:
140 return ULONG_MAX;
141
142 case _SC_USHRT_MAX:
143 return USHRT_MAX;
144
28f540f4
RM
145 case _SC_ARG_MAX:
146 case _SC_CHILD_MAX:
147 case _SC_CLK_TCK:
148 case _SC_NGROUPS_MAX:
149 case _SC_OPEN_MAX:
036cc82f 150 case _SC_STREAM_MAX:
28f540f4
RM
151 case _SC_JOB_CONTROL:
152 case _SC_SAVED_IDS:
75cd5204
RM
153 case _SC_REALTIME_SIGNALS:
154 case _SC_PRIORITY_SCHEDULING:
155 case _SC_TIMERS:
156 case _SC_ASYNCHRONOUS_IO:
157 case _SC_PRIORITIZED_IO:
158 case _SC_SYNCHRONIZED_IO:
159 case _SC_FSYNC:
160 case _SC_MAPPED_FILES:
161 case _SC_MEMLOCK:
162 case _SC_MEMLOCK_RANGE:
163 case _SC_MEMORY_PROTECTION:
164 case _SC_MESSAGE_PASSING:
165 case _SC_SEMAPHORES:
166 case _SC_SHARED_MEMORY_OBJECTS:
036cc82f 167
1f205a47 168 case _SC_AIO_LISTIO_MAX:
036cc82f
RM
169 case _SC_AIO_MAX:
170 case _SC_AIO_PRIO_DELTA_MAX:
1f205a47 171 case _SC_DELAYTIMER_MAX:
036cc82f
RM
172 case _SC_MQ_OPEN_MAX:
173 case _SC_MQ_PRIO_MAX:
28f540f4 174 case _SC_VERSION:
036cc82f
RM
175 case _SC_PAGESIZE:
176 case _SC_RTSIG_MAX:
177 case _SC_SEM_NSEMS_MAX:
178 case _SC_SEM_VALUE_MAX:
179 case _SC_SIGQUEUE_MAX:
180 case _SC_TIMER_MAX:
28f540f4 181
503054c0
RM
182 case _SC_PII:
183 case _SC_PII_XTI:
184 case _SC_PII_SOCKET:
185 case _SC_PII_OSI:
186 case _SC_POLL:
187 case _SC_SELECT:
188 case _SC_UIO_MAXIOV:
189 case _SC_PII_INTERNET_STREAM:
190 case _SC_PII_INTERNET_DGRAM:
191 case _SC_PII_OSI_COTS:
192 case _SC_PII_OSI_CLTS:
193 case _SC_PII_OSI_M:
194 case _SC_T_IOV_MAX:
195
28f540f4
RM
196 case _SC_BC_BASE_MAX:
197 case _SC_BC_DIM_MAX:
198 case _SC_BC_SCALE_MAX:
199 case _SC_BC_STRING_MAX:
28f540f4
RM
200 case _SC_EXPR_NEST_MAX:
201 case _SC_LINE_MAX:
202 case _SC_RE_DUP_MAX:
203 case _SC_2_VERSION:
204 case _SC_2_C_BIND:
205 case _SC_2_C_DEV:
206 case _SC_2_FORT_DEV:
207 case _SC_2_SW_DEV:
b5791037
UD
208 case _SC_2_CHAR_TERM:
209 case _SC_2_C_VERSION:
210 case _SC_2_UPE:
28f540f4 211
23396375
UD
212 case _SC_THREADS:
213 case _SC_THREAD_SAFE_FUNCTIONS:
214 case _SC_GETGR_R_SIZE_MAX:
215 case _SC_GETPW_R_SIZE_MAX:
216 case _SC_LOGIN_NAME_MAX:
217 case _SC_TTY_NAME_MAX:
218 case _SC_THREAD_DESTRUCTOR_ITERATIONS:
219 case _SC_THREAD_KEYS_MAX:
220 case _SC_THREAD_STACK_MIN:
221 case _SC_THREAD_THREADS_MAX:
222 case _SC_THREAD_ATTR_STACKADDR:
223 case _SC_THREAD_ATTR_STACKSIZE:
224 case _SC_THREAD_PRIORITY_SCHEDULING:
225 case _SC_THREAD_PRIO_INHERIT:
226 case _SC_THREAD_PRIO_PROTECT:
227 case _SC_THREAD_PROCESS_SHARED:
228
845dcb57 229 case _SC_XOPEN_VERSION:
b5791037
UD
230 case _SC_XOPEN_XCU_VERSION:
231 case _SC_XOPEN_UNIX:
232 case _SC_XOPEN_CRYPT:
233 case _SC_XOPEN_ENH_I18N:
234 case _SC_XOPEN_SHM:
235 case _SC_XOPEN_XPG2:
236 case _SC_XOPEN_XPG3:
237 case _SC_XOPEN_XPG4:
238
239 case _SC_NL_ARGMAX:
240 case _SC_NL_LANGMAX:
241 case _SC_NL_MSGMAX:
242 case _SC_NL_NMAX:
243 case _SC_NL_SETMAX:
244 case _SC_NL_TEXTMAX:
845dcb57 245
9756dfe1
UD
246 case _SC_XBS5_ILP32_OFF32:
247 case _SC_XBS5_ILP32_OFFBIG:
248 case _SC_XBS5_LP64_OFF64:
249 case _SC_XBS5_LPBIG_OFFBIG:
250
251 case _SC_XOPEN_LEGACY:
252 case _SC_XOPEN_REALTIME:
253 case _SC_XOPEN_REALTIME_THREADS:
254
28f540f4
RM
255 break;
256 }
257
c4029823 258 __set_errno (ENOSYS);
28f540f4
RM
259 return -1;
260}
261
262weak_alias (__sysconf, sysconf)
a20d8dbe 263libc_hidden_def (__sysconf)
10ceac89
RM
264
265stub_warning (sysconf)
f2ea0f5b 266#include <stub-tag.h>