Print this page
10120 smatch indenting fixes for usr/src/cmd
Reviewed by: Gergő Doma <domag02@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/getconf/getconf.c
+++ new/usr/src/cmd/getconf/getconf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright 1985, 1993 by Mortice Kern Systems Inc. All rights reserved.
29 29 *
30 30 */
31 31
32 32 /*
33 + * Copyright (c) 2018, Joyent, Inc.
34 + */
35 +
36 +/*
33 37 * getconf -- POSIX.2 compatible utility to query configuration specific
34 38 * parameters.
35 39 * -- XPG4 support added June/93
36 40 *
37 41 * -- XPG5 support added Dec/97
38 42 *
39 43 * -- XPG6 support added May/2003
40 44 */
41 45
42 46 #include <stdio.h>
43 47 #include <stdlib.h>
44 48 #include <string.h>
45 49 #include <errno.h>
46 50 #include <unistd.h>
47 51 #include <limits.h>
48 52 #include <locale.h>
49 53 #include <libintl.h>
50 54 #include <assert.h>
51 55
52 56 extern size_t confstr(int, char *, size_t);
53 57
54 58 static int aflag = 0;
55 59
56 60 #define INVAL_ARG "getconf: Invalid argument (%s)\n"
57 61 #define INVAL_PATHARG "getconf: Invalid argument (%s or %s)\n"
58 62
59 63 /*
60 64 * Notes:
61 65 * The sctab.value field is defined to be a long.
62 66 * There are some values that are "unsigned long"; these values
63 67 * can be stored in a "long" field but when output, must be printed
64 68 * as an unsigned value. Thus, these values must have UNSIGNED_VALUE bit
65 69 * set in sctab.flag field.
66 70 *
67 71 * There are 2 different ways to indicate a symbol is undefined:
68 72 * 1) sctab.flag = UNDEFINED
69 73 * 2) or sctab.value = -1 (and if !UNDEFINED and !UNSIGNED_VALUE)
70 74 *
71 75 * There are a group of symbols (e.g CHAR_MIN, INT_MAX, INT_MIN, LONG_BIT ...)
72 76 * which we may set to -1 if they are not pre-defined in a system header file.
73 77 * This is used to indicate that these symbols are "undefined".
74 78 * We are assuming that these symbols cannot reasonably have a value of -1
75 79 * if they were defined in a system header file.
76 80 * (Unless of course -1 can be used to indicate "undefined" for that symbol)
77 81 */
78 82
79 83 static struct sctab {
80 84 long value;
81 85 char *name;
82 86 enum { SELFCONF, SYSCONF, PATHCONF, CONFSTR } type;
83 87 int flag;
84 88 /* bit fields for sctab.flag member */
85 89 #define NOFLAGS 0 /* no special indicators */
86 90 #define UNDEFINED 1 /* value is known undefined at compile time */
87 91 #define UNSIGNED_VALUE 2 /* value is an unsigned */
88 92 } sctab[] = {
89 93 /*
90 94 * Some entries in this structure have both leading _ and non leading _
91 95 * versions for compatibility with various versions of the specifications.
92 96 * It is not expected that both forms will be required for new entries.
93 97 */
94 98
95 99 /* POSIX.2-1992 table 2-17 */
96 100 _POSIX2_BC_BASE_MAX, "POSIX2_BC_BASE_MAX", SELFCONF, NOFLAGS,
97 101 _POSIX2_BC_BASE_MAX, "_POSIX2_BC_BASE_MAX", SELFCONF, NOFLAGS,
98 102 _POSIX2_BC_DIM_MAX, "POSIX2_BC_DIM_MAX", SELFCONF, NOFLAGS,
99 103 _POSIX2_BC_DIM_MAX, "_POSIX2_BC_DIM_MAX", SELFCONF, NOFLAGS,
100 104 _POSIX2_BC_SCALE_MAX, "POSIX2_BC_SCALE_MAX", SELFCONF, NOFLAGS,
101 105 _POSIX2_BC_SCALE_MAX, "_POSIX2_BC_SCALE_MAX", SELFCONF, NOFLAGS,
102 106 _POSIX2_BC_STRING_MAX, "POSIX2_BC_STRING_MAX", SELFCONF, NOFLAGS,
103 107 _POSIX2_BC_STRING_MAX, "_POSIX2_BC_STRING_MAX", SELFCONF, NOFLAGS,
104 108 _POSIX2_COLL_WEIGHTS_MAX, "POSIX2_COLL_WEIGHTS_MAX", SELFCONF, NOFLAGS,
105 109 _POSIX2_COLL_WEIGHTS_MAX, "_POSIX2_COLL_WEIGHTS_MAX", SELFCONF, NOFLAGS,
106 110 _POSIX2_EXPR_NEST_MAX, "POSIX2_EXPR_NEST_MAX", SELFCONF, NOFLAGS,
107 111 _POSIX2_EXPR_NEST_MAX, "_POSIX2_EXPR_NEST_MAX", SELFCONF, NOFLAGS,
108 112 _POSIX2_LINE_MAX, "POSIX2_LINE_MAX", SELFCONF, NOFLAGS,
109 113 _POSIX2_LINE_MAX, "_POSIX2_LINE_MAX", SELFCONF, NOFLAGS,
110 114 _POSIX2_RE_DUP_MAX, "POSIX2_RE_DUP_MAX", SELFCONF, NOFLAGS,
111 115 _POSIX2_RE_DUP_MAX, "_POSIX2_RE_DUP_MAX", SELFCONF, NOFLAGS,
112 116 /* See limits.h section below for _POSIX_RE_DUP_MAX */
113 117
114 118 /* UNIX 98 */
115 119 _POSIX_AIO_LISTIO_MAX, "_POSIX_AIO_LISTIO_MAX", SELFCONF, NOFLAGS,
116 120 _POSIX_AIO_MAX, "_POSIX_AIO_MAX", SELFCONF, NOFLAGS,
117 121 _POSIX_DELAYTIMER_MAX, "_POSIX_DELAYTIMER_MAX", SELFCONF, NOFLAGS,
118 122 _POSIX_LOGIN_NAME_MAX, "_POSIX_LOGIN_NAME_MAX", SELFCONF, NOFLAGS,
119 123 _POSIX_MQ_OPEN_MAX, "_POSIX_MQ_OPEN_MAX", SELFCONF, NOFLAGS,
120 124 _POSIX_MQ_PRIO_MAX, "_POSIX_MQ_PRIO_MAX", SELFCONF, NOFLAGS,
121 125 _POSIX_RTSIG_MAX, "_POSIX_RTSIG_MAX", SELFCONF, NOFLAGS,
122 126 _POSIX_SEM_NSEMS_MAX, "_POSIX_SEM_NSEMS_MAX", SELFCONF, NOFLAGS,
123 127 _POSIX_SEM_VALUE_MAX, "_POSIX_SEM_VALUE_MAX", SELFCONF, NOFLAGS,
124 128 _POSIX_SIGQUEUE_MAX, "_POSIX_SIGQUEUE_MAX", SELFCONF, NOFLAGS,
125 129 _POSIX_TTY_NAME_MAX, "_POSIX_TTY_NAME_MAX", SELFCONF, NOFLAGS,
126 130
127 131 /* UNIX 03 */
128 132 _POSIX_HOST_NAME_MAX, "_POSIX_HOST_NAME_MAX", SELFCONF, NOFLAGS,
129 133 _POSIX_RE_DUP_MAX, "_POSIX_RE_DUP_MAX", SELFCONF, NOFLAGS,
130 134 _POSIX_CLOCKRES_MIN, "_POSIX_CLOCKRES_MIN", SELFCONF, NOFLAGS,
131 135 _POSIX_SYMLINK_MAX, "_POSIX_SYMLINK_MAX", SELFCONF, NOFLAGS,
132 136 _POSIX_SYMLOOP_MAX, "_POSIX_SYMLOOP_MAX", SELFCONF, NOFLAGS,
133 137 CHARCLASS_NAME_MAX, "_POSIX2_CHARCLASS_NAME_MAX", SELFCONF, NOFLAGS,
134 138
135 139 /* POSIX.2-1992 table 2-17 */
136 140 _SC_2_VERSION, "POSIX2_VERSION", SYSCONF, NOFLAGS,
137 141 _SC_2_VERSION, "_POSIX2_VERSION", SYSCONF, NOFLAGS,
138 142
139 143 /* POSIX.2-1992 table 2-18 */
140 144 _SC_BC_BASE_MAX, "BC_BASE_MAX", SYSCONF, NOFLAGS,
141 145 _SC_BC_DIM_MAX, "BC_DIM_MAX", SYSCONF, NOFLAGS,
142 146 _SC_BC_SCALE_MAX, "BC_SCALE_MAX", SYSCONF, NOFLAGS,
143 147 _SC_BC_STRING_MAX, "BC_STRING_MAX", SYSCONF, NOFLAGS,
144 148 _SC_COLL_WEIGHTS_MAX, "COLL_WEIGHTS_MAX", SYSCONF, NOFLAGS,
145 149 _SC_EXPR_NEST_MAX, "EXPR_NEST_MAX", SYSCONF, NOFLAGS,
146 150 _SC_LINE_MAX, "LINE_MAX", SYSCONF, NOFLAGS,
147 151 _SC_RE_DUP_MAX, "RE_DUP_MAX", SYSCONF, NOFLAGS,
148 152
149 153 /* POSIX.2-1992 table 2-19 */
150 154 _SC_2_C_BIND, "POSIX2_C_BIND", SYSCONF, NOFLAGS,
151 155 _SC_2_C_BIND, "_POSIX2_C_BIND", SYSCONF, NOFLAGS,
152 156 _SC_2_C_DEV, "POSIX2_C_DEV", SYSCONF, NOFLAGS,
153 157 _SC_2_C_DEV, "_POSIX2_C_DEV", SYSCONF, NOFLAGS,
154 158 _SC_2_CHAR_TERM, "POSIX2_CHAR_TERM", SYSCONF, NOFLAGS,
155 159 _SC_2_CHAR_TERM, "_POSIX2_CHAR_TERM", SYSCONF, NOFLAGS,
156 160 _SC_2_FORT_DEV, "POSIX2_FORT_DEV", SYSCONF, NOFLAGS,
157 161 _SC_2_FORT_DEV, "_POSIX2_FORT_DEV", SYSCONF, NOFLAGS,
158 162 _SC_2_FORT_RUN, "POSIX2_FORT_RUN", SYSCONF, NOFLAGS,
159 163 _SC_2_FORT_RUN, "_POSIX2_FORT_RUN", SYSCONF, NOFLAGS,
160 164 _SC_2_LOCALEDEF, "POSIX2_LOCALEDEF", SYSCONF, NOFLAGS,
161 165 _SC_2_LOCALEDEF, "_POSIX2_LOCALEDEF", SYSCONF, NOFLAGS,
162 166 _SC_2_SW_DEV, "POSIX2_SW_DEV", SYSCONF, NOFLAGS,
163 167 _SC_2_SW_DEV, "_POSIX2_SW_DEV", SYSCONF, NOFLAGS,
164 168 _SC_2_UPE, "POSIX2_UPE", SYSCONF, NOFLAGS,
165 169 _SC_2_UPE, "_POSIX2_UPE", SYSCONF, NOFLAGS,
166 170
167 171 /* POSIX.1-1990 table 2-3 */
168 172 _POSIX_ARG_MAX, "_POSIX_ARG_MAX", SELFCONF, NOFLAGS,
169 173 _POSIX_CHILD_MAX, "_POSIX_CHILD_MAX", SELFCONF, NOFLAGS,
170 174 _POSIX_LINK_MAX, "_POSIX_LINK_MAX", SELFCONF, NOFLAGS,
171 175 _POSIX_MAX_CANON, "_POSIX_MAX_CANON", SELFCONF, NOFLAGS,
172 176 _POSIX_MAX_INPUT, "_POSIX_MAX_INPUT", SELFCONF, NOFLAGS,
173 177 _POSIX_NAME_MAX, "_POSIX_NAME_MAX", SELFCONF, NOFLAGS,
174 178 _POSIX_NGROUPS_MAX, "_POSIX_NGROUPS_MAX", SELFCONF, NOFLAGS,
175 179 _POSIX_OPEN_MAX, "_POSIX_OPEN_MAX", SELFCONF, NOFLAGS,
176 180 _POSIX_PATH_MAX, "_POSIX_PATH_MAX", SELFCONF, NOFLAGS,
177 181 _POSIX_PIPE_BUF, "_POSIX_PIPE_BUF", SELFCONF, NOFLAGS,
178 182 _POSIX_SSIZE_MAX, "_POSIX_SSIZE_MAX", SELFCONF, NOFLAGS,
179 183 _POSIX_STREAM_MAX, "_POSIX_STREAM_MAX", SELFCONF, NOFLAGS,
180 184 _POSIX_TIMER_MAX, "_POSIX_TIMER_MAX", SELFCONF, NOFLAGS,
181 185 _POSIX_THREAD_DESTRUCTOR_ITERATIONS,
182 186 "_POSIX_THREAD_DESTRUCTOR_ITERATIONS", SELFCONF, NOFLAGS,
183 187 _POSIX_THREAD_KEYS_MAX,
184 188 "_POSIX_THREAD_KEYS_MAX", SELFCONF, NOFLAGS,
185 189 _POSIX_THREAD_THREADS_MAX,
186 190 "_POSIX_THREAD_THREADS_MAX", SELFCONF, NOFLAGS,
187 191 _POSIX_TZNAME_MAX, "_POSIX_TZNAME_MAX", SELFCONF, NOFLAGS,
188 192
189 193 /* POSIX.1-1990 table 4-2 */
190 194 _SC_ARG_MAX, "ARG_MAX", SYSCONF, NOFLAGS,
191 195 _SC_CHILD_MAX, "CHILD_MAX", SYSCONF, NOFLAGS,
192 196 _SC_CLK_TCK, "CLK_TCK", SYSCONF, NOFLAGS,
193 197 _SC_JOB_CONTROL, "_POSIX_JOB_CONTROL", SYSCONF, NOFLAGS,
194 198 _SC_NGROUPS_MAX, "NGROUPS_MAX", SYSCONF, NOFLAGS,
195 199 _SC_OPEN_MAX, "OPEN_MAX", SYSCONF, NOFLAGS,
196 200 _SC_SAVED_IDS, "_POSIX_SAVED_IDS", SYSCONF, NOFLAGS,
197 201 _SC_STREAM_MAX, "STREAM_MAX", SYSCONF, NOFLAGS,
198 202 _SC_TZNAME_MAX, "TZNAME_MAX", SYSCONF, NOFLAGS,
199 203 _SC_VERSION, "_POSIX_VERSION", SYSCONF, NOFLAGS,
200 204
201 205 /* pathconf() variables */
202 206
203 207 /* POSIX.1-1990 table 5-2 */
204 208
205 209 _PC_LINK_MAX, "LINK_MAX", PATHCONF, NOFLAGS,
206 210 _PC_MAX_CANON, "MAX_CANON", PATHCONF, NOFLAGS,
207 211 _PC_MAX_INPUT, "MAX_INPUT", PATHCONF, NOFLAGS,
208 212 _PC_NAME_MAX, "NAME_MAX", PATHCONF, NOFLAGS,
209 213 _PC_PATH_MAX, "PATH_MAX", PATHCONF, NOFLAGS,
210 214 _PC_PIPE_BUF, "PIPE_BUF", PATHCONF, NOFLAGS,
211 215 _PC_CHOWN_RESTRICTED, "_POSIX_CHOWN_RESTRICTED", PATHCONF, NOFLAGS,
212 216 _PC_NO_TRUNC, "_POSIX_NO_TRUNC", PATHCONF, NOFLAGS,
213 217 _PC_VDISABLE, "_POSIX_VDISABLE", PATHCONF, NOFLAGS,
214 218
215 219 /* UNIX 98 additions */
216 220
217 221 _PC_ASYNC_IO, "_POSIX_ASYNC_IO", PATHCONF, NOFLAGS,
218 222 _PC_PRIO_IO, "_POSIX_PRIO_IO", PATHCONF, NOFLAGS,
219 223 _PC_SYNC_IO, "_POSIX_SYNC_IO", PATHCONF, NOFLAGS,
220 224
221 225 /* Large File Summit name (UNIX 98) */
222 226
223 227 _PC_FILESIZEBITS, "FILESIZEBITS", PATHCONF, NOFLAGS,
224 228 _PC_XATTR_ENABLED, "XATTR_ENABLED", PATHCONF, NOFLAGS,
225 229 _PC_XATTR_EXISTS, "XATTR_EXISTS", PATHCONF, NOFLAGS,
226 230
227 231 /* UNIX 03 Additions */
228 232
229 233 /* Advisory Information (ADV) */
230 234 _PC_ALLOC_SIZE_MIN, "POSIX_ALLOC_SIZE_MIN", PATHCONF, NOFLAGS,
231 235 _PC_REC_INCR_XFER_SIZE, "POSIX_REC_INCR_XFER_SIZE", PATHCONF, NOFLAGS,
232 236 _PC_REC_MAX_XFER_SIZE, "POSIX_REC_MAX_XFER_SIZE", PATHCONF, NOFLAGS,
233 237 _PC_REC_MIN_XFER_SIZE, "POSIX_REC_MIN_XFER_SIZE", PATHCONF, NOFLAGS,
234 238 _PC_REC_XFER_ALIGN, "POSIX_REC_XFER_ALIGN", PATHCONF, NOFLAGS,
235 239
236 240 _PC_2_SYMLINKS, "POSIX2_SYMLINKS", PATHCONF, NOFLAGS,
237 241 _PC_SYMLINK_MAX, "SYMLINK_MAX", PATHCONF, NOFLAGS,
238 242
239 243 _PC_ACL_ENABLED, "ACL_ENABLED", PATHCONF, NOFLAGS,
240 244 _PC_MIN_HOLE_SIZE, "MIN_HOLE_SIZE", PATHCONF, NOFLAGS,
241 245 _PC_SATTR_ENABLED, "SATTR_ENABLED", PATHCONF, NOFLAGS,
242 246 _PC_SATTR_EXISTS, "SATTR_EXISTS", PATHCONF, NOFLAGS,
243 247
244 248 /* UNIX 08 additions */
245 249
246 250 _PC_TIMESTAMP_RESOLUTION, "_POSIX_TIMESTAMP_RESOLUTION",
247 251 PATHCONF, NOFLAGS,
248 252
249 253 /* confstr() variables */
250 254
251 255 /* POSIX.2-1992 description of getconf utility */
252 256 _CS_PATH, "PATH", CONFSTR, NOFLAGS,
253 257
254 258 /* POSIX.2-1992 table B-18 */
255 259 _CS_PATH, "CS_PATH", CONFSTR, NOFLAGS,
256 260 _CS_PATH, "_CS_PATH", CONFSTR, NOFLAGS,
257 261
258 262 /* command names for large file configuration information */
259 263 /* large file compilation environment configuration */
260 264
261 265 _CS_LFS_CFLAGS, "LFS_CFLAGS", CONFSTR, NOFLAGS,
262 266 _CS_LFS_LDFLAGS, "LFS_LDFLAGS", CONFSTR, NOFLAGS,
263 267 _CS_LFS_LIBS, "LFS_LIBS", CONFSTR, NOFLAGS,
264 268 _CS_LFS_LINTFLAGS, "LFS_LINTFLAGS", CONFSTR, NOFLAGS,
265 269
266 270 /* transitional large file interface configuration */
267 271
268 272 _CS_LFS64_CFLAGS, "LFS64_CFLAGS", CONFSTR, NOFLAGS,
269 273 _CS_LFS64_LDFLAGS, "LFS64_LDFLAGS", CONFSTR, NOFLAGS,
270 274 _CS_LFS64_LIBS, "LFS64_LIBS", CONFSTR, NOFLAGS,
271 275 _CS_LFS64_LINTFLAGS, "LFS64_LINTFLAGS", CONFSTR, NOFLAGS,
272 276
273 277 /*
274 278 * UNIX 98:
275 279 * confstr additions, these support
276 280 * programming specifications/environments.
277 281 *
278 282 * Unfortunately there is some uncertainty with
279 283 * the standard at this point about the constant
280 284 * name, thus we need to recognize BOTH with and
281 285 * without the initial underscore.
282 286 */
283 287 _CS_XBS5_ILP32_OFF32_CFLAGS, "XBS5_ILP32_OFF32_CFLAGS",
284 288 CONFSTR, NOFLAGS,
285 289 _CS_XBS5_ILP32_OFF32_CFLAGS, "_XBS5_ILP32_OFF32_CFLAGS",
286 290 CONFSTR, NOFLAGS,
287 291
288 292 _CS_XBS5_ILP32_OFF32_LDFLAGS, "XBS5_ILP32_OFF32_LDFLAGS",
289 293 CONFSTR, NOFLAGS,
290 294 _CS_XBS5_ILP32_OFF32_LDFLAGS, "_XBS5_ILP32_OFF32_LDFLAGS",
291 295 CONFSTR, NOFLAGS,
292 296
293 297 _CS_XBS5_ILP32_OFF32_LIBS, "XBS5_ILP32_OFF32_LIBS",
294 298 CONFSTR, NOFLAGS,
295 299 _CS_XBS5_ILP32_OFF32_LIBS, "_XBS5_ILP32_OFF32_LIBS",
296 300 CONFSTR, NOFLAGS,
297 301
298 302 _CS_XBS5_ILP32_OFF32_LINTFLAGS, "XBS5_ILP32_OFF32_LINTFLAGS",
299 303 CONFSTR, NOFLAGS,
300 304 _CS_XBS5_ILP32_OFF32_LINTFLAGS, "_XBS5_ILP32_OFF32_LINTFLAGS",
301 305 CONFSTR, NOFLAGS,
302 306
303 307 _CS_XBS5_ILP32_OFFBIG_CFLAGS, "XBS5_ILP32_OFFBIG_CFLAGS",
304 308 CONFSTR, NOFLAGS,
305 309 _CS_XBS5_ILP32_OFFBIG_CFLAGS, "_XBS5_ILP32_OFFBIG_CFLAGS",
306 310 CONFSTR, NOFLAGS,
307 311
308 312 _CS_XBS5_ILP32_OFFBIG_LDFLAGS, "XBS5_ILP32_OFFBIG_LDFLAGS",
309 313 CONFSTR, NOFLAGS,
310 314 _CS_XBS5_ILP32_OFFBIG_LDFLAGS, "_XBS5_ILP32_OFFBIG_LDFLAGS",
311 315 CONFSTR, NOFLAGS,
312 316
313 317 _CS_XBS5_ILP32_OFFBIG_LIBS, "XBS5_ILP32_OFFBIG_LIBS",
314 318 CONFSTR, NOFLAGS,
315 319 _CS_XBS5_ILP32_OFFBIG_LIBS, "_XBS5_ILP32_OFFBIG_LIBS",
316 320 CONFSTR, NOFLAGS,
317 321
318 322 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, "XBS5_ILP32_OFFBIG_LINTFLAGS",
319 323 CONFSTR, NOFLAGS,
320 324 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, "_XBS5_ILP32_OFFBIG_LINTFLAGS",
321 325 CONFSTR, NOFLAGS,
322 326
323 327 _CS_XBS5_LP64_OFF64_CFLAGS, "XBS5_LP64_OFF64_CFLAGS",
324 328 CONFSTR, NOFLAGS,
325 329 _CS_XBS5_LP64_OFF64_CFLAGS, "_XBS5_LP64_OFF64_CFLAGS",
326 330 CONFSTR, NOFLAGS,
327 331
328 332 _CS_XBS5_LP64_OFF64_LDFLAGS, "XBS5_LP64_OFF64_LDFLAGS",
329 333 CONFSTR, NOFLAGS,
330 334 _CS_XBS5_LP64_OFF64_LDFLAGS, "_XBS5_LP64_OFF64_LDFLAGS",
331 335 CONFSTR, NOFLAGS,
332 336
333 337 _CS_XBS5_LP64_OFF64_LIBS, "XBS5_LP64_OFF64_LIBS",
334 338 CONFSTR, NOFLAGS,
335 339 _CS_XBS5_LP64_OFF64_LIBS, "_XBS5_LP64_OFF64_LIBS",
336 340 CONFSTR, NOFLAGS,
337 341
338 342 _CS_XBS5_LP64_OFF64_LINTFLAGS, "XBS5_LP64_OFF64_LINTFLAGS",
339 343 CONFSTR, NOFLAGS,
340 344 _CS_XBS5_LP64_OFF64_LINTFLAGS, "_XBS5_LP64_OFF64_LINTFLAGS",
341 345 CONFSTR, NOFLAGS,
342 346
343 347 _CS_XBS5_LPBIG_OFFBIG_CFLAGS, "XBS5_LPBIG_OFFBIG_CFLAGS",
344 348 CONFSTR, NOFLAGS,
345 349 _CS_XBS5_LPBIG_OFFBIG_CFLAGS, "_XBS5_LPBIG_OFFBIG_CFLAGS",
346 350 CONFSTR, NOFLAGS,
347 351
348 352 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, "XBS5_LPBIG_OFFBIG_LDFLAGS",
349 353 CONFSTR, NOFLAGS,
350 354 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, "_XBS5_LPBIG_OFFBIG_LDFLAGS",
351 355 CONFSTR, NOFLAGS,
352 356
353 357 _CS_XBS5_LPBIG_OFFBIG_LIBS, "XBS5_LPBIG_OFFBIG_LIBS",
354 358 CONFSTR, NOFLAGS,
355 359 _CS_XBS5_LPBIG_OFFBIG_LIBS, "_XBS5_LPBIG_OFFBIG_LIBS",
356 360 CONFSTR, NOFLAGS,
357 361
358 362 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, "XBS5_LPBIG_OFFBIG_LINTFLAGS",
359 363 CONFSTR, NOFLAGS,
360 364 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, "_XBS5_LPBIG_OFFBIG_LINTFLAGS",
361 365 CONFSTR, NOFLAGS,
362 366
363 367 /*
364 368 * UNIX 03 confstr() additions for compilation environments
365 369 */
366 370 _CS_POSIX_V6_ILP32_OFF32_CFLAGS, "POSIX_V6_ILP32_OFF32_CFLAGS",
367 371 CONFSTR, NOFLAGS,
368 372 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, "POSIX_V6_ILP32_OFF32_LDFLAGS",
369 373 CONFSTR, NOFLAGS,
370 374 _CS_POSIX_V6_ILP32_OFF32_LIBS, "POSIX_V6_ILP32_OFF32_LIBS",
371 375 CONFSTR, NOFLAGS,
372 376 _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, "POSIX_V6_ILP32_OFFBIG_CFLAGS",
373 377 CONFSTR, NOFLAGS,
374 378 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, "POSIX_V6_ILP32_OFFBIG_LDFLAGS",
375 379 CONFSTR, NOFLAGS,
376 380 _CS_POSIX_V6_ILP32_OFFBIG_LIBS, "POSIX_V6_ILP32_OFFBIG_LIBS",
377 381 CONFSTR, NOFLAGS,
378 382 _CS_POSIX_V6_LP64_OFF64_CFLAGS, "POSIX_V6_LP64_OFF64_CFLAGS",
379 383 CONFSTR, NOFLAGS,
380 384 _CS_POSIX_V6_LP64_OFF64_LDFLAGS, "POSIX_V6_LP64_OFF64_LDFLAGS",
381 385 CONFSTR, NOFLAGS,
382 386 _CS_POSIX_V6_LP64_OFF64_LIBS, "POSIX_V6_LP64_OFF64_LIBS",
383 387 CONFSTR, NOFLAGS,
384 388 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, "POSIX_V6_LPBIG_OFFBIG_CFLAGS",
385 389 CONFSTR, NOFLAGS,
386 390 _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, "POSIX_V6_LPBIG_OFFBIG_LDFLAGS",
387 391 CONFSTR, NOFLAGS,
388 392 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, "POSIX_V6_LPBIG_OFFBIG_LIBS",
389 393 CONFSTR, NOFLAGS,
390 394 _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS, "POSIX_V6_WIDTH_RESTRICTED_ENVS",
391 395 CONFSTR, NOFLAGS,
392 396 /* End of UNIX 03 compilation environments */
393 397
394 398 #ifdef _SC_2_C_VERSION /* POSIX.2 table B-4 */
395 399 _SC_2_C_VERSION, "_POSIX2_C_VERSION", SYSCONF, NOFLAGS,
396 400 #else
397 401 _POSIX2_C_VERSION, "_POSIX2_C_VERSION", SELFCONF, NOFLAGS,
398 402 #endif
399 403
400 404 /*
401 405 * XPG4 support BEGINS
402 406 */
403 407
404 408 #ifndef CHARCLASS_NAME_MAX
405 409 #define CHARCLASS_NAME_MAX -1
406 410 #endif
407 411 #ifndef CHAR_BIT
408 412 #define CHAR_BIT -1
409 413 #endif
410 414 #ifndef CHAR_MAX
411 415 #define CHAR_MAX -1
412 416 #endif
413 417 #ifndef CHAR_MIN
414 418 #define CHAR_MIN -1
415 419 #endif
416 420 #ifndef INT_MAX
417 421 #define INT_MAX -1
418 422 #endif
419 423 #ifndef INT_MIN
420 424 #define INT_MIN -1
421 425 #endif
422 426 #ifndef LONG_BIT
423 427 #define LONG_BIT -1
424 428 #endif
425 429 #ifndef LONG_MAX
426 430 #define LONG_MAX -1
427 431 #endif
428 432 #ifndef LONG_MIN
429 433 #define LONG_MIN -1
430 434 #endif
431 435 #ifndef MB_LEN_MAX
432 436 #define MB_LEN_MAX -1
433 437 #endif
434 438 #ifndef NL_NMAX
435 439 #define NL_NMAX -1
436 440 #endif
437 441 #ifndef NL_ARGMAX
438 442 #define NL_ARGMAX -1
439 443 #endif
440 444 #ifndef NL_LANGMAX
441 445 #define NL_LANGMAX -1
442 446 #endif
443 447 #ifndef NL_MSGMAX
444 448 #define NL_MSGMAX -1
445 449 #endif
446 450 #ifndef NL_SETMAX
447 451 #define NL_SETMAX -1
448 452 #endif
449 453 #ifndef NL_TEXTMAX
450 454 #define NL_TEXTMAX -1
451 455 #endif
452 456 #ifndef NZERO
453 457 #define NZERO -1
454 458 #endif
455 459 #ifndef SCHAR_MAX
456 460 #define SCHAR_MAX -1
457 461 #endif
458 462 #ifndef SCHAR_MIN
459 463 #define SCHAR_MIN -1
460 464 #endif
461 465 #ifndef SHRT_MAX
462 466 #define SHRT_MAX -1
463 467 #endif
464 468 #ifndef SHRT_MIN
465 469 #define SHRT_MIN -1
466 470 #endif
467 471 #ifndef TMP_MAX
468 472 #define TMP_MAX -1
469 473 #endif
470 474 #ifndef WORD_BIT
471 475 #define WORD_BIT -1
472 476 #endif
473 477
474 478
475 479 #ifndef _XOPEN_XPG2
476 480 #define _XOPEN_XPG2 -1
477 481 #endif
478 482 #ifndef _XOPEN_XPG3
479 483 #define _XOPEN_XPG3 -1
480 484 #endif
481 485 #ifndef _XOPEN_XPG4
482 486 #define _XOPEN_XPG4 -1
483 487 #endif
484 488
485 489 /*
486 490 * the following are values that we should find in <limits.h>
487 491 * so we use SELFCONF here.
488 492 *
489 493 */
490 494
491 495 /* POSIX.1-1990 */
492 496 CHARCLASS_NAME_MAX, "CHARCLASS_NAME_MAX", SELFCONF, NOFLAGS,
493 497 SSIZE_MAX, "SSIZE_MAX", SELFCONF, NOFLAGS,
494 498
495 499 /* POSIX.1-1988 */
496 500 CHAR_BIT, "CHAR_BIT", SELFCONF, NOFLAGS,
497 501 CHAR_MAX, "CHAR_MAX", SELFCONF, NOFLAGS,
498 502 CHAR_MIN, "CHAR_MIN", SELFCONF, NOFLAGS,
499 503 INT_MAX, "INT_MAX", SELFCONF, NOFLAGS,
500 504 INT_MIN, "INT_MIN", SELFCONF, NOFLAGS,
501 505 LONG_BIT, "LONG_BIT", SELFCONF, NOFLAGS,
502 506 LONG_MAX, "LONG_MAX", SELFCONF, NOFLAGS,
503 507 LONG_MIN, "LONG_MIN", SELFCONF, NOFLAGS,
504 508 MB_LEN_MAX, "MB_LEN_MAX", SELFCONF, NOFLAGS,
505 509 NL_NMAX, "NL_NMAX", SELFCONF, NOFLAGS,
506 510 NL_ARGMAX, "NL_ARGMAX", SELFCONF, NOFLAGS,
507 511 NL_LANGMAX, "NL_LANGMAX", SELFCONF, NOFLAGS,
508 512 NL_MSGMAX, "NL_MSGMAX", SELFCONF, NOFLAGS,
509 513 NL_SETMAX, "NL_SETMAX", SELFCONF, NOFLAGS,
510 514 NL_TEXTMAX, "NL_TEXTMAX", SELFCONF, NOFLAGS,
511 515 NZERO, "NZERO", SELFCONF, NOFLAGS,
512 516 SCHAR_MAX, "SCHAR_MAX", SELFCONF, NOFLAGS,
513 517 SCHAR_MIN, "SCHAR_MIN", SELFCONF, NOFLAGS,
514 518 SHRT_MAX, "SHRT_MAX", SELFCONF, NOFLAGS,
515 519 SHRT_MIN, "SHRT_MIN", SELFCONF, NOFLAGS,
516 520 TMP_MAX, "TMP_MAX", SELFCONF, NOFLAGS,
517 521
518 522 /*
519 523 * for the unsigned maximums, we cannot rely on the value -1
520 524 * to indicate "undefined".
521 525 */
522 526 #ifndef UCHAR_MAX
523 527 0, "UCHAR_MAX", SELFCONF, UNDEFINED,
524 528 #else
525 529 (long)UCHAR_MAX, "UCHAR_MAX", SELFCONF, UNSIGNED_VALUE,
526 530 #endif /* UCHAR_MAX */
527 531 #ifndef UINT_MAX
528 532 0, "UINT_MAX", SELFCONF, UNDEFINED,
529 533 #else
530 534 (long)UINT_MAX, "UINT_MAX", SELFCONF, UNSIGNED_VALUE,
531 535 #endif /* UINT_MAX */
532 536 #ifndef ULONG_MAX
533 537 0, "ULONG_MAX", SELFCONF, UNDEFINED,
534 538 #else
535 539 (long)ULONG_MAX, "ULONG_MAX", SELFCONF, UNSIGNED_VALUE,
536 540 #endif /* ULONG_MAX */
537 541 #ifndef USHRT_MAX
538 542 0, "USHRT_MAX", SELFCONF, UNDEFINED,
539 543 #else
540 544 (long)USHRT_MAX, "USHRT_MAX", SELFCONF, UNSIGNED_VALUE,
541 545 #endif /* USHRT_MAX */
542 546 #ifndef SIZE_MAX
543 547 0, "SIZE_MAX", SELFCONF, UNDEFINED,
544 548 #else
545 549 (long)SIZE_MAX, "SIZE_MAX", SELFCONF, UNSIGNED_VALUE,
546 550 #endif /* SIZE_MAX */
547 551
548 552 WORD_BIT, "WORD_BIT", SELFCONF, NOFLAGS,
549 553
550 554 /* XPG4 Version 2 */
551 555 _XOPEN_IOV_MAX, "_XOPEN_IOV_MAX", SELFCONF, NOFLAGS,
552 556
553 557 /* UNIX 03 */
554 558 _XOPEN_NAME_MAX, "_XOPEN_NAME_MAX", SELFCONF, NOFLAGS,
555 559 _XOPEN_PATH_MAX, "_XOPEN_PATH_MAX", SELFCONF, NOFLAGS,
556 560
557 561 /*
558 562 * The following are defined via sysconf(). These are considered
559 563 * an extension to sysconf().
560 564 * The -0 is needed if _XOPEN_XPG? is defined to be an empty string.
561 565 */
562 566 _XOPEN_XPG2-0, "_XOPEN_XPG2", SELFCONF, NOFLAGS,
563 567 _XOPEN_XPG3-0, "_XOPEN_XPG3", SELFCONF, NOFLAGS,
564 568 _XOPEN_XPG4-0, "_XOPEN_XPG4", SELFCONF, NOFLAGS,
565 569
566 570 /*
567 571 * The following should be provided by sysconf() (e.g use SYSCONF),
568 572 * so we look for the appropriate _SC_* symbol in <unistd.h>.
569 573 * If it is not defined, then we use SELFCONF with the value of -1.
570 574 */
571 575 _SC_XOPEN_VERSION, "_XOPEN_VERSION", SYSCONF, NOFLAGS,
572 576 _SC_XOPEN_XCU_VERSION, "_XOPEN_XCU_VERSION", SYSCONF, NOFLAGS,
573 577 _SC_XOPEN_CRYPT, "_XOPEN_CRYPT", SYSCONF, NOFLAGS,
574 578 _SC_XOPEN_ENH_I18N, "_XOPEN_ENH_I18N", SYSCONF, NOFLAGS,
575 579 _SC_XOPEN_SHM, "_XOPEN_SHM", SYSCONF, NOFLAGS,
576 580
577 581 /*
578 582 * XPG4 support ends
579 583 */
580 584
581 585 /* XPG4, Version 2 support */
582 586
583 587 _SC_ATEXIT_MAX, "ATEXIT_MAX", SYSCONF, NOFLAGS,
584 588 _SC_PAGESIZE, "PAGESIZE", SYSCONF, NOFLAGS,
585 589 _SC_PAGE_SIZE, "PAGE_SIZE", SYSCONF, NOFLAGS,
586 590 _SC_XOPEN_UNIX, "_XOPEN_UNIX", SYSCONF, NOFLAGS,
587 591 _SC_IOV_MAX, "IOV_MAX", SYSCONF, NOFLAGS,
588 592
589 593 /*
590 594 * UNIX 98 - XPG5 additions
591 595 */
592 596 _SC_XOPEN_LEGACY, "_XOPEN_LEGACY", SYSCONF, NOFLAGS,
593 597 _SC_PASS_MAX, "PASS_MAX", SYSCONF, NOFLAGS,
594 598 _SC_AIO_LISTIO_MAX, "AIO_LISTIO_MAX", SYSCONF, NOFLAGS,
595 599 _SC_AIO_MAX, "AIO_MAX", SYSCONF, NOFLAGS,
596 600 _SC_AIO_PRIO_DELTA_MAX, "AIO_PRIO_DELTA_MAX", SYSCONF, NOFLAGS,
597 601 _SC_DELAYTIMER_MAX, "DELAYTIMER_MAX", SYSCONF, NOFLAGS,
598 602 _SC_MQ_OPEN_MAX, "MQ_OPEN_MAX", SYSCONF, NOFLAGS,
599 603 _SC_MQ_PRIO_MAX, "MQ_PRIO_MAX", SYSCONF, NOFLAGS,
600 604 _SC_RTSIG_MAX, "RTSIG_MAX", SYSCONF, NOFLAGS,
601 605 _SC_SEM_NSEMS_MAX, "SEM_NSEMS_MAX", SYSCONF, NOFLAGS,
602 606 _SC_SEM_VALUE_MAX, "SEM_VALUE_MAX", SYSCONF, NOFLAGS,
603 607 _SC_SIGQUEUE_MAX, "SIGQUEUE_MAX", SYSCONF, NOFLAGS,
604 608 _SC_TIMER_MAX, "TIMER_MAX", SYSCONF, NOFLAGS,
605 609
606 610 _SC_ASYNCHRONOUS_IO, "_POSIX_ASYNCHRONOUS_IO", SYSCONF, NOFLAGS,
607 611 _SC_FSYNC, "_POSIX_FSYNC", SYSCONF, NOFLAGS,
608 612 _SC_MAPPED_FILES, "_POSIX_MAPPED_FILES", SYSCONF, NOFLAGS,
609 613 _SC_MEMLOCK, "_POSIX_MEMLOCK", SYSCONF, NOFLAGS,
610 614 _SC_MEMLOCK_RANGE, "_POSIX_MEMLOCK_RANGE", SYSCONF, NOFLAGS,
611 615 _SC_MEMORY_PROTECTION, "_POSIX_MEMORY_PROTECTION", SYSCONF, NOFLAGS,
612 616 _SC_MESSAGE_PASSING, "_POSIX_MESSAGE_PASSING", SYSCONF, NOFLAGS,
613 617 _SC_PRIORITIZED_IO, "_POSIX_PRIORITIZED_IO", SYSCONF, NOFLAGS,
614 618 _SC_PRIORITY_SCHEDULING, "_POSIX_PRIORITY_SCHEDULING", SYSCONF, NOFLAGS,
615 619 _SC_REALTIME_SIGNALS, "_POSIX_REALTIME_SIGNALS", SYSCONF, NOFLAGS,
616 620 _SC_SEMAPHORES, "_POSIX_SEMAPHORES", SYSCONF, NOFLAGS,
617 621
618 622 _SC_SHARED_MEMORY_OBJECTS, "_POSIX_SHARED_MEMORY_OBJECTS",
619 623 SYSCONF, NOFLAGS,
620 624
621 625 _SC_SYNCHRONIZED_IO, "_POSIX_SYNCHRONIZED_IO", SYSCONF, NOFLAGS,
622 626 _SC_TIMERS, "_POSIX_TIMERS", SYSCONF, NOFLAGS,
623 627
624 628 _SC_LOGIN_NAME_MAX, "LOGIN_NAME_MAX", SYSCONF, NOFLAGS,
625 629
626 630 _SC_THREAD_DESTRUCTOR_ITERATIONS, "PTHREAD_DESTRUCTOR_ITERATIONS",
627 631 SYSCONF, NOFLAGS,
628 632
629 633 _SC_THREAD_KEYS_MAX, "PTHREAD_KEYS_MAX", SYSCONF, NOFLAGS,
630 634 _SC_THREAD_STACK_MIN, "PTHREAD_STACK_MIN", SYSCONF, NOFLAGS,
631 635 _SC_THREAD_THREADS_MAX, "PTHREAD_THREADS_MAX", SYSCONF, NOFLAGS,
632 636
633 637 _SC_THREADS, "_POSIX_THREADS", SYSCONF, NOFLAGS,
634 638
635 639 _SC_THREAD_ATTR_STACKADDR, "POSIX_THREAD_ATTR_STACKADDR",
636 640 SYSCONF, NOFLAGS,
637 641 _SC_THREAD_ATTR_STACKADDR, "_POSIX_THREAD_ATTR_STACKADDR",
638 642 SYSCONF, NOFLAGS,
639 643
640 644 _SC_THREAD_ATTR_STACKSIZE, "POSIX_THREAD_ATTR_STACKSIZE",
641 645 SYSCONF, NOFLAGS,
642 646 _SC_THREAD_ATTR_STACKSIZE, "_POSIX_THREAD_ATTR_STACKSIZE",
643 647 SYSCONF, NOFLAGS,
644 648
645 649 _SC_THREAD_PRIORITY_SCHEDULING, "POSIX_THREAD_PRIORITY_SCHEDULING",
646 650 SYSCONF, NOFLAGS,
647 651 _SC_THREAD_PRIORITY_SCHEDULING, "_POSIX_THREAD_PRIORITY_SCHEDULING",
648 652 SYSCONF, NOFLAGS,
649 653
650 654 _SC_THREAD_PRIO_INHERIT, "POSIX_THREAD_PRIO_INHERIT",
651 655 SYSCONF, NOFLAGS,
652 656 _SC_THREAD_PRIO_INHERIT, "_POSIX_THREAD_PRIO_INHERIT",
653 657 SYSCONF, NOFLAGS,
654 658
655 659 _SC_THREAD_PRIO_PROTECT, "POSIX_THREAD_PRIO_PROTECT",
656 660 SYSCONF, NOFLAGS,
657 661 _SC_THREAD_PRIO_PROTECT, "_POSIX_THREAD_PRIO_PROTECT",
658 662 SYSCONF, NOFLAGS,
659 663
660 664 _SC_THREAD_PROCESS_SHARED, "POSIX_THREAD_PROCESS_SHARED",
661 665 SYSCONF, NOFLAGS,
662 666 _SC_THREAD_PROCESS_SHARED, "_POSIX_THREAD_PROCESS_SHARED",
663 667 SYSCONF, NOFLAGS,
664 668
665 669 _SC_THREAD_SAFE_FUNCTIONS, "POSIX_THREAD_SAFE_FUNCTIONS",
666 670 SYSCONF, NOFLAGS,
667 671 _SC_THREAD_SAFE_FUNCTIONS, "_POSIX_THREAD_SAFE_FUNCTIONS",
668 672 SYSCONF, NOFLAGS,
669 673
670 674 _SC_TTY_NAME_MAX, "TTY_NAME_MAX", SYSCONF, NOFLAGS,
671 675 _SC_XOPEN_REALTIME, "_XOPEN_REALTIME", SYSCONF, NOFLAGS,
672 676 _SC_XOPEN_REALTIME_THREADS, "_XOPEN_REALTIME_THREADS", SYSCONF, NOFLAGS,
673 677
674 678 /*
675 679 * Due to ambiguity in the standard we need
676 680 * to recognize both the underscored name
677 681 * and the non-underscored version in the
678 682 * following variables.
679 683 */
680 684 _SC_XBS5_ILP32_OFF32, "XBS5_ILP32_OFF32", SYSCONF, NOFLAGS,
681 685 _SC_XBS5_ILP32_OFF32, "_XBS5_ILP32_OFF32", SYSCONF, NOFLAGS,
682 686
683 687 _SC_XBS5_ILP32_OFFBIG, "XBS5_ILP32_OFFBIG", SYSCONF, NOFLAGS,
684 688 _SC_XBS5_ILP32_OFFBIG, "_XBS5_ILP32_OFFBIG", SYSCONF, NOFLAGS,
685 689
686 690 _SC_XBS5_LP64_OFF64, "XBS5_LP64_OFF64", SYSCONF, NOFLAGS,
687 691 _SC_XBS5_LP64_OFF64, "_XBS5_LP64_OFF64", SYSCONF, NOFLAGS,
688 692
689 693 _SC_XBS5_LPBIG_OFFBIG, "XBS5_LPBIG_OFFBIG", SYSCONF, NOFLAGS,
690 694 _SC_XBS5_LPBIG_OFFBIG, "_XBS5_LPBIG_OFFBIG", SYSCONF, NOFLAGS,
691 695
692 696 /*
693 697 * UNIX 03 additions for sysconf() names, and names that are not in interfaces
694 698 */
695 699 _SC_REGEXP, "_POSIX_REGEXP", SYSCONF, NOFLAGS,
696 700 _SC_SHELL, "_POSIX_SHELL", SYSCONF, NOFLAGS,
697 701 _SC_HOST_NAME_MAX, "HOST_NAME_MAX", SYSCONF, NOFLAGS,
698 702 _SC_READER_WRITER_LOCKS, "_POSIX_READER_WRITER_LOCKS", SYSCONF, NOFLAGS,
699 703 _SC_IPV6, "_POSIX_IPV6", SYSCONF, NOFLAGS,
700 704 _SC_RAW_SOCKETS, "_POSIX_RAW_SOCKETS", SYSCONF, NOFLAGS,
701 705 _SC_XOPEN_STREAMS, "_XOPEN_STREAMS", SYSCONF, NOFLAGS,
702 706 _SC_SYMLOOP_MAX, "SYMLOOP_MAX", SYSCONF, NOFLAGS,
703 707 _SC_2_PBS, "_POSIX2_PBS", SYSCONF, NOFLAGS,
704 708 _SC_2_PBS_ACCOUNTING, "_POSIX2_PBS_ACCOUNTING", SYSCONF, NOFLAGS,
705 709 _SC_2_PBS_CHECKPOINT, "_POSIX2_PBS_CHECKPOINT", SYSCONF, NOFLAGS,
706 710 _SC_2_PBS_LOCATE, "_POSIX2_PBS_LOCATE", SYSCONF, NOFLAGS,
707 711 _SC_2_PBS_MESSAGE, "_POSIX2_PBS_MESSAGE", SYSCONF, NOFLAGS,
708 712 _SC_2_PBS_TRACK, "_POSIX2_PBS_TRACK", SYSCONF, NOFLAGS,
709 713
710 714 _SC_ADVISORY_INFO, "_POSIX_ADVISORY_INFO", SYSCONF, NOFLAGS,
711 715 _SC_BARRIERS, "_POSIX_BARRIERS", SYSCONF, NOFLAGS,
712 716 _SC_CLOCK_SELECTION, "_POSIX_CLOCK_SELECTION", SYSCONF, NOFLAGS,
713 717 _SC_CPUTIME, "_POSIX_CPUTIME", SYSCONF, NOFLAGS,
714 718 _SC_MONOTONIC_CLOCK, "_POSIX_MONOTONIC_CLOCK", SYSCONF, NOFLAGS,
715 719 _SC_SPAWN, "_POSIX_SPAWN", SYSCONF, NOFLAGS,
716 720 _SC_SPIN_LOCKS, "_POSIX_SPIN_LOCKS", SYSCONF, NOFLAGS,
717 721 _SC_SPORADIC_SERVER, "_POSIX_SPORADIC_SERVER", SYSCONF, NOFLAGS,
718 722 _SC_SS_REPL_MAX, "_POSIX_SS_REPL_MAX", SYSCONF, NOFLAGS,
719 723 _SC_THREAD_CPUTIME, "_POSIX_THREAD_CPUTIME", SYSCONF, NOFLAGS,
720 724 _SC_THREAD_SPORADIC_SERVER, "_POSIX_THREAD_SPORADIC_SERVER", SYSCONF,
721 725 NOFLAGS,
722 726 _SC_TIMEOUTS, "_POSIX_TIMEOUTS", SYSCONF, NOFLAGS,
723 727 _SC_TRACE, "_POSIX_TRACE", SYSCONF, NOFLAGS,
724 728 _SC_TRACE_EVENT_FILTER, "_POSIX_TRACE_EVENT_FILTER", SYSCONF, NOFLAGS,
725 729 _SC_TRACE_EVENT_NAME_MAX, "_POSIX_TRACE_EVENT_NAME_MAX", SYSCONF,
726 730 NOFLAGS,
727 731 _SC_TRACE_INHERIT, "_POSIX_TRACE_INHERIT", SYSCONF, NOFLAGS,
728 732 _SC_TRACE_LOG, "_POSIX_TRACE_LOG", SYSCONF, NOFLAGS,
729 733 _SC_TRACE_NAME_MAX, "_POSIX_TRACE_NAME_MAX", SYSCONF, NOFLAGS,
730 734 _SC_TRACE_SYS_MAX, "_POSIX_TRACE_SYS_MAX", SYSCONF, NOFLAGS,
731 735 _SC_TRACE_USER_EVENT_MAX, "_POSIX_TRACE_USER_EVENT_MAX", SYSCONF,
732 736 NOFLAGS,
733 737 _SC_TYPED_MEMORY_OBJECTS, "_POSIX_TYPED_MEMORY_OBJECTS", SYSCONF,
734 738 NOFLAGS,
735 739
736 740 /*
737 741 * Due to an ambiguity in the specification, we need to recognize both
738 742 * the underscored POSIX name and the non-underscored name. In addition,
739 743 * we need to permit the use of the _V6_* environment names specified
740 744 * in unistd.h.
741 745 */
742 746 _SC_V6_ILP32_OFF32, "_V6_ILP32_OFF32", SYSCONF, NOFLAGS,
743 747 _SC_V6_ILP32_OFF32, "_POSIX_V6_ILP32_OFF32", SYSCONF, NOFLAGS,
744 748 _SC_V6_ILP32_OFF32, "POSIX_V6_ILP32_OFF32", SYSCONF, NOFLAGS,
745 749
746 750 _SC_V6_ILP32_OFFBIG, "_V6_ILP32_OFFBIG", SYSCONF, NOFLAGS,
747 751 _SC_V6_ILP32_OFFBIG, "_POSIX_V6_ILP32_OFFBIG", SYSCONF, NOFLAGS,
748 752 _SC_V6_ILP32_OFFBIG, "POSIX_V6_ILP32_OFFBIG", SYSCONF, NOFLAGS,
749 753
750 754 _SC_V6_LP64_OFF64, "_V6_LP64_OFF64", SYSCONF, NOFLAGS,
751 755 _SC_V6_LP64_OFF64, "_POSIX_V6_LP64_OFF64", SYSCONF, NOFLAGS,
752 756 _SC_V6_LP64_OFF64, "POSIX_V6_LP64_OFF64", SYSCONF, NOFLAGS,
753 757
754 758 _SC_V6_LPBIG_OFFBIG, "_V6_LPBIG_OFFBIG", SYSCONF, NOFLAGS,
755 759 _SC_V6_LPBIG_OFFBIG, "_POSIX_V6_LPBIG_OFFBIG", SYSCONF, NOFLAGS,
756 760 _SC_V6_LPBIG_OFFBIG, "POSIX_V6_LPBIG_OFFBIG", SYSCONF, NOFLAGS,
757 761 /*
758 762 * System V Interface Definition
759 763 */
760 764 _SC_NPROCESSORS_CONF, "NPROCESSORS_CONF", SYSCONF, NOFLAGS,
761 765 _SC_NPROCESSORS_MAX, "NPROCESSORS_MAX", SYSCONF, NOFLAGS,
762 766 _SC_NPROCESSORS_ONLN, "NPROCESSORS_ONLN", SYSCONF, NOFLAGS,
763 767 0, NULL, 0, 0 /* end of table */
764 768 };
765 769
766 770
767 771 /*
768 772 * Print usage message.
769 773 */
770 774 static int
771 775 usage()
772 776 {
773 777
774 778 (void) fputs(gettext(
775 779 "usage:\tgetconf [-v specification] system_var\n"
776 780 "\tgetconf [-v specification] path_var pathname\n"
777 781 "\tgetconf -a\n"), stderr);
778 782 return (2);
779 783 }
780 784
781 785
782 786 static int
783 787 namecmp(const void *a, const void *b)
784 788 {
785 789 return (strcoll(((const struct sctab *)a)->name,
786 790 ((const struct sctab *)b)->name));
787 791 }
788 792
789 793
790 794 static int
791 795 getconf(struct sctab *scp, int argc, char *name, char *file)
792 796 {
793 797 register size_t len;
794 798 register char *buffer;
795 799 long value;
796 800
797 801 switch (scp->type) {
798 802 case SELFCONF:
799 803 if (argc > 2)
800 804 return (usage());
801 805 if (scp->flag & UNDEFINED ||
802 806 (!(scp->flag&UNSIGNED_VALUE) && scp->value == -1)) {
803 807 /* DO NOT TRANSLATE */
804 808 (void) printf("undefined\n");
805 809 } else
806 810 if (scp->flag & UNSIGNED_VALUE)
807 811 (void) printf("%lu\n", scp->value);
808 812 else
809 813 (void) printf("%ld\n", scp->value);
810 814 break;
811 815
812 816 case SYSCONF:
813 817 if (argc > 2)
814 818 return (usage());
815 819 errno = 0;
816 820 if (scp->flag & UNDEFINED ||
817 821 (value = sysconf((int)scp->value)) == -1) {
818 822 if (errno == EINVAL) {
819 823 (void) fprintf(stderr,
820 824 gettext(INVAL_ARG), name);
821 825 return (1);
822 826 } else {
823 827 /* DO NOT TRANSLATE */
824 828 (void) printf("undefined\n");
825 829 return (0);
826 830 }
827 831 } else
828 832 (void) printf("%ld\n", value);
829 833 break;
830 834
831 835 case CONFSTR:
832 836 if (argc > 2)
833 837 return (usage());
834 838 errno = 0;
835 839 len = confstr((int)scp->value, NULL, (size_t)0);
836 840 if (len == 0) {
837 841 if (errno == EINVAL) {
838 842 (void) fprintf(stderr, gettext(INVAL_ARG),
839 843 name);
840 844 return (1);
841 845 } else {
842 846 /* DO NOT TRANSLATE */
843 847 (void) printf("undefined\n");
844 848 return (0);
845 849 }
846 850 }
847 851 /*
848 852 * allocate space to store result of constr() into
849 853 */
850 854 if ((buffer = malloc(len)) == NULL) {
851 855 (void) fprintf(stderr,
852 856 gettext("insufficient memory available"));
853 857 return (1);
854 858 }
855 859
856 860 assert(confstr((int)scp->value, buffer, len) != 0);
857 861
858 862 (void) printf("%s\n", buffer);
859 863 free(buffer);
860 864 break;
861 865
862 866 case PATHCONF:
863 867 if (argc != 3)
864 868 return (usage());
865 869 errno = 0;
866 870 if ((value = pathconf(file, (int)scp->value)) == -1) {
867 871 if (errno == EINVAL || errno == 0) {
868 872 /* Does not support the association */
869 873 /* DO NOT TRANSLATE */
870 874 (void) printf("undefined\n");
871 875 return (0);
872 876 } else {
873 877 /* Probably problems with the pathname itself */
874 878 if (aflag) {
875 879 (void) printf("%s\n", file);
876 880 } else {
877 881 (void) printf("%s", file);
878 882 }
879 883 return (1);
880 884 }
881 885 }
882 886 (void) printf("%ld\n", value);
883 887 break;
884 888 }
885 889 return (0);
886 890 }
887 891
888 892 int
889 893 main(int argc, char **argv)
890 894 {
891 895 register struct sctab *scp;
892 896 int c;
893 897 int exstat = 0;
894 898
895 899 (void) setlocale(LC_ALL, "");
896 900 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
897 901 #define TEXT_DOMAIN "SYS_TEST"
898 902 #endif
899 903 (void) textdomain(TEXT_DOMAIN);
900 904
901 905 while ((c = getopt(argc, argv, "av:")) != -1)
902 906 switch (c) {
903 907 case 'a':
904 908 aflag = 1;
905 909 break;
906 910 case 'v':
907 911 /*
908 912 * Unix98 adds the -v option to allow
909 913 * programming 'specifications' to be
910 914 * indicated, for present purposes
911 915 * the specification isn't really
912 916 * doing anything of value, so for
913 917 * the moment getopt just processes the
914 918 * option value and argv[1] is adjusted.
915 919 *
916 920 * At some later date we might want to
917 921 * do specification processing at this
918 922 * point.
919 923 */
920 924 break;
921 925 case '?':
922 926 return (usage());
923 927 }
924 928 argc -= optind-1;
925 929 argv += optind-1;
926 930
927 931 if ((aflag && argc >= 2) || (!aflag && argc < 2))
928 932 return (usage());
↓ open down ↓ |
886 lines elided |
↑ open up ↑ |
929 933 if (aflag) {
930 934
931 935 #define TabStop 8
932 936 #define RightColumn 32
933 937 #define DefPathName "."
934 938
935 939 /*
936 940 * sort the table by the "name" field
937 941 * so we print it in sorted order
938 942 */
939 - qsort(&sctab[0], (sizeof (sctab)/sizeof (struct sctab))-1,
940 - sizeof (struct sctab), namecmp);
943 + qsort(&sctab[0], (sizeof (sctab) /
944 + sizeof (struct sctab)) - 1,
945 + sizeof (struct sctab), namecmp);
941 946
942 947 /*
943 948 * print all the known symbols and their values
944 949 */
945 950 for (scp = &sctab[0]; scp->name != NULL; ++scp) {
946 951 int stat;
947 952
948 953 /*
949 954 * create 2 columns:
950 955 * variable name in the left column,
951 956 * value in the right column.
952 957 * The right column starts at a tab stop.
953 958 */
954 959 (void) printf("%s:\t", scp->name);
955 960
956 961 c = strlen(scp->name) + 1;
957 962 c = (c+TabStop) / TabStop, c *= TabStop;
958 963 for (; c < RightColumn; c += TabStop)
959 964 (void) putchar('\t');
960 965
961 966 /*
962 967 * for pathconf() related variables that require
963 968 * a pathname, use "."
964 969 */
965 970 stat = getconf(scp, scp->type == PATHCONF ? 3 : 2,
966 971 scp->name, DefPathName);
967 972
968 973 exstat |= stat;
969 974
970 975 /*
971 976 * if stat != 0, then an error message was already
972 977 * printed in getconf(),
973 978 * so don't need to print one here
974 979 */
975 980 }
976 981 } else {
977 982
978 983 /*
979 984 * find the name of the specified variable (argv[1])
980 985 * and print its value.
981 986 */
982 987 for (scp = &sctab[0]; scp->name != NULL; ++scp)
983 988 if (strcmp(argv[1], scp->name) == 0) {
984 989 exstat = getconf(scp, argc, argv[1], argv[2]);
985 990 break;
986 991 }
987 992
988 993 /*
989 994 * if at last entry in table, then the user specified
990 995 * variable is invalid
991 996 */
992 997 if (scp->name == NULL) {
993 998 errno = EINVAL;
994 999 (void) fprintf(stderr, gettext(INVAL_ARG), argv[1]);
995 1000 return (1);
996 1001 }
997 1002 }
998 1003 return (exstat);
999 1004 }
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX