xref: /netbsd-src/lib/libc/gen/sysconf.3 (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1.\"	$NetBSD: sysconf.3,v 1.34 2008/08/06 17:17:04 matt 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 August 14, 2006
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.Aq Pa unistd.h .
59.Pp
60The available values are as follows:
61.Pp
62.Bl -tag -width "123456"
63.Pp
64.It Li _SC_ARG_MAX
65The maximum bytes of argument to
66.Xr execve 2 .
67.It Li _SC_ATEXIT_MAX
68The maxmimum number of functions that may be registered with
69.Xr atexit 3 .
70.It Li _SC_BARRIERS
71The version of
72.St -p1003.1
73and its
74Barriers
75option to which the system attempts to conform,
76otherwise \-1.
77.It Li _SC_CLOCK_SELECTION
78Return the
79.Tn POSIX
80version the implementation of the Clock Selection Option
81on this system conforms to,
82or \-1 if unavailable.
83.It Li _SC_CHILD_MAX
84The maximum number of simultaneous processes per user id.
85.It Li _SC_CLK_TCK
86The number of clock ticks per second.
87.It Li _SC_FSYNC
88Return 1 if the File Synchronization Option is available on this system,
89otherwise \-1.
90.It Li _SC_HOST_NAME_MAX
91The maximum size of a hostname, including NULL.
92.It Li _SC_IOV_MAX
93The maximum number of
94.Va iovec
95structures that a process has available for use with
96.Xr preadv 2 ,
97.Xr pwritev 2 ,
98.Xr readv 2 ,
99.Xr recvmsg 2 ,
100.Xr sendmsg 2
101or
102.Xr writev 2 .
103.It Li _SC_JOB_CONTROL
104Return 1 if job control is available on this system, otherwise \-1.
105.It Li _SC_LOGIN_NAME_MAX
106Returns the size of the storage required for a login name, in bytes,
107including the terminating NUL.
108.It Li _SC_MAPPED_FILES
109Return 1 if the Memory Mapped Files Option is available on this system,
110otherwise \-1.
111.It Li _SC_MEMLOCK
112Return 1 if the Process Memory Locking Option is available on this system,
113otherwise \-1.
114.It Li _SC_MEMLOCK_RANGE
115Return 1 if the Range Memory Locking Option is available on this system,
116otherwise \-1.
117.It Li _SC_MEMORY_PROTECTION
118Return 1 if the Memory Protection Option is available on this system,
119otherwise \-1.
120.It Li _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 Li _SC_NGROUPS_MAX
127The maximum number of supplemental groups.
128.It Li _SC_OPEN_MAX
129The maximum number of open files per process.
130.It Li _SC_PAGESIZE
131The size of a system page in bytes.
132.It Li _SC_PASS_MAX
133The maximum length of the password, not counting NULL.
134.It Li _SC_READER_WRITER_LOCKS
135The version of
136.St -p1003.1
137and its
138Read-Write Locks
139option to which the system attempts to conform,
140otherwise \-1.
141.It Li _SC_REGEXP
142Return 1 if
143.Tn POSIX
144regular expressions are available on this system, otherwise \-1.
145.It Li _SC_SEMAPHORES
146The version of
147.St -p1003.1
148and its
149Semaphores
150option to which the system attempts to conform,
151otherwise \-1.
152.Pp
153Availability of the
154Semaphores
155option depends on the
156.Li P1003_1B_SEMAPHORE
157kernel option.
158.It Li _SC_SHELL
159Return 1 if
160.Tn POSIX
161shell is available on this system, otherwise \-1.
162.It Li _SC_SPIN_LOCKS
163The version of
164.St -p1003.1
165and its
166Spin Locks
167option to which the system attempts to conform,
168otherwise \-1.
169.It Li _SC_STREAM_MAX
170The minimum maximum number of streams that a process may have open
171at any one time.
172.It Li _SC_SYMLOOP_MAX
173The maximum number of symbolic links that may be expanded in a path name.
174.It Li _SC_SYNCHRONIZED_IO
175Return 1 if the Synchronized I/O Option is available on this system,
176otherwise \-1.
177.It Li _SC_THREADS
178The version of
179.St -p1003.1
180and its
181Threads
182option to which the system attempts to conform,
183otherwise \-1.
184.It Li _SC_TIMERS
185The version of
186.St -p1003.1
187and its
188Timers
189option to which the system attempts to conform,
190otherwise \-1.
191.It Li _SC_TZNAME_MAX
192The minimum maximum number of types supported for the name of a
193timezone.
194.It Li _SC_SAVED_IDS
195Returns 1 if saved set-group and saved set-user ID is available,
196otherwise \-1.
197.It Li _SC_VERSION
198The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
199attempts to comply.
200.It Li _SC_XOPEN_SHM
201Return 1 if the
202.St -xpg4.2
203Shared Memory
204option is available on this system,
205otherwise \-1.
206.Pp
207Availability of the
208Shared Memory
209option depends on the
210.Li SYSVSHM
211kernel option.
212.It Li _SC_BC_BASE_MAX
213The maximum ibase/obase values in the
214.Xr bc 1
215utility.
216.It Li _SC_BC_DIM_MAX
217The maximum array size in the
218.Xr bc 1
219utility.
220.It Li _SC_BC_SCALE_MAX
221The maximum scale value in the
222.Xr bc 1
223utility.
224.It Li _SC_BC_STRING_MAX
225The maximum string length in the
226.Xr bc 1
227utility.
228.It Li _SC_COLL_WEIGHTS_MAX
229The maximum number of weights that can be assigned to any entry of
230the LC_COLLATE order keyword in the locale definition file.
231.It Li _SC_EXPR_NEST_MAX
232The maximum number of expressions that can be nested within
233parenthesis by the
234.Xr expr 1
235utility.
236.It Li _SC_LINE_MAX
237The maximum length in bytes of a text-processing utility's input
238line.
239.It Li _SC_RE_DUP_MAX
240The maximum number of repeated occurrences of a regular expression
241permitted when using interval notation.
242.It Li _SC_2_VERSION
243The version of POSIX 1003.2 with which the system attempts to comply.
244.It Li _SC_2_C_BIND
245Return 1 if the system's C-language development facilities support the
246C-Language Bindings Option, otherwise \-1.
247.It Li _SC_2_C_DEV
248Return 1 if the system supports the C-Language Development Utilities Option,
249otherwise \-1.
250.It Li _SC_2_CHAR_TERM
251Return 1 if the system supports at least one terminal type capable of
252all operations described in POSIX 1003.2, otherwise \-1.
253.It Li _SC_2_FORT_DEV
254Return 1 if the system supports the FORTRAN Development Utilities Option,
255otherwise \-1.
256.It Li _SC_2_FORT_RUN
257Return 1 if the system supports the FORTRAN Runtime Utilities Option,
258otherwise \-1.
259.It Li _SC_2_LOCALEDEF
260Return 1 if the system supports the creation of locales, otherwise \-1.
261.It Li _SC_2_SW_DEV
262Return 1 if the system supports the Software Development Utilities Option,
263otherwise \-1.
264.It Li _SC_2_UPE
265Return 1 if the system supports the User Portability Utilities Option,
266otherwise \-1.
267.It Li _SC_GETGR_R_SIZE_MAX
268The minimum size of the
269.Fa buffer
270passed to
271.Xr getgrgid_r 3
272and
273.Xr getgrnam_r 3 .
274.It Li _SC_GETPW_R_SIZE_MAX
275The minimum size of the
276.Fa buffer
277passed to
278.Xr getpwnam_r 3
279and
280.Xr getpwuid_r 3 .
281.It Li _SC_NPROCESSORS_CONF
282The number of processors configured.
283.It Li _SC_NPROCESSORS_ONLN
284The number of processors online (capable of running processes).
285.El
286.Sh RETURN VALUES
287If the call to
288.Nm sysconf
289is not successful, \-1 is returned and
290.Va errno
291is set appropriately.
292Otherwise, if the variable is associated with functionality that is not
293supported, \-1 is returned and
294.Va errno
295is not modified.
296Otherwise, the current variable value is returned.
297.Sh ERRORS
298The
299.Fn sysconf
300function may fail and set
301.Va errno
302for any of the errors specified for the library functions
303.Xr sysctl 3 .
304In addition, the following error may be reported:
305.Bl -tag -width Er
306.It Bq Er EINVAL
307The value of the
308.Fa name
309argument is invalid.
310.El
311.Sh SEE ALSO
312.Xr sysctl 3
313.Sh STANDARDS
314The
315.Fn sysconf
316function conforms to
317.St -p1003.1-90 .
318The constants
319.Li _SC_NPROCESSORS_CONF
320and
321.Li _SC_NPROCESSORS_ONLN
322are not part of the standard, but are provided by many systems.
323.Sh HISTORY
324The
325.Nm sysconf
326function first appeared in
327.Bx 4.4 .
328.Sh BUGS
329The value for _SC_STREAM_MAX is a minimum maximum, and required to be
330the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously
331small and misleading number.
332