Only provide non-default symbols in libpthread for vfork
[glibc.git] / posix / sysconf.c
blob51d2f989d057eba7994b47bcd93a0b6d2c05ad6e
1 /* Copyright (C) 1991-2014 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 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.
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <grp.h>
20 #include <pwd.h>
21 #include <stdio.h>
22 #include <unistd.h>
23 #include <time.h>
24 #include <limits.h>
25 #include <sys/param.h>
26 #include <sys/sysinfo.h>
29 /* Get the value of the system variable NAME. */
30 long int
31 __sysconf (name)
32 int name;
34 switch (name)
36 default:
37 __set_errno (EINVAL);
38 return -1;
40 case _SC_TZNAME_MAX:
41 return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
43 case _SC_CHARCLASS_NAME_MAX:
44 #ifdef CHARCLASS_NAME_MAX
45 return CHARCLASS_NAME_MAX;
46 #else
47 return -1;
48 #endif
50 case _SC_COLL_WEIGHTS_MAX:
51 #ifdef COLL_WEIGHTS_MAX
52 return COLL_WEIGHTS_MAX;
53 #else
54 return -1;
55 #endif
57 case _SC_EQUIV_CLASS_MAX:
58 #ifdef EQUIV_CLASS_MAX
59 return EQUIV_CLASS_MAX;
60 #else
61 return -1;
62 #endif
64 case _SC_2_LOCALEDEF:
65 #ifdef _POSIX2_LOCALEDEF
66 return _POSIX2_LOCALEDEF;
67 #else
68 return -1;
69 #endif
71 case _SC_NPROCESSORS_CONF:
72 return __get_nprocs_conf ();
74 case _SC_NPROCESSORS_ONLN:
75 return __get_nprocs ();
77 case _SC_PHYS_PAGES:
78 return __get_phys_pages ();
80 case _SC_AVPHYS_PAGES:
81 return __get_avphys_pages ();
83 case _SC_ATEXIT_MAX:
84 /* We have no limit since we use lists. */
85 return INT_MAX;
87 case _SC_PASS_MAX:
88 /* We have no limit but since the return value might be used to
89 allocate a buffer we restrict the value. */
90 return BUFSIZ;
92 case _SC_CHAR_BIT:
93 return CHAR_BIT;
95 case _SC_CHAR_MAX:
96 return CHAR_MAX;
98 case _SC_CHAR_MIN:
99 return CHAR_MIN;
101 case _SC_INT_MAX:
102 return INT_MAX;
104 case _SC_INT_MIN:
105 return INT_MIN;
107 case _SC_LONG_BIT:
108 return sizeof (long int) * CHAR_BIT;
110 case _SC_WORD_BIT:
111 return sizeof (int) * CHAR_BIT;
113 case _SC_MB_LEN_MAX:
114 return MB_LEN_MAX;
116 case _SC_NZERO:
117 return NZERO;
119 case _SC_SSIZE_MAX:
120 return _POSIX_SSIZE_MAX;
122 case _SC_SCHAR_MAX:
123 return SCHAR_MAX;
125 case _SC_SCHAR_MIN:
126 return SCHAR_MIN;
128 case _SC_SHRT_MAX:
129 return SHRT_MAX;
131 case _SC_SHRT_MIN:
132 return SHRT_MIN;
134 case _SC_UCHAR_MAX:
135 return UCHAR_MAX;
137 case _SC_UINT_MAX:
138 return UINT_MAX;
140 case _SC_ULONG_MAX:
141 return ULONG_MAX;
143 case _SC_USHRT_MAX:
144 return USHRT_MAX;
146 case _SC_GETGR_R_SIZE_MAX:
147 return NSS_BUFLEN_GROUP;
149 case _SC_GETPW_R_SIZE_MAX:
150 return NSS_BUFLEN_PASSWD;
152 case _SC_ARG_MAX:
153 case _SC_CHILD_MAX:
154 case _SC_CLK_TCK:
155 case _SC_NGROUPS_MAX:
156 case _SC_OPEN_MAX:
157 case _SC_STREAM_MAX:
158 case _SC_JOB_CONTROL:
159 case _SC_SAVED_IDS:
160 case _SC_REALTIME_SIGNALS:
161 case _SC_PRIORITY_SCHEDULING:
162 case _SC_TIMERS:
163 case _SC_ASYNCHRONOUS_IO:
164 case _SC_PRIORITIZED_IO:
165 case _SC_SYNCHRONIZED_IO:
166 case _SC_FSYNC:
167 case _SC_MAPPED_FILES:
168 case _SC_MEMLOCK:
169 case _SC_MEMLOCK_RANGE:
170 case _SC_MEMORY_PROTECTION:
171 case _SC_MESSAGE_PASSING:
172 case _SC_SEMAPHORES:
173 case _SC_SHARED_MEMORY_OBJECTS:
175 case _SC_AIO_LISTIO_MAX:
176 case _SC_AIO_MAX:
177 case _SC_AIO_PRIO_DELTA_MAX:
178 case _SC_DELAYTIMER_MAX:
179 case _SC_MQ_OPEN_MAX:
180 case _SC_MQ_PRIO_MAX:
181 case _SC_VERSION:
182 case _SC_PAGESIZE:
183 case _SC_RTSIG_MAX:
184 case _SC_SEM_NSEMS_MAX:
185 case _SC_SEM_VALUE_MAX:
186 case _SC_SIGQUEUE_MAX:
187 case _SC_TIMER_MAX:
189 case _SC_PII:
190 case _SC_PII_XTI:
191 case _SC_PII_SOCKET:
192 case _SC_PII_OSI:
193 case _SC_POLL:
194 case _SC_SELECT:
195 case _SC_UIO_MAXIOV:
196 case _SC_PII_INTERNET_STREAM:
197 case _SC_PII_INTERNET_DGRAM:
198 case _SC_PII_OSI_COTS:
199 case _SC_PII_OSI_CLTS:
200 case _SC_PII_OSI_M:
201 case _SC_T_IOV_MAX:
203 case _SC_BC_BASE_MAX:
204 case _SC_BC_DIM_MAX:
205 case _SC_BC_SCALE_MAX:
206 case _SC_BC_STRING_MAX:
207 case _SC_EXPR_NEST_MAX:
208 case _SC_LINE_MAX:
209 case _SC_RE_DUP_MAX:
210 case _SC_2_VERSION:
211 case _SC_2_C_BIND:
212 case _SC_2_C_DEV:
213 case _SC_2_FORT_DEV:
214 case _SC_2_SW_DEV:
215 case _SC_2_CHAR_TERM:
216 case _SC_2_C_VERSION:
217 case _SC_2_UPE:
219 case _SC_THREADS:
220 case _SC_THREAD_SAFE_FUNCTIONS:
221 case _SC_LOGIN_NAME_MAX:
222 case _SC_TTY_NAME_MAX:
223 case _SC_THREAD_DESTRUCTOR_ITERATIONS:
224 case _SC_THREAD_KEYS_MAX:
225 case _SC_THREAD_STACK_MIN:
226 case _SC_THREAD_THREADS_MAX:
227 case _SC_THREAD_ATTR_STACKADDR:
228 case _SC_THREAD_ATTR_STACKSIZE:
229 case _SC_THREAD_PRIORITY_SCHEDULING:
230 case _SC_THREAD_PRIO_INHERIT:
231 case _SC_THREAD_PRIO_PROTECT:
232 case _SC_THREAD_PROCESS_SHARED:
234 case _SC_XOPEN_VERSION:
235 case _SC_XOPEN_XCU_VERSION:
236 case _SC_XOPEN_UNIX:
237 case _SC_XOPEN_CRYPT:
238 case _SC_XOPEN_ENH_I18N:
239 case _SC_XOPEN_SHM:
240 case _SC_XOPEN_XPG2:
241 case _SC_XOPEN_XPG3:
242 case _SC_XOPEN_XPG4:
244 case _SC_NL_ARGMAX:
245 case _SC_NL_LANGMAX:
246 case _SC_NL_MSGMAX:
247 case _SC_NL_NMAX:
248 case _SC_NL_SETMAX:
249 case _SC_NL_TEXTMAX:
251 case _SC_XBS5_ILP32_OFF32:
252 case _SC_XBS5_ILP32_OFFBIG:
253 case _SC_XBS5_LP64_OFF64:
254 case _SC_XBS5_LPBIG_OFFBIG:
256 case _SC_POSIX_V6_ILP32_OFF32:
257 case _SC_POSIX_V6_ILP32_OFFBIG:
258 case _SC_POSIX_V6_LP64_OFF64:
259 case _SC_POSIX_V6_LPBIG_OFFBIG:
261 case _SC_POSIX_V7_ILP32_OFF32:
262 case _SC_POSIX_V7_ILP32_OFFBIG:
263 case _SC_POSIX_V7_LP64_OFF64:
264 case _SC_POSIX_V7_LPBIG_OFFBIG:
266 case _SC_XOPEN_LEGACY:
267 case _SC_XOPEN_REALTIME:
268 case _SC_XOPEN_REALTIME_THREADS:
270 break;
273 __set_errno (ENOSYS);
274 return -1;
277 weak_alias (__sysconf, sysconf)
278 libc_hidden_def (__sysconf)
280 stub_warning (sysconf)