LIMITS(3)

πŸ“¦
version 11.0 Β· 2 versions
, in nixpkgs unstable

🌈 LIMITS(3) β€” limits: standard limits 🌈

okay bestie, this is the LIMITS(3) page from the Library Functions Manual, and she is literally here to explain standard limits. no cap. πŸ’…

πŸŽ€ NAME πŸŽ€

limits β€” standard limits. that's the whole vibe. ✨

✨ SYNOPSIS ✨

#include <limits.h>

πŸ’… DESCRIPTION πŸ’…

okay so the <limits.h> header defines various compile-time and runtime limits. these can be grouped into three categories:

  1. Compile-time limits defined in a header file.
  2. Runtime system limits that are not associated with a file or directory; see sysconf(3).
  3. Runtime limits that are associated with a file or directory; see pathconf(2).

the <limits.h> header has been standardized by at least three entities. iconic behavior fr fr. πŸ‘‘

🌸 ISO Limits 🌸

the limits defined by the ISO/IEC 9899:1999 (β€œISO C99”) standard are all compile-time limits. the numerical (integer) limits are:

Constant       Type                    Minimum value
CHAR_BIT       char                    8
SCHAR_MAX      signed char             127
SCHAR_MIN      signed char            -127
UCHAR_MAX      unsigned char           255

INT_MAX        int                     32767
INT_MIN        int                    -32767
UINT_MAX       unsigned int            65535

SHRT_MIN       short                  -32767
SHRT_MAX       short                   32767
USHRT_MAX      unsigned short          65535

LONG_MAX       long int                2147483647
LONG_MIN       long int               -2147483647
ULONG_MAX      unsigned long int       4294967295

LLONG_MAX      long long int           9223372036854775807
LLONG_MIN      long long int          -9223372036854775807
ULLONG_MAX     unsigned long long int  18446744073709551615

MB_LEN_MAX     -                      1

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. πŸ’€

depending whether the system defines char as signed or unsigned, the maximum and minimum values are:

Constant       Type                   Minimum value
CHAR_MAX       char                   either SCHAR_MAX or UCHAR_MAX
CHAR_MIN       char                   either SCHAR_MIN or 0

the two special cases, CHAR_BIT and MB_LEN_MAX, define the number of bits in char and the maximum number of bytes in a multibyte character constant, respectively. 🫢

πŸ’– POSIX Limits πŸ’–

the POSIX.1 standard specifies numerous limits related to the operating system. for each limit, a separate constant prefixed with _POSIX_ defines the lowest value that the limit is allowed to have on any POSIX compliant system. for instance, _POSIX_OPEN_MAX defines the minimum upper bound permitted by 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. πŸ’–

as the limits aren't necessarily invariant, pathconf(2) and 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 NetBSD. πŸ¦‹

πŸ¦‹ XSI Limits πŸ¦‹

also the X/Open System Interface Extension (XSI) specifies few limits. in NetBSD these are limited to LONG_BIT (the number of bits in long), WORD_BIT (the number of bits in a β€œword”), and few limits related to float and double. 🌈

πŸ”₯ SEE ALSO πŸ”₯

Richard W. Stevens and Stephen A. Rago, Advanced Programming in the UNIX Environment, Addison-Wesley, Second Edition, 2005. πŸ“š


mwah πŸ’‹ this cutie was served to you by Debian, dated August 9, 2011, and it's the LIMITS(3) page. periodt. πŸŽ€

πŸ“¦ where this page comes from