xref: /netbsd-src/share/man/man3/limits.3 (revision e5ce0ad0c8f4695917acb8ac2813f56f40c3e528)
1.\" $NetBSD: limits.3,v 1.2 2011/08/29 16:56:32 njoly Exp $
2.\"
3.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jukka Ruohonen.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd August 9, 2011
31.Dt LIMITS 3
32.Os
33.Sh NAME
34.Nm limits
35.Nd standard limits
36.Sh SYNOPSIS
37.In limits.h
38.Sh DESCRIPTION
39The
40.In limits.h
41header defines various compile-time and runtime limits.
42These can be grouped into three categories:
43.Bl -enum -offset indent
44.It
45Compile-time limits defined in a header file.
46.It
47Runtime system limits that are not associated with a file or directory; see
48.Xr sysconf 3 .
49.It
50Runtime limits that are associated with a file or directory; see
51.Xr pathconf 2 .
52.El
53.Pp
54The
55.In limits.h
56header has been standardized by at least three entities.
57.Ss ISO Limits
58The limits defined by the
59.St -isoC-99
60standard are all compile-time limits.
61The numerical (integer) limits are:
62.Bl -column -offset indent \
63"Constant   " "  Type             " "either SCHAR_MAX or UCHAR_MAX  "
64.It Sy "Constant" Ta Sy "Type" Ta Sy " Minimum value"
65.It Dv CHAR_BIT Ta Va char Ta " 8"
66.It Dv SCHAR_MAX Ta Va signed char Ta " 127"
67.It Dv SCHAR_MIN Ta Va signed char Ta "\-127"
68.It Dv UCHAR_MAX Ta Va unsigned char Ta " 255"
69.Pp
70.It Dv INT_MAX Ta Va int Ta " 32767"
71.It Dv INT_MIN Ta Va int Ta "\-32767"
72.It Dv UINT_MAX Ta Va unsigned int Ta " 65535"
73.Pp
74.It Dv SHRT_MIN Ta Va short Ta "\-32767"
75.It Dv SHRT_MAX Ta Va short Ta " 32767"
76.It Dv USHRT_MAX Ta Va unsigned short Ta " 65535"
77.Pp
78.It Dv LONG_MAX Ta Va long int Ta " 2147483647"
79.It Dv LONG_MIN Ta Va long int Ta "\-2147483647"
80.It Dv ULONG_MAX Ta Va unsigned long int Ta " 4294967295"
81.Pp
82.It Dv LLONG_MAX Ta Va long long int Ta " 9223372036854775807"
83.It Dv LLONG_MIN Ta Va long long int Ta "\-9223372036854775807"
84.It Dv ULLONG_MAX Ta Va unsigned long long int Ta " 18446744073709551615"
85.Pp
86.It Dv MB_LEN_MAX Ta - Ta 1
87.El
88.Pp
89All listed limits may vary across machines and operating systems.
90The standard guarantees only that the implementation-defined values are
91equal or greater in absolute value to those shown.
92The values permit a system with 16-bit integers
93using one's complement arithmetic.
94.Pp
95Depending whether the system defines
96.Va char
97as signed or unsigned, the maximum and minimum values are:
98.Bl -column -offset indent \
99"Constant   " "  Type             " "either SCHAR_MAX or UCHAR_MAX  "
100.It Sy "Constant" Ta Sy "Type" Ta Sy "Minimum value"
101.It Dv CHAR_MAX Ta Va char Ta either Dv SCHAR_MAX or Dv UCHAR_MAX
102.It Dv CHAR_MIN Ta Va char Ta either Dv SCHAR_MIN or 0
103.El
104.Pp
105The two special cases,
106.Dv CHAR_BIT
107and
108.Dv MB_LEN_MAX ,
109define the number of bits in
110.Va char
111and the maximum number of bytes in a multibyte character constant,
112respectively.
113.Ss POSIX Limits
114The
115.Dv POSIX.1
116standard specifies numerous limits related to the operating system.
117For each limit, a separate constant prefixed with
118.Dq Dv _POSIX_
119defines the
120.Em lowest
121value that the limit is allowed to have on
122.Em any
123.Tn POSIX
124compliant system.
125For instance,
126.Dv _POSIX_OPEN_MAX
127defines the minimum upper bound permitted by
128.Tn POSIX
129for the number of files that a single process may have open at any time.
130This ensures that a portable program can safely reach these limits without
131prior knowledge about the actual limits used in a particular system.
132.Pp
133As the limits are not necessary invariant,
134.Xr pathconf 2
135and
136.Xr sysconf 3
137should be used to determine the actual value of a limit at runtime.
138The manual pages of these two functions also contain a more detailed
139description of the limits available in
140.Nx .
141.Ss XSI Limits
142Also the X/Open System Interface Extension
143.Pq Dv XSI
144specifies few limits.
145In
146.Nx
147these are limited to
148.Dv LONG_BIT
149(the number of bits in
150.Vt long ) ,
151.Dv WORD_BIT
152(the number of bits in a
153.Dq word ) ,
154and few limits related to
155.Vt float
156and
157.Vt double .
158.Sh SEE ALSO
159.Xr getconf 1 ,
160.Xr pathconf 2 ,
161.Xr sysconf 3 ,
162.Xr types 3 ,
163.Xr unistd 3
164.Rs
165.%A Richard W. Stevens
166.%A Stephen A. Rago
167.%B Advanced Programming in the UNIX Environment
168.%V Second Edition
169.%D 2005
170.%I Addison-Wesley
171.Re
172