4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2019 Lauri Tirkkonen <lotheac@iki.fi>
24 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
26 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #ifndef _SYS_INT_LIMITS_H
31 #define _SYS_INT_LIMITS_H
34 * This file, <sys/int_limits.h>, is part of the Sun Microsystems implementation
35 * of <inttypes.h> as defined in the ISO C standard, ISO/IEC 9899:1999
36 * Programming language - C.
38 * Programs/Modules should not directly include this file. Access to the
39 * types defined in this file should be through the inclusion of one of the
42 * <limits.h> This nested inclusion is disabled for strictly
43 * ANSI-C conforming compilations. The *_MIN
44 * definitions are not visible to POSIX or XPG
45 * conforming applications (due to what may be
46 * a bug in the specification - this is under
49 * <sys/inttypes.h> Provides the Kernel and Driver appropriate
50 * components of <inttypes.h>.
52 * <inttypes.h> For use by applications.
54 * See these files for more details.
57 #include <sys/feature_tests.h>
62 * The following define the limits for the types defined in <sys/int_types.h>.
64 * INTMAX_MIN (minimum value of the largest supported signed integer type),
65 * INTMAX_MAX (maximum value of the largest supported signed integer type),
66 * and UINTMAX_MAX (maximum value of the largest supported unsigned integer
67 * type) can be set to implementation defined limits.
69 * NOTE : A programmer can test to see whether an implementation supports
70 * a particular size of integer by testing if the macro that gives the
71 * maximum for that datatype is defined. For example, if #ifdef UINT64_MAX
72 * tests false, the implementation does not support unsigned 64 bit integers.
74 * The type of these macros is intentionally unspecified.
76 * The types int8_t, int_least8_t, and int_fast8_t are not defined for ISAs
77 * where the ABI specifies "char" as unsigned when the translation mode is
80 #define INT8_MIN (-0x7f - 1)
81 #define INT16_MIN (-0x7fff - 1)
82 #define INT32_MIN (-0x7fffffff - 1)
83 #define INT64_MIN (-0x7fffffffffffffffLL - 1)
86 #define INT16_MAX 0x7fff
87 #define INT32_MAX 0x7fffffff
88 #define INT64_MAX 0x7fffffffffffffffLL
90 #define UINT8_MAX 0xff
91 #define UINT16_MAX 0xffff
92 #define UINT32_MAX 0xffffffffU
93 #define UINT64_MAX 0xffffffffffffffffULL
95 #define INT_LEAST8_MIN INT8_MIN
96 #define INT_LEAST16_MIN INT16_MIN
97 #define INT_LEAST32_MIN INT32_MIN
98 #define INT_LEAST64_MIN INT64_MIN
100 #define INT_LEAST8_MAX INT8_MAX
101 #define INT_LEAST16_MAX INT16_MAX
102 #define INT_LEAST32_MAX INT32_MAX
103 #define INT_LEAST64_MAX INT64_MAX
105 #define UINT_LEAST8_MAX UINT8_MAX
106 #define UINT_LEAST16_MAX UINT16_MAX
107 #define UINT_LEAST32_MAX UINT32_MAX
108 #define UINT_LEAST64_MAX UINT64_MAX
110 #define INT_FAST8_MIN INT8_MIN
111 #define INT_FAST16_MIN INT16_MIN
112 #define INT_FAST32_MIN INT32_MIN
113 #define INT_FAST64_MIN INT64_MIN
115 #define INT_FAST8_MAX INT8_MAX
116 #define INT_FAST16_MAX INT16_MAX
117 #define INT_FAST32_MAX INT32_MAX
118 #define INT_FAST64_MAX INT64_MAX
120 #define UINT_FAST8_MAX UINT8_MAX
121 #define UINT_FAST16_MAX UINT16_MAX
122 #define UINT_FAST32_MAX UINT32_MAX
123 #define UINT_FAST64_MAX UINT64_MAX
125 #define INTMAX_MIN INT64_MIN
126 #define INTMAX_MAX INT64_MAX
127 #define UINTMAX_MAX UINT64_MAX
129 #if defined(_LP64) || defined(_I32LPx)
130 #define INTPTR_MIN (-0x7fffffffffffffffL - 1)
131 #define INTPTR_MAX 0x7fffffffffffffffL
132 #define UINTPTR_MAX 0xffffffffffffffffUL
134 #define INTPTR_MIN (-0x7fffffffL - 1)
135 #define INTPTR_MAX 0x7fffffffL
136 #define UINTPTR_MAX 0xffffffffUL
140 * Maximum value of a "size_t". SIZE_MAX was previously defined
141 * in <limits.h>, however, the standards specify it be defined
142 * in <stdint.h>. The <stdint.h> headers includes this header as
143 * does <limits.h>. The value of SIZE_MAX should not deviate
144 * from the value of ULONG_MAX defined <sys/types.h>.
146 #define SIZE_MAX UINTPTR_MAX
148 /* Limits of ptrdiff_t defined in <sys/types.h> */
149 #define PTRDIFF_MIN INTPTR_MIN
150 #define PTRDIFF_MAX INTPTR_MAX
152 /* Limits of sig_atomic_t defined in <sys/types.h> */
153 #ifndef SIG_ATOMIC_MIN
154 #define SIG_ATOMIC_MIN INT32_MIN
156 #ifndef SIG_ATOMIC_MAX
157 #define SIG_ATOMIC_MAX INT32_MAX
161 * Limits of wchar_t. The WCHAR_* macros are also
162 * defined in <iso/wchar_iso.h>, but inclusion of that header
163 * will break ISO/IEC C namespace.
166 #define WCHAR_MIN INT32_MIN
169 #define WCHAR_MAX INT32_MAX
172 /* Limits of wint_t */
174 #define WINT_MIN INT32_MIN
177 #define WINT_MAX INT32_MAX
180 #endif /* _SYS_INT_LIMITS_H */