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