Patch-ID: bash41-003
[bash.git] / examples / loadables / getconf.c
blobd3dec415ad22372d4b71050202a047c3138efd10
1 /*
2 * ORIGINAL COPYRIGHT STATEMENT:
4 * Copyright (c) 1994 Winning Strategies, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Winning Strategies, Inc.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * POSIX.2 getconf utility
36 * Originally Written by:
37 * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
39 * Heavily modified for inclusion in bash by
40 * Chet Ramey <chet@po.cwru.edu>
43 #ifdef HAVE_CONFIG_H
44 # include <config.h>
45 #endif
47 #ifdef HAVE_SYS_PARAM_H
48 # include <sys/param.h>
49 #endif
51 #include <stdio.h>
52 #ifdef HAVE_LIMITS_H
53 #include <limits.h>
54 #endif
55 #ifdef HAVE_LOCALE_H
56 #include <locale.h>
57 #endif
58 #ifdef HAVE_UNISTD_H
59 #include <unistd.h>
60 #endif
61 #include <errno.h>
63 #include "typemax.h"
65 #include "bashansi.h"
66 #include "shell.h"
67 #include "builtins.h"
68 #include "stdc.h"
69 #include "common.h"
70 #include "bashgetopt.h"
72 #include "getconf.h"
74 #ifndef errno
75 extern int errno;
76 #endif
78 struct conf_variable
80 const char *name;
81 enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, LLCONST, G_UNDEF } type;
82 long value;
85 #ifndef HAVE_CONFSTR
86 static size_t confstr __P((int, char *, size_t));
87 #endif
89 #ifndef HAVE_SYSCONF
90 static long sysconf __P((int));
91 #endif
93 #ifndef HAVE_PATHCONF
94 static long pathconf __P((const char *, int));
95 #endif
97 /* Hack to `encode' values wider than long into a conf_variable */
98 #define VAL_LLONG_MIN -1000
99 #define VAL_LLONG_MAX -1001
100 #define VAL_ULLONG_MAX -1002
102 static const struct conf_variable conf_table[] =
104 /* POSIX.2 Configurable Variable Values */
105 { "PATH", CONFSTR, _CS_PATH },
106 { "CS_PATH", CONFSTR, _CS_PATH },
108 /* POSIX.1 Configurable Variable Values (only Solaris?) */
109 #if defined (_CS_LFS_CFLAGS)
110 { "LFS_CFLAGS", CONFSTR, _CS_LFS_CFLAGS },
111 { "LFS_LDFLAGS", CONFSTR, _CS_LFS_LDFLAGS },
112 { "LFS_LIBS", CONFSTR, _CS_LFS_LIBS },
113 { "LFS_LINTFLAGS", CONFSTR, _CS_LFS_LINTFLAGS },
114 #endif
115 #if defined (_CS_LFS64_CFLAGS)
116 { "LFS64_CFLAGS", CONFSTR, _CS_LFS64_CFLAGS },
117 { "LFS64_LDFLAGS", CONFSTR, _CS_LFS64_LDFLAGS },
118 { "LFS64_LIBS", CONFSTR, _CS_LFS64_LIBS },
119 { "LFS64_LINTFLAGS", CONFSTR, _CS_LFS64_LINTFLAGS },
120 #endif
122 /* Single UNIX Specification version 2 Configurable Variable Values. The
123 SYSCONF variables say whether or not the appropriate CONFSTR variables
124 are available. */
125 #if defined (_SC_XBS5_ILP32_OFF32)
126 { "XBS5_ILP32_OFF32", SYSCONF, _SC_XBS5_ILP32_OFF32 },
127 { "_XBS5_ILP32_OFF32", SYSCONF, _SC_XBS5_ILP32_OFF32 },
128 #endif
129 #if defined (_CS_XBS5_ILP32_OFF32_CFLAGS)
130 { "XBS5_ILP32_OFF32_CFLAGS", CONFSTR, _CS_XBS5_ILP32_OFF32_CFLAGS },
131 { "XBS5_ILP32_OFF32_LDFLAGS", CONFSTR, _CS_XBS5_ILP32_OFF32_LDFLAGS },
132 { "XBS5_ILP32_OFF32_LIBS", CONFSTR, _CS_XBS5_ILP32_OFF32_LIBS },
133 { "XBS5_ILP32_OFF32_LINTFLAGS", CONFSTR, _CS_XBS5_ILP32_OFF32_LINTFLAGS },
134 #endif
135 #if defined (_SC_XBS5_ILP32_OFFBIG)
136 { "XBS5_ILP32_OFFBIG", SYSCONF, _SC_XBS5_ILP32_OFFBIG },
137 { "_XBS5_ILP32_OFFBIG", SYSCONF, _SC_XBS5_ILP32_OFFBIG },
138 #endif
139 #if defined (_CS_XBS5_ILP32_OFFBIG_CFLAGS)
140 { "XBS5_ILP32_OFFBIG_CFLAGS", CONFSTR, _CS_XBS5_ILP32_OFFBIG_CFLAGS },
141 { "XBS5_ILP32_OFFBIG_LDFLAGS", CONFSTR, _CS_XBS5_ILP32_OFFBIG_LDFLAGS },
142 { "XBS5_ILP32_OFFBIG_LIBS", CONFSTR, _CS_XBS5_ILP32_OFFBIG_LIBS },
143 { "XBS5_ILP32_OFFBIG_LINTFLAGS", CONFSTR, _CS_XBS5_ILP32_OFFBIG_LINTFLAGS },
144 #endif
145 #if defined (_SC_XBS5_LP64_OFF64)
146 { "XBS5_LP64_OFF64", SYSCONF, _SC_XBS5_LP64_OFF64 },
147 { "_XBS5_LP64_OFF64", SYSCONF, _SC_XBS5_LP64_OFF64 },
148 #endif
149 #if defined (_CS_XBS5_LP64_OFF64_CFLAGS)
150 { "XBS5_LP64_OFF64_CFLAGS", CONFSTR, _CS_XBS5_LP64_OFF64_CFLAGS },
151 { "XBS5_LP64_OFF64_LDFLAGS", CONFSTR, _CS_XBS5_LP64_OFF64_LDFLAGS },
152 { "XBS5_LP64_OFF64_LIBS", CONFSTR, _CS_XBS5_LP64_OFF64_LIBS },
153 { "XBS5_LP64_OFF64_LINTFLAGS", CONFSTR, _CS_XBS5_LP64_OFF64_LINTFLAGS },
154 #endif
155 #if defined (_SC_XBS5_LPBIG_OFFBIG)
156 { "XBS5_LPBIG_OFFBIG", SYSCONF, _SC_XBS5_LPBIG_OFFBIG },
157 { "_XBS5_LPBIG_OFFBIG", SYSCONF, _SC_XBS5_LPBIG_OFFBIG },
158 #endif
159 #if defined (_CS_XBS5_LPBIG_OFFBIG_CFLAGS)
160 { "XBS5_LPBIG_OFFBIG_CFLAGS", CONFSTR, _CS_XBS5_LPBIG_OFFBIG_CFLAGS },
161 { "XBS5_LPBIG_OFFBIG_LDFLAGS", CONFSTR, _CS_XBS5_LPBIG_OFFBIG_LDFLAGS },
162 { "XBS5_LPBIG_OFFBIG_LIBS", CONFSTR, _CS_XBS5_LPBIG_OFFBIG_LIBS },
163 { "XBS5_LPBIG_OFFBIG_LINTFLAGS", CONFSTR, _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS },
164 #endif
166 /* Single UNIX Specification version 3 (POSIX.1-200x) Configurable Variable
167 Values. The SYSCONF variables say whether or not the appropriate CONFSTR
168 variables are available. */
170 #if defined (_SC_POSIX_V6_ILP32_OFF32)
171 { "_POSIX_V6_ILP32_OFF32", SYSCONF, _SC_POSIX_V6_ILP32_OFF32 },
172 #endif
173 #if defined (_CS_POSIX_V6_ILP32_OFF32_CFLAGS)
174 { "POSIX_V6_ILP32_OFF32_CFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFF32_CFLAGS },
175 { "POSIX_V6_ILP32_OFF32_LDFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFF32_LDFLAGS },
176 { "POSIX_V6_ILP32_OFF32_LIBS", CONFSTR, _CS_POSIX_V6_ILP32_OFF32_LIBS },
177 #endif
178 #if defined (_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS)
179 { "POSIX_V6_ILP32_OFF32_LINTFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS },
180 #endif
181 #if defined (_SC_POSIX_V6_ILP32_OFFBIG)
182 { "_POSIX_V6_ILP32_OFFBIG", SYSCONF, _SC_POSIX_V6_ILP32_OFFBIG },
183 #endif
184 #if defined (_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
185 { "POSIX_V6_ILP32_OFFBIG_CFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS },
186 { "POSIX_V6_ILP32_OFFBIG_LDFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS },
187 { "POSIX_V6_ILP32_OFFBIG_LIBS", CONFSTR, _CS_POSIX_V6_ILP32_OFFBIG_LIBS },
188 #endif
189 #if defined (_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS)
190 { "POSIX_V6_ILP32_OFFBIG_LINTFLAGS", CONFSTR, _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS },
191 #endif
192 #if defined (_SC_POSIX_V6_LP64_OFF64)
193 { "_POSIX_V6_LP64_OFF64", SYSCONF, _SC_POSIX_V6_LP64_OFF64 },
194 #endif
195 #if defined (_CS_POSIX_V6_LP64_OFF64_CFLAGS)
196 { "POSIX_V6_LP64_OFF64_CFLAGS", CONFSTR, _CS_POSIX_V6_LP64_OFF64_CFLAGS },
197 { "POSIX_V6_LP64_OFF64_LDFLAGS", CONFSTR, _CS_POSIX_V6_LP64_OFF64_LDFLAGS },
198 { "POSIX_V6_LP64_OFF64_LIBS", CONFSTR, _CS_POSIX_V6_LP64_OFF64_LIBS },
199 #endif
200 #if defined (CS_POSIX_V6_LP64_OFF64_LINTFLAGS)
201 { "POSIX_V6_LP64_OFF64_LINTFLAGS", CONFSTR, _CS_POSIX_V6_LP64_OFF64_LINTFLAGS },
202 #endif
203 #if defined (_SC_POSIX_V6_LPBIG_OFFBIG)
204 { "_POSIX_V6_LPBIG_OFFBIG", SYSCONF, _SC_POSIX_V6_LPBIG_OFFBIG },
205 #endif
206 #if defined (_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
207 { "POSIX_V6_LPBIG_OFFBIG_CFLAGS", CONFSTR, _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS },
208 { "POSIX_V6_LPBIG_OFFBIG_LDFLAGS", CONFSTR, _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS },
209 { "POSIX_V6_LPBIG_OFFBIG_LIBS", CONFSTR, _CS_POSIX_V6_LPBIG_OFFBIG_LIBS },
210 #endif
211 #if defined (_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS)
212 { "POSIX_V6_LPBIG_OFFBIG_LINTFLAGS", CONFSTR, _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS },
213 #endif
215 #if defined (_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS)
216 { "POSIX_6_WIDTH_RESTRICTED_ENVS", CONFSTR, _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS },
217 #endif
219 /* POSIX.2 Utility Limit Minimum Values */
220 #ifdef _POSIX2_BC_BASE_MAX
221 { "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX },
222 #else
223 { "POSIX2_BC_BASE_MAX", G_UNDEF, -1 },
224 #endif
225 #ifdef _POSIX2_BC_DIM_MAX
226 { "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX },
227 #else
228 { "POSIX2_BC_DIM_MAX", G_UNDEF, -1 },
229 #endif
230 #ifdef _POSIX2_BC_SCALE_MAX
231 { "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX },
232 #else
233 { "POSIX2_BC_SCALE_MAX", G_UNDEF, -1 },
234 #endif
235 #ifdef _POSIX2_BC_STRING_MAX
236 { "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX },
237 #else
238 { "POSIX2_BC_STRING_MAX", G_UNDEF, -1 },
239 #endif
240 #ifdef _POSIX2_CHARCLASS_NAME_MAX
241 { "POSIX2_CHARCLASS_NAME_MAX", CONSTANT, _POSIX2_CHARCLASS_NAME_MAX },
242 #else
243 { "POSIX2_CHARCLASS_NAME_MAX", G_UNDEF, -1 },
244 #endif
245 #ifdef _POSIX2_COLL_WEIGHTS_MAX
246 { "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX },
247 #else
248 { "POSIX2_COLL_WEIGHTS_MAX", G_UNDEF, -1 },
249 #endif
250 #if defined (_POSIX2_EQUIV_CLASS_MAX)
251 { "POSIX2_EQUIV_CLASS_MAX", CONSTANT, _POSIX2_EQUIV_CLASS_MAX },
252 #endif
253 #ifdef _POSIX2_EXPR_NEST_MAX
254 { "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX },
255 #else
256 { "POSIX2_EXPR_NEST_MAX", G_UNDEF, -1 },
257 #endif
258 #ifdef _POSIX2_LINE_MAX
259 { "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX },
260 #else
261 { "POSIX2_LINE_MAX", G_UNDEF, -1 },
262 #endif
263 #ifdef _POSIX2_RE_DUP_MAX
264 { "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX },
265 #else
266 { "POSIX2_RE_DUP_MAX", G_UNDEF, -1 },
267 #endif
268 #if defined (_POSIX2_VERSION)
269 { "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION },
270 #else
271 # if !defined (_SC_2_VERSION)
272 { "POSIX2_VERSION", G_UNDEF, -1 },
273 # endif
274 #endif
276 #ifdef _POSIX2_BC_BASE_MAX
277 { "_POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX },
278 #else
279 { "_POSIX2_BC_BASE_MAX", G_UNDEF, -1 },
280 #endif
281 #ifdef _POSIX2_BC_DIM_MAX
282 { "_POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX },
283 #else
284 { "_POSIX2_BC_DIM_MAX", G_UNDEF, -1 },
285 #endif
286 #ifdef _POSIX2_BC_SCALE_MAX
287 { "_POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX },
288 #else
289 { "_POSIX2_BC_SCALE_MAX", G_UNDEF, -1 },
290 #endif
291 #ifdef _POSIX2_BC_STRING_MAX
292 { "_POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX },
293 #else
294 { "_POSIX2_BC_STRING_MAX", G_UNDEF, -1 },
295 #endif
296 #ifdef _POSIX2_CHARCLASS_NAME_MAX
297 { "_POSIX2_CHARCLASS_NAME_MAX", CONSTANT, _POSIX2_CHARCLASS_NAME_MAX },
298 #else
299 { "_POSIX2_CHARCLASS_NAME_MAX", G_UNDEF, -1 },
300 #endif
301 #ifdef _POSIX2_COLL_WEIGHTS_MAX
302 { "_POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX },
303 #else
304 { "_POSIX2_COLL_WEIGHTS_MAX", G_UNDEF, -1 },
305 #endif
306 #if defined (_POSIX2_EQUIV_CLASS_MAX)
307 { "POSIX2_EQUIV_CLASS_MAX", CONSTANT, _POSIX2_EQUIV_CLASS_MAX },
308 #endif
309 #ifdef _POSIX2_EXPR_NEST_MAX
310 { "_POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX },
311 #else
312 { "_POSIX2_EXPR_NEST_MAX", G_UNDEF, -1 },
313 #endif
314 #ifdef _POSIX2_LINE_MAX
315 { "_POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX },
316 #else
317 { "_POSIX2_LINE_MAX", G_UNDEF, -1 },
318 #endif
319 #ifdef _POSIX2_RE_DUP_MAX
320 { "_POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX },
321 #else
322 { "_POSIX2_RE_DUP_MAX", G_UNDEF, -1 },
323 #endif
325 /* X/OPEN Maxmimum Values */
326 #ifdef _XOPEN_IOV_MAX
327 { "_XOPEN_IOV_MAX", CONSTANT, _XOPEN_IOV_MAX },
328 #else
329 { "_XOPEN_IOV_MAX", G_UNDEF, -1 },
330 #endif
331 #ifdef _XOPEN_NAME_MAX
332 { "_XOPEN_NAME_MAX", CONSTANT, _XOPEN_NAME_MAX },
333 #else
334 { "_XOPEN_NAME_MAX", G_UNDEF, -1 },
335 #endif
336 #ifdef _XOPEN_PATH_MAX
337 { "_XOPEN_PATH_MAX", CONSTANT, _XOPEN_PATH_MAX },
338 #else
339 { "_XOPEN_PATH_MAX", G_UNDEF, -1 },
340 #endif
342 /* POSIX.1 Minimum Values */
343 #ifdef _POSIX_AIO_LISTIO_MAX
344 { "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX },
345 #else
346 { "_POSIX_AIO_LISTIO_MAX", G_UNDEF, -1 },
347 #endif
348 #ifdef _POSIX_AIO_MAX
349 { "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX },
350 #else
351 { "_POSIX_AIO_MAX", G_UNDEF, -1 },
352 #endif
353 #ifdef _POSIX_ARG_MAX
354 { "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX },
355 #else
356 { "_POSIX_ARG_MAX", G_UNDEF, -1 },
357 #endif
358 #ifdef _POSIX_CHILD_MAX
359 { "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX },
360 #else
361 { "_POSIX_CHILD_MAX", G_UNDEF, -1 },
362 #endif
363 #ifdef _POSIX_DELAYTIMER_MAX
364 { "_POSIX_DELAYTIMER_MAX", CONSTANT, _POSIX_DELAYTIMER_MAX },
365 #else
366 { "_POSIX_DELAYTIMER_MAX", G_UNDEF, -1 },
367 #endif
368 #ifdef _POSIX_HOST_NAME_MAX
369 { "_POSIX_HOST_NAME_MAX", CONSTANT, _POSIX_HOST_NAME_MAX },
370 #else
371 { "_POSIX_HOST_NAME_MAX", G_UNDEF, -1 },
372 #endif
373 #ifdef _POSIX_LINK_MAX
374 { "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX },
375 #else
376 { "_POSIX_LINK_MAX", G_UNDEF, -1 },
377 #endif
378 #ifdef _POSIX_LOGIN_NAME_MAX
379 { "_POSIX_LOGIN_NAME_MAX", CONSTANT, _POSIX_LOGIN_NAME_MAX },
380 #else
381 { "_POSIX_LOGIN_NAME_MAX", G_UNDEF, -1 },
382 #endif
383 #ifdef _POSIX_MAX_CANON
384 { "_POSIX_MAX_CANON", CONSTANT, _POSIX_MAX_CANON },
385 #else
386 { "_POSIX_MAX_CANON", G_UNDEF, -1 },
387 #endif
388 #ifdef _POSIX_MAX_INPUT
389 { "_POSIX_MAX_INPUT", CONSTANT, _POSIX_MAX_INPUT },
390 #else
391 { "_POSIX_MAX_INPUT", G_UNDEF, -1 },
392 #endif
393 #ifdef _POSIX_MQ_OPEN_MAX
394 { "_POSIX_MQ_OPEN_MAX", CONSTANT, _POSIX_MQ_OPEN_MAX },
395 #else
396 { "_POSIX_MQ_OPEN_MAX", G_UNDEF, -1 },
397 #endif
398 #ifdef _POSIX_MQ_PRIO_MAX
399 { "_POSIX_MQ_PRIO_MAX", CONSTANT, _POSIX_MQ_PRIO_MAX },
400 #else
401 { "_POSIX_MQ_PRIO_MAX", G_UNDEF, -1 },
402 #endif
403 #ifdef _POSIX_NAME_MAX
404 { "_POSIX_NAME_MAX", CONSTANT, _POSIX_NAME_MAX },
405 #else
406 { "_POSIX_NAME_MAX", G_UNDEF, -1 },
407 #endif
408 #ifdef _POSIX_NGROUPS_MAX
409 { "_POSIX_NGROUPS_MAX", CONSTANT, _POSIX_NGROUPS_MAX },
410 #else
411 { "_POSIX_NGROUPS_MAX", G_UNDEF, -1 },
412 #endif
413 #ifdef _POSIX_OPEN_MAX
414 { "_POSIX_OPEN_MAX", CONSTANT, _POSIX_OPEN_MAX },
415 #else
416 { "_POSIX_OPEN_MAX", G_UNDEF, -1 },
417 #endif
418 #ifdef _POSIX_PATH_MAX
419 { "_POSIX_PATH_MAX", CONSTANT, _POSIX_PATH_MAX },
420 #else
421 { "_POSIX_PATH_MAX", G_UNDEF, -1 },
422 #endif
423 #ifdef _POSIX_PIPE_BUF
424 { "_POSIX_PIPE_BUF", CONSTANT, _POSIX_PIPE_BUF },
425 #else
426 { "_POSIX_PIPE_BUF", G_UNDEF, -1 },
427 #endif
428 #ifdef _POSIX_RE_DUP_MAX
429 { "_POSIX_RE_DUP_MAX", CONSTANT, _POSIX_RE_DUP_MAX },
430 #else
431 { "_POSIX_RE_DUP_MAX", G_UNDEF, -1 },
432 #endif
433 #ifdef _POSIX_RTSIG_MAX
434 { "_POSIX_RTSIG_MAX", CONSTANT, _POSIX_RTSIG_MAX },
435 #else
436 { "_POSIX_RTSIG_MAX", G_UNDEF, -1 },
437 #endif
438 #ifdef _POSIX_SEM_NSEMS_MAX
439 { "_POSIX_SEM_NSEMS_MAX", CONSTANT, _POSIX_SEM_NSEMS_MAX },
440 #else
441 { "_POSIX_SEM_NSEMS_MAX", G_UNDEF, -1 },
442 #endif
443 #ifdef _POSIX_SEM_VALUE_MAX
444 { "_POSIX_SEM_VALUE_MAX", CONSTANT, _POSIX_SEM_VALUE_MAX },
445 #else
446 { "_POSIX_SEM_VALUE_MAX", G_UNDEF, -1 },
447 #endif
448 #ifdef _POSIX_SIGQUEUE_MAX
449 { "_POSIX_SIGQUEUE_MAX", CONSTANT, _POSIX_SIGQUEUE_MAX },
450 #else
451 { "_POSIX_SIGQUEUE_MAX", G_UNDEF, -1 },
452 #endif
453 #ifdef _POSIX_SSIZE_MAX
454 { "_POSIX_SSIZE_MAX", CONSTANT, _POSIX_SSIZE_MAX },
455 #else
456 { "_POSIX_SSIZE_MAX", G_UNDEF, -1 },
457 #endif
458 #ifdef _POSIX_SS_REPL_MAX
459 { "_POSIX_SS_REPL_MAX", CONSTANT, _POSIX_SS_REPL_MAX },
460 #else
461 { "_POSIX_SS_REPL_MAX", G_UNDEF, -1 },
462 #endif
463 #ifdef _POSIX_STREAM_MAX
464 { "_POSIX_STREAM_MAX", CONSTANT, _POSIX_STREAM_MAX },
465 #else
466 { "_POSIX_STREAM_MAX", G_UNDEF, -1 },
467 #endif
468 #ifdef _POSIX_SYMLINK_MAX
469 { "_POSIX_SYMLINK_MAX", CONSTANT, _POSIX_SYMLINK_MAX },
470 #else
471 { "_POSIX_SYMLINK_MAX", G_UNDEF, -1 },
472 #endif
473 #ifdef _POSIX_SYMLOOP_MAX
474 { "_POSIX_SYMLOOP_MAX", CONSTANT, _POSIX_SYMLOOP_MAX },
475 #else
476 { "_POSIX_SYMLOOP_MAX", G_UNDEF, -1 },
477 #endif
478 #ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
479 { "_POSIX_THREAD_DESTRUCTOR_ITERATIONS", CONSTANT, _POSIX_THREAD_DESTRUCTOR_ITERATIONS },
480 #else
481 { "_POSIX_THREAD_DESTRUCTOR_ITERATIONS", G_UNDEF, -1 },
482 #endif
483 #ifdef _POSIX_THREAD_KEYS_MAX
484 { "_POSIX_THREAD_KEYS_MAX", CONSTANT, _POSIX_THREAD_KEYS_MAX },
485 #else
486 { "_POSIX_THREAD_KEYS_MAX", G_UNDEF, -1 },
487 #endif
488 #ifdef _POSIX_THREAD_THREADS_MAX
489 { "_POSIX_THREAD_THREADS_MAX",CONSTANT, _POSIX_THREAD_THREADS_MAX },
490 #else
491 { "_POSIX_THREAD_THREADS_MAX",G_UNDEF, -1 },
492 #endif
493 #ifdef _POSIX_TIMER_MAX
494 { "_POSIX_TIMER_MAX", CONSTANT, _POSIX_TIMER_MAX },
495 #else
496 { "_POSIX_TIMER_MAX", G_UNDEF, -1 },
497 #endif
498 #ifdef _POSIX_TRACE_EVENT_NAME_MAX
499 { "_POSIX_TRACE_EVENT_NAME_MAX", CONSTANT, _POSIX_TRACE_EVENT_NAME_MAX },
500 #else
501 { "_POSIX_TRACE_EVENT_NAME_MAX", G_UNDEF, -1 },
502 #endif
503 #ifdef _POSIX_TRACE_NAME_MAX
504 { "_POSIX_TRACE_NAME_MAX", CONSTANT, _POSIX_TRACE_NAME_MAX },
505 #else
506 { "_POSIX_TRACE_NAME_MAX", G_UNDEF, -1 },
507 #endif
508 #ifdef _POSIX_TRACE_SYS_MAX
509 { "_POSIX_TRACE_SYS_MAX", CONSTANT, _POSIX_TRACE_SYS_MAX },
510 #else
511 { "_POSIX_TRACE_SYS_MAX", G_UNDEF, -1 },
512 #endif
513 #ifdef _POSIX_TRACE_USER_EVENT_MAX
514 { "_POSIX_TRACE_USER_EVENT_MAX", CONSTANT, _POSIX_TRACE_USER_EVENT_MAX },
515 #else
516 { "_POSIX_TRACE_USER_EVENT_MAX", G_UNDEF, -1 },
517 #endif
518 #ifdef _POSIX_TTY_NAME_MAX
519 { "_POSIX_TTY_NAME_MAX", CONSTANT, _POSIX_TTY_NAME_MAX },
520 #else
521 { "_POSIX_TTY_NAME_MAX", G_UNDEF, -1 },
522 #endif
523 #ifdef _POSIX_TZNAME_MAX
524 { "_POSIX_TZNAME_MAX", CONSTANT, _POSIX_TZNAME_MAX },
525 #else
526 { "_POSIX_TZNAME_MAX", G_UNDEF, -1 },
527 #endif
529 /* POSIX.1 Maximum Values */
530 #ifdef _POSIX_CLOCKRES_MIN
531 { "_POSIX_CLOCKRES_MIN", CONSTANT, _POSIX_CLOCKRES_MIN },
532 #else
533 { "_POSIX_CLOCKRES_MIN", G_UNDEF, -1 },
534 #endif
536 /* POSIX.1-2001/XPG6 (and later) Runtime Invariants from <limits.h> */
537 #ifdef _SC_SS_REPL_MAX
538 { "SS_REPL_MAX", SYSCONF, _SC_SS_REPL_MAX },
539 #endif
540 #ifdef _SC_TRACE_EVENT_NAME_MAX
541 { "TRACE_EVENT_NAME_MAX", SYSCONF, _SC_TRACE_EVENT_NAME_MAX },
542 #endif
543 #ifdef _SC_TRACE_NAME_MAX
544 { "TRACE_NAME_MAX", SYSCONF, _SC_TRACE_NAME_MAX },
545 #endif
546 #ifdef _SC_TRACE_SYS_MAX
547 { "TRACE_SYS_MAX", SYSCONF, _SC_TRACE_SYS_MAX },
548 #endif
549 #ifdef _SC_TRACE_USER_EVENT_MAX
550 { "TRACE_USER_EVENT_MAX", SYSCONF, _SC_TRACE_USER_EVENT_MAX },
551 #endif
553 /* POSIX.2/XPG 4.2 (and later) Symbolic Utility Limits */
554 #ifdef _SC_BC_BASE_MAX
555 { "BC_BASE_MAX", SYSCONF, _SC_BC_BASE_MAX },
556 #endif
557 #ifdef _SC_BC_DIM_MAX
558 { "BC_DIM_MAX", SYSCONF, _SC_BC_DIM_MAX },
559 #endif
560 #ifdef _SC_BC_SCALE_MAX
561 { "BC_SCALE_MAX", SYSCONF, _SC_BC_SCALE_MAX },
562 #endif
563 #ifdef _SC_BC_STRING_MAX
564 { "BC_STRING_MAX", SYSCONF, _SC_BC_STRING_MAX },
565 #endif
566 #ifdef CHARCLASS_NAME_MAX
567 { "CHARCLASS_NAME_MAX", CONSTANT, CHARCLASS_NAME_MAX },
568 #endif
569 #ifdef _SC_COLL_WEIGHTS_MAX
570 { "COLL_WEIGHTS_MAX", SYSCONF, _SC_COLL_WEIGHTS_MAX },
571 #endif
572 #ifdef _SC_EXPR_NEST_MAX
573 { "EXPR_NEST_MAX", SYSCONF, _SC_EXPR_NEST_MAX },
574 #endif
575 #ifdef _SC_LINE_MAX
576 { "LINE_MAX", SYSCONF, _SC_LINE_MAX },
577 #endif
578 # ifdef NL_ARGMAX
579 { "NL_ARGMAX", CONSTANT, NL_ARGMAX },
580 #endif
581 #ifdef NL_LANGMAX
582 { "NL_LANGMAX", CONSTANT, NL_LANGMAX },
583 #endif
584 #ifdef NL_MSGMAX
585 { "NL_MSGMAX", CONSTANT, NL_MSGMAX },
586 #endif
587 #ifdef NL_NMAX
588 { "NL_NMAX", CONSTANT, NL_NMAX },
589 #endif
590 #ifdef NL_SETMAX
591 { "NL_SETMAX", CONSTANT, NL_SETMAX },
592 #endif
593 #ifdef NL_TEXTMAX
594 { "NL_TEXTMAX", CONSTANT, NL_TEXTMAX },
595 #endif
596 #ifdef _SC_RAW_SOCKET
597 { "RAW_SOCKET", SYSCONF, _SC_RAW_SOCKET },
598 #endif
599 #ifdef _SC_RE_DUP_MAX
600 { "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX },
601 #endif
603 /* POSIX.2 Optional Facility Configuration Values */
604 #ifdef _SC_2_C_BIND
605 { "POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND },
606 #else
607 { "POSIX2_C_BIND", G_UNDEF, -1 },
608 #endif
609 #ifdef _SC_2_C_DEV
610 { "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV },
611 #else
612 { "POSIX2_C_DEV", G_UNDEF, -1 },
613 #endif
614 #if defined (_SC_2_C_VERSION)
615 { "POSIX2_C_VERSION", SYSCONF, _SC_2_C_VERSION },
616 #else
617 { "POSIX2_C_VERSION", G_UNDEF, -1 },
618 #endif
619 #if defined (_SC_2_CHAR_TERM)
620 { "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM },
621 #else
622 { "POSIX2_CHAR_TERM", G_UNDEF, -1 },
623 #endif
624 #ifdef _SC_2_FORT_DEV
625 { "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV },
626 #else
627 { "POSIX2_FORT_DEV", G_UNDEF, -1 },
628 #endif
629 #ifdef _SC_2_FORT_RUN
630 { "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN },
631 #else
632 { "POSIX2_FORT_RUN", G_UNDEF, -1 },
633 #endif
634 #ifdef _SC_2_LOCALEDEF
635 { "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF },
636 #else
637 { "POSIX2_LOCALEDEF", G_UNDEF, -1 },
638 #endif
639 #ifdef _SC_2_SW_DEV
640 { "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV },
641 #else
642 { "POSIX2_SW_DEV", G_UNDEF, -1 },
643 #endif
644 #if defined (_SC2_UPE)
645 { "POSIX2_UPE", SYSCONF, _SC_2_UPE },
646 #else
647 { "POSIX2_UPE", G_UNDEF, -1 },
648 #endif
649 #if !defined (_POSIX2_VERSION) && defined (_SC_2_VERSION)
650 { "_POSIX2_VERSION", SYSCONF, _SC_2_VERSION },
651 #else
652 { "_POSIX2_VERSION", G_UNDEF, -1 },
653 #endif
654 #if defined (_SC_REGEX_VERSION)
655 { "REGEX_VERSION", SYSCONF, _SC_REGEX_VERSION },
656 { "_REGEX_VERSION", SYSCONF, _SC_REGEX_VERSION },
657 #else
658 { "REGEX_VERSION", G_UNDEF, -1 },
659 { "_REGEX_VERSION", G_UNDEF, -1 },
660 #endif
662 #if defined (_SC_2_PBS)
663 { "_POSIX2_PBS", SYSCONF, _SC_2_PBS },
664 { "_POSIX2_PBS_ACCOUNTING", SYSCONF, _SC_2_PBS_ACCOUNTING },
665 # if defined (_SC_2_PBS_CHECKPOINT)
666 { "_POSIX2_PBS_CHECKPOINT", SYSCONF, _SC_2_PBS_CHECKPOINT },
667 # endif
668 { "_POSIX2_PBS_LOCATE", SYSCONF, _SC_2_PBS_LOCATE },
669 { "_POSIX2_PBS_MESSAGE", SYSCONF, _SC_2_PBS_MESSAGE },
670 { "_POSIX2_PBS_TRACK", SYSCONF, _SC_2_PBS_TRACK },
671 #endif
673 /* POSIX.1 Configurable System Variables */
674 #ifdef _SC_ARG_MAX
675 { "ARG_MAX", SYSCONF, _SC_ARG_MAX },
676 #endif
677 #ifdef _SC_CHILD_MAX
678 { "CHILD_MAX", SYSCONF, _SC_CHILD_MAX },
679 #endif
680 #ifdef _SC_CLK_TCK
681 { "CLK_TCK", SYSCONF, _SC_CLK_TCK },
682 #endif
683 #ifdef _SC_DELAYTIMER_MAX
684 { "DELAYTIMER_MAX", SYSCONF, _SC_DELAYTIMER_MAX },
685 #endif
686 #ifdef _SC_NGROUPS_MAX
687 { "NGROUPS_MAX", SYSCONF, _SC_NGROUPS_MAX },
688 #endif
689 #ifdef NZERO
690 { "NZERO", CONSTANT, NZERO },
691 #endif
692 #ifdef _SC_OPEN_MAX
693 { "OPEN_MAX", SYSCONF, _SC_OPEN_MAX },
694 #endif
695 #ifdef PASS_MAX
696 { "PASS_MAX", CONSTANT, PASS_MAX },
697 #endif
698 #ifdef _SC_STREAM_MAX
699 { "STREAM_MAX", SYSCONF, _SC_STREAM_MAX },
700 #endif
701 #ifdef TMP_MAX
702 { "TMP_MAX", CONSTANT, TMP_MAX },
703 #endif
704 #ifdef _SC_TZNAME_MAX
705 { "TZNAME_MAX", SYSCONF, _SC_TZNAME_MAX },
706 #endif
708 /* POSIX.1 Optional Facility Configuration Values */
709 #if defined (_SC_ADVISORY_INFO)
710 { "_POSIX_ADVISORY_INFO", SYSCONF, _SC_ADVISORY_INFO },
711 #endif
712 #if defined (_SC_ASYNCHRONOUS_IO)
713 { "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO },
714 #endif
715 #if defined (_SC_BARRIERS)
716 { "_POSIX_BARRIERS", SYSCONF, _SC_BARRIERS },
717 #endif
718 #if defined (_SC_BASE)
719 { "_POSIX_BASE", SYSCONF, _SC_BASE },
720 #endif
721 #if defined (_SC_C_LANG_SUPPORT)
722 { "_POSIX_C_LANG_SUPPORT", SYSCONF, _SC_C_LANG_SUPPORT },
723 #endif
724 #if defined (_SC_C_LANG_SUPPORT_R)
725 { "_POSIX_C_LANG_SUPPORT_R", SYSCONF, _SC_C_LANG_SUPPORT_R },
726 #endif
727 #if defined (_SC_CLOCK_SELECTION)
728 { "_POSIX_CLOCK_SELECTION", SYSCONF, _SC_CLOCK_SELECTION },
729 #endif
730 #if defined (_SC_CPUTIME)
731 { "_POSIX_CPUTIME", SYSCONF, _SC_CPUTIME },
732 #endif
733 #if defined (_SC_DEVICE_IO)
734 { "_POSIX_DEVICE_IO", SYSCONF, _SC_DEVICE_IO },
735 #endif
736 #if defined (_SC_DEVICE_SPECIFIC)
737 { "_POSIX_DEVICE_SPECIFIC", SYSCONF, _SC_DEVICE_SPECIFIC },
738 #endif
739 #if defined (_SC_DEVICE_SPECIFIC_R)
740 { "_POSIX_DEVICE_SPECIFIC_R", SYSCONF, _SC_DEVICE_SPECIFIC_R },
741 #endif
742 #if defined (_SC_FD_MGMT)
743 { "_POSIX_FD_MGMT", SYSCONF, _SC_FD_MGMT },
744 #endif
745 #if defined (_SC_FIFO)
746 { "_POSIX_FIFO", SYSCONF, _SC_FIFO },
747 #endif
748 #if defined (_SC_FILE_ATTRIBUTES)
749 { "_POSIX_FILE_ATTRIBUTES", SYSCONF, _SC_FILE_ATTRIBUTES },
750 #endif
751 #if defined (_SC_FILE_LOCKING)
752 { "_POSIX_FILE_LOCKING", SYSCONF, _SC_FILE_LOCKING },
753 #endif
754 #if defined (_SC_FILE_SYSTEM)
755 { "_POSIX_FILE_SYSTEM", SYSCONF, _SC_FILE_SYSTEM },
756 #endif
757 #if defined (_SC_FSYNC)
758 { "_POSIX_FSYNC", SYSCONF, _SC_FSYNC },
759 #endif
760 #if defined (_SC_IPV6)
761 { "_POSIX_IPV6", SYSCONF, _SC_IPV6 },
762 #endif
763 #if defined (_SC_JOB_CONTROL)
764 { "_POSIX_JOB_CONTROL", SYSCONF, _SC_JOB_CONTROL },
765 #endif
766 #if defined (_SC_MAPPED_FILES)
767 { "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES },
768 #endif
769 #if defined (_SC_MEMLOCK)
770 { "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK },
771 #endif
772 #if defined (_SC_MEMLOCK_RANGE)
773 { "_POSIX_MEMLOCK_RANGE", SYSCONF, _SC_MEMLOCK_RANGE },
774 #endif
775 #if defined (_SC_MEMORY_PROTECTION)
776 { "_POSIX_MEMORY_PROTECTION", SYSCONF, _SC_MEMORY_PROTECTION },
777 #endif
778 #if defined (_SC_MESSAGE_PASSING)
779 { "_POSIX_MESSAGE_PASSING", SYSCONF, _SC_MESSAGE_PASSING },
780 #endif
781 #if defined (_SC_MONOTONIC_CLOCK)
782 { "_POSIX_MONOTONIC_CLOCK", SYSCONF, _SC_MONOTONIC_CLOCK },
783 #endif
784 #if defined (_SC_MULTI_PROCESS)
785 { "_POSIX_MULTI_PROCESS", SYSCONF, _SC_MULTI_PROCESS },
786 #endif
787 #if defined (_SC_NETWORKING)
788 { "_POSIX_NETWORKING", SYSCONF, _SC_NETWORKING },
789 #endif
790 #if defined (_SC_PIPE)
791 { "_POSIX_PIPE", SYSCONF, _SC_PIPE },
792 #endif
793 #if defined (SC_PRIORITIZED_IO)
794 { "_POSIX_PRIORITIZED_IO", SYSCONF, _SC_PRIORITIZED_IO },
795 #endif
796 #if defined (_SC_PRIORITY_SCHEDULING)
797 { "_POSIX_PRIORITY_SCHEDULING", SYSCONF, _SC_PRIORITY_SCHEDULING },
798 #endif
799 #if defined (_SC_READER_WRITER_LOCKS)
800 { "_POSIX_READER_WRITER_LOCKS", SYSCONF, _SC_READER_WRITER_LOCKS },
801 #endif
802 #if defined (_SC_RAW_SOCKETS)
803 { "_POSIX_RAW_SOCKETS", SYSCONF, _SC_RAW_SOCKETS },
804 #endif
805 #if defined (_SC_REALTIME_SIGNALS)
806 { "_POSIX_REALTIME_SIGNALS", SYSCONF, _SC_REALTIME_SIGNALS },
807 #endif
808 #if defined (_SC_REGEXP)
809 { "_POSIX_REGEXP", SYSCONF, _SC_REGEXP },
810 #endif
811 #if defined (_SC_SAVED_IDS)
812 { "_POSIX_SAVED_IDS", SYSCONF, _SC_SAVED_IDS },
813 #endif
814 #if defined (_SC_SEMAPHORES)
815 { "_POSIX_SEMAPHORES", SYSCONF, _SC_SEMAPHORES },
816 #endif
817 #if defined (_SC_SHARED_MEMORY_OBJECTS)
818 { "_POSIX_SHARED_MEMORY_OBJECTS", SYSCONF, _SC_SHARED_MEMORY_OBJECTS },
819 #endif
820 { "_POSIX_SHELL", CONSTANT, 1 },
821 #if defined (_SC_SIGNALS)
822 { "_POSIX_SIGNALS", SYSCONF, _SC_SIGNALS },
823 #endif
824 #if defined (_SC_SINGLE_PROCESS)
825 { "_POSIX_SINGLE_PROCESS", SYSCONF, _SC_SINGLE_PROCESS },
826 #endif
827 #if defined (_SC_SPAWN)
828 { "_POSIX_SPAWN", SYSCONF, _SC_SPAWN },
829 #endif
830 #if defined (_SC_SPIN_LOCKS)
831 { "_POSIX_SPIN_LOCKS", SYSCONF, _SC_SPIN_LOCKS },
832 #endif
833 #if defined (_SC_SPORADIC_SERVER)
834 { "_POSIX_SPORADIC_SERVER", SYSCONF, _SC_SPORADIC_SERVER },
835 #endif
836 #if defined (_SC_SYMLOOP_MAX)
837 { "_POSIX_SYMLOOP_MAX", SYSCONF, _SC_SYMLOOP_MAX },
838 #endif
839 #if defined (_SC_SYNCHRONIZED_IO)
840 { "_POSIX_SYNCHRONIZED_IO", SYSCONF, _SC_SYNCHRONIZED_IO },
841 #endif
842 #if defined (_SC_SYSTEM_DATABASE)
843 { "_POSIX_SYSTEM_DATABASE", SYSCONF, _SC_SYSTEM_DATABASE },
844 #endif
845 #if defined (_SC_SYSTEM_DATABASE_R)
846 { "_POSIX_SYSTEM_DATABASE_R", SYSCONF, _SC_SYSTEM_DATABASE_R },
847 #endif
848 #if defined (_SC_THREAD_ATTR_STACKADDR)
849 { "_POSIX_THREAD_ATTR_STACKADDR", SYSCONF, _SC_THREAD_ATTR_STACKADDR },
850 #endif
851 #if defined (_SC_THREAD_ATTR_STACKSIZE)
852 { "_POSIX_THREAD_ATTR_STACKSIZE", SYSCONF, _SC_THREAD_ATTR_STACKSIZE },
853 #endif
854 #if defined (_SC_THREAD_CPUTIME)
855 { "_POSIX_THREAD_CPUTIME", SYSCONF, _SC_THREAD_CPUTIME },
856 #endif
857 #if defined (_SC_THREAD_PRIO_INHERIT)
858 { "_POSIX_THREAD_PRIO_INHERIT", SYSCONF, _SC_THREAD_PRIO_INHERIT },
859 #endif
860 #if defined (_SC_THREAD_PRIO_PROTECT)
861 { "_POSIX_THREAD_PRIO_PROTECT", SYSCONF, _SC_THREAD_PRIO_PROTECT },
862 #endif
863 #if defined (_SC_THREAD_PRIORITY_SCHEDULING)
864 { "_POSIX_THREAD_PRIORITY_SCHEDULING", SYSCONF, _SC_THREAD_PRIORITY_SCHEDULING },
865 #endif
866 #if defined (_SC_THREAD_PROCESS_SHARED)
867 { "_POSIX_THREAD_PROCESS_SHARED", SYSCONF, _SC_THREAD_PROCESS_SHARED },
868 #endif
869 #if defined (_SC_THREAD_SAFE_FUNCTIONS)
870 { "_POSIX_THREAD_SAFE_FUNCTIONS", SYSCONF, _SC_THREAD_SAFE_FUNCTIONS },
871 #endif
872 #if defined (_SC_THREAD_SPORADIC_SERVER)
873 { "_POSIX_THREAD_SPORADIC_SERVER", SYSCONF, _SC_THREAD_SPORADIC_SERVER },
874 #endif
875 #if defined (_SC_THREADS)
876 { "_POSIX_THREADS", SYSCONF, _SC_THREADS },
877 #endif
878 #if defined (_SC_TIMEOUTS)
879 { "_POSIX_TIMEOUTS", SYSCONF, _SC_TIMEOUTS },
880 #endif
881 #if defined (_SC_TIMERS)
882 { "_POSIX_TIMERS", SYSCONF, _SC_TIMERS },
883 #endif
884 #if defined (_SC_TRACE)
885 { "_POSIX_TRACE", SYSCONF, _SC_TRACE },
886 #endif
887 #if defined (_SC_TRACE)
888 { "_POSIX_TRACE_EVENT_FILTER",SYSCONF, _SC_TRACE_EVENT_FILTER },
889 #endif
890 #if defined (_SC_TRACE)
891 { "_POSIX_TRACE_INHERIT", SYSCONF, _SC_TRACE_INHERIT },
892 #endif
893 #if defined (_SC_TRACE)
894 { "_POSIX_TRACE_LOG", SYSCONF, _SC_TRACE_LOG },
895 #endif
896 #if defined (_SC_TYPED_MEMORY_OBJECTS)
897 { "_POSIX_TYPED_MEMORY_OBJECTS", SYSCONF, _SC_TYPED_MEMORY_OBJECTS },
898 #endif
899 #if defined (_SC_VERSION)
900 { "_POSIX_VERSION", SYSCONF, _SC_VERSION },
901 #endif
903 /* XPG 4.2 Configurable System Variables. */
904 #if defined (_SC_ATEXIT_MAX)
905 { "ATEXIT_MAX", SYSCONF, _SC_ATEXIT_MAX },
906 #endif
907 #if defined (_SC_GETGR_R_SIZE_MAX)
908 { "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX },
909 #endif
910 #if defined (_SC_GETPW_R_SIZE_MAX)
911 { "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX },
912 #endif
913 #if defined (_SC_HOST_NAME_MAX)
914 { "HOST_NAME_MAX", SYSCONF, _SC_HOST_NAME_MAX },
915 #endif
916 #if defined (_SC_IOV_MAX)
917 { "IOV_MAX", SYSCONF, _SC_IOV_MAX },
918 #endif
919 #if defined (_SC_LOGIN_NAME_MAX)
920 { "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX },
921 #endif
922 #if defined (_SC_LOGNAME_MAX)
923 { "LOGNAME_MAX", SYSCONF, _SC_LOGNAME_MAX },
924 #endif
925 #if defined (_SC_PAGESIZE)
926 { "PAGESIZE", SYSCONF, _SC_PAGESIZE },
927 #endif
928 #if defined (_SC_PAGE_SIZE)
929 { "PAGE_SIZE", SYSCONF, _SC_PAGE_SIZE },
930 #endif
931 #if defined (_SC_SYMLOOP_MAX)
932 { "SYMLOOP_MAX", SYSCONF, _SC_SYMLOOP_MAX },
933 #endif
934 #if defined (_SC_TTY_NAME_MAX)
935 { "TTY_NAME_MAX", SYSCONF, _SC_TTY_NAME_MAX },
936 #endif
937 #if defined (_SC_USER_GROUPS)
938 { "_POSIX_USER_GROUPS", SYSCONF, _SC_USER_GROUPS },
939 #endif
940 #if defined (_SC_USER_GROUPS_R)
941 { "_POSIX_USER_GROUPS_R", SYSCONF, _SC_USER_GROUPS_R },
942 #endif
944 #if defined (_SC_AIO_LISTIO_MAX)
945 { "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX },
946 #endif
947 #if defined (_SC_AIO_MAX)
948 { "AIO_MAX", SYSCONF, _SC_AIO_MAX },
949 #endif
950 #if defined (_SC_AIO_PRIO_DELTA_MAX)
951 { "AIO_PRIO_DELTA_MAX", SYSCONF, _SC_AIO_PRIO_DELTA_MAX },
952 #endif
953 #if defined (_SC_MQ_OPEN_MAX)
954 { "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX },
955 #endif
956 #if defined (_SC_MQ_PRIO_MAX)
957 { "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX },
958 #endif
959 #if defined (_SC_RTSIG_MAX)
960 { "RTSIG_MAX", SYSCONF, _SC_RTSIG_MAX },
961 #endif
962 #if defined (_SC_SEM_NSEMS_MAX)
963 { "SEM_NSEMS_MAX", SYSCONF, _SC_SEM_NSEMS_MAX },
964 #endif
965 #if defined (_SC_SEM_VALUE_MAX)
966 { "SEM_VALUE_MAX", SYSCONF, _SC_SEM_VALUE_MAX },
967 #endif
968 #if defined (_SC_SIGQUEUE_MAX)
969 { "SIGQUEUE_MAX", SYSCONF, _SC_SIGQUEUE_MAX },
970 #endif
971 #if defined (_SC_TIMER_MAX)
972 { "TIMER_MAX", SYSCONF, _SC_TIMER_MAX },
973 #endif
975 #if defined (_SC_THREAD_DESTRUCTOR_ITERATIONS)
976 { "PTHREAD_DESTRUCTOR_ITERATIONS", SYSCONF, _SC_THREAD_DESTRUCTOR_ITERATIONS },
977 #endif
978 #if defined (_SC_THREAD_KEYS_MAX)
979 { "PTHREAD_KEYS_MAX", SYSCONF, _SC_THREAD_KEYS_MAX },
980 #endif
981 #if defined (_SC_THREAD_STACK_MIN)
982 { "PTHREAD_STACK_MIN", SYSCONF, _SC_THREAD_STACK_MIN },
983 #endif
984 #if defined (_SC_THREAD_THREADS_MAX)
985 { "PTHREAD_THREADS_MAX", SYSCONF, _SC_THREAD_THREADS_MAX },
986 #endif
988 /* XPG 4.2 (and later) Optional Facility Configuration Values */
989 #if defined (_SC_XOPEN_CRYPT)
990 { "_XOPEN_CRYPT", SYSCONF, _SC_XOPEN_CRYPT },
991 #endif
992 #if defined (_SC_XOPEN_ENH_I18N)
993 { "_XOPEN_ENH_I18N", SYSCONF, _SC_XOPEN_ENH_I18N },
994 #endif
995 #if defined (_SC_XOPEN_LEGACY)
996 { "_XOPEN_LEGACY", SYSCONF, _SC_XOPEN_LEGACY },
997 #endif /* _SC_XOPEN_LEGACY */
998 #if defined (_SC_XOPEN_REALTIME)
999 { "_XOPEN_REALTIME", SYSCONF, _SC_XOPEN_REALTIME },
1000 #endif
1001 #if defined (_SC_XOPEN_REALTIME_THREADS)
1002 { "_XOPEN_REALTIME_THREADS", SYSCONF, _SC_XOPEN_REALTIME_THREADS },
1003 #endif
1004 #if defined (_SC_XOPEN_SHM)
1005 { "_XOPEN_SHM", SYSCONF, _SC_XOPEN_SHM },
1006 #endif
1007 #if defined (_SC_XOPEN_STREAMS)
1008 { "_XOPEN_STREAMS", SYSCONF, _SC_XOPEN_STREAMS },
1009 #endif
1010 #if defined (_SC_XOPEN_UNIX)
1011 { "_XOPEN_UNIX", SYSCONF, _SC_XOPEN_UNIX },
1012 #endif
1013 #if defined (_SC_XOPEN_VERSION)
1014 { "_XOPEN_VERSION", SYSCONF, _SC_XOPEN_VERSION },
1015 #endif
1016 #if defined (_SC_XOPEN_XCU_VERSION)
1017 { "_XOPEN_XCU_VERSION", SYSCONF, _SC_XOPEN_XCU_VERSION },
1018 #endif
1019 #if defined (_SC_XOPEN_XPG2)
1020 { "_XOPEN_XPG2", SYSCONF, _SC_XOPEN_XPG2 },
1021 #endif
1022 #if defined (_SC_XOPEN_XPG3)
1023 { "_XOPEN_XPG3", SYSCONF, _SC_XOPEN_XPG3 },
1024 #endif
1025 #if defined (_SC_XOPEN_XPG4)
1026 { "_XOPEN_XPG4", SYSCONF, _SC_XOPEN_XPG4 },
1027 #endif
1028 #if defined (_SC_XOPEN_XPG5)
1029 { "_XOPEN_XPG5", SYSCONF, _SC_XOPEN_XPG5 },
1030 #endif
1032 /* POSIX.1 Configurable Pathname Values */
1033 #ifdef _PC_LINK_MAX
1034 { "LINK_MAX", PATHCONF, _PC_LINK_MAX },
1035 #endif
1036 #ifdef _PC_MAX_CANON
1037 { "MAX_CANON", PATHCONF, _PC_MAX_CANON },
1038 #endif
1039 #ifdef _PC_MAX_INPUT
1040 { "MAX_INPUT", PATHCONF, _PC_MAX_INPUT },
1041 #endif
1042 #ifdef _PC_NAME_MAX
1043 { "NAME_MAX", PATHCONF, _PC_NAME_MAX },
1044 #endif
1045 #ifdef _PC_PATH_MAX
1046 { "PATH_MAX", PATHCONF, _PC_PATH_MAX },
1047 #endif
1048 #ifdef _PC_PIPE_BUF
1049 { "PIPE_BUF", PATHCONF, _PC_PIPE_BUF },
1050 #endif
1051 #ifdef _PC_SYMLINK_MAX
1052 { "SYMLINK_MAX", PATHCONF, _PC_SYMLINK_MAX },
1053 #endif
1054 #ifdef _PC_CHOWN_RESTRICTED
1055 { "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED },
1056 #endif
1057 #ifdef _PC_NO_TRUNC
1058 { "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC },
1059 #endif
1060 #ifdef _PC_VDISABLE
1061 { "_POSIX_VDISABLE", PATHCONF, _PC_VDISABLE },
1062 #endif
1064 /* XPG 4.2 Configurable Pathname Values */
1065 #if defined (_PC_FILESIZEBITS)
1066 { "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS },
1067 #endif
1068 #if defined (_PC_ASYNC_IO)
1069 { "_POSIX_ASYNC_IO", PATHCONF, _PC_ASYNC_IO },
1070 #endif
1071 #if defined (_PC_PRIO_IO)
1072 { "_POSIX_PRIO_IO", PATHCONF, _PC_PRIO_IO },
1073 #endif
1074 #if defined (_PC_SYNC_IO)
1075 { "_POSIX_SYNC_IO", PATHCONF, _PC_SYNC_IO },
1076 #endif
1078 /* POSIX.1-200x configurable pathname values */
1079 #if defined (_PC_ALLOC_SIZE_MIN)
1080 { "POSIX_ALLOC_SIZE_MIN", PATHCONF, _PC_ALLOC_SIZE_MIN },
1081 { "POSIX_REC_INCR_XFER_SIZE", PATHCONF, _PC_REC_INCR_XFER_SIZE },
1082 { "POSIX_REC_MAX_XFER_SIZE", PATHCONF, _PC_REC_MAX_XFER_SIZE },
1083 { "POSIX_REC_MIN_XFER_SIZE", PATHCONF, _PC_REC_MIN_XFER_SIZE },
1084 { "POSIX_REC_XFER_ALIGN", PATHCONF, _PC_REC_XFER_ALIGN },
1085 #endif
1087 /* ANSI/ISO C, POSIX.1-200x, XPG 4.2 (and later) C language type limits. */
1088 { "CHAR_BIT", CONSTANT, CHAR_BIT },
1089 { "CHAR_MAX", CONSTANT, CHAR_MAX },
1090 { "CHAR_MIN", CONSTANT, CHAR_MIN },
1091 { "INT_BIT", CONSTANT, INT_BIT },
1092 { "INT_MAX", CONSTANT, INT_MAX },
1093 { "INT_MIN", CONSTANT, INT_MIN },
1094 #ifdef LLONG_MAX
1095 { "LLONG_MAX", LLCONST, VAL_LLONG_MAX },
1096 { "LLONG_MIN", LLCONST, VAL_LLONG_MIN },
1097 #endif
1098 { "LONG_BIT", CONSTANT, LONG_BIT },
1099 { "LONG_MAX", CONSTANT, LONG_MAX },
1100 { "LONG_MIN", CONSTANT, LONG_MIN },
1101 #ifdef MB_LEN_MAX
1102 { "MB_LEN_MAX", CONSTANT, MB_LEN_MAX },
1103 #endif
1104 { "SCHAR_MAX", CONSTANT, SCHAR_MAX },
1105 { "SCHAR_MIN", CONSTANT, SCHAR_MIN },
1106 { "SHRT_MAX", CONSTANT, SHRT_MAX },
1107 { "SHRT_MIN", CONSTANT, SHRT_MIN },
1108 { "SIZE_MAX", CONSTANT, SIZE_MAX },
1109 { "SSIZE_MAX", CONSTANT, SSIZE_MAX },
1110 { "UCHAR_MAX", CONSTANT, UCHAR_MAX },
1111 { "UINT_MAX", CONSTANT, UINT_MAX },
1112 #ifdef ULLONG_MAX
1113 { "ULLONG_MAX", LLCONST, VAL_ULLONG_MAX },
1114 #endif
1115 { "ULONG_MAX", CONSTANT, ULONG_MAX },
1116 { "USHRT_MAX", CONSTANT, USHRT_MAX },
1117 { "WORD_BIT", CONSTANT, WORD_BIT },
1119 { NULL }
1122 static int num_getconf_variables = sizeof(conf_table) / sizeof(struct conf_variable) - 1;
1124 extern char *this_command_name;
1125 extern char **make_builtin_argv ();
1127 static void getconf_help ();
1128 static int getconf_print ();
1129 static int getconf_one ();
1130 static int getconf_all ();
1133 getconf_builtin (list)
1134 WORD_LIST *list;
1136 int c, r, opt, aflag;
1137 char **v;
1139 aflag = 0;
1140 reset_internal_getopt();
1141 while ((opt = internal_getopt (list, "ahv:")) != -1) {
1142 switch (opt) {
1143 case 'a':
1144 aflag = 1;
1145 break;
1146 case 'h':
1147 getconf_help();
1148 return(EXECUTION_SUCCESS);
1149 case 'v':
1150 break; /* ignored */
1151 default:
1152 builtin_usage();
1153 return(EX_USAGE);
1157 list = loptend;
1158 if ((aflag == 0 && list == 0) || (aflag && list) || list_length(list) > 2) {
1159 builtin_usage();
1160 return(EX_USAGE);
1163 r = aflag ? getconf_all() : getconf_one(list);
1165 return r;
1168 static void
1169 getconf_help()
1171 const struct conf_variable *cp;
1172 register int i, column;
1174 builtin_usage();
1175 printf("Acceptable variable names are:\n");
1176 for (cp = conf_table; cp->name != NULL; cp++) {
1177 if (cp->type == PATHCONF)
1178 printf("%s pathname\n", cp->name);
1179 else
1180 printf("%s\n", cp->name);
1184 static int
1185 getconf_print(cp, vpath, all)
1186 struct conf_variable *cp;
1187 char *vpath;
1188 int all;
1190 long val;
1191 char *sval;
1192 size_t slen;
1194 switch (cp->type) {
1195 case G_UNDEF:
1196 printf("undefined\n");
1197 break;
1199 #ifdef LLONG_MAX
1200 case LLCONST:
1201 switch (cp->value) {
1202 default:
1203 case VAL_LLONG_MIN:
1204 printf ("%lld\n", LLONG_MIN);
1205 break;
1206 case VAL_LLONG_MAX:
1207 printf ("%lld\n", LLONG_MAX);
1208 break;
1209 # if (ULLONG_MAX != LLONG_MAX)
1210 case VAL_ULLONG_MAX:
1211 printf ("%llu\n", ULLONG_MAX);
1212 break;
1213 # endif
1215 break;
1216 #endif
1217 case CONSTANT:
1218 switch (cp->value) {
1219 case UCHAR_MAX:
1220 case USHRT_MAX:
1221 case UINT_MAX:
1222 #if (ULONG_MAX != UINT_MAX)
1223 case ULONG_MAX:
1224 #endif
1225 #if (SIZE_MAX != UINT_MAX) && (SIZE_MAX != ULONG_MAX)
1226 case SIZE_MAX:
1227 #endif
1229 printf("%lu\n", cp->value);
1230 break;
1231 default:
1232 printf("%ld\n", cp->value);
1233 break;
1235 break;
1237 case CONFSTR:
1238 errno = 0;
1239 slen = confstr (cp->value, (char *) 0, (size_t) 0);
1240 if (slen == 0) {
1241 if (errno != 0) {
1242 if (all)
1243 printf ("getconf: %s\n", strerror(errno));
1244 else
1245 builtin_error ("%s", strerror(errno));
1246 } else
1247 printf ("undefined\n");
1248 return (EXECUTION_FAILURE);
1250 sval = xmalloc(slen);
1252 confstr(cp->value, sval, slen);
1253 printf("%s\n", sval);
1254 free(sval);
1255 break;
1257 case SYSCONF:
1258 errno = 0;
1259 if ((val = sysconf(cp->value)) == -1) {
1260 if (errno != 0) {
1261 if (all)
1262 printf("getconf: %s\n", strerror (errno));
1263 else
1264 builtin_error ("%s", strerror (errno));
1265 return (EXECUTION_FAILURE);
1268 printf ("undefined\n");
1269 } else {
1270 printf("%ld\n", val);
1272 break;
1274 case PATHCONF:
1275 errno = 0;
1276 if ((val = pathconf(vpath, cp->value)) == -1) {
1277 if (errno != 0) {
1278 if (all)
1279 printf("getconf: %s: %s\n", vpath, strerror (errno));
1280 else
1281 builtin_error ("%s: %s", vpath, strerror (errno));
1282 return (EXECUTION_FAILURE);
1285 printf ("undefined\n");
1286 } else {
1287 printf ("%ld\n", val);
1289 break;
1292 return (ferror(stdout) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
1295 static int
1296 getconf_all()
1298 const struct conf_variable *cp;
1299 int ret;
1301 ret = EXECUTION_SUCCESS;
1302 for (cp = conf_table; cp->name != NULL; cp++) {
1303 printf("%-35s", cp->name);
1304 if (getconf_print(cp, "/", 1) == EXECUTION_FAILURE)
1305 ret = EXECUTION_FAILURE;
1307 return ret;
1310 static int
1311 getconf_one(list)
1312 WORD_LIST *list;
1314 const struct conf_variable *cp;
1315 char *vname, *vpath;
1317 vname = list->word->word;
1318 vpath = (list->next && list->next->word) ? list->next->word->word
1319 : (char *)NULL;
1321 for (cp = conf_table; cp->name != NULL; cp++) {
1322 if (strcmp(vname, cp->name) == 0)
1323 break;
1325 if (cp->name == NULL) {
1326 builtin_error ("%s: unknown variable", vname);
1327 return (EXECUTION_FAILURE);
1330 if (cp->type == PATHCONF) {
1331 if (list->next == 0) {
1332 builtin_usage();
1333 return(EX_USAGE);
1335 } else {
1336 if (list->next) {
1337 builtin_usage();
1338 return(EX_USAGE);
1342 return (getconf_print(cp, vpath, 0));
1345 static char *getconf_doc[] = {
1346 "Display values of system limits and options.",
1348 "getconf writes the current value of a configurable system limit or",
1349 "option variable to the standard output.",
1350 (char *)NULL
1353 struct builtin getconf_struct = {
1354 "getconf",
1355 getconf_builtin,
1356 BUILTIN_ENABLED,
1357 getconf_doc,
1358 "getconf -[ah] or getconf [-v spec] sysvar or getconf [-v spec] pathvar pathname",
1362 #ifndef HAVE_CONFSTR
1363 static size_t
1364 confstr (name, buf, len)
1365 int name;
1366 char *buf;
1367 size_t len;
1369 switch (name)
1371 case _CS_PATH:
1372 if (len > 0 && buf)
1374 strncpy (buf, STANDARD_UTILS_PATH, len - 1);
1375 buf[len - 1] = '\0';
1377 return (sizeof (STANDARD_UTILS_PATH) + 1);
1378 default:
1379 errno = EINVAL;
1380 return 0;
1383 #endif
1385 #ifndef HAVE_SYSCONF
1386 extern long get_clk_tck __P((void));
1388 static long
1389 sysconf (name)
1390 int name;
1392 # if defined (_POSIX_VERSION)
1393 switch (name)
1395 case _SC_ARG_MAX:
1396 return _POSIX_ARG_MAX;
1397 case _SC_CHILD_MAX:
1398 return _POSIX_CHILD_MAX;
1399 case _SC_CLK_TCK:
1400 return get_clk_tck();
1401 case _SC_NGROUPS_MAX:
1402 return _POSIX_NGROUPS_MAX;
1403 case _SC_OPEN_MAX:
1404 return _POSIX_OPEN_MAX;
1405 case _SC_JOB_CONTROL:
1406 return _POSIX_JOB_CONTROL;
1407 case _SC_SAVED_IDS:
1408 return _POSIX_SAVED_IDS;
1409 case _SC_VERSION:
1410 return _POSIX_VERSION;
1411 case _SC_BC_BASE_MAX:
1412 return _POSIX2_BC_BASE_MAX;
1413 case _SC_BC_DIM_MAX:
1414 return _POSIX2_BC_DIM_MAX;
1415 case _SC_BC_SCALE_MAX:
1416 return _POSIX2_BC_SCALE_MAX;
1417 case _SC_BC_STRING_MAX:
1418 return _POSIX2_BC_STRING_MAX;
1419 case _SC_COLL_WEIGHTS_MAX:
1420 return -1;
1421 case _SC_EXPR_NEST_MAX:
1422 return _POSIX2_EXPR_NEST_MAX;
1423 case _SC_LINE_MAX:
1424 return _POSIX2_LINE_MAX;
1425 case _SC_RE_DUP_MAX:
1426 return _POSIX2_RE_DUP_MAX;
1427 case _SC_STREAM_MAX:
1428 return _POSIX_STREAM_MAX;
1429 case _SC_TZNAME_MAX:
1430 return _POSIX_TZNAME_MAX;
1431 default:
1432 errno = EINVAL;
1433 return -1;
1435 #else
1436 errno = EINVAL;
1437 return -1;
1438 #endif
1440 #endif
1442 #ifndef HAVE_PATHCONF
1443 static long
1444 pathconf (path, name)
1445 const char *path;
1446 int name;
1448 #if defined (_POSIX_VERSION)
1449 switch (name)
1451 case _PC_LINK_MAX:
1452 return _POSIX_LINK_MAX;
1453 case _PC_MAX_CANON:
1454 return _POSIX_MAX_CANON;
1455 case _PC_MAX_INPUT:
1456 return _POSIX_MAX_INPUT;
1457 case _PC_NAME_MAX:
1458 return _POSIX_NAME_MAX;
1459 case _PC_PATH_MAX:
1460 return _POSIX_PATH_MAX;
1461 case _PC_PIPE_BUF:
1462 return _POSIX_PIPE_BUF;
1463 case _PC_CHOWN_RESTRICTED:
1464 #ifdef _POSIX_CHOWN_RESTRICTED
1465 return _POSIX_CHOWN_RESTRICTED;
1466 #else
1467 return -1;
1468 #endif
1469 case _PC_NO_TRUNC:
1470 #ifdef _POSIX_NO_TRUNC
1471 return _POSIX_NO_TRUNC;
1472 #else
1473 return -1;
1474 #endif
1475 case _PC_VDISABLE:
1476 #ifdef _POSIX_VDISABLE
1477 return _POSIX_VDISABLE;
1478 #else
1479 return -1;
1480 #endif
1481 default:
1482 errno = EINVAL;
1483 return -1;
1485 #else
1486 errno = EINVAL;
1487 return -1;
1488 #endif
1490 #endif