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