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