xref: /dflybsd-src/lib/libc/gen/sysconf.3 (revision d28c1c80af323326e64cb10dee40f878380e36ff)
1.\" Copyright (c) 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)sysconf.3	8.3 (Berkeley) 4/19/94
29.\" $FreeBSD: src/lib/libc/gen/sysconf.3,v 1.8.2.6 2001/12/14 18:33:51 ru Exp $
30.\"
31.Dd June 10, 2021
32.Dt SYSCONF 3
33.Os
34.Sh NAME
35.Nm sysconf
36.Nd get configurable system variables
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS
40.In unistd.h
41.Ft long
42.Fn sysconf "int name"
43.Sh DESCRIPTION
44This interface is defined by
45.St -p1003.1-88 .
46A far more complete interface is available using
47.Xr sysctl 3 .
48.Pp
49The
50.Fn sysconf
51function provides a method for applications to determine the current
52value of a configurable system limit or option variable.
53The
54.Fa name
55argument specifies the system variable to be queried.
56Symbolic constants for each name value are found in the include file
57.In unistd.h .
58.Pp
59The available values are as follows:
60.Bl -tag -width 6n
61.It Dv _SC_ARG_MAX
62The maximum bytes of argument to
63.Xr execve 2 .
64.It Dv _SC_BC_BASE_MAX
65The maximum ibase/obase values in the
66.Xr bc 1
67utility.
68.It Dv _SC_BC_DIM_MAX
69The maximum array size in the
70.Xr bc 1
71utility.
72.It Dv _SC_BC_SCALE_MAX
73The maximum scale value in the
74.Xr bc 1
75utility.
76.It Dv _SC_BC_STRING_MAX
77The maximum string length in the
78.Xr bc 1
79utility.
80.It Dv _SC_CHILD_MAX
81The maximum number of simultaneous processes per user id.
82.It Dv _SC_CLK_TCK
83The frequency of the statistics clock in ticks per second.
84.It Dv _SC_COLL_WEIGHTS_MAX
85The maximum number of weights that can be assigned to any entry of
86the LC_COLLATE order keyword in the locale definition file.
87.It Dv _SC_EXPR_NEST_MAX
88The maximum number of expressions that can be nested within
89parenthesis by the
90.Xr expr 1
91utility.
92.It Dv _SC_HOST_NAME_MAX
93Maximum length of a host name (not including the terminating null) as
94returned from the
95.Xr gethostname 3 ,
96function.
97.It Dv _SC_IOV_MAX
98The maximum number of elements in the I/O vector used by
99.Xr readv 2 ,
100.Xr writev 2 ,
101.Xr recvmsg 2 ,
102and
103.Xr sendmsg 2 .
104.It Dv _SC_JOB_CONTROL
105Return 1 if job control is available on this system, otherwise \-1.
106.It Dv _SC_LINE_MAX
107The maximum length in bytes of a text-processing utility's input
108line.
109.It Dv _SC_MESSAGE_PASSING
110Whether Message Passing option is supported.
111.It Dv _SC_MQ_OPEN_MAX
112The maximum number of open message queue descriptors per process.
113.It Dv _SC_MQ_PRIO_MAX
114The maximum number of message priorities supported by the implementation.
115.It Dv _SC_NGROUPS_MAX
116The maximum number of supplemental groups.
117.It Dv _SC_OPEN_MAX
118The maximum number of open files per user id.
119.It Dv _SC_PAGESIZE
120The size of a system page in bytes.
121.It Dv _SC_PAGE_SIZE
122Equivalent to
123.Dv _SC_PAGESIZE .
124.It Dv _SC_RE_DUP_MAX
125The maximum number of repeated occurrences of a regular expression
126permitted when using interval notation.
127.It Dv _SC_REGEXP
128Return 1 if the system supports regular expression handling.
129.It Dv _SC_SAVED_IDS
130Return 1 if saved set-group and saved set-user ID is available,
131otherwise \-1.
132.It Dv _SC_SHELL
133Return 1 if the system supports the
134.Tn POSIX
135shell.
136.It Dv _SC_STREAM_MAX
137The minimum maximum number of streams that a process may have open
138at any one time.
139.It Dv _SC_TZNAME_MAX
140The minimum maximum number of types supported for the name of a
141timezone.
142.It Dv _SC_VERSION
143The version of
144.St -p1003.1
145with which the system
146attempts to comply.
147.It Dv _SC_XOPEN_SHM
148Return 1 if the system supports the
149.St -xpg4.2
150Shared Memory Feature
151for both compilation and execution, or 0 if only compilation support is
152guaranteed.
153.It Dv _SC_2_C_BIND
154Return 1 if the system's C-language development facilities support the
155C-Language Bindings Option, otherwise \-1.
156.It Dv _SC_2_C_DEV
157Return 1 if the system supports the C-Language Development Utilities Option,
158otherwise \-1.
159.It Dv _SC_2_CHAR_TERM
160Return 1 if the system supports at least one terminal type capable of
161all operations described in
162.St -p1003.2 ,
163otherwise \-1.
164.It Dv _SC_2_FORT_DEV
165Return 1 if the system supports the FORTRAN Development Utilities Option,
166otherwise \-1.
167.It Dv _SC_2_FORT_RUN
168Return 1 if the system supports the FORTRAN Runtime Utilities Option,
169otherwise \-1.
170.It Dv _SC_2_LOCALEDEF
171Return 1 if the system supports the creation of locales, otherwise \-1.
172.It Dv _SC_2_SW_DEV
173Return 1 if the system supports the Software Development Utilities Option,
174otherwise \-1.
175.It Dv _SC_2_UPE
176Return 1 if the system supports the User Portability Utilities Option,
177otherwise \-1.
178.It Dv _SC_2_VERSION
179The version of
180.St -p1003.2
181with which the system attempts to comply.
182.El
183.Pp
184These values also exist, but may not be standard:
185.Bl -tag -width 6n
186.It Dv _SC_LEVEL1_DCACHE_LINESIZE
187Returns the L1 cache line size.
188.It Dv _SC_NPROCESSORS_CONF
189The number of processors configured.
190.It Dv _SC_NPROCESSORS_ONLN
191The number of processors online.
192.It Dv _SC_PHYS_PAGES
193The number of pages of physical memory.
194.El
195.Sh RETURN VALUES
196If the call to
197.Fn sysconf
198is not successful, \-1 is returned and
199.Va errno
200is set appropriately.
201Otherwise, if the variable is associated with functionality that is not
202supported, \-1 is returned and
203.Va errno
204is not modified.
205Otherwise, the current variable value is returned.
206.Sh ERRORS
207The
208.Fn sysconf
209function may fail and set
210.Va errno
211for any of the errors specified for the library function
212.Xr sysctl 3 .
213In addition, the following error may be reported:
214.Bl -tag -width Er
215.It Bq Er EINVAL
216The value of the
217.Fa name
218argument is invalid.
219.El
220.Sh SEE ALSO
221.Xr getconf 1 ,
222.Xr pathconf 2 ,
223.Xr confstr 3 ,
224.Xr sysctl 3
225.Sh STANDARDS
226Except for the fact that values returned by
227.Fn sysconf
228may change over the lifetime of the calling process,
229this function conforms to
230.St -p1003.1-88 .
231.Pp
232.Dv _SC_NPROCESSORS_CONF
233and
234.Dv _SC_NPROCESSORS_ONLN
235are nonstandard, but implemented in many systems.
236.Sh HISTORY
237The
238.Fn sysconf
239function first appeared in
240.Bx 4.4 .
241.Sh BUGS
242The value for
243.Dv _SC_STREAM_MAX
244is a minimum maximum, and required to be the same as ANSI C's
245.Dv FOPEN_MAX ,
246so the returned value is a ridiculously small and misleading number.
247