PowerPC: modf optimization fix
[glibc.git] / posix / sysconf.c
blob8428f79ab3474067ff6c22bac43c372bb55b189e
1 /* Copyright (C) 1991,1993,1995-1997,2001,2002,2003,2009
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <grp.h>
21 #include <pwd.h>
22 #include <stdio.h>
23 #include <unistd.h>
24 #include <time.h>
25 #include <limits.h>
26 #include <sys/param.h>
27 #include <sys/sysinfo.h>
30 /* Get the value of the system variable NAME. */
31 long int
32 __sysconf (name)
33 int name;
35 switch (name)
37 default:
38 __set_errno (EINVAL);
39 return -1;
41 case _SC_TZNAME_MAX:
42 return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
44 case _SC_CHARCLASS_NAME_MAX:
45 #ifdef CHARCLASS_NAME_MAX
46 return CHARCLASS_NAME_MAX;
47 #else
48 return -1;
49 #endif
51 case _SC_COLL_WEIGHTS_MAX:
52 #ifdef COLL_WEIGHTS_MAX
53 return COLL_WEIGHTS_MAX;
54 #else
55 return -1;
56 #endif
58 case _SC_EQUIV_CLASS_MAX:
59 #ifdef EQUIV_CLASS_MAX
60 return EQUIV_CLASS_MAX;
61 #else
62 return -1;
63 #endif
65 case _SC_2_LOCALEDEF:
66 #ifdef _POSIX2_LOCALEDEF
67 return _POSIX2_LOCALEDEF;
68 #else
69 return -1;
70 #endif
72 case _SC_NPROCESSORS_CONF:
73 return __get_nprocs_conf ();
75 case _SC_NPROCESSORS_ONLN:
76 return __get_nprocs ();
78 case _SC_PHYS_PAGES:
79 return __get_phys_pages ();
81 case _SC_AVPHYS_PAGES:
82 return __get_avphys_pages ();
84 case _SC_ATEXIT_MAX:
85 /* We have no limit since we use lists. */
86 return INT_MAX;
88 case _SC_PASS_MAX:
89 /* We have no limit but since the return value might be used to
90 allocate a buffer we restrict the value. */
91 return BUFSIZ;
93 case _SC_CHAR_BIT:
94 return CHAR_BIT;
96 case _SC_CHAR_MAX:
97 return CHAR_MAX;
99 case _SC_CHAR_MIN:
100 return CHAR_MIN;
102 case _SC_INT_MAX:
103 return INT_MAX;
105 case _SC_INT_MIN:
106 return INT_MIN;
108 case _SC_LONG_BIT:
109 return sizeof (long int) * CHAR_BIT;
111 case _SC_WORD_BIT:
112 return sizeof (int) * CHAR_BIT;
114 case _SC_MB_LEN_MAX:
115 return MB_LEN_MAX;
117 case _SC_NZERO:
118 return NZERO;
120 case _SC_SSIZE_MAX:
121 return _POSIX_SSIZE_MAX;
123 case _SC_SCHAR_MAX:
124 return SCHAR_MAX;
126 case _SC_SCHAR_MIN:
127 return SCHAR_MIN;
129 case _SC_SHRT_MAX:
130 return SHRT_MAX;
132 case _SC_SHRT_MIN:
133 return SHRT_MIN;
135 case _SC_UCHAR_MAX:
136 return UCHAR_MAX;
138 case _SC_UINT_MAX:
139 return UINT_MAX;
141 case _SC_ULONG_MAX:
142 return ULONG_MAX;
144 case _SC_USHRT_MAX:
145 return USHRT_MAX;
147 case _SC_GETGR_R_SIZE_MAX:
148 return NSS_BUFLEN_GROUP;
150 case _SC_GETPW_R_SIZE_MAX:
151 return NSS_BUFLEN_PASSWD;
153 case _SC_ARG_MAX:
154 case _SC_CHILD_MAX:
155 case _SC_CLK_TCK:
156 case _SC_NGROUPS_MAX:
157 case _SC_OPEN_MAX:
158 case _SC_STREAM_MAX:
159 case _SC_JOB_CONTROL:
160 case _SC_SAVED_IDS:
161 case _SC_REALTIME_SIGNALS:
162 case _SC_PRIORITY_SCHEDULING:
163 case _SC_TIMERS:
164 case _SC_ASYNCHRONOUS_IO:
165 case _SC_PRIORITIZED_IO:
166 case _SC_SYNCHRONIZED_IO:
167 case _SC_FSYNC:
168 case _SC_MAPPED_FILES:
169 case _SC_MEMLOCK:
170 case _SC_MEMLOCK_RANGE:
171 case _SC_MEMORY_PROTECTION:
172 case _SC_MESSAGE_PASSING:
173 case _SC_SEMAPHORES:
174 case _SC_SHARED_MEMORY_OBJECTS:
176 case _SC_AIO_LISTIO_MAX:
177 case _SC_AIO_MAX:
178 case _SC_AIO_PRIO_DELTA_MAX:
179 case _SC_DELAYTIMER_MAX:
180 case _SC_MQ_OPEN_MAX:
181 case _SC_MQ_PRIO_MAX:
182 case _SC_VERSION:
183 case _SC_PAGESIZE:
184 case _SC_RTSIG_MAX:
185 case _SC_SEM_NSEMS_MAX:
186 case _SC_SEM_VALUE_MAX:
187 case _SC_SIGQUEUE_MAX:
188 case _SC_TIMER_MAX:
190 case _SC_PII:
191 case _SC_PII_XTI:
192 case _SC_PII_SOCKET:
193 case _SC_PII_OSI:
194 case _SC_POLL:
195 case _SC_SELECT:
196 case _SC_UIO_MAXIOV:
197 case _SC_PII_INTERNET_STREAM:
198 case _SC_PII_INTERNET_DGRAM:
199 case _SC_PII_OSI_COTS:
200 case _SC_PII_OSI_CLTS:
201 case _SC_PII_OSI_M:
202 case _SC_T_IOV_MAX:
204 case _SC_BC_BASE_MAX:
205 case _SC_BC_DIM_MAX:
206 case _SC_BC_SCALE_MAX:
207 case _SC_BC_STRING_MAX:
208 case _SC_EXPR_NEST_MAX:
209 case _SC_LINE_MAX:
210 case _SC_RE_DUP_MAX:
211 case _SC_2_VERSION:
212 case _SC_2_C_BIND:
213 case _SC_2_C_DEV:
214 case _SC_2_FORT_DEV:
215 case _SC_2_SW_DEV:
216 case _SC_2_CHAR_TERM:
217 case _SC_2_C_VERSION:
218 case _SC_2_UPE:
220 case _SC_THREADS:
221 case _SC_THREAD_SAFE_FUNCTIONS:
222 case _SC_LOGIN_NAME_MAX:
223 case _SC_TTY_NAME_MAX:
224 case _SC_THREAD_DESTRUCTOR_ITERATIONS:
225 case _SC_THREAD_KEYS_MAX:
226 case _SC_THREAD_STACK_MIN:
227 case _SC_THREAD_THREADS_MAX:
228 case _SC_THREAD_ATTR_STACKADDR:
229 case _SC_THREAD_ATTR_STACKSIZE:
230 case _SC_THREAD_PRIORITY_SCHEDULING:
231 case _SC_THREAD_PRIO_INHERIT:
232 case _SC_THREAD_PRIO_PROTECT:
233 case _SC_THREAD_PROCESS_SHARED:
235 case _SC_XOPEN_VERSION:
236 case _SC_XOPEN_XCU_VERSION:
237 case _SC_XOPEN_UNIX:
238 case _SC_XOPEN_CRYPT:
239 case _SC_XOPEN_ENH_I18N:
240 case _SC_XOPEN_SHM:
241 case _SC_XOPEN_XPG2:
242 case _SC_XOPEN_XPG3:
243 case _SC_XOPEN_XPG4:
245 case _SC_NL_ARGMAX:
246 case _SC_NL_LANGMAX:
247 case _SC_NL_MSGMAX:
248 case _SC_NL_NMAX:
249 case _SC_NL_SETMAX:
250 case _SC_NL_TEXTMAX:
252 case _SC_XBS5_ILP32_OFF32:
253 case _SC_XBS5_ILP32_OFFBIG:
254 case _SC_XBS5_LP64_OFF64:
255 case _SC_XBS5_LPBIG_OFFBIG:
257 case _SC_POSIX_V6_ILP32_OFF32:
258 case _SC_POSIX_V6_ILP32_OFFBIG:
259 case _SC_POSIX_V6_LP64_OFF64:
260 case _SC_POSIX_V6_LPBIG_OFFBIG:
262 case _SC_POSIX_V7_ILP32_OFF32:
263 case _SC_POSIX_V7_ILP32_OFFBIG:
264 case _SC_POSIX_V7_LP64_OFF64:
265 case _SC_POSIX_V7_LPBIG_OFFBIG:
267 case _SC_XOPEN_LEGACY:
268 case _SC_XOPEN_REALTIME:
269 case _SC_XOPEN_REALTIME_THREADS:
271 break;
274 __set_errno (ENOSYS);
275 return -1;
278 weak_alias (__sysconf, sysconf)
279 libc_hidden_def (__sysconf)
281 stub_warning (sysconf)