xref: /netbsd-src/lib/libc/gen/sysconf.3 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\"	$NetBSD: sysconf.3,v 1.33 2007/10/15 14:12:56 ad 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_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_READER_WRITER_LOCKS
131The version of
132.St -p1003.1
133and its
134Read-Write Locks
135option to which the system attempts to conform,
136otherwise \-1.
137.It Li _SC_SEMAPHORES
138The version of
139.St -p1003.1
140and its
141Semaphores
142option to which the system attempts to conform,
143otherwise \-1.
144.Pp
145Availability of the
146Semaphores
147option depends on the
148.Li P1003_1B_SEMAPHORE
149kernel option.
150.It Li _SC_SPIN_LOCKS
151The version of
152.St -p1003.1
153and its
154Spin Locks
155option to which the system attempts to conform,
156otherwise \-1.
157.It Li _SC_STREAM_MAX
158The minimum maximum number of streams that a process may have open
159at any one time.
160.It Li _SC_SYNCHRONIZED_IO
161Return 1 if the Synchronized I/O Option is available on this system,
162otherwise \-1.
163.It Li _SC_THREADS
164The version of
165.St -p1003.1
166and its
167Threads
168option to which the system attempts to conform,
169otherwise \-1.
170.It Li _SC_TIMERS
171The version of
172.St -p1003.1
173and its
174Timers
175option to which the system attempts to conform,
176otherwise \-1.
177.It Li _SC_TZNAME_MAX
178The minimum maximum number of types supported for the name of a
179timezone.
180.It Li _SC_SAVED_IDS
181Returns 1 if saved set-group and saved set-user ID is available,
182otherwise \-1.
183.It Li _SC_VERSION
184The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
185attempts to comply.
186.It Li _SC_XOPEN_SHM
187Return 1 if the
188.St -xpg4.2
189Shared Memory
190option is available on this system,
191otherwise \-1.
192.Pp
193Availability of the
194Shared Memory
195option depends on the
196.Li SYSVSHM
197kernel option.
198.It Li _SC_BC_BASE_MAX
199The maximum ibase/obase values in the
200.Xr bc 1
201utility.
202.It Li _SC_BC_DIM_MAX
203The maximum array size in the
204.Xr bc 1
205utility.
206.It Li _SC_BC_SCALE_MAX
207The maximum scale value in the
208.Xr bc 1
209utility.
210.It Li _SC_BC_STRING_MAX
211The maximum string length in the
212.Xr bc 1
213utility.
214.It Li _SC_COLL_WEIGHTS_MAX
215The maximum number of weights that can be assigned to any entry of
216the LC_COLLATE order keyword in the locale definition file.
217.It Li _SC_EXPR_NEST_MAX
218The maximum number of expressions that can be nested within
219parenthesis by the
220.Xr expr 1
221utility.
222.It Li _SC_LINE_MAX
223The maximum length in bytes of a text-processing utility's input
224line.
225.It Li _SC_RE_DUP_MAX
226The maximum number of repeated occurrences of a regular expression
227permitted when using interval notation.
228.It Li _SC_2_VERSION
229The version of POSIX 1003.2 with which the system attempts to comply.
230.It Li _SC_2_C_BIND
231Return 1 if the system's C-language development facilities support the
232C-Language Bindings Option, otherwise \-1.
233.It Li _SC_2_C_DEV
234Return 1 if the system supports the C-Language Development Utilities Option,
235otherwise \-1.
236.It Li _SC_2_CHAR_TERM
237Return 1 if the system supports at least one terminal type capable of
238all operations described in POSIX 1003.2, otherwise \-1.
239.It Li _SC_2_FORT_DEV
240Return 1 if the system supports the FORTRAN Development Utilities Option,
241otherwise \-1.
242.It Li _SC_2_FORT_RUN
243Return 1 if the system supports the FORTRAN Runtime Utilities Option,
244otherwise \-1.
245.It Li _SC_2_LOCALEDEF
246Return 1 if the system supports the creation of locales, otherwise \-1.
247.It Li _SC_2_SW_DEV
248Return 1 if the system supports the Software Development Utilities Option,
249otherwise \-1.
250.It Li _SC_2_UPE
251Return 1 if the system supports the User Portability Utilities Option,
252otherwise \-1.
253.It Li _SC_GETGR_R_SIZE_MAX
254The minimum size of the
255.Fa buffer
256passed to
257.Xr getgrgid_r 3
258and
259.Xr getgrnam_r 3 .
260.It Li _SC_GETPW_R_SIZE_MAX
261The minimum size of the
262.Fa buffer
263passed to
264.Xr getpwnam_r 3
265and
266.Xr getpwuid_r 3 .
267.It Li _SC_NPROCESSORS_CONF
268The number of processors configured.
269.It Li _SC_NPROCESSORS_ONLN
270The number of processors online (capable of running processes).
271.El
272.Sh RETURN VALUES
273If the call to
274.Nm sysconf
275is not successful, \-1 is returned and
276.Va errno
277is set appropriately.
278Otherwise, if the variable is associated with functionality that is not
279supported, \-1 is returned and
280.Va errno
281is not modified.
282Otherwise, the current variable value is returned.
283.Sh ERRORS
284The
285.Fn sysconf
286function may fail and set
287.Va errno
288for any of the errors specified for the library functions
289.Xr sysctl 3 .
290In addition, the following error may be reported:
291.Bl -tag -width Er
292.It Bq Er EINVAL
293The value of the
294.Fa name
295argument is invalid.
296.El
297.Sh SEE ALSO
298.Xr sysctl 3
299.Sh STANDARDS
300The
301.Fn sysconf
302function conforms to
303.St -p1003.1-90 .
304The constants
305.Li _SC_NPROCESSORS_CONF
306and
307.Li _SC_NPROCESSORS_ONLN
308are not part of the standard, but are provided by many systems.
309.Sh HISTORY
310The
311.Nm sysconf
312function first appeared in
313.Bx 4.4 .
314.Sh BUGS
315The value for _SC_STREAM_MAX is a minimum maximum, and required to be
316the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously
317small and misleading number.
318