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