3 *
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
7 * with the License.
8 *
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.
13 *
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]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _SYS_INT_LIMITS_H
28 #define _SYS_INT_LIMITS_H
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 /*
33 * This file, <sys/int_limits.h>, is part of the Sun Microsystems implementation
34 * of <inttypes.h> as defined in the ISO C standard, ISO/IEC 9899:1999
35 * Programming language - C.
36 *
37 * Programs/Modules should not directly include this file. Access to the
38 * types defined in this file should be through the inclusion of one of the
39 * following files:
40 *
41 * <limits.h> This nested inclusion is disabled for strictly
42 * ANSI-C conforming compilations. The *_MIN
43 * definitions are not visible to POSIX or XPG
44 * conforming applications (due to what may be
45 * a bug in the specification - this is under
46 * investigation)
47 *
48 * <sys/inttypes.h> Provides the Kernel and Driver appropriate
49 * components of <inttypes.h>.
50 *
51 * <inttypes.h> For use by applications.
63 * Limits
64 *
65 * The following define the limits for the types defined in <sys/int_types.h>.
66 *
67 * INTMAX_MIN (minimum value of the largest supported signed integer type),
68 * INTMAX_MAX (maximum value of the largest supported signed integer type),
69 * and UINTMAX_MAX (maximum value of the largest supported unsigned integer
70 * type) can be set to implementation defined limits.
71 *
72 * NOTE : A programmer can test to see whether an implementation supports
73 * a particular size of integer by testing if the macro that gives the
74 * maximum for that datatype is defined. For example, if #ifdef UINT64_MAX
75 * tests false, the implementation does not support unsigned 64 bit integers.
76 *
77 * The type of these macros is intentionally unspecified.
78 *
79 * The types int8_t, int_least8_t, and int_fast8_t are not defined for ISAs
80 * where the ABI specifies "char" as unsigned when the translation mode is
81 * not ANSI-C.
82 */
83 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
84 #define INT8_MAX (127)
85 #endif
86 #define INT16_MAX (32767)
87 #define INT32_MAX (2147483647)
88 #if defined(_LP64)
89 #define INT64_MAX (9223372036854775807L)
90 #elif defined(_LONGLONG_TYPE)
91 #define INT64_MAX (9223372036854775807LL)
92 #endif
93
94 #define UINT8_MAX (255U)
95 #define UINT16_MAX (65535U)
96 #define UINT32_MAX (4294967295U)
97 #if defined(_LP64)
98 #define UINT64_MAX (18446744073709551615UL)
99 #elif defined(_LONGLONG_TYPE)
100 #define UINT64_MAX (18446744073709551615ULL)
101 #endif
102
103 #ifdef INT64_MAX
104 #define INTMAX_MAX INT64_MAX
105 #else
106 #define INTMAX_MAX INT32_MAX
107 #endif
108
109 #ifdef UINT64_MAX
110 #define UINTMAX_MAX UINT64_MAX
111 #else
112 #define UINTMAX_MAX UINT32_MAX
113 #endif
114
115 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
116 #define INT_LEAST8_MAX INT8_MAX
117 #endif
118 #define INT_LEAST16_MAX INT16_MAX
119 #define INT_LEAST32_MAX INT32_MAX
120 #ifdef INT64_MAX
121 #define INT_LEAST64_MAX INT64_MAX
122 #endif
123
124 #define UINT_LEAST8_MAX UINT8_MAX
125 #define UINT_LEAST16_MAX UINT16_MAX
126 #define UINT_LEAST32_MAX UINT32_MAX
127 #ifdef UINT64_MAX
128 #define UINT_LEAST64_MAX UINT64_MAX
129 #endif
130
131 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
132 #define INT_FAST8_MAX INT8_MAX
133 #endif
134 #define INT_FAST16_MAX INT16_MAX
135 #define INT_FAST32_MAX INT32_MAX
136 #ifdef INT64_MAX
137 #define INT_FAST64_MAX INT64_MAX
138 #endif
139
140 #define UINT_FAST8_MAX UINT8_MAX
141 #define UINT_FAST16_MAX UINT16_MAX
142 #define UINT_FAST32_MAX UINT32_MAX
143 #ifdef UINT64_MAX
144 #define UINT_FAST64_MAX UINT64_MAX
145 #endif
146
147 /*
148 * The following 2 macros are provided for testing whether the types
149 * intptr_t and uintptr_t (integers large enough to hold a void *) are
150 * defined in this header. They are needed in case the architecture can't
151 * represent a pointer in any standard integral type.
152 */
153 #if defined(_LP64) || defined(_I32LPx)
187 * Maximum limit of wchar_t. The WCHAR_* macros are also
188 * defined in <iso/wchar_iso.h>, but inclusion of that header
189 * will break ISO/IEC C namespace.
190 */
191 #ifndef WCHAR_MAX
192 #define WCHAR_MAX 2147483647
193 #endif
194
195 /* Maximum limit of wint_t */
196 #ifndef WINT_MAX
197 #define WINT_MAX 2147483647
198 #endif
199
200 /*
201 * It is probably a bug in the POSIX specification (IEEE-1003.1-1990) that
202 * when including <limits.h> that the suffix _MAX is reserved but not the
203 * suffix _MIN. However, until that issue is resolved....
204 */
205 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG6)
206
207 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
208 #define INT8_MIN (-128)
209 #endif
210 #define INT16_MIN (-32767-1)
211 #define INT32_MIN (-2147483647-1)
212 #if defined(_LP64)
213 #define INT64_MIN (-9223372036854775807L-1)
214 #elif defined(_LONGLONG_TYPE)
215 #define INT64_MIN (-9223372036854775807LL-1)
216 #endif
217
218 #ifdef INT64_MIN
219 #define INTMAX_MIN INT64_MIN
220 #else
221 #define INTMAX_MIN INT32_MIN
222 #endif
223
224 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
225 #define INT_LEAST8_MIN INT8_MIN
226 #endif
227 #define INT_LEAST16_MIN INT16_MIN
228 #define INT_LEAST32_MIN INT32_MIN
229 #ifdef INT64_MIN
230 #define INT_LEAST64_MIN INT64_MIN
231 #endif
232
233 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
234 #define INT_FAST8_MIN INT8_MIN
235 #endif
236 #define INT_FAST16_MIN INT16_MIN
237 #define INT_FAST32_MIN INT32_MIN
238 #ifdef INT64_MIN
239 #define INT_FAST64_MIN INT64_MIN
240 #endif
241
242 /* Minimum value of a pointer-holding signed integer type */
243 #if defined(_LP64) || defined(_I32LPx)
244 #define INTPTR_MIN INT64_MIN
245 #else
246 #define INTPTR_MIN INT32_MIN
247 #endif
248
249 /* Minimum limits of ptrdiff_t defined in <sys/types.h> */
250 #if defined(_LP64) || defined(_I32LPx)
251 #define PTRDIFF_MIN (-9223372036854775807L-1L)
252 #else
253 #define PTRDIFF_MIN (-2147483647-1)
254 #endif
255
|
3 *
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
7 * with the License.
8 *
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.
13 *
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]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 *
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29 #ifndef _SYS_INT_LIMITS_H
30 #define _SYS_INT_LIMITS_H
31
32 /*
33 * This file, <sys/int_limits.h>, is part of the Sun Microsystems implementation
34 * of <inttypes.h> as defined in the ISO C standard, ISO/IEC 9899:1999
35 * Programming language - C.
36 *
37 * Programs/Modules should not directly include this file. Access to the
38 * types defined in this file should be through the inclusion of one of the
39 * following files:
40 *
41 * <limits.h> This nested inclusion is disabled for strictly
42 * ANSI-C conforming compilations. The *_MIN
43 * definitions are not visible to POSIX or XPG
44 * conforming applications (due to what may be
45 * a bug in the specification - this is under
46 * investigation)
47 *
48 * <sys/inttypes.h> Provides the Kernel and Driver appropriate
49 * components of <inttypes.h>.
50 *
51 * <inttypes.h> For use by applications.
63 * Limits
64 *
65 * The following define the limits for the types defined in <sys/int_types.h>.
66 *
67 * INTMAX_MIN (minimum value of the largest supported signed integer type),
68 * INTMAX_MAX (maximum value of the largest supported signed integer type),
69 * and UINTMAX_MAX (maximum value of the largest supported unsigned integer
70 * type) can be set to implementation defined limits.
71 *
72 * NOTE : A programmer can test to see whether an implementation supports
73 * a particular size of integer by testing if the macro that gives the
74 * maximum for that datatype is defined. For example, if #ifdef UINT64_MAX
75 * tests false, the implementation does not support unsigned 64 bit integers.
76 *
77 * The type of these macros is intentionally unspecified.
78 *
79 * The types int8_t, int_least8_t, and int_fast8_t are not defined for ISAs
80 * where the ABI specifies "char" as unsigned when the translation mode is
81 * not ANSI-C.
82 */
83 #define INT8_MAX (127)
84 #define INT16_MAX (32767)
85 #define INT32_MAX (2147483647)
86 #if defined(_LP64)
87 #define INT64_MAX (9223372036854775807L)
88 #elif defined(_LONGLONG_TYPE)
89 #define INT64_MAX (9223372036854775807LL)
90 #endif
91
92 #define UINT8_MAX (255U)
93 #define UINT16_MAX (65535U)
94 #define UINT32_MAX (4294967295U)
95 #if defined(_LP64)
96 #define UINT64_MAX (18446744073709551615UL)
97 #elif defined(_LONGLONG_TYPE)
98 #define UINT64_MAX (18446744073709551615ULL)
99 #endif
100
101 #ifdef INT64_MAX
102 #define INTMAX_MAX INT64_MAX
103 #else
104 #define INTMAX_MAX INT32_MAX
105 #endif
106
107 #ifdef UINT64_MAX
108 #define UINTMAX_MAX UINT64_MAX
109 #else
110 #define UINTMAX_MAX UINT32_MAX
111 #endif
112
113 #define INT_LEAST8_MAX INT8_MAX
114 #define INT_LEAST16_MAX INT16_MAX
115 #define INT_LEAST32_MAX INT32_MAX
116 #ifdef INT64_MAX
117 #define INT_LEAST64_MAX INT64_MAX
118 #endif
119
120 #define UINT_LEAST8_MAX UINT8_MAX
121 #define UINT_LEAST16_MAX UINT16_MAX
122 #define UINT_LEAST32_MAX UINT32_MAX
123 #ifdef UINT64_MAX
124 #define UINT_LEAST64_MAX UINT64_MAX
125 #endif
126
127 #define INT_FAST8_MAX INT8_MAX
128 #define INT_FAST16_MAX INT16_MAX
129 #define INT_FAST32_MAX INT32_MAX
130 #ifdef INT64_MAX
131 #define INT_FAST64_MAX INT64_MAX
132 #endif
133
134 #define UINT_FAST8_MAX UINT8_MAX
135 #define UINT_FAST16_MAX UINT16_MAX
136 #define UINT_FAST32_MAX UINT32_MAX
137 #ifdef UINT64_MAX
138 #define UINT_FAST64_MAX UINT64_MAX
139 #endif
140
141 /*
142 * The following 2 macros are provided for testing whether the types
143 * intptr_t and uintptr_t (integers large enough to hold a void *) are
144 * defined in this header. They are needed in case the architecture can't
145 * represent a pointer in any standard integral type.
146 */
147 #if defined(_LP64) || defined(_I32LPx)
181 * Maximum limit of wchar_t. The WCHAR_* macros are also
182 * defined in <iso/wchar_iso.h>, but inclusion of that header
183 * will break ISO/IEC C namespace.
184 */
185 #ifndef WCHAR_MAX
186 #define WCHAR_MAX 2147483647
187 #endif
188
189 /* Maximum limit of wint_t */
190 #ifndef WINT_MAX
191 #define WINT_MAX 2147483647
192 #endif
193
194 /*
195 * It is probably a bug in the POSIX specification (IEEE-1003.1-1990) that
196 * when including <limits.h> that the suffix _MAX is reserved but not the
197 * suffix _MIN. However, until that issue is resolved....
198 */
199 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG6)
200
201 #define INT8_MIN (-128)
202 #define INT16_MIN (-32767-1)
203 #define INT32_MIN (-2147483647-1)
204 #if defined(_LP64)
205 #define INT64_MIN (-9223372036854775807L-1)
206 #elif defined(_LONGLONG_TYPE)
207 #define INT64_MIN (-9223372036854775807LL-1)
208 #endif
209
210 #ifdef INT64_MIN
211 #define INTMAX_MIN INT64_MIN
212 #else
213 #define INTMAX_MIN INT32_MIN
214 #endif
215
216 #define INT_LEAST8_MIN INT8_MIN
217 #define INT_LEAST16_MIN INT16_MIN
218 #define INT_LEAST32_MIN INT32_MIN
219 #ifdef INT64_MIN
220 #define INT_LEAST64_MIN INT64_MIN
221 #endif
222
223 #define INT_FAST8_MIN INT8_MIN
224 #define INT_FAST16_MIN INT16_MIN
225 #define INT_FAST32_MIN INT32_MIN
226 #ifdef INT64_MIN
227 #define INT_FAST64_MIN INT64_MIN
228 #endif
229
230 /* Minimum value of a pointer-holding signed integer type */
231 #if defined(_LP64) || defined(_I32LPx)
232 #define INTPTR_MIN INT64_MIN
233 #else
234 #define INTPTR_MIN INT32_MIN
235 #endif
236
237 /* Minimum limits of ptrdiff_t defined in <sys/types.h> */
238 #if defined(_LP64) || defined(_I32LPx)
239 #define PTRDIFF_MIN (-9223372036854775807L-1L)
240 #else
241 #define PTRDIFF_MIN (-2147483647-1)
242 #endif
243
|