]> git.ipfire.org Git - thirdparty/glibc.git/blob - manual/conf.texi
Use C11 atomics instead of atomic_increment(_val)
[thirdparty/glibc.git] / manual / conf.texi
1 @node System Configuration, Cryptographic Functions, System Management, Top
2 @c %MENU% Parameters describing operating system limits
3 @chapter System Configuration Parameters
4
5 The functions and macros listed in this chapter give information about
6 configuration parameters of the operating system---for example, capacity
7 limits, presence of optional POSIX features, and the default path for
8 executable files (@pxref{String Parameters}).
9
10 @menu
11 * General Limits:: Constants and functions that describe
12 various process-related limits that have
13 one uniform value for any given machine.
14 * System Options:: Optional POSIX features.
15 * Version Supported:: Version numbers of POSIX.1 and POSIX.2.
16 * Sysconf:: Getting specific configuration values
17 of general limits and system options.
18 * Minimums:: Minimum values for general limits.
19
20 * Limits for Files:: Size limitations that pertain to individual files.
21 These can vary between file systems
22 or even from file to file.
23 * Options for Files:: Optional features that some files may support.
24 * File Minimums:: Minimum values for file limits.
25 * Pathconf:: Getting the limit values for a particular file.
26
27 * Utility Limits:: Capacity limits of some POSIX.2 utility programs.
28 * Utility Minimums:: Minimum allowable values of those limits.
29
30 * String Parameters:: Getting the default search path.
31 @end menu
32
33 @node General Limits
34 @section General Capacity Limits
35 @cindex POSIX capacity limits
36 @cindex limits, POSIX
37 @cindex capacity limits, POSIX
38
39 The POSIX.1 and POSIX.2 standards specify a number of parameters that
40 describe capacity limitations of the system. These limits can be fixed
41 constants for a given operating system, or they can vary from machine to
42 machine. For example, some limit values may be configurable by the
43 system administrator, either at run time or by rebuilding the kernel,
44 and this should not require recompiling application programs.
45
46 @pindex limits.h
47 Each of the following limit parameters has a macro that is defined in
48 @file{limits.h} only if the system has a fixed, uniform limit for the
49 parameter in question. If the system allows different file systems or
50 files to have different limits, then the macro is undefined; use
51 @code{sysconf} to find out the limit that applies at a particular time
52 on a particular machine. @xref{Sysconf}.
53
54 Each of these parameters also has another macro, with a name starting
55 with @samp{_POSIX}, which gives the lowest value that the limit is
56 allowed to have on @emph{any} POSIX system. @xref{Minimums}.
57
58 @cindex limits, program argument size
59 @deftypevr Macro int ARG_MAX
60 @standards{POSIX.1, limits.h}
61 If defined, the unvarying maximum combined length of the @var{argv} and
62 @var{environ} arguments that can be passed to the @code{exec} functions.
63 @end deftypevr
64
65 @cindex limits, number of processes
66 @deftypevr Macro int CHILD_MAX
67 @standards{POSIX.1, limits.h}
68 If defined, the unvarying maximum number of processes that can exist
69 with the same real user ID at any one time. In BSD and GNU, this is
70 controlled by the @code{RLIMIT_NPROC} resource limit; @pxref{Limits on
71 Resources}.
72 @end deftypevr
73
74 @cindex limits, number of open files
75 @deftypevr Macro int OPEN_MAX
76 @standards{POSIX.1, limits.h}
77 If defined, the unvarying maximum number of files that a single process
78 can have open simultaneously. In BSD and GNU, this is controlled
79 by the @code{RLIMIT_NOFILE} resource limit; @pxref{Limits on Resources}.
80 @end deftypevr
81
82 @deftypevr Macro int STREAM_MAX
83 @standards{POSIX.1, limits.h}
84 If defined, the unvarying maximum number of streams that a single
85 process can have open simultaneously. @xref{Opening Streams}.
86 @end deftypevr
87
88 @cindex limits, time zone name length
89 @deftypevr Macro int TZNAME_MAX
90 @standards{POSIX.1, limits.h}
91 If defined, the unvarying maximum length of a time zone name.
92 @xref{Time Zone Functions}.
93 @end deftypevr
94
95 These limit macros are always defined in @file{limits.h}.
96
97 @cindex limits, number of supplementary group IDs
98 @deftypevr Macro int NGROUPS_MAX
99 @standards{POSIX.1, limits.h}
100 The maximum number of supplementary group IDs that one process can have.
101
102 The value of this macro is actually a lower bound for the maximum. That
103 is, you can count on being able to have that many supplementary group
104 IDs, but a particular machine might let you have even more. You can use
105 @code{sysconf} to see whether a particular machine will let you have
106 more (@pxref{Sysconf}).
107 @end deftypevr
108
109 @deftypevr Macro ssize_t SSIZE_MAX
110 @standards{POSIX.1, limits.h}
111 The largest value that can fit in an object of type @code{ssize_t}.
112 Effectively, this is the limit on the number of bytes that can be read
113 or written in a single operation.
114
115 This macro is defined in all POSIX systems because this limit is never
116 configurable.
117 @end deftypevr
118
119 @deftypevr Macro int RE_DUP_MAX
120 @standards{POSIX.2, limits.h}
121 The largest number of repetitions you are guaranteed is allowed in the
122 construct @samp{\@{@var{min},@var{max}\@}} in a regular expression.
123
124 The value of this macro is actually a lower bound for the maximum. That
125 is, you can count on being able to have that many repetitions, but a
126 particular machine might let you have even more. You can use
127 @code{sysconf} to see whether a particular machine will let you have
128 more (@pxref{Sysconf}). And even the value that @code{sysconf} tells
129 you is just a lower bound---larger values might work.
130
131 This macro is defined in all POSIX.2 systems, because POSIX.2 says it
132 should always be defined even if there is no specific imposed limit.
133 @end deftypevr
134
135 @node System Options
136 @section Overall System Options
137 @cindex POSIX optional features
138 @cindex optional POSIX features
139
140 POSIX defines certain system-specific options that not all POSIX systems
141 support. Since these options are provided in the kernel, not in the
142 library, simply using @theglibc{} does not guarantee any of these
143 features are supported; it depends on the system you are using.
144
145 @pindex unistd.h
146 You can test for the availability of a given option using the macros in
147 this section, together with the function @code{sysconf}. The macros are
148 defined only if you include @file{unistd.h}.
149
150 For the following macros, if the macro is defined in @file{unistd.h},
151 then the option is supported. Otherwise, the option may or may not be
152 supported; use @code{sysconf} to find out. @xref{Sysconf}.
153
154 @deftypevr Macro int _POSIX_JOB_CONTROL
155 @standards{POSIX.1, unistd.h}
156 If this symbol is defined, it indicates that the system supports job
157 control. Otherwise, the implementation behaves as if all processes
158 within a session belong to a single process group. @xref{Job Control}.
159 Systems conforming to the 2001 revision of POSIX, or newer, will
160 always define this symbol.
161 @end deftypevr
162
163 @deftypevr Macro int _POSIX_SAVED_IDS
164 @standards{POSIX.1, unistd.h}
165 If this symbol is defined, it indicates that the system remembers the
166 effective user and group IDs of a process before it executes an
167 executable file with the set-user-ID or set-group-ID bits set, and that
168 explicitly changing the effective user or group IDs back to these values
169 is permitted. If this option is not defined, then if a nonprivileged
170 process changes its effective user or group ID to the real user or group
171 ID of the process, it can't change it back again. @xref{Enable/Disable
172 Setuid}.
173 @end deftypevr
174
175 For the following macros, if the macro is defined in @file{unistd.h},
176 then its value indicates whether the option is supported. A value of
177 @code{-1} means no, and any other value means yes. If the macro is not
178 defined, then the option may or may not be supported; use @code{sysconf}
179 to find out. @xref{Sysconf}.
180
181 @deftypevr Macro int _POSIX2_C_DEV
182 @standards{POSIX.2, unistd.h}
183 If this symbol is defined, it indicates that the system has the POSIX.2
184 C compiler command, @code{c89}. @Theglibc{} always defines this
185 as @code{1}, on the assumption that you would not have installed it if
186 you didn't have a C compiler.
187 @end deftypevr
188
189 @deftypevr Macro int _POSIX2_FORT_DEV
190 @standards{POSIX.2, unistd.h}
191 If this symbol is defined, it indicates that the system has the POSIX.2
192 Fortran compiler command, @code{fort77}. @Theglibc{} never
193 defines this, because we don't know what the system has.
194 @end deftypevr
195
196 @deftypevr Macro int _POSIX2_FORT_RUN
197 @standards{POSIX.2, unistd.h}
198 If this symbol is defined, it indicates that the system has the POSIX.2
199 @code{asa} command to interpret Fortran carriage control. @Theglibc{}
200 never defines this, because we don't know what the system has.
201 @end deftypevr
202
203 @deftypevr Macro int _POSIX2_LOCALEDEF
204 @standards{POSIX.2, unistd.h}
205 If this symbol is defined, it indicates that the system has the POSIX.2
206 @code{localedef} command. @Theglibc{} never defines this, because
207 we don't know what the system has.
208 @end deftypevr
209
210 @deftypevr Macro int _POSIX2_SW_DEV
211 @standards{POSIX.2, unistd.h}
212 If this symbol is defined, it indicates that the system has the POSIX.2
213 commands @code{ar}, @code{make}, and @code{strip}. @Theglibc{}
214 always defines this as @code{1}, on the assumption that you had to have
215 @code{ar} and @code{make} to install the library, and it's unlikely that
216 @code{strip} would be absent when those are present.
217 @end deftypevr
218
219 @node Version Supported
220 @section Which Version of POSIX is Supported
221
222 @deftypevr Macro {long int} _POSIX_VERSION
223 @standards{POSIX.1, unistd.h}
224 This constant represents the version of the POSIX.1 standard to which
225 the implementation conforms. For an implementation conforming to the
226 1995 POSIX.1 standard, the value is the integer @code{199506L}.
227
228 @code{_POSIX_VERSION} is always defined (in @file{unistd.h}) in any
229 POSIX system.
230
231 @strong{Usage Note:} Don't try to test whether the system supports POSIX
232 by including @file{unistd.h} and then checking whether
233 @code{_POSIX_VERSION} is defined. On a non-POSIX system, this will
234 probably fail because there is no @file{unistd.h}. We do not know of
235 @emph{any} way you can reliably test at compilation time whether your
236 target system supports POSIX or whether @file{unistd.h} exists.
237 @end deftypevr
238
239 @deftypevr Macro {long int} _POSIX2_C_VERSION
240 @standards{POSIX.2, unistd.h}
241 This constant represents the version of the POSIX.2 standard which the
242 library and system kernel support. We don't know what value this will
243 be for the first version of the POSIX.2 standard, because the value is
244 based on the year and month in which the standard is officially adopted.
245
246 The value of this symbol says nothing about the utilities installed on
247 the system.
248
249 @strong{Usage Note:} You can use this macro to tell whether a POSIX.1
250 system library supports POSIX.2 as well. Any POSIX.1 system contains
251 @file{unistd.h}, so include that file and then test @code{defined
252 (_POSIX2_C_VERSION)}.
253 @end deftypevr
254
255 @node Sysconf
256 @section Using @code{sysconf}
257
258 When your system has configurable system limits, you can use the
259 @code{sysconf} function to find out the value that applies to any
260 particular machine. The function and the associated @var{parameter}
261 constants are declared in the header file @file{unistd.h}.
262
263 @menu
264 * Sysconf Definition:: Detailed specifications of @code{sysconf}.
265 * Constants for Sysconf:: The list of parameters @code{sysconf} can read.
266 * Examples of Sysconf:: How to use @code{sysconf} and the parameter
267 macros properly together.
268 @end menu
269
270 @node Sysconf Definition
271 @subsection Definition of @code{sysconf}
272
273 @deftypefun {long int} sysconf (int @var{parameter})
274 @standards{POSIX.1, unistd.h}
275 @safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
276 @c Some parts of the implementation open /proc and /sys files and dirs
277 @c to collect system details, using fd and stream I/O depending on the
278 @c case. The returned max value may change over time for NPROCS,
279 @c NPROCS_CONF, PHYS_PAGES, AVPHYS_PAGES, NGROUPS_MAX, SIGQUEUE_MAX,
280 @c depending on variable values read from /proc at each call, and from
281 @c rlimit-obtained values CHILD_MAX, OPEN_MAX, ARG_MAX, SIGQUEUE_MAX.
282 This function is used to inquire about runtime system parameters. The
283 @var{parameter} argument should be one of the @samp{_SC_} symbols listed
284 below.
285
286 The normal return value from @code{sysconf} is the value you requested.
287 A value of @code{-1} is returned both if the implementation does not
288 impose a limit, and in case of an error.
289
290 The following @code{errno} error conditions are defined for this function:
291
292 @table @code
293 @item EINVAL
294 The value of the @var{parameter} is invalid.
295 @end table
296 @end deftypefun
297
298 @node Constants for Sysconf
299 @subsection Constants for @code{sysconf} Parameters
300
301 Here are the symbolic constants for use as the @var{parameter} argument
302 to @code{sysconf}. The values are all integer constants (more
303 specifically, enumeration type values).
304
305 @vtable @code
306 @item _SC_ARG_MAX
307 @standards{POSIX.1, unistd.h}
308 Inquire about the parameter corresponding to @code{ARG_MAX}.
309
310 @item _SC_CHILD_MAX
311 @standards{POSIX.1, unistd.h}
312 Inquire about the parameter corresponding to @code{CHILD_MAX}.
313
314 @item _SC_OPEN_MAX
315 @standards{POSIX.1, unistd.h}
316 Inquire about the parameter corresponding to @code{OPEN_MAX}.
317
318 @item _SC_STREAM_MAX
319 @standards{POSIX.1, unistd.h}
320 Inquire about the parameter corresponding to @code{STREAM_MAX}.
321
322 @item _SC_TZNAME_MAX
323 @standards{POSIX.1, unistd.h}
324 Inquire about the parameter corresponding to @code{TZNAME_MAX}.
325
326 @item _SC_NGROUPS_MAX
327 @standards{POSIX.1, unistd.h}
328 Inquire about the parameter corresponding to @code{NGROUPS_MAX}.
329
330 @item _SC_JOB_CONTROL
331 @standards{POSIX.1, unistd.h}
332 Inquire about the parameter corresponding to @code{_POSIX_JOB_CONTROL}.
333
334 @item _SC_SAVED_IDS
335 @standards{POSIX.1, unistd.h}
336 Inquire about the parameter corresponding to @code{_POSIX_SAVED_IDS}.
337
338 @item _SC_VERSION
339 @standards{POSIX.1, unistd.h}
340 Inquire about the parameter corresponding to @code{_POSIX_VERSION}.
341
342 @item _SC_CLK_TCK
343 @standards{POSIX.1, unistd.h}
344 Inquire about the number of clock ticks per second; @pxref{CPU Time}.
345 The corresponding parameter @code{CLK_TCK} is obsolete.
346
347 @item _SC_CHARCLASS_NAME_MAX
348 @standards{GNU, unistd.h}
349 Inquire about the parameter corresponding to maximal length allowed for
350 a character class name in an extended locale specification. These
351 extensions are not yet standardized and so this option is not standardized
352 as well.
353
354 @item _SC_REALTIME_SIGNALS
355 @standards{POSIX.1, unistdh.h}
356 Inquire about the parameter corresponding to @code{_POSIX_REALTIME_SIGNALS}.
357
358 @item _SC_PRIORITY_SCHEDULING
359 @standards{POSIX.1, unistd.h}
360 Inquire about the parameter corresponding to @code{_POSIX_PRIORITY_SCHEDULING}.
361
362 @item _SC_TIMERS
363 @standards{POSIX.1, unistd.h}
364 Inquire about the parameter corresponding to @code{_POSIX_TIMERS}.
365
366 @item _SC_ASYNCHRONOUS_IO
367 @standards{POSIX.1, unistd.h}
368 Inquire about the parameter corresponding to @code{_POSIX_ASYNCHRONOUS_IO}.
369
370 @item _SC_PRIORITIZED_IO
371 @standards{POSIX.1, unistd.h}
372 Inquire about the parameter corresponding to @code{_POSIX_PRIORITIZED_IO}.
373
374 @item _SC_SYNCHRONIZED_IO
375 @standards{POSIX.1, unistd.h}
376 Inquire about the parameter corresponding to @code{_POSIX_SYNCHRONIZED_IO}.
377
378 @item _SC_FSYNC
379 @standards{POSIX.1, unistd.h}
380 Inquire about the parameter corresponding to @code{_POSIX_FSYNC}.
381
382 @item _SC_MAPPED_FILES
383 @standards{POSIX.1, unistd.h}
384 Inquire about the parameter corresponding to @code{_POSIX_MAPPED_FILES}.
385
386 @item _SC_MEMLOCK
387 @standards{POSIX.1, unistd.h}
388 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK}.
389
390 @item _SC_MEMLOCK_RANGE
391 @standards{POSIX.1, unistd.h}
392 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK_RANGE}.
393
394 @item _SC_MEMORY_PROTECTION
395 @standards{POSIX.1, unistd.h}
396 Inquire about the parameter corresponding to @code{_POSIX_MEMORY_PROTECTION}.
397
398 @item _SC_MESSAGE_PASSING
399 @standards{POSIX.1, unistd.h}
400 Inquire about the parameter corresponding to @code{_POSIX_MESSAGE_PASSING}.
401
402 @item _SC_SEMAPHORES
403 @standards{POSIX.1, unistd.h}
404 Inquire about the parameter corresponding to @code{_POSIX_SEMAPHORES}.
405
406 @item _SC_SHARED_MEMORY_OBJECTS
407 @standards{POSIX.1, unistd.h}
408 Inquire about the parameter corresponding to@*
409 @code{_POSIX_SHARED_MEMORY_OBJECTS}.
410
411 @item _SC_AIO_LISTIO_MAX
412 @standards{POSIX.1, unistd.h}
413 Inquire about the parameter corresponding to @code{_POSIX_AIO_LISTIO_MAX}.
414
415 @item _SC_AIO_MAX
416 @standards{POSIX.1, unistd.h}
417 Inquire about the parameter corresponding to @code{_POSIX_AIO_MAX}.
418
419 @item _SC_AIO_PRIO_DELTA_MAX
420 @standards{POSIX.1, unistd.h}
421 Inquire about the value by which a process can decrease its asynchronous I/O
422 priority level from its own scheduling priority. This corresponds to the
423 run-time invariant value @code{AIO_PRIO_DELTA_MAX}.
424
425 @item _SC_DELAYTIMER_MAX
426 @standards{POSIX.1, unistd.h}
427 Inquire about the parameter corresponding to @code{_POSIX_DELAYTIMER_MAX}.
428
429 @item _SC_MQ_OPEN_MAX
430 @standards{POSIX.1, unistd.h}
431 Inquire about the parameter corresponding to @code{_POSIX_MQ_OPEN_MAX}.
432
433 @item _SC_MQ_PRIO_MAX
434 @standards{POSIX.1, unistd.h}
435 Inquire about the parameter corresponding to @code{_POSIX_MQ_PRIO_MAX}.
436
437 @item _SC_RTSIG_MAX
438 @standards{POSIX.1, unistd.h}
439 Inquire about the parameter corresponding to @code{_POSIX_RTSIG_MAX}.
440
441 @item _SC_SEM_NSEMS_MAX
442 @standards{POSIX.1, unistd.h}
443 Inquire about the parameter corresponding to @code{_POSIX_SEM_NSEMS_MAX}.
444
445 @item _SC_SEM_VALUE_MAX
446 @standards{POSIX.1, unistd.h}
447 Inquire about the parameter corresponding to @code{_POSIX_SEM_VALUE_MAX}.
448
449 @item _SC_SIGQUEUE_MAX
450 @standards{POSIX.1, unistd.h}
451 Inquire about the parameter corresponding to @code{_POSIX_SIGQUEUE_MAX}.
452
453 @item _SC_TIMER_MAX
454 @standards{POSIX.1, unistd.h}
455 Inquire about the parameter corresponding to @code{_POSIX_TIMER_MAX}.
456
457 @item _SC_PII
458 @standards{POSIX.1g, unistd.h}
459 Inquire about the parameter corresponding to @code{_POSIX_PII}.
460
461 @item _SC_PII_XTI
462 @standards{POSIX.1g, unistd.h}
463 Inquire about the parameter corresponding to @code{_POSIX_PII_XTI}.
464
465 @item _SC_PII_SOCKET
466 @standards{POSIX.1g, unistd.h}
467 Inquire about the parameter corresponding to @code{_POSIX_PII_SOCKET}.
468
469 @item _SC_PII_INTERNET
470 @standards{POSIX.1g, unistd.h}
471 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET}.
472
473 @item _SC_PII_OSI
474 @standards{POSIX.1g, unistd.h}
475 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI}.
476
477 @item _SC_SELECT
478 @standards{POSIX.1g, unistd.h}
479 Inquire about the parameter corresponding to @code{_POSIX_SELECT}.
480
481 @item _SC_UIO_MAXIOV
482 @standards{POSIX.1g, unistd.h}
483 Inquire about the parameter corresponding to @code{_POSIX_UIO_MAXIOV}.
484
485 @item _SC_PII_INTERNET_STREAM
486 @standards{POSIX.1g, unistd.h}
487 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_STREAM}.
488
489 @item _SC_PII_INTERNET_DGRAM
490 @standards{POSIX.1g, unistd.h}
491 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_DGRAM}.
492
493 @item _SC_PII_OSI_COTS
494 @standards{POSIX.1g, unistd.h}
495 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_COTS}.
496
497 @item _SC_PII_OSI_CLTS
498 @standards{POSIX.1g, unistd.h}
499 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_CLTS}.
500
501 @item _SC_PII_OSI_M
502 @standards{POSIX.1g, unistd.h}
503 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_M}.
504
505 @item _SC_T_IOV_MAX
506 @standards{POSIX.1g, unistd.h}
507 Inquire about the value associated with the @code{T_IOV_MAX}
508 variable.
509
510 @item _SC_THREADS
511 @standards{POSIX.1, unistd.h}
512 Inquire about the parameter corresponding to @code{_POSIX_THREADS}.
513
514 @item _SC_THREAD_SAFE_FUNCTIONS
515 @standards{POSIX.1, unistd.h}
516 Inquire about the parameter corresponding to@*
517 @code{_POSIX_THREAD_SAFE_FUNCTIONS}.
518
519 @item _SC_GETGR_R_SIZE_MAX
520 @standards{POSIX.1, unistd.h}
521 Inquire about the parameter corresponding to @code{_POSIX_GETGR_R_SIZE_MAX}.
522
523 @item _SC_GETPW_R_SIZE_MAX
524 @standards{POSIX.1, unistd.h}
525 Inquire about the parameter corresponding to @code{_POSIX_GETPW_R_SIZE_MAX}.
526
527 @item _SC_LOGIN_NAME_MAX
528 @standards{POSIX.1, unistd.h}
529 Inquire about the parameter corresponding to @code{_POSIX_LOGIN_NAME_MAX}.
530
531 @item _SC_TTY_NAME_MAX
532 @standards{POSIX.1, unistd.h}
533 Inquire about the parameter corresponding to @code{_POSIX_TTY_NAME_MAX}.
534
535 @item _SC_THREAD_DESTRUCTOR_ITERATIONS
536 @standards{POSIX.1, unistd.h}
537 Inquire about the parameter corresponding to
538 @code{_POSIX_THREAD_DESTRUCTOR_ITERATIONS}.
539
540 @item _SC_THREAD_KEYS_MAX
541 @standards{POSIX.1, unistd.h}
542 Inquire about the parameter corresponding to @code{_POSIX_THREAD_KEYS_MAX}.
543
544 @item _SC_THREAD_STACK_MIN
545 @standards{POSIX.1, unistd.h}
546 Inquire about the parameter corresponding to @code{_POSIX_THREAD_STACK_MIN}.
547
548 @item _SC_THREAD_THREADS_MAX
549 @standards{POSIX.1, unistd.h}
550 Inquire about the parameter corresponding to @code{_POSIX_THREAD_THREADS_MAX}.
551
552 @item _SC_THREAD_ATTR_STACKADDR
553 @standards{POSIX.1, unistd.h}
554 Inquire about the parameter corresponding to@*a
555 @code{_POSIX_THREAD_ATTR_STACKADDR}.
556
557 @item _SC_THREAD_ATTR_STACKSIZE
558 @standards{POSIX.1, unistd.h}
559 Inquire about the parameter corresponding to@*
560 @code{_POSIX_THREAD_ATTR_STACKSIZE}.
561
562 @item _SC_THREAD_PRIORITY_SCHEDULING
563 @standards{POSIX.1, unistd.h}
564 Inquire about the parameter corresponding to
565 @code{_POSIX_THREAD_PRIORITY_SCHEDULING}.
566
567 @item _SC_THREAD_PRIO_INHERIT
568 @standards{POSIX.1, unistd.h}
569 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_INHERIT}.
570
571 @item _SC_THREAD_PRIO_PROTECT
572 @standards{POSIX.1, unistd.h}
573 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_PROTECT}.
574
575 @item _SC_THREAD_PROCESS_SHARED
576 @standards{POSIX.1, unistd.h}
577 Inquire about the parameter corresponding to
578 @code{_POSIX_THREAD_PROCESS_SHARED}.
579
580 @item _SC_2_C_DEV
581 @standards{POSIX.2, unistd.h}
582 Inquire about whether the system has the POSIX.2 C compiler command,
583 @code{c89}.
584
585 @item _SC_2_FORT_DEV
586 @standards{POSIX.2, unistd.h}
587 Inquire about whether the system has the POSIX.2 Fortran compiler
588 command, @code{fort77}.
589
590 @item _SC_2_FORT_RUN
591 @standards{POSIX.2, unistd.h}
592 Inquire about whether the system has the POSIX.2 @code{asa} command to
593 interpret Fortran carriage control.
594
595 @item _SC_2_LOCALEDEF
596 @standards{POSIX.2, unistd.h}
597 Inquire about whether the system has the POSIX.2 @code{localedef}
598 command.
599
600 @item _SC_2_SW_DEV
601 @standards{POSIX.2, unistd.h}
602 Inquire about whether the system has the POSIX.2 commands @code{ar},
603 @code{make}, and @code{strip}.
604
605 @item _SC_BC_BASE_MAX
606 @standards{POSIX.2, unistd.h}
607 Inquire about the maximum value of @code{obase} in the @code{bc}
608 utility.
609
610 @item _SC_BC_DIM_MAX
611 @standards{POSIX.2, unistd.h}
612 Inquire about the maximum size of an array in the @code{bc}
613 utility.
614
615 @item _SC_BC_SCALE_MAX
616 @standards{POSIX.2, unistd.h}
617 Inquire about the maximum value of @code{scale} in the @code{bc}
618 utility.
619
620 @item _SC_BC_STRING_MAX
621 @standards{POSIX.2, unistd.h}
622 Inquire about the maximum size of a string constant in the
623 @code{bc} utility.
624
625 @item _SC_COLL_WEIGHTS_MAX
626 @standards{POSIX.2, unistd.h}
627 Inquire about the maximum number of weights that can necessarily
628 be used in defining the collating sequence for a locale.
629
630 @item _SC_EXPR_NEST_MAX
631 @standards{POSIX.2, unistd.h}
632 Inquire about the maximum number of expressions nested within
633 parentheses when using the @code{expr} utility.
634
635 @item _SC_LINE_MAX
636 @standards{POSIX.2, unistd.h}
637 Inquire about the maximum size of a text line that the POSIX.2 text
638 utilities can handle.
639
640 @item _SC_EQUIV_CLASS_MAX
641 @standards{POSIX.2, unistd.h}
642 Inquire about the maximum number of weights that can be assigned to an
643 entry of the @code{LC_COLLATE} category @samp{order} keyword in a locale
644 definition. @Theglibc{} does not presently support locale
645 definitions.
646
647 @item _SC_VERSION
648 @standards{POSIX.2, unistd.h}
649 Inquire about the version number of POSIX.1 that the library and kernel
650 support.
651
652 @item _SC_2_VERSION
653 @standards{POSIX.2, unistd.h}
654 Inquire about the version number of POSIX.2 that the system utilities
655 support.
656
657 @item _SC_PAGESIZE
658 @standards{GNU, unistd.h}
659 Inquire about the virtual memory page size of the machine.
660 @code{getpagesize} returns the same value (@pxref{Query Memory Parameters}).
661
662 @item _SC_NPROCESSORS_CONF
663 @standards{GNU, unistd.h}
664 Inquire about the number of configured processors.
665
666 @item _SC_NPROCESSORS_ONLN
667 @standards{GNU, unistd.h}
668 Inquire about the number of processors online.
669
670 @item _SC_PHYS_PAGES
671 @standards{GNU, unistd.h}
672 Inquire about the number of physical pages in the system.
673
674 @item _SC_AVPHYS_PAGES
675 @standards{GNU, unistd.h}
676 Inquire about the number of available physical pages in the system.
677
678 @item _SC_ATEXIT_MAX
679 @standards{GNU, unistd.h}
680 Inquire about the number of functions which can be registered as termination
681 functions for @code{atexit}; @pxref{Cleanups on Exit}.
682
683 @item _SC_LEVEL1_ICACHE_SIZE
684 @standards{GNU, unistd.h}
685 Inquire about the size of the Level 1 instruction cache.
686
687 @item _SC_LEVEL1_ICACHE_ASSOC
688 @standards{GNU, unistd.h}
689 Inquire about the associativity of the Level 1 instruction cache.
690
691 @item _SC_LEVEL1_ICACHE_LINESIZE
692 @standards{GNU, unistd.h}
693 Inquire about the line length of the Level 1 instruction cache.
694
695 On aarch64, the cache line size returned is the minimum instruction cache line
696 size observable by userspace. This is typically the same as the L1 icache
697 size but on some cores it may not be so. However, it is specified in the
698 architecture that operations such as cache line invalidation are consistent
699 with the size reported with this variable.
700
701 @item _SC_LEVEL1_DCACHE_SIZE
702 @standards{GNU, unistd.h}
703 Inquire about the size of the Level 1 data cache.
704
705 @item _SC_LEVEL1_DCACHE_ASSOC
706 @standards{GNU, unistd.h}
707 Inquire about the associativity of the Level 1 data cache.
708
709 @item _SC_LEVEL1_DCACHE_LINESIZE
710 @standards{GNU, unistd.h}
711 Inquire about the line length of the Level 1 data cache.
712
713 On aarch64, the cache line size returned is the minimum data cache line size
714 observable by userspace. This is typically the same as the L1 dcache size but
715 on some cores it may not be so. However, it is specified in the architecture
716 that operations such as cache line invalidation are consistent with the size
717 reported with this variable.
718
719 @item _SC_LEVEL2_CACHE_SIZE
720 @standards{GNU, unistd.h}
721 Inquire about the size of the Level 2 cache.
722
723 @item _SC_LEVEL2_CACHE_ASSOC
724 @standards{GNU, unistd.h}
725 Inquire about the associativity of the Level 2 cache.
726
727 @item _SC_LEVEL2_CACHE_LINESIZE
728 @standards{GNU, unistd.h}
729 Inquire about the line length of the Level 2 cache.
730
731 @item _SC_LEVEL3_CACHE_SIZE
732 @standards{GNU, unistd.h}
733 Inquire about the size of the Level 3 cache.
734
735 @item _SC_LEVEL3_CACHE_ASSOC
736 @standards{GNU, unistd.h}
737 Inquire about the associativity of the Level 3 cache.
738
739 @item _SC_LEVEL3_CACHE_LINESIZE
740 @standards{GNU, unistd.h}
741 Inquire about the line length of the Level 3 cache.
742
743 @item _SC_LEVEL4_CACHE_SIZE
744 @standards{GNU, unistd.h}
745 Inquire about the size of the Level 4 cache.
746
747 @item _SC_LEVEL4_CACHE_ASSOC
748 @standards{GNU, unistd.h}
749 Inquire about the associativity of the Level 4 cache.
750
751 @item _SC_LEVEL4_CACHE_LINESIZE
752 @standards{GNU, unistd.h}
753 Inquire about the line length of the Level 4 cache.
754
755
756 @item _SC_XOPEN_VERSION
757 @standards{X/Open, unistd.h}
758 Inquire about the parameter corresponding to @code{_XOPEN_VERSION}.
759
760 @item _SC_XOPEN_XCU_VERSION
761 @standards{X/Open, unistd.h}
762 Inquire about the parameter corresponding to @code{_XOPEN_XCU_VERSION}.
763
764 @item _SC_XOPEN_UNIX
765 @standards{X/Open, unistd.h}
766 Inquire about the parameter corresponding to @code{_XOPEN_UNIX}.
767
768 @item _SC_XOPEN_REALTIME
769 @standards{X/Open, unistd.h}
770 Inquire about the parameter corresponding to @code{_XOPEN_REALTIME}.
771
772 @item _SC_XOPEN_REALTIME_THREADS
773 @standards{X/Open, unistd.h}
774 Inquire about the parameter corresponding to @code{_XOPEN_REALTIME_THREADS}.
775
776 @item _SC_XOPEN_LEGACY
777 @standards{X/Open, unistd.h}
778 Inquire about the parameter corresponding to @code{_XOPEN_LEGACY}.
779
780 @item _SC_XOPEN_CRYPT
781 @standards{X/Open, unistd.h}
782 Inquire about the parameter corresponding to @code{_XOPEN_CRYPT}.
783 @Theglibc no longer implements the @code{_XOPEN_CRYPT} extensions,
784 so @samp{sysconf (_SC_XOPEN_CRYPT)} always returns @code{-1}.
785
786 @item _SC_XOPEN_ENH_I18N
787 @standards{X/Open, unistd.h}
788 Inquire about the parameter corresponding to @code{_XOPEN_ENH_I18N}.
789
790 @item _SC_XOPEN_SHM
791 @standards{X/Open, unistd.h}
792 Inquire about the parameter corresponding to @code{_XOPEN_SHM}.
793
794 @item _SC_XOPEN_XPG2
795 @standards{X/Open, unistd.h}
796 Inquire about the parameter corresponding to @code{_XOPEN_XPG2}.
797
798 @item _SC_XOPEN_XPG3
799 @standards{X/Open, unistd.h}
800 Inquire about the parameter corresponding to @code{_XOPEN_XPG3}.
801
802 @item _SC_XOPEN_XPG4
803 @standards{X/Open, unistd.h}
804 Inquire about the parameter corresponding to @code{_XOPEN_XPG4}.
805
806 @item _SC_CHAR_BIT
807 @standards{X/Open, unistd.h}
808 Inquire about the number of bits in a variable of type @code{char}.
809
810 @item _SC_CHAR_MAX
811 @standards{X/Open, unistd.h}
812 Inquire about the maximum value which can be stored in a variable of type
813 @code{char}.
814
815 @item _SC_CHAR_MIN
816 @standards{X/Open, unistd.h}
817 Inquire about the minimum value which can be stored in a variable of type
818 @code{char}.
819
820 @item _SC_INT_MAX
821 @standards{X/Open, unistd.h}
822 Inquire about the maximum value which can be stored in a variable of type
823 @code{int}.
824
825 @item _SC_INT_MIN
826 @standards{X/Open, unistd.h}
827 Inquire about the minimum value which can be stored in a variable of type
828 @code{int}.
829
830 @item _SC_LONG_BIT
831 @standards{X/Open, unistd.h}
832 Inquire about the number of bits in a variable of type @code{long int}.
833
834 @item _SC_WORD_BIT
835 @standards{X/Open, unistd.h}
836 Inquire about the number of bits in a variable of a register word.
837
838 @item _SC_MB_LEN_MAX
839 @standards{X/Open, unistd.h}
840 Inquire about the maximum length of a multi-byte representation of a wide
841 character value.
842
843 @item _SC_NZERO
844 @standards{X/Open, unistd.h}
845 Inquire about the value used to internally represent the zero priority level for
846 the process execution.
847
848 @item _SC_SSIZE_MAX
849 @standards{X/Open, unistd.h}
850 Inquire about the maximum value which can be stored in a variable of type
851 @code{ssize_t}.
852
853 @item _SC_SCHAR_MAX
854 @standards{X/Open, unistd.h}
855 Inquire about the maximum value which can be stored in a variable of type
856 @code{signed char}.
857
858 @item _SC_SCHAR_MIN
859 @standards{X/Open, unistd.h}
860 Inquire about the minimum value which can be stored in a variable of type
861 @code{signed char}.
862
863 @item _SC_SHRT_MAX
864 @standards{X/Open, unistd.h}
865 Inquire about the maximum value which can be stored in a variable of type
866 @code{short int}.
867
868 @item _SC_SHRT_MIN
869 @standards{X/Open, unistd.h}
870 Inquire about the minimum value which can be stored in a variable of type
871 @code{short int}.
872
873 @item _SC_UCHAR_MAX
874 @standards{X/Open, unistd.h}
875 Inquire about the maximum value which can be stored in a variable of type
876 @code{unsigned char}.
877
878 @item _SC_UINT_MAX
879 @standards{X/Open, unistd.h}
880 Inquire about the maximum value which can be stored in a variable of type
881 @code{unsigned int}.
882
883 @item _SC_ULONG_MAX
884 @standards{X/Open, unistd.h}
885 Inquire about the maximum value which can be stored in a variable of type
886 @code{unsigned long int}.
887
888 @item _SC_USHRT_MAX
889 @standards{X/Open, unistd.h}
890 Inquire about the maximum value which can be stored in a variable of type
891 @code{unsigned short int}.
892
893 @item _SC_NL_ARGMAX
894 @standards{X/Open, unistd.h}
895 Inquire about the parameter corresponding to @code{NL_ARGMAX}.
896
897 @item _SC_NL_LANGMAX
898 @standards{X/Open, unistd.h}
899 Inquire about the parameter corresponding to @code{NL_LANGMAX}.
900
901 @item _SC_NL_MSGMAX
902 @standards{X/Open, unistd.h}
903 Inquire about the parameter corresponding to @code{NL_MSGMAX}.
904
905 @item _SC_NL_NMAX
906 @standards{X/Open, unistd.h}
907 Inquire about the parameter corresponding to @code{NL_NMAX}.
908
909 @item _SC_NL_SETMAX
910 @standards{X/Open, unistd.h}
911 Inquire about the parameter corresponding to @code{NL_SETMAX}.
912
913 @item _SC_NL_TEXTMAX
914 @standards{X/Open, unistd.h}
915 Inquire about the parameter corresponding to @code{NL_TEXTMAX}.
916
917 @item _SC_MINSIGSTKSZ
918 @standards{GNU, unistd.h}
919 Inquire about the minimum number of bytes of free stack space required
920 in order to guarantee successful, non-nested handling of a single signal
921 whose handler is an empty function.
922
923 @item _SC_SIGSTKSZ
924 @standards{GNU, unistd.h}
925 Inquire about the suggested minimum number of bytes of stack space
926 required for a signal stack.
927
928 This is not guaranteed to be enough for any specific purpose other than
929 the invocation of a single, non-nested, empty handler, but nonetheless
930 should be enough for basic scenarios involving simple signal handlers
931 and very low levels of signal nesting (say, 2 or 3 levels at the very
932 most).
933
934 This value is provided for developer convenience and to ease migration
935 from the legacy @code{SIGSTKSZ} constant. Programs requiring stronger
936 guarantees should avoid using it if at all possible.
937 @end vtable
938
939 @node Examples of Sysconf
940 @subsection Examples of @code{sysconf}
941
942 We recommend that you first test for a macro definition for the
943 parameter you are interested in, and call @code{sysconf} only if the
944 macro is not defined. For example, here is how to test whether job
945 control is supported:
946
947 @smallexample
948 @group
949 int
950 have_job_control (void)
951 @{
952 #ifdef _POSIX_JOB_CONTROL
953 return 1;
954 #else
955 int value = sysconf (_SC_JOB_CONTROL);
956 if (value < 0)
957 /* @r{If the system is that badly wedged,}
958 @r{there's no use trying to go on.} */
959 fatal (strerror (errno));
960 return value;
961 #endif
962 @}
963 @end group
964 @end smallexample
965
966 Here is how to get the value of a numeric limit:
967
968 @smallexample
969 int
970 get_child_max ()
971 @{
972 #ifdef CHILD_MAX
973 return CHILD_MAX;
974 #else
975 int value = sysconf (_SC_CHILD_MAX);
976 if (value < 0)
977 fatal (strerror (errno));
978 return value;
979 #endif
980 @}
981 @end smallexample
982
983 @node Minimums
984 @section Minimum Values for General Capacity Limits
985
986 Here are the names for the POSIX minimum upper bounds for the system
987 limit parameters. The significance of these values is that you can
988 safely push to these limits without checking whether the particular
989 system you are using can go that far.
990
991 @vtable @code
992 @item _POSIX_AIO_LISTIO_MAX
993 @standards{POSIX.1, limits.h}
994 The most restrictive limit permitted by POSIX for the maximum number of
995 I/O operations that can be specified in a list I/O call. The value of
996 this constant is @code{2}; thus you can add up to two new entries
997 of the list of outstanding operations.
998
999 @item _POSIX_AIO_MAX
1000 @standards{POSIX.1, limits.h}
1001 The most restrictive limit permitted by POSIX for the maximum number of
1002 outstanding asynchronous I/O operations. The value of this constant is
1003 @code{1}. So you cannot expect that you can issue more than one
1004 operation and immediately continue with the normal work, receiving the
1005 notifications asynchronously.
1006
1007 @item _POSIX_ARG_MAX
1008 @standards{POSIX.1, limits.h}
1009 The value of this macro is the most restrictive limit permitted by POSIX
1010 for the maximum combined length of the @var{argv} and @var{environ}
1011 arguments that can be passed to the @code{exec} functions.
1012 Its value is @code{4096}.
1013
1014 @item _POSIX_CHILD_MAX
1015 @standards{POSIX.1, limits.h}
1016 The value of this macro is the most restrictive limit permitted by POSIX
1017 for the maximum number of simultaneous processes per real user ID. Its
1018 value is @code{6}.
1019
1020 @item _POSIX_NGROUPS_MAX
1021 @standards{POSIX.1, limits.h}
1022 The value of this macro is the most restrictive limit permitted by POSIX
1023 for the maximum number of supplementary group IDs per process. Its
1024 value is @code{0}.
1025
1026 @item _POSIX_OPEN_MAX
1027 @standards{POSIX.1, limits.h}
1028 The value of this macro is the most restrictive limit permitted by POSIX
1029 for the maximum number of files that a single process can have open
1030 simultaneously. Its value is @code{16}.
1031
1032 @item _POSIX_SSIZE_MAX
1033 @standards{POSIX.1, limits.h}
1034 The value of this macro is the most restrictive limit permitted by POSIX
1035 for the maximum value that can be stored in an object of type
1036 @code{ssize_t}. Its value is @code{32767}.
1037
1038 @item _POSIX_STREAM_MAX
1039 @standards{POSIX.1, limits.h}
1040 The value of this macro is the most restrictive limit permitted by POSIX
1041 for the maximum number of streams that a single process can have open
1042 simultaneously. Its value is @code{8}.
1043
1044 @item _POSIX_TZNAME_MAX
1045 @standards{POSIX.1, limits.h}
1046 The value of this macro is the most restrictive limit permitted by POSIX
1047 for the maximum length of a time zone name. Its value is @code{3}.
1048
1049 @item _POSIX2_RE_DUP_MAX
1050 @standards{POSIX.2, limits.h}
1051 The value of this macro is the most restrictive limit permitted by POSIX
1052 for the numbers used in the @samp{\@{@var{min},@var{max}\@}} construct
1053 in a regular expression. Its value is @code{255}.
1054 @end vtable
1055
1056 @node Limits for Files
1057 @section Limits on File System Capacity
1058
1059 The POSIX.1 standard specifies a number of parameters that describe the
1060 limitations of the file system. It's possible for the system to have a
1061 fixed, uniform limit for a parameter, but this isn't the usual case. On
1062 most systems, it's possible for different file systems (and, for some
1063 parameters, even different files) to have different maximum limits. For
1064 example, this is very likely if you use NFS to mount some of the file
1065 systems from other machines.
1066
1067 @pindex limits.h
1068 Each of the following macros is defined in @file{limits.h} only if the
1069 system has a fixed, uniform limit for the parameter in question. If the
1070 system allows different file systems or files to have different limits,
1071 then the macro is undefined; use @code{pathconf} or @code{fpathconf} to
1072 find out the limit that applies to a particular file. @xref{Pathconf}.
1073
1074 Each parameter also has another macro, with a name starting with
1075 @samp{_POSIX}, which gives the lowest value that the limit is allowed to
1076 have on @emph{any} POSIX system. @xref{File Minimums}.
1077
1078 @cindex limits, link count of files
1079 @deftypevr Macro int LINK_MAX
1080 @standards{POSIX.1, limits.h (optional)}
1081 The uniform system limit (if any) for the number of names for a given
1082 file. @xref{Hard Links}.
1083 @end deftypevr
1084
1085 @cindex limits, terminal input queue
1086 @deftypevr Macro int MAX_CANON
1087 @standards{POSIX.1, limits.h}
1088 The uniform system limit (if any) for the amount of text in a line of
1089 input when input editing is enabled. @xref{Canonical or Not}.
1090 @end deftypevr
1091
1092 @deftypevr Macro int MAX_INPUT
1093 @standards{POSIX.1, limits.h}
1094 The uniform system limit (if any) for the total number of characters
1095 typed ahead as input. @xref{I/O Queues}.
1096 @end deftypevr
1097
1098 @cindex limits, file name length
1099 @deftypevr Macro int NAME_MAX
1100 @standards{POSIX.1, limits.h}
1101 The uniform system limit (if any) for the length of a file name component, not
1102 including the terminating null character.
1103
1104 @strong{Portability Note:} On some systems, @theglibc{} defines
1105 @code{NAME_MAX}, but does not actually enforce this limit.
1106 @end deftypevr
1107
1108 @deftypevr Macro int PATH_MAX
1109 @standards{POSIX.1, limits.h}
1110 The uniform system limit (if any) for the length of an entire file name (that
1111 is, the argument given to system calls such as @code{open}), including the
1112 terminating null character.
1113
1114 @strong{Portability Note:} @Theglibc{} does not enforce this limit
1115 even if @code{PATH_MAX} is defined.
1116 @end deftypevr
1117
1118 @cindex limits, pipe buffer size
1119 @deftypevr Macro int PIPE_BUF
1120 @standards{POSIX.1, limits.h}
1121 The uniform system limit (if any) for the number of bytes that can be
1122 written atomically to a pipe. If multiple processes are writing to the
1123 same pipe simultaneously, output from different processes might be
1124 interleaved in chunks of this size. @xref{Pipes and FIFOs}.
1125 @end deftypevr
1126
1127 These are alternative macro names for some of the same information.
1128
1129 @deftypevr Macro int MAXNAMLEN
1130 @standards{BSD, dirent.h}
1131 This is the BSD name for @code{NAME_MAX}. It is defined in
1132 @file{dirent.h}.
1133 @end deftypevr
1134
1135 @deftypevr Macro int FILENAME_MAX
1136 @standards{ISO, stdio.h}
1137 The value of this macro is an integer constant expression that
1138 represents the maximum length of a file name string. It is defined in
1139 @file{stdio.h}.
1140
1141 Unlike @code{PATH_MAX}, this macro is defined even if there is no actual
1142 limit imposed. In such a case, its value is typically a very large
1143 number. @strong{This is always the case on @gnuhurdsystems{}.}
1144
1145 @strong{Usage Note:} Don't use @code{FILENAME_MAX} as the size of an
1146 array in which to store a file name! You can't possibly make an array
1147 that big! Use dynamic allocation (@pxref{Memory Allocation}) instead.
1148 @end deftypevr
1149
1150 @node Options for Files
1151 @section Optional Features in File Support
1152
1153 POSIX defines certain system-specific options in the system calls for
1154 operating on files. Some systems support these options and others do
1155 not. Since these options are provided in the kernel, not in the
1156 library, simply using @theglibc{} does not guarantee that any of these
1157 features is supported; it depends on the system you are using. They can
1158 also vary between file systems on a single machine.
1159
1160 @pindex unistd.h
1161 This section describes the macros you can test to determine whether a
1162 particular option is supported on your machine. If a given macro is
1163 defined in @file{unistd.h}, then its value says whether the
1164 corresponding feature is supported. (A value of @code{-1} indicates no;
1165 any other value indicates yes.) If the macro is undefined, it means
1166 particular files may or may not support the feature.
1167
1168 Since all the machines that support @theglibc{} also support NFS,
1169 one can never make a general statement about whether all file systems
1170 support the @code{_POSIX_CHOWN_RESTRICTED} and @code{_POSIX_NO_TRUNC}
1171 features. So these names are never defined as macros in @theglibc{}.
1172
1173 @deftypevr Macro int _POSIX_CHOWN_RESTRICTED
1174 @standards{POSIX.1, unistd.h}
1175 If this option is in effect, the @code{chown} function is restricted so
1176 that the only changes permitted to nonprivileged processes is to change
1177 the group owner of a file to either be the effective group ID of the
1178 process, or one of its supplementary group IDs. @xref{File Owner}.
1179 @end deftypevr
1180
1181 @deftypevr Macro int _POSIX_NO_TRUNC
1182 @standards{POSIX.1, unistd.h}
1183 If this option is in effect, file name components longer than
1184 @code{NAME_MAX} generate an @code{ENAMETOOLONG} error. Otherwise, file
1185 name components that are too long are silently truncated.
1186 @end deftypevr
1187
1188 @deftypevr Macro {unsigned char} _POSIX_VDISABLE
1189 @standards{POSIX.1, unistd.h}
1190 This option is only meaningful for files that are terminal devices.
1191 If it is enabled, then handling for special control characters can
1192 be disabled individually. @xref{Special Characters}.
1193 @end deftypevr
1194
1195 @pindex unistd.h
1196 If one of these macros is undefined, that means that the option might be
1197 in effect for some files and not for others. To inquire about a
1198 particular file, call @code{pathconf} or @code{fpathconf}.
1199 @xref{Pathconf}.
1200
1201 @node File Minimums
1202 @section Minimum Values for File System Limits
1203
1204 Here are the names for the POSIX minimum upper bounds for some of the
1205 above parameters. The significance of these values is that you can
1206 safely push to these limits without checking whether the particular
1207 system you are using can go that far. In most cases @gnusystems{} do not
1208 have these strict limitations. The actual limit should be requested if
1209 necessary.
1210
1211 @vtable @code
1212 @item _POSIX_LINK_MAX
1213 @standards{POSIX.1, limits.h}
1214 The most restrictive limit permitted by POSIX for the maximum value of a
1215 file's link count. The value of this constant is @code{8}; thus, you
1216 can always make up to eight names for a file without running into a
1217 system limit.
1218
1219 @item _POSIX_MAX_CANON
1220 @standards{POSIX.1, limits.h}
1221 The most restrictive limit permitted by POSIX for the maximum number of
1222 bytes in a canonical input line from a terminal device. The value of
1223 this constant is @code{255}.
1224
1225 @item _POSIX_MAX_INPUT
1226 @standards{POSIX.1, limits.h}
1227 The most restrictive limit permitted by POSIX for the maximum number of
1228 bytes in a terminal device input queue (or typeahead buffer).
1229 @xref{Input Modes}. The value of this constant is @code{255}.
1230
1231 @item _POSIX_NAME_MAX
1232 @standards{POSIX.1, limits.h}
1233 The most restrictive limit permitted by POSIX for the maximum number of
1234 bytes in a file name component. The value of this constant is
1235 @code{14}.
1236
1237 @item _POSIX_PATH_MAX
1238 @standards{POSIX.1, limits.h}
1239 The most restrictive limit permitted by POSIX for the maximum number of
1240 bytes in a file name. The value of this constant is @code{256}.
1241
1242 @item _POSIX_PIPE_BUF
1243 @standards{POSIX.1, limits.h}
1244 The most restrictive limit permitted by POSIX for the maximum number of
1245 bytes that can be written atomically to a pipe. The value of this
1246 constant is @code{512}.
1247
1248 @item SYMLINK_MAX
1249 @standards{POSIX.1, limits.h}
1250 Maximum number of bytes in a symbolic link.
1251
1252 @item POSIX_REC_INCR_XFER_SIZE
1253 @standards{POSIX.1, limits.h}
1254 Recommended increment for file transfer sizes between the
1255 @code{POSIX_REC_MIN_XFER_SIZE} and @code{POSIX_REC_MAX_XFER_SIZE}
1256 values.
1257
1258 @item POSIX_REC_MAX_XFER_SIZE
1259 @standards{POSIX.1, limits.h}
1260 Maximum recommended file transfer size.
1261
1262 @item POSIX_REC_MIN_XFER_SIZE
1263 @standards{POSIX.1, limits.h}
1264 Minimum recommended file transfer size.
1265
1266 @item POSIX_REC_XFER_ALIGN
1267 @standards{POSIX.1, limits.h}
1268 Recommended file transfer buffer alignment.
1269 @end vtable
1270
1271 @node Pathconf
1272 @section Using @code{pathconf}
1273
1274 When your machine allows different files to have different values for a
1275 file system parameter, you can use the functions in this section to find
1276 out the value that applies to any particular file.
1277
1278 These functions and the associated constants for the @var{parameter}
1279 argument are declared in the header file @file{unistd.h}.
1280
1281 @deftypefun {long int} pathconf (const char *@var{filename}, int @var{parameter})
1282 @standards{POSIX.1, unistd.h}
1283 @safety{@prelim{}@mtsafe{}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsfd{} @acsmem{}}}
1284 @c When __statfs_link_max finds an ext* filesystem, it may read
1285 @c /proc/mounts or similar as a mntent stream.
1286 @c __statfs_chown_restricted may read from
1287 @c /proc/sys/fs/xfs/restrict_chown as a file descriptor.
1288 This function is used to inquire about the limits that apply to
1289 the file named @var{filename}.
1290
1291 The @var{parameter} argument should be one of the @samp{_PC_} constants
1292 listed below.
1293
1294 The normal return value from @code{pathconf} is the value you requested.
1295 A value of @code{-1} is returned both if the implementation does not
1296 impose a limit, and in case of an error. In the former case,
1297 @code{errno} is not set, while in the latter case, @code{errno} is set
1298 to indicate the cause of the problem. So the only way to use this
1299 function robustly is to store @code{0} into @code{errno} just before
1300 calling it.
1301
1302 Besides the usual file name errors (@pxref{File Name Errors}),
1303 the following error condition is defined for this function:
1304
1305 @table @code
1306 @item EINVAL
1307 The value of @var{parameter} is invalid, or the implementation doesn't
1308 support the @var{parameter} for the specific file.
1309 @end table
1310 @end deftypefun
1311
1312 @deftypefun {long int} fpathconf (int @var{filedes}, int @var{parameter})
1313 @standards{POSIX.1, unistd.h}
1314 @safety{@prelim{}@mtsafe{}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsfd{} @acsmem{}}}
1315 @c Same caveats as pathconf.
1316 This is just like @code{pathconf} except that an open file descriptor
1317 is used to specify the file for which information is requested, instead
1318 of a file name.
1319
1320 The following @code{errno} error conditions are defined for this function:
1321
1322 @table @code
1323 @item EBADF
1324 The @var{filedes} argument is not a valid file descriptor.
1325
1326 @item EINVAL
1327 The value of @var{parameter} is invalid, or the implementation doesn't
1328 support the @var{parameter} for the specific file.
1329 @end table
1330 @end deftypefun
1331
1332 Here are the symbolic constants that you can use as the @var{parameter}
1333 argument to @code{pathconf} and @code{fpathconf}. The values are all
1334 integer constants.
1335
1336 @vtable @code
1337 @item _PC_LINK_MAX
1338 @standards{POSIX.1, unistd.h}
1339 Inquire about the value of @code{LINK_MAX}.
1340
1341 @item _PC_MAX_CANON
1342 @standards{POSIX.1, unistd.h}
1343 Inquire about the value of @code{MAX_CANON}.
1344
1345 @item _PC_MAX_INPUT
1346 @standards{POSIX.1, unistd.h}
1347 Inquire about the value of @code{MAX_INPUT}.
1348
1349 @item _PC_NAME_MAX
1350 @standards{POSIX.1, unistd.h}
1351 Inquire about the value of @code{NAME_MAX}.
1352
1353 @item _PC_PATH_MAX
1354 @standards{POSIX.1, unistd.h}
1355 Inquire about the value of @code{PATH_MAX}.
1356
1357 @item _PC_PIPE_BUF
1358 @standards{POSIX.1, unistd.h}
1359 Inquire about the value of @code{PIPE_BUF}.
1360
1361 @item _PC_CHOWN_RESTRICTED
1362 @standards{POSIX.1, unistd.h}
1363 Inquire about the value of @code{_POSIX_CHOWN_RESTRICTED}.
1364
1365 @item _PC_NO_TRUNC
1366 @standards{POSIX.1, unistd.h}
1367 Inquire about the value of @code{_POSIX_NO_TRUNC}.
1368
1369 @item _PC_VDISABLE
1370 @standards{POSIX.1, unistd.h}
1371 Inquire about the value of @code{_POSIX_VDISABLE}.
1372
1373 @item _PC_SYNC_IO
1374 @standards{POSIX.1, unistd.h}
1375 Inquire about the value of @code{_POSIX_SYNC_IO}.
1376
1377 @item _PC_ASYNC_IO
1378 @standards{POSIX.1, unistd.h}
1379 Inquire about the value of @code{_POSIX_ASYNC_IO}.
1380
1381 @item _PC_PRIO_IO
1382 @standards{POSIX.1, unistd.h}
1383 Inquire about the value of @code{_POSIX_PRIO_IO}.
1384
1385 @item _PC_FILESIZEBITS
1386 @standards{LFS, unistd.h}
1387 Inquire about the availability of large files on the filesystem.
1388
1389 @item _PC_REC_INCR_XFER_SIZE
1390 @standards{POSIX.1, unistd.h}
1391 Inquire about the value of @code{POSIX_REC_INCR_XFER_SIZE}.
1392
1393 @item _PC_REC_MAX_XFER_SIZE
1394 @standards{POSIX.1, unistd.h}
1395 Inquire about the value of @code{POSIX_REC_MAX_XFER_SIZE}.
1396
1397 @item _PC_REC_MIN_XFER_SIZE
1398 @standards{POSIX.1, unistd.h}
1399 Inquire about the value of @code{POSIX_REC_MIN_XFER_SIZE}.
1400
1401 @item _PC_REC_XFER_ALIGN
1402 @standards{POSIX.1, unistd.h}
1403 Inquire about the value of @code{POSIX_REC_XFER_ALIGN}.
1404 @end vtable
1405
1406 @strong{Portability Note:} On some systems, @theglibc{} does not
1407 enforce @code{_PC_NAME_MAX} or @code{_PC_PATH_MAX} limits.
1408
1409 @node Utility Limits
1410 @section Utility Program Capacity Limits
1411
1412 The POSIX.2 standard specifies certain system limits that you can access
1413 through @code{sysconf} that apply to utility behavior rather than the
1414 behavior of the library or the operating system.
1415
1416 @Theglibc{} defines macros for these limits, and @code{sysconf}
1417 returns values for them if you ask; but these values convey no
1418 meaningful information. They are simply the smallest values that
1419 POSIX.2 permits.
1420
1421 @deftypevr Macro int BC_BASE_MAX
1422 @standards{POSIX.2, limits.h}
1423 The largest value of @code{obase} that the @code{bc} utility is
1424 guaranteed to support.
1425 @end deftypevr
1426
1427 @deftypevr Macro int BC_DIM_MAX
1428 @standards{POSIX.2, limits.h}
1429 The largest number of elements in one array that the @code{bc} utility
1430 is guaranteed to support.
1431 @end deftypevr
1432
1433 @deftypevr Macro int BC_SCALE_MAX
1434 @standards{POSIX.2, limits.h}
1435 The largest value of @code{scale} that the @code{bc} utility is
1436 guaranteed to support.
1437 @end deftypevr
1438
1439 @deftypevr Macro int BC_STRING_MAX
1440 @standards{POSIX.2, limits.h}
1441 The largest number of characters in one string constant that the
1442 @code{bc} utility is guaranteed to support.
1443 @end deftypevr
1444
1445 @deftypevr Macro int COLL_WEIGHTS_MAX
1446 @standards{POSIX.2, limits.h}
1447 The largest number of weights that can necessarily be used in defining
1448 the collating sequence for a locale.
1449 @end deftypevr
1450
1451 @deftypevr Macro int EXPR_NEST_MAX
1452 @standards{POSIX.2, limits.h}
1453 The maximum number of expressions that can be nested within parentheses
1454 by the @code{expr} utility.
1455 @end deftypevr
1456
1457 @deftypevr Macro int LINE_MAX
1458 @standards{POSIX.2, limits.h}
1459 The largest text line that the text-oriented POSIX.2 utilities can
1460 support. (If you are using the GNU versions of these utilities, then
1461 there is no actual limit except that imposed by the available virtual
1462 memory, but there is no way that the library can tell you this.)
1463 @end deftypevr
1464
1465 @deftypevr Macro int EQUIV_CLASS_MAX
1466 @standards{POSIX.2, limits.h}
1467 The maximum number of weights that can be assigned to an entry of the
1468 @code{LC_COLLATE} category @samp{order} keyword in a locale definition.
1469 @Theglibc{} does not presently support locale definitions.
1470 @end deftypevr
1471
1472 @node Utility Minimums
1473 @section Minimum Values for Utility Limits
1474
1475 @vtable @code
1476 @item _POSIX2_BC_BASE_MAX
1477 @standards{POSIX.2, limits.h}
1478 The most restrictive limit permitted by POSIX.2 for the maximum value of
1479 @code{obase} in the @code{bc} utility. Its value is @code{99}.
1480
1481 @item _POSIX2_BC_DIM_MAX
1482 @standards{POSIX.2, limits.h}
1483 The most restrictive limit permitted by POSIX.2 for the maximum size of
1484 an array in the @code{bc} utility. Its value is @code{2048}.
1485
1486 @item _POSIX2_BC_SCALE_MAX
1487 @standards{POSIX.2, limits.h}
1488 The most restrictive limit permitted by POSIX.2 for the maximum value of
1489 @code{scale} in the @code{bc} utility. Its value is @code{99}.
1490
1491 @item _POSIX2_BC_STRING_MAX
1492 @standards{POSIX.2, limits.h}
1493 The most restrictive limit permitted by POSIX.2 for the maximum size of
1494 a string constant in the @code{bc} utility. Its value is @code{1000}.
1495
1496 @item _POSIX2_COLL_WEIGHTS_MAX
1497 @standards{POSIX.2, limits.h}
1498 The most restrictive limit permitted by POSIX.2 for the maximum number
1499 of weights that can necessarily be used in defining the collating
1500 sequence for a locale. Its value is @code{2}.
1501
1502 @item _POSIX2_EXPR_NEST_MAX
1503 @standards{POSIX.2, limits.h}
1504 The most restrictive limit permitted by POSIX.2 for the maximum number
1505 of expressions nested within parenthesis when using the @code{expr} utility.
1506 Its value is @code{32}.
1507
1508 @item _POSIX2_LINE_MAX
1509 @standards{POSIX.2, limits.h}
1510 The most restrictive limit permitted by POSIX.2 for the maximum size of
1511 a text line that the text utilities can handle. Its value is
1512 @code{2048}.
1513
1514 @item _POSIX2_EQUIV_CLASS_MAX
1515 @standards{POSIX.2, limits.h}
1516 The most restrictive limit permitted by POSIX.2 for the maximum number
1517 of weights that can be assigned to an entry of the @code{LC_COLLATE}
1518 category @samp{order} keyword in a locale definition. Its value is
1519 @code{2}. @Theglibc{} does not presently support locale
1520 definitions.
1521 @end vtable
1522
1523 @node String Parameters
1524 @section String-Valued Parameters
1525
1526 POSIX.2 defines a way to get string-valued parameters from the operating
1527 system with the function @code{confstr}:
1528
1529 @deftypefun size_t confstr (int @var{parameter}, char *@var{buf}, size_t @var{len})
1530 @standards{POSIX.2, unistd.h}
1531 @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
1532 This function reads the value of a string-valued system parameter,
1533 storing the string into @var{len} bytes of memory space starting at
1534 @var{buf}. The @var{parameter} argument should be one of the
1535 @samp{_CS_} symbols listed below.
1536
1537 The normal return value from @code{confstr} is the length of the string
1538 value that you asked for. If you supply a null pointer for @var{buf},
1539 then @code{confstr} does not try to store the string; it just returns
1540 its length. A value of @code{0} indicates an error.
1541
1542 If the string you asked for is too long for the buffer (that is, longer
1543 than @code{@var{len} - 1}), then @code{confstr} stores just that much
1544 (leaving room for the terminating null character). You can tell that
1545 this has happened because @code{confstr} returns a value greater than or
1546 equal to @var{len}.
1547
1548 The following @code{errno} error conditions are defined for this function:
1549
1550 @table @code
1551 @item EINVAL
1552 The value of the @var{parameter} is invalid.
1553 @end table
1554 @end deftypefun
1555
1556 Currently there is just one parameter you can read with @code{confstr}:
1557
1558 @vtable @code
1559 @item _CS_PATH
1560 @standards{POSIX.2, unistd.h}
1561 This parameter's value is the recommended default path for searching for
1562 executable files. This is the path that a user has by default just
1563 after logging in.
1564
1565 @item _CS_LFS_CFLAGS
1566 @standards{Unix98, unistd.h}
1567 The returned string specifies which additional flags must be given to
1568 the C compiler if a source is compiled using the
1569 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1570
1571 @item _CS_LFS_LDFLAGS
1572 @standards{Unix98, unistd.h}
1573 The returned string specifies which additional flags must be given to
1574 the linker if a source is compiled using the
1575 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1576
1577 @item _CS_LFS_LIBS
1578 @standards{Unix98, unistd.h}
1579 The returned string specifies which additional libraries must be linked
1580 to the application if a source is compiled using the
1581 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1582
1583 @item _CS_LFS_LINTFLAGS
1584 @standards{Unix98, unistd.h}
1585 The returned string specifies which additional flags must be given to
1586 the lint tool if a source is compiled using the
1587 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1588
1589 @item _CS_LFS64_CFLAGS
1590 @standards{Unix98, unistd.h}
1591 The returned string specifies which additional flags must be given to
1592 the C compiler if a source is compiled using the
1593 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1594
1595 @item _CS_LFS64_LDFLAGS
1596 @standards{Unix98, unistd.h}
1597 The returned string specifies which additional flags must be given to
1598 the linker if a source is compiled using the
1599 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1600
1601 @item _CS_LFS64_LIBS
1602 @standards{Unix98, unistd.h}
1603 The returned string specifies which additional libraries must be linked
1604 to the application if a source is compiled using the
1605 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1606
1607 @item _CS_LFS64_LINTFLAGS
1608 @standards{Unix98, unistd.h}
1609 The returned string specifies which additional flags must be given to
1610 the lint tool if a source is compiled using the
1611 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1612 @end vtable
1613
1614 The way to use @code{confstr} without any arbitrary limit on string size
1615 is to call it twice: first call it to get the length, allocate the
1616 buffer accordingly, and then call @code{confstr} again to fill the
1617 buffer, like this:
1618
1619 @smallexample
1620 @group
1621 char *
1622 get_default_path (void)
1623 @{
1624 size_t len = confstr (_CS_PATH, NULL, 0);
1625 char *buffer = (char *) xmalloc (len);
1626
1627 if (confstr (_CS_PATH, buf, len + 1) == 0)
1628 @{
1629 free (buffer);
1630 return NULL;
1631 @}
1632
1633 return buffer;
1634 @}
1635 @end group
1636 @end smallexample