Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

.\" $NetBSD: limits.3,v 1.2 2011/08/29 16:56:32 njoly Exp $
.\"
.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jukka Ruohonen.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 9, 2011
.Dt LIMITS 3
.Os
.Sh NAME
.Nm limits
.Nd standard limits
.Sh SYNOPSIS
.In limits.h
.Sh DESCRIPTION
The
.In limits.h
header defines various compile-time and runtime limits.
These can be grouped into three categories:
.Bl -enum -offset indent
.It
Compile-time limits defined in a header file.
.It
Runtime system limits that are not associated with a file or directory; see
.Xr sysconf 3 .
.It
Runtime limits that are associated with a file or directory; see
.Xr pathconf 2 .
.El
.Pp
The
.In limits.h
header has been standardized by at least three entities.
.Ss ISO Limits
The limits defined by the
.St -isoC-99
standard are all compile-time limits.
The numerical (integer) limits are:
.Bl -column -offset indent \
"Constant   " "  Type             " "either SCHAR_MAX or UCHAR_MAX  "
.It Sy "Constant" Ta Sy "Type" Ta Sy " Minimum value"
.It Dv CHAR_BIT Ta Va char Ta " 8"
.It Dv SCHAR_MAX Ta Va signed char Ta " 127"
.It Dv SCHAR_MIN Ta Va signed char Ta "\-127"
.It Dv UCHAR_MAX Ta Va unsigned char Ta " 255"
.Pp
.It Dv INT_MAX Ta Va int Ta " 32767"
.It Dv INT_MIN Ta Va int Ta "\-32767"
.It Dv UINT_MAX Ta Va unsigned int Ta " 65535"
.Pp
.It Dv SHRT_MIN Ta Va short Ta "\-32767"
.It Dv SHRT_MAX Ta Va short Ta " 32767"
.It Dv USHRT_MAX Ta Va unsigned short Ta " 65535"
.Pp
.It Dv LONG_MAX Ta Va long int Ta " 2147483647"
.It Dv LONG_MIN Ta Va long int Ta "\-2147483647"
.It Dv ULONG_MAX Ta Va unsigned long int Ta " 4294967295"
.Pp
.It Dv LLONG_MAX Ta Va long long int Ta " 9223372036854775807"
.It Dv LLONG_MIN Ta Va long long int Ta "\-9223372036854775807"
.It Dv ULLONG_MAX Ta Va unsigned long long int Ta " 18446744073709551615"
.Pp
.It Dv MB_LEN_MAX Ta - Ta 1
.El
.Pp
All listed limits may vary across machines and operating systems.
The standard guarantees only that the implementation-defined values are
equal or greater in absolute value to those shown.
The values permit a system with 16-bit integers
using one's complement arithmetic.
.Pp
Depending whether the system defines
.Va char
as signed or unsigned, the maximum and minimum values are:
.Bl -column -offset indent \
"Constant   " "  Type             " "either SCHAR_MAX or UCHAR_MAX  "
.It Sy "Constant" Ta Sy "Type" Ta Sy "Minimum value"
.It Dv CHAR_MAX Ta Va char Ta either Dv SCHAR_MAX or Dv UCHAR_MAX
.It Dv CHAR_MIN Ta Va char Ta either Dv SCHAR_MIN or 0
.El
.Pp
The two special cases,
.Dv CHAR_BIT
and
.Dv MB_LEN_MAX ,
define the number of bits in
.Va char
and the maximum number of bytes in a multibyte character constant,
respectively.
.Ss POSIX Limits
The
.Dv POSIX.1
standard specifies numerous limits related to the operating system.
For each limit, a separate constant prefixed with
.Dq Dv _POSIX_
defines the
.Em lowest
value that the limit is allowed to have on
.Em any
.Tn POSIX
compliant system.
For instance,
.Dv _POSIX_OPEN_MAX
defines the minimum upper bound permitted by
.Tn POSIX
for the number of files that a single process may have open at any time.
This ensures that a portable program can safely reach these limits without
prior knowledge about the actual limits used in a particular system.
.Pp
As the limits are not necessary invariant,
.Xr pathconf 2
and
.Xr sysconf 3
should be used to determine the actual value of a limit at runtime.
The manual pages of these two functions also contain a more detailed
description of the limits available in
.Nx .
.Ss XSI Limits
Also the X/Open System Interface Extension
.Pq Dv XSI
specifies few limits.
In
.Nx
these are limited to
.Dv LONG_BIT
(the number of bits in
.Vt long ) ,
.Dv WORD_BIT
(the number of bits in a
.Dq word ) ,
and few limits related to
.Vt float
and
.Vt double .
.Sh SEE ALSO
.Xr getconf 1 ,
.Xr pathconf 2 ,
.Xr sysconf 3 ,
.Xr types 3 ,
.Xr unistd 3
.Rs
.%A Richard W. Stevens
.%A Stephen A. Rago
.%B Advanced Programming in the UNIX Environment
.%V Second Edition
.%D 2005
.%I Addison-Wesley
.Re