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