xref: /netbsd-src/lib/libc/gen/sysconf.3 (revision e610bdf86708e8fc76cc6643f2c0805e537c37a2)
1.\"	$NetBSD: sysconf.3,v 1.57 2024/03/21 22:27:55 uwe Exp $
2.\"
3.\" Copyright (c) 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)sysconf.3	8.3 (Berkeley) 4/19/94
31.\"
32.Dd October 25, 2023
33.Dt SYSCONF 3
34.Os
35.Sh NAME
36.Nm sysconf
37.Nd get configurable system variables
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In unistd.h
42.Ft long
43.Fn sysconf "int name"
44.Sh DESCRIPTION
45This interface is defined by
46.St -p1003.1-88 .
47A far more complete interface is available using
48.Xr sysctl 3 .
49.Pp
50The
51.Fn sysconf
52function provides a method for applications to determine the current
53value of a configurable system limit or option variable.
54The
55.Fa name
56argument specifies the system variable to be queried.
57Symbolic constants for each name value are found in the include file
58.In unistd.h .
59.Pp
60The available values are as follows:
61.Bl -tag -width Dv
62.It Dv _SC_ARG_MAX
63The maximum bytes of argument to
64.Xr execve 2 .
65.It Dv _SC_ATEXIT_MAX
66The maximum number of functions that may be registered with
67.Xr atexit 3 .
68.It Dv _SC_BARRIERS
69The version of
70.St -p1003.1
71and its
72Barriers
73option to which the system attempts to conform,
74otherwise \-1.
75.It Dv _SC_CLOCK_SELECTION
76Return the
77.Tn POSIX
78version the implementation of the Clock Selection option
79on this system conforms to,
80or \-1 if unavailable.
81.It Dv _SC_CHILD_MAX
82The maximum number of simultaneous processes per user id.
83.It Dv _SC_CLK_TCK
84The number of clock ticks per second.
85.It Dv _SC_FSYNC
86Return 1 if the File Synchronization option is available on this system,
87otherwise \-1.
88.It Dv _SC_HOST_NAME_MAX
89The maximum size of a hostname, including the terminating
90.Tn NUL .
91.It Dv _SC_IOV_MAX
92The maximum number of
93.Vt iovec
94structures that a process has available for use with
95.Xr preadv 2 ,
96.Xr pwritev 2 ,
97.Xr readv 2 ,
98.Xr recvmsg 2 ,
99.Xr sendmsg 2
100or
101.Xr writev 2 .
102.It Dv _SC_JOB_CONTROL
103Return 1 if job control is available on this system, otherwise \-1.
104.It Dv _SC_LOGIN_NAME_MAX
105Returns the size of the storage required for a login name, in bytes,
106including the terminating
107.Tn NUL .
108.It Dv _SC_MAPPED_FILES
109Return 1 if the Memory Mapped Files option is available on this system,
110otherwise \-1.
111.It Dv _SC_MEMLOCK
112Return 1 if the Process Memory Locking option is available on this system,
113otherwise \-1.
114.It Dv _SC_MEMLOCK_RANGE
115Return 1 if the Range Memory Locking option is available on this system,
116otherwise \-1.
117.It Dv _SC_MEMORY_PROTECTION
118Return 1 if the Memory Protection option is available on this system,
119otherwise \-1.
120.It Dv _SC_MONOTONIC_CLOCK
121Return the
122.Tn POSIX
123version the implementation of the Monotonic Clock option
124on this system conforms to,
125or \-1 if unavailable.
126.It Dv _SC_NGROUPS_MAX
127The maximum number of supplemental groups.
128.It Dv _SC_OPEN_MAX
129The maximum number of open files per process.
130.It Dv _SC_PAGESIZE
131The size of a system page in bytes.
132.It Dv _SC_PASS_MAX
133The maximum length of the password, not counting the terminating
134.Tn NUL .
135.It Dv _SC_READER_WRITER_LOCKS
136The version of
137.St -p1003.1
138and its
139Read-Write Locks
140option to which the system attempts to conform,
141otherwise \-1.
142.It Dv _SC_REGEXP
143Return 1 if
144.Tn POSIX
145regular expressions are available on this system, otherwise \-1.
146.It Dv _SC_SEMAPHORES
147The version of
148.St -p1003.1
149and its
150Semaphores
151option to which the system attempts to conform,
152otherwise \-1.
153.It Dv _SC_SEM_NSEMS_MAX
154The maximum number of semaphores that one process can have open at a time,
155otherwise \-1.
156.It Dv _SC_SHELL
157Return 1 if
158.Tn POSIX
159shell is available on this system, otherwise \-1.
160.It Dv _SC_SPIN_LOCKS
161The version of
162.St -p1003.1
163and its
164Spin Locks
165option to which the system attempts to conform,
166otherwise \-1.
167.It Dv _SC_STREAM_MAX
168The minimum maximum number of streams that a process may have open
169at any one time.
170.It Dv _SC_SYMLOOP_MAX
171The maximum number of symbolic links that may be expanded in a path name.
172.It Dv _SC_SYNCHRONIZED_IO
173Return 1 if the Synchronized I/O option is available on this system,
174otherwise \-1.
175.It Dv _SC_THREADS
176The version of
177.St -p1003.1
178and its
179Threads
180option to which the system attempts to conform,
181otherwise \-1.
182.It Dv _SC_THREAD_PRIO_PROTECT
183System supports the priority ceiling protocol for POSIX threads.
184.It Dv _SC_TIMERS
185The version of
186.St -p1003.1
187and its
188Timers
189option to which the system attempts to conform,
190otherwise \-1.
191.It Dv _SC_CPUTIME
192The clockID
193.Dv CLOCK_PROCESS_CPUTIME_ID
194is supported, otherwise \-1.
195.It Dv _SC_THREAD_CPUTIME
196The clockID
197.Dv CLOCK_THREAD_CPUTIME_ID
198is supported, otherwise \-1.
199.It Dv _SC_DELAYTIMER_MAX
200The maximum number of overrun for a specific timer,
201otherwise \-1.
202.It Dv _SC_TZNAME_MAX
203The minimum maximum number of types supported for the name of a
204timezone.
205.It Dv _SC_SAVED_IDS
206Returns 1 if saved set-group and saved set-user ID is available,
207otherwise \-1.
208.It Dv _SC_VERSION
209The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
210attempts to comply.
211.It Dv _SC_XOPEN_SHM
212Return 1 if the
213.St -xpg4.2
214Shared Memory
215option is available on this system,
216otherwise \-1.
217.Pp
218Availability of the
219Shared Memory
220option depends on the
221.Dv SYSVSHM
222kernel option.
223.It Dv _SC_BC_BASE_MAX
224The maximum ibase/obase values in the
225.Xr bc 1
226utility.
227.It Dv _SC_BC_DIM_MAX
228The maximum array size in the
229.Xr bc 1
230utility.
231.It Dv _SC_BC_SCALE_MAX
232The maximum scale value in the
233.Xr bc 1
234utility.
235.It Dv _SC_BC_STRING_MAX
236The maximum string length in the
237.Xr bc 1
238utility.
239.It Dv _SC_COLL_WEIGHTS_MAX
240The maximum number of weights that can be assigned to any entry of
241the LC_COLLATE order keyword in the locale definition file.
242.It Dv _SC_EXPR_NEST_MAX
243The maximum number of expressions that can be nested within
244parenthesis by the
245.Xr expr 1
246utility.
247.It Dv _SC_LINE_MAX
248The maximum length in bytes of a text-processing utility's input
249line.
250.It Dv _SC_RE_DUP_MAX
251The maximum number of repeated occurrences of a regular expression
252permitted when using interval notation.
253.It Dv _SC_2_VERSION
254The version of POSIX 1003.2 with which the system attempts to comply.
255.It Dv _SC_2_C_BIND
256Return 1 if the system's C-language development facilities support the
257C-Language Bindings option, otherwise \-1.
258.It Dv _SC_2_C_DEV
259Return 1 if the system supports the C-Language Development Utilities option,
260otherwise \-1.
261.It Dv _SC_2_CHAR_TERM
262Return 1 if the system supports at least one terminal type capable of
263all operations described in POSIX 1003.2, otherwise \-1.
264.It Dv _SC_2_FORT_DEV
265Return 1 if the system supports the FORTRAN Development Utilities option,
266otherwise \-1.
267.It Dv _SC_2_FORT_RUN
268Return 1 if the system supports the FORTRAN Runtime Utilities option,
269otherwise \-1.
270.It Dv _SC_2_LOCALEDEF
271Return 1 if the system supports the creation of locales, otherwise \-1.
272.It Dv _SC_2_SW_DEV
273Return 1 if the system supports the Software Development Utilities option,
274otherwise \-1.
275.It Dv _SC_2_UPE
276Return 1 if the system supports the User Portability Utilities option,
277otherwise \-1.
278.It Dv _SC_GETGR_R_SIZE_MAX
279The minimum size of the
280.Fa buffer
281passed to
282.Xr getgrgid_r 3
283and
284.Xr getgrnam_r 3 .
285.It Dv _SC_GETPW_R_SIZE_MAX
286The minimum size of the
287.Fa buffer
288passed to
289.Xr getpwnam_r 3
290and
291.Xr getpwuid_r 3 .
292.It Dv _SC_NPROCESSORS_CONF
293The number of processors configured.
294.It Dv _SC_NPROCESSORS_ONLN
295The number of processors online (capable of running processes).
296.It Dv _SC_PHYS_PAGES
297The total number of pages of physical memory.
298See
299.Dv _SC_PAGESIZE
300for the system page size.
301.It Dv _SC_AVPHYS_PAGES
302The number of available pages of physical memory.
303See
304.Dv _SC_PAGESIZE
305for the system page size.
306.It Dv _SC_TIMER_MAX
307The number of timers available for
308.Xr timer_create 2 .
309This is also known as
310.Dv _POSIX_TIMER_MAX .
311.El
312.Sh RETURN VALUES
313If the call to
314.Nm sysconf
315is not successful, \-1 is returned and
316.Va errno
317is set appropriately.
318Otherwise, if the variable is associated with functionality that is not
319supported, \-1 is returned and
320.Va errno
321is not modified.
322Otherwise, the current variable value is returned.
323.Sh ERRORS
324The
325.Fn sysconf
326function may fail and set
327.Va errno
328for any of the errors specified for the library functions
329.Xr sysctl 3 .
330In addition, the following error may be reported:
331.Bl -tag -width Er
332.It Bq Er EINVAL
333The value of the
334.Fa name
335argument is invalid.
336.El
337.Sh SEE ALSO
338.Xr getconf 1 ,
339.Xr limits 3 ,
340.Xr sysctl 3
341.Sh STANDARDS
342The
343.Fn sysconf
344function conforms to
345.St -p1003.1-90 .
346The constants
347.Dv _SC_NPROCESSORS_CONF
348and
349.Dv _SC_NPROCESSORS_ONLN
350are not part of the standard, but are provided by many systems.
351.Sh HISTORY
352The
353.Nm sysconf
354function first appeared in
355.Bx 4.4 .
356.Sh BUGS
357The value for
358.Dv _SC_STREAM_MAX
359is a minimum maximum, and required to be the same as
360.Tn ANSI C Ap s
361.Dv FOPEN_MAX ,
362so the returned value is a ridiculously small and misleading number.
363