Commit | Line | Data |
---|---|---|
5e8754f9 | 1 | /* Copyright (C) 2001-2002, 2004-2016 Free Software Foundation, Inc. |
f6ea5628 DJ |
2 | Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. |
3 | This file is part of gnulib. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
4c38e0a4 | 7 | the Free Software Foundation; either version 3, or (at your option) |
f6ea5628 DJ |
8 | any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
5e8754f9 | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
f6ea5628 DJ |
17 | |
18 | /* | |
19 | * ISO C 99 <stdint.h> for platforms that lack it. | |
20 | * <http://www.opengroup.org/susv3xbd/stdint.h.html> | |
21 | */ | |
22 | ||
770d76d7 | 23 | #ifndef _@GUARD_PREFIX@_STDINT_H |
f6ea5628 | 24 | |
f434ba03 PA |
25 | #if __GNUC__ >= 3 |
26 | @PRAGMA_SYSTEM_HEADER@ | |
27 | #endif | |
770d76d7 | 28 | @PRAGMA_COLUMNS@ |
f434ba03 | 29 | |
f6ea5628 DJ |
30 | /* When including a system file that in turn includes <inttypes.h>, |
31 | use the system <inttypes.h>, not our substitute. This avoids | |
32 | problems with (for example) VMS, whose <sys/bitypes.h> includes | |
33 | <inttypes.h>. */ | |
34 | #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H | |
35 | ||
770d76d7 PA |
36 | /* On Android (Bionic libc), <sys/types.h> includes this file before |
37 | having defined 'time_t'. Therefore in this case avoid including | |
38 | other system header files; just include the system's <stdint.h>. | |
39 | Ideally we should test __BIONIC__ here, but it is only defined after | |
40 | <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */ | |
4a626d0a | 41 | #if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H |
770d76d7 PA |
42 | # @INCLUDE_NEXT@ @NEXT_STDINT_H@ |
43 | #else | |
44 | ||
f6ea5628 DJ |
45 | /* Get those types that are already defined in other system include |
46 | files, so that we can "#define int8_t signed char" below without | |
47 | worrying about a later system include file containing a "typedef | |
48 | signed char int8_t;" that will get messed up by our macro. Our | |
49 | macros should all be consistent with the system versions, except | |
50 | for the "fast" types and macros, which we recommend against using | |
51 | in public interfaces due to compiler differences. */ | |
52 | ||
53 | #if @HAVE_STDINT_H@ | |
54 | # if defined __sgi && ! defined __c99 | |
55 | /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users | |
56 | with "This header file is to be used only for c99 mode compilations" | |
57 | diagnostics. */ | |
58 | # define __STDINT_H__ | |
59 | # endif | |
770d76d7 PA |
60 | |
61 | /* Some pre-C++11 <stdint.h> implementations need this. */ | |
62 | # ifdef __cplusplus | |
63 | # ifndef __STDC_CONSTANT_MACROS | |
64 | # define __STDC_CONSTANT_MACROS 1 | |
65 | # endif | |
66 | # ifndef __STDC_LIMIT_MACROS | |
67 | # define __STDC_LIMIT_MACROS 1 | |
68 | # endif | |
69 | # endif | |
70 | ||
f6ea5628 DJ |
71 | /* Other systems may have an incomplete or buggy <stdint.h>. |
72 | Include it before <inttypes.h>, since any "#include <stdint.h>" | |
73 | in <inttypes.h> would reinclude us, skipping our contents because | |
770d76d7 | 74 | _@GUARD_PREFIX@_STDINT_H is defined. |
f6ea5628 DJ |
75 | The include_next requires a split double-inclusion guard. */ |
76 | # @INCLUDE_NEXT@ @NEXT_STDINT_H@ | |
77 | #endif | |
78 | ||
770d76d7 PA |
79 | #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H |
80 | #define _@GUARD_PREFIX@_STDINT_H | |
f6ea5628 | 81 | |
49e4877c PA |
82 | /* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, |
83 | LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ | |
84 | #include <limits.h> | |
85 | ||
86 | #if ! @HAVE_C99_STDINT_H@ | |
87 | ||
f6ea5628 DJ |
88 | /* <sys/types.h> defines some of the stdint.h types as well, on glibc, |
89 | IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). | |
90 | AIX 5.2 <sys/types.h> isn't needed and causes troubles. | |
40a73391 | 91 | Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but |
f6ea5628 DJ |
92 | relies on the system <stdint.h> definitions, so include |
93 | <sys/types.h> after @NEXT_STDINT_H@. */ | |
49e4877c PA |
94 | # if @HAVE_SYS_TYPES_H@ && ! defined _AIX |
95 | # include <sys/types.h> | |
96 | # endif | |
f6ea5628 | 97 | |
49e4877c | 98 | # if @HAVE_INTTYPES_H@ |
f6ea5628 DJ |
99 | /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines |
100 | int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. | |
101 | <inttypes.h> also defines intptr_t and uintptr_t. */ | |
49e4877c PA |
102 | # include <inttypes.h> |
103 | # elif @HAVE_SYS_INTTYPES_H@ | |
f6ea5628 DJ |
104 | /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and |
105 | the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ | |
49e4877c PA |
106 | # include <sys/inttypes.h> |
107 | # endif | |
f6ea5628 | 108 | |
49e4877c | 109 | # if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ |
f6ea5628 DJ |
110 | /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines |
111 | int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is | |
112 | included by <sys/types.h>. */ | |
49e4877c PA |
113 | # include <sys/bitypes.h> |
114 | # endif | |
f6ea5628 | 115 | |
49e4877c | 116 | # undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H |
f6ea5628 | 117 | |
770d76d7 | 118 | /* Minimum and maximum values for an integer type under the usual assumption. |
f6ea5628 DJ |
119 | Return an unspecified value if BITS == 0, adding a check to pacify |
120 | picky compilers. */ | |
121 | ||
5e8754f9 SDJ |
122 | # define _STDINT_MIN(signed, bits, zero) \ |
123 | ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero)) | |
f6ea5628 | 124 | |
49e4877c PA |
125 | # define _STDINT_MAX(signed, bits, zero) \ |
126 | (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) | |
f6ea5628 | 127 | |
770d76d7 PA |
128 | #if !GNULIB_defined_stdint_types |
129 | ||
f6ea5628 DJ |
130 | /* 7.18.1.1. Exact-width integer types */ |
131 | ||
132 | /* Here we assume a standard architecture where the hardware integer | |
133 | types have 8, 16, 32, optionally 64 bits. */ | |
134 | ||
49e4877c PA |
135 | # undef int8_t |
136 | # undef uint8_t | |
f434ba03 PA |
137 | typedef signed char gl_int8_t; |
138 | typedef unsigned char gl_uint8_t; | |
49e4877c PA |
139 | # define int8_t gl_int8_t |
140 | # define uint8_t gl_uint8_t | |
f6ea5628 | 141 | |
49e4877c PA |
142 | # undef int16_t |
143 | # undef uint16_t | |
f434ba03 PA |
144 | typedef short int gl_int16_t; |
145 | typedef unsigned short int gl_uint16_t; | |
49e4877c PA |
146 | # define int16_t gl_int16_t |
147 | # define uint16_t gl_uint16_t | |
f6ea5628 | 148 | |
49e4877c PA |
149 | # undef int32_t |
150 | # undef uint32_t | |
f434ba03 PA |
151 | typedef int gl_int32_t; |
152 | typedef unsigned int gl_uint32_t; | |
49e4877c PA |
153 | # define int32_t gl_int32_t |
154 | # define uint32_t gl_uint32_t | |
f6ea5628 | 155 | |
770d76d7 PA |
156 | /* If the system defines INT64_MAX, assume int64_t works. That way, |
157 | if the underlying platform defines int64_t to be a 64-bit long long | |
158 | int, the code below won't mistakenly define it to be a 64-bit long | |
159 | int, which would mess up C++ name mangling. We must use #ifdef | |
160 | rather than #if, to avoid an error with HP-UX 10.20 cc. */ | |
161 | ||
49e4877c PA |
162 | # ifdef INT64_MAX |
163 | # define GL_INT64_T | |
164 | # else | |
f6ea5628 DJ |
165 | /* Do not undefine int64_t if gnulib is not being used with 64-bit |
166 | types, since otherwise it breaks platforms like Tandem/NSK. */ | |
49e4877c PA |
167 | # if LONG_MAX >> 31 >> 31 == 1 |
168 | # undef int64_t | |
f434ba03 | 169 | typedef long int gl_int64_t; |
49e4877c PA |
170 | # define int64_t gl_int64_t |
171 | # define GL_INT64_T | |
172 | # elif defined _MSC_VER | |
173 | # undef int64_t | |
f434ba03 | 174 | typedef __int64 gl_int64_t; |
49e4877c PA |
175 | # define int64_t gl_int64_t |
176 | # define GL_INT64_T | |
177 | # elif @HAVE_LONG_LONG_INT@ | |
178 | # undef int64_t | |
f434ba03 | 179 | typedef long long int gl_int64_t; |
49e4877c PA |
180 | # define int64_t gl_int64_t |
181 | # define GL_INT64_T | |
182 | # endif | |
770d76d7 | 183 | # endif |
f6ea5628 | 184 | |
49e4877c | 185 | # ifdef UINT64_MAX |
770d76d7 | 186 | # define GL_UINT64_T |
49e4877c PA |
187 | # else |
188 | # if ULONG_MAX >> 31 >> 31 >> 1 == 1 | |
189 | # undef uint64_t | |
190 | typedef unsigned long int gl_uint64_t; | |
191 | # define uint64_t gl_uint64_t | |
192 | # define GL_UINT64_T | |
193 | # elif defined _MSC_VER | |
194 | # undef uint64_t | |
f434ba03 | 195 | typedef unsigned __int64 gl_uint64_t; |
49e4877c PA |
196 | # define uint64_t gl_uint64_t |
197 | # define GL_UINT64_T | |
198 | # elif @HAVE_UNSIGNED_LONG_LONG_INT@ | |
199 | # undef uint64_t | |
f434ba03 | 200 | typedef unsigned long long int gl_uint64_t; |
49e4877c PA |
201 | # define uint64_t gl_uint64_t |
202 | # define GL_UINT64_T | |
203 | # endif | |
770d76d7 | 204 | # endif |
f6ea5628 DJ |
205 | |
206 | /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ | |
49e4877c PA |
207 | # define _UINT8_T |
208 | # define _UINT32_T | |
209 | # define _UINT64_T | |
f6ea5628 DJ |
210 | |
211 | ||
212 | /* 7.18.1.2. Minimum-width integer types */ | |
213 | ||
214 | /* Here we assume a standard architecture where the hardware integer | |
215 | types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types | |
216 | are the same as the corresponding N_t types. */ | |
217 | ||
49e4877c PA |
218 | # undef int_least8_t |
219 | # undef uint_least8_t | |
220 | # undef int_least16_t | |
221 | # undef uint_least16_t | |
222 | # undef int_least32_t | |
223 | # undef uint_least32_t | |
224 | # undef int_least64_t | |
225 | # undef uint_least64_t | |
226 | # define int_least8_t int8_t | |
227 | # define uint_least8_t uint8_t | |
228 | # define int_least16_t int16_t | |
229 | # define uint_least16_t uint16_t | |
230 | # define int_least32_t int32_t | |
231 | # define uint_least32_t uint32_t | |
232 | # ifdef GL_INT64_T | |
233 | # define int_least64_t int64_t | |
234 | # endif | |
235 | # ifdef GL_UINT64_T | |
236 | # define uint_least64_t uint64_t | |
237 | # endif | |
f6ea5628 DJ |
238 | |
239 | /* 7.18.1.3. Fastest minimum-width integer types */ | |
240 | ||
241 | /* Note: Other <stdint.h> substitutes may define these types differently. | |
242 | It is not recommended to use these types in public header files. */ | |
243 | ||
244 | /* Here we assume a standard architecture where the hardware integer | |
245 | types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types | |
40a73391 JK |
246 | are taken from the same list of types. The following code normally |
247 | uses types consistent with glibc, as that lessens the chance of | |
248 | incompatibility with older GNU hosts. */ | |
f6ea5628 | 249 | |
49e4877c PA |
250 | # undef int_fast8_t |
251 | # undef uint_fast8_t | |
252 | # undef int_fast16_t | |
253 | # undef uint_fast16_t | |
254 | # undef int_fast32_t | |
255 | # undef uint_fast32_t | |
256 | # undef int_fast64_t | |
257 | # undef uint_fast64_t | |
40a73391 JK |
258 | typedef signed char gl_int_fast8_t; |
259 | typedef unsigned char gl_uint_fast8_t; | |
260 | ||
49e4877c | 261 | # ifdef __sun |
40a73391 JK |
262 | /* Define types compatible with SunOS 5.10, so that code compiled under |
263 | earlier SunOS versions works with code compiled under SunOS 5.10. */ | |
264 | typedef int gl_int_fast32_t; | |
265 | typedef unsigned int gl_uint_fast32_t; | |
49e4877c | 266 | # else |
f434ba03 PA |
267 | typedef long int gl_int_fast32_t; |
268 | typedef unsigned long int gl_uint_fast32_t; | |
49e4877c | 269 | # endif |
40a73391 JK |
270 | typedef gl_int_fast32_t gl_int_fast16_t; |
271 | typedef gl_uint_fast32_t gl_uint_fast16_t; | |
272 | ||
49e4877c PA |
273 | # define int_fast8_t gl_int_fast8_t |
274 | # define uint_fast8_t gl_uint_fast8_t | |
275 | # define int_fast16_t gl_int_fast16_t | |
276 | # define uint_fast16_t gl_uint_fast16_t | |
277 | # define int_fast32_t gl_int_fast32_t | |
278 | # define uint_fast32_t gl_uint_fast32_t | |
279 | # ifdef GL_INT64_T | |
280 | # define int_fast64_t int64_t | |
281 | # endif | |
282 | # ifdef GL_UINT64_T | |
283 | # define uint_fast64_t uint64_t | |
284 | # endif | |
f6ea5628 DJ |
285 | |
286 | /* 7.18.1.4. Integer types capable of holding object pointers */ | |
287 | ||
49e4877c PA |
288 | /* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own |
289 | definitions of intptr_t and uintptr_t (which use int and unsigned) | |
290 | to avoid clashes with declarations of system functions like sbrk. */ | |
291 | # ifndef _INTPTR_T_DECLARED | |
292 | # undef intptr_t | |
293 | # undef uintptr_t | |
f434ba03 PA |
294 | typedef long int gl_intptr_t; |
295 | typedef unsigned long int gl_uintptr_t; | |
49e4877c PA |
296 | # define intptr_t gl_intptr_t |
297 | # define uintptr_t gl_uintptr_t | |
298 | # endif | |
f6ea5628 DJ |
299 | |
300 | /* 7.18.1.5. Greatest-width integer types */ | |
301 | ||
302 | /* Note: These types are compiler dependent. It may be unwise to use them in | |
303 | public header files. */ | |
304 | ||
770d76d7 PA |
305 | /* If the system defines INTMAX_MAX, assume that intmax_t works, and |
306 | similarly for UINTMAX_MAX and uintmax_t. This avoids problems with | |
307 | assuming one type where another is used by the system. */ | |
308 | ||
49e4877c PA |
309 | # ifndef INTMAX_MAX |
310 | # undef INTMAX_C | |
311 | # undef intmax_t | |
312 | # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | |
f434ba03 | 313 | typedef long long int gl_intmax_t; |
49e4877c PA |
314 | # define intmax_t gl_intmax_t |
315 | # elif defined GL_INT64_T | |
316 | # define intmax_t int64_t | |
317 | # else | |
f434ba03 | 318 | typedef long int gl_intmax_t; |
49e4877c PA |
319 | # define intmax_t gl_intmax_t |
320 | # endif | |
770d76d7 | 321 | # endif |
f6ea5628 | 322 | |
49e4877c PA |
323 | # ifndef UINTMAX_MAX |
324 | # undef UINTMAX_C | |
325 | # undef uintmax_t | |
326 | # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | |
f434ba03 | 327 | typedef unsigned long long int gl_uintmax_t; |
49e4877c PA |
328 | # define uintmax_t gl_uintmax_t |
329 | # elif defined GL_UINT64_T | |
330 | # define uintmax_t uint64_t | |
331 | # else | |
f434ba03 | 332 | typedef unsigned long int gl_uintmax_t; |
49e4877c PA |
333 | # define uintmax_t gl_uintmax_t |
334 | # endif | |
770d76d7 | 335 | # endif |
f6ea5628 DJ |
336 | |
337 | /* Verify that intmax_t and uintmax_t have the same size. Too much code | |
338 | breaks if this is not the case. If this check fails, the reason is likely | |
339 | to be found in the autoconf macros. */ | |
770d76d7 PA |
340 | typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) |
341 | ? 1 : -1]; | |
f6ea5628 | 342 | |
49e4877c PA |
343 | # define GNULIB_defined_stdint_types 1 |
344 | # endif /* !GNULIB_defined_stdint_types */ | |
f6ea5628 | 345 | |
770d76d7 | 346 | /* 7.18.2. Limits of specified-width integer types */ |
f6ea5628 DJ |
347 | |
348 | /* 7.18.2.1. Limits of exact-width integer types */ | |
349 | ||
350 | /* Here we assume a standard architecture where the hardware integer | |
351 | types have 8, 16, 32, optionally 64 bits. */ | |
352 | ||
49e4877c PA |
353 | # undef INT8_MIN |
354 | # undef INT8_MAX | |
355 | # undef UINT8_MAX | |
356 | # define INT8_MIN (~ INT8_MAX) | |
357 | # define INT8_MAX 127 | |
358 | # define UINT8_MAX 255 | |
359 | ||
360 | # undef INT16_MIN | |
361 | # undef INT16_MAX | |
362 | # undef UINT16_MAX | |
363 | # define INT16_MIN (~ INT16_MAX) | |
364 | # define INT16_MAX 32767 | |
365 | # define UINT16_MAX 65535 | |
366 | ||
367 | # undef INT32_MIN | |
368 | # undef INT32_MAX | |
369 | # undef UINT32_MAX | |
370 | # define INT32_MIN (~ INT32_MAX) | |
371 | # define INT32_MAX 2147483647 | |
372 | # define UINT32_MAX 4294967295U | |
373 | ||
374 | # if defined GL_INT64_T && ! defined INT64_MAX | |
f6ea5628 DJ |
375 | /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 |
376 | evaluates the latter incorrectly in preprocessor expressions. */ | |
49e4877c PA |
377 | # define INT64_MIN (- INTMAX_C (1) << 63) |
378 | # define INT64_MAX INTMAX_C (9223372036854775807) | |
379 | # endif | |
f6ea5628 | 380 | |
49e4877c PA |
381 | # if defined GL_UINT64_T && ! defined UINT64_MAX |
382 | # define UINT64_MAX UINTMAX_C (18446744073709551615) | |
383 | # endif | |
f6ea5628 DJ |
384 | |
385 | /* 7.18.2.2. Limits of minimum-width integer types */ | |
386 | ||
387 | /* Here we assume a standard architecture where the hardware integer | |
388 | types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types | |
389 | are the same as the corresponding N_t types. */ | |
390 | ||
49e4877c PA |
391 | # undef INT_LEAST8_MIN |
392 | # undef INT_LEAST8_MAX | |
393 | # undef UINT_LEAST8_MAX | |
394 | # define INT_LEAST8_MIN INT8_MIN | |
395 | # define INT_LEAST8_MAX INT8_MAX | |
396 | # define UINT_LEAST8_MAX UINT8_MAX | |
397 | ||
398 | # undef INT_LEAST16_MIN | |
399 | # undef INT_LEAST16_MAX | |
400 | # undef UINT_LEAST16_MAX | |
401 | # define INT_LEAST16_MIN INT16_MIN | |
402 | # define INT_LEAST16_MAX INT16_MAX | |
403 | # define UINT_LEAST16_MAX UINT16_MAX | |
404 | ||
405 | # undef INT_LEAST32_MIN | |
406 | # undef INT_LEAST32_MAX | |
407 | # undef UINT_LEAST32_MAX | |
408 | # define INT_LEAST32_MIN INT32_MIN | |
409 | # define INT_LEAST32_MAX INT32_MAX | |
410 | # define UINT_LEAST32_MAX UINT32_MAX | |
411 | ||
412 | # undef INT_LEAST64_MIN | |
413 | # undef INT_LEAST64_MAX | |
414 | # ifdef GL_INT64_T | |
415 | # define INT_LEAST64_MIN INT64_MIN | |
416 | # define INT_LEAST64_MAX INT64_MAX | |
417 | # endif | |
f6ea5628 | 418 | |
49e4877c PA |
419 | # undef UINT_LEAST64_MAX |
420 | # ifdef GL_UINT64_T | |
421 | # define UINT_LEAST64_MAX UINT64_MAX | |
422 | # endif | |
f6ea5628 DJ |
423 | |
424 | /* 7.18.2.3. Limits of fastest minimum-width integer types */ | |
425 | ||
426 | /* Here we assume a standard architecture where the hardware integer | |
427 | types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types | |
428 | are taken from the same list of types. */ | |
429 | ||
49e4877c PA |
430 | # undef INT_FAST8_MIN |
431 | # undef INT_FAST8_MAX | |
432 | # undef UINT_FAST8_MAX | |
433 | # define INT_FAST8_MIN SCHAR_MIN | |
434 | # define INT_FAST8_MAX SCHAR_MAX | |
435 | # define UINT_FAST8_MAX UCHAR_MAX | |
436 | ||
437 | # undef INT_FAST16_MIN | |
438 | # undef INT_FAST16_MAX | |
439 | # undef UINT_FAST16_MAX | |
440 | # define INT_FAST16_MIN INT_FAST32_MIN | |
441 | # define INT_FAST16_MAX INT_FAST32_MAX | |
442 | # define UINT_FAST16_MAX UINT_FAST32_MAX | |
443 | ||
444 | # undef INT_FAST32_MIN | |
445 | # undef INT_FAST32_MAX | |
446 | # undef UINT_FAST32_MAX | |
447 | # ifdef __sun | |
448 | # define INT_FAST32_MIN INT_MIN | |
449 | # define INT_FAST32_MAX INT_MAX | |
450 | # define UINT_FAST32_MAX UINT_MAX | |
451 | # else | |
452 | # define INT_FAST32_MIN LONG_MIN | |
453 | # define INT_FAST32_MAX LONG_MAX | |
454 | # define UINT_FAST32_MAX ULONG_MAX | |
455 | # endif | |
f6ea5628 | 456 | |
49e4877c PA |
457 | # undef INT_FAST64_MIN |
458 | # undef INT_FAST64_MAX | |
459 | # ifdef GL_INT64_T | |
460 | # define INT_FAST64_MIN INT64_MIN | |
461 | # define INT_FAST64_MAX INT64_MAX | |
462 | # endif | |
f6ea5628 | 463 | |
49e4877c PA |
464 | # undef UINT_FAST64_MAX |
465 | # ifdef GL_UINT64_T | |
466 | # define UINT_FAST64_MAX UINT64_MAX | |
467 | # endif | |
f6ea5628 DJ |
468 | |
469 | /* 7.18.2.4. Limits of integer types capable of holding object pointers */ | |
470 | ||
49e4877c PA |
471 | # undef INTPTR_MIN |
472 | # undef INTPTR_MAX | |
473 | # undef UINTPTR_MAX | |
474 | # define INTPTR_MIN LONG_MIN | |
475 | # define INTPTR_MAX LONG_MAX | |
476 | # define UINTPTR_MAX ULONG_MAX | |
f6ea5628 DJ |
477 | |
478 | /* 7.18.2.5. Limits of greatest-width integer types */ | |
479 | ||
49e4877c PA |
480 | # ifndef INTMAX_MAX |
481 | # undef INTMAX_MIN | |
482 | # ifdef INT64_MAX | |
483 | # define INTMAX_MIN INT64_MIN | |
484 | # define INTMAX_MAX INT64_MAX | |
485 | # else | |
486 | # define INTMAX_MIN INT32_MIN | |
487 | # define INTMAX_MAX INT32_MAX | |
488 | # endif | |
770d76d7 | 489 | # endif |
f6ea5628 | 490 | |
49e4877c PA |
491 | # ifndef UINTMAX_MAX |
492 | # ifdef UINT64_MAX | |
493 | # define UINTMAX_MAX UINT64_MAX | |
494 | # else | |
495 | # define UINTMAX_MAX UINT32_MAX | |
496 | # endif | |
770d76d7 | 497 | # endif |
f6ea5628 DJ |
498 | |
499 | /* 7.18.3. Limits of other integer types */ | |
500 | ||
501 | /* ptrdiff_t limits */ | |
49e4877c PA |
502 | # undef PTRDIFF_MIN |
503 | # undef PTRDIFF_MAX | |
504 | # if @APPLE_UNIVERSAL_BUILD@ | |
505 | # ifdef _LP64 | |
5e8754f9 | 506 | # define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) |
49e4877c PA |
507 | # define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) |
508 | # else | |
5e8754f9 | 509 | # define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) |
49e4877c PA |
510 | # define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) |
511 | # endif | |
f434ba03 | 512 | # else |
49e4877c | 513 | # define PTRDIFF_MIN \ |
5e8754f9 | 514 | _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) |
49e4877c | 515 | # define PTRDIFF_MAX \ |
f434ba03 | 516 | _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) |
49e4877c | 517 | # endif |
f6ea5628 DJ |
518 | |
519 | /* sig_atomic_t limits */ | |
49e4877c PA |
520 | # undef SIG_ATOMIC_MIN |
521 | # undef SIG_ATOMIC_MAX | |
5e8754f9 SDJ |
522 | # define SIG_ATOMIC_MIN \ |
523 | _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ | |
524 | 0@SIG_ATOMIC_T_SUFFIX@) | |
49e4877c | 525 | # define SIG_ATOMIC_MAX \ |
f6ea5628 | 526 | _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
f434ba03 | 527 | 0@SIG_ATOMIC_T_SUFFIX@) |
f6ea5628 DJ |
528 | |
529 | ||
530 | /* size_t limit */ | |
49e4877c PA |
531 | # undef SIZE_MAX |
532 | # if @APPLE_UNIVERSAL_BUILD@ | |
533 | # ifdef _LP64 | |
534 | # define SIZE_MAX _STDINT_MAX (0, 64, 0ul) | |
535 | # else | |
536 | # define SIZE_MAX _STDINT_MAX (0, 32, 0ul) | |
537 | # endif | |
f434ba03 | 538 | # else |
49e4877c | 539 | # define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) |
f434ba03 | 540 | # endif |
f6ea5628 DJ |
541 | |
542 | /* wchar_t limits */ | |
f434ba03 | 543 | /* Get WCHAR_MIN, WCHAR_MAX. |
770d76d7 PA |
544 | This include is not on the top, above, because on OSF/1 4.0 we have a |
545 | sequence of nested includes | |
546 | <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes | |
f434ba03 | 547 | <stdint.h> and assumes its types are already defined. */ |
49e4877c | 548 | # if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) |
770d76d7 PA |
549 | /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
550 | included before <wchar.h>. */ | |
49e4877c PA |
551 | # include <stddef.h> |
552 | # include <stdio.h> | |
553 | # include <time.h> | |
554 | # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H | |
555 | # include <wchar.h> | |
556 | # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H | |
557 | # endif | |
558 | # undef WCHAR_MIN | |
559 | # undef WCHAR_MAX | |
5e8754f9 SDJ |
560 | # define WCHAR_MIN \ |
561 | _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) | |
49e4877c | 562 | # define WCHAR_MAX \ |
f6ea5628 DJ |
563 | _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) |
564 | ||
565 | /* wint_t limits */ | |
49e4877c PA |
566 | # undef WINT_MIN |
567 | # undef WINT_MAX | |
5e8754f9 SDJ |
568 | # define WINT_MIN \ |
569 | _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) | |
49e4877c | 570 | # define WINT_MAX \ |
f6ea5628 DJ |
571 | _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) |
572 | ||
f6ea5628 DJ |
573 | /* 7.18.4. Macros for integer constants */ |
574 | ||
f6ea5628 DJ |
575 | /* 7.18.4.1. Macros for minimum-width integer constants */ |
576 | /* According to ISO C 99 Technical Corrigendum 1 */ | |
577 | ||
578 | /* Here we assume a standard architecture where the hardware integer | |
579 | types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ | |
580 | ||
49e4877c PA |
581 | # undef INT8_C |
582 | # undef UINT8_C | |
583 | # define INT8_C(x) x | |
584 | # define UINT8_C(x) x | |
585 | ||
586 | # undef INT16_C | |
587 | # undef UINT16_C | |
588 | # define INT16_C(x) x | |
589 | # define UINT16_C(x) x | |
590 | ||
591 | # undef INT32_C | |
592 | # undef UINT32_C | |
593 | # define INT32_C(x) x | |
594 | # define UINT32_C(x) x ## U | |
595 | ||
596 | # undef INT64_C | |
597 | # undef UINT64_C | |
598 | # if LONG_MAX >> 31 >> 31 == 1 | |
599 | # define INT64_C(x) x##L | |
600 | # elif defined _MSC_VER | |
601 | # define INT64_C(x) x##i64 | |
602 | # elif @HAVE_LONG_LONG_INT@ | |
603 | # define INT64_C(x) x##LL | |
604 | # endif | |
605 | # if ULONG_MAX >> 31 >> 31 >> 1 == 1 | |
606 | # define UINT64_C(x) x##UL | |
607 | # elif defined _MSC_VER | |
608 | # define UINT64_C(x) x##ui64 | |
609 | # elif @HAVE_UNSIGNED_LONG_LONG_INT@ | |
610 | # define UINT64_C(x) x##ULL | |
611 | # endif | |
f6ea5628 DJ |
612 | |
613 | /* 7.18.4.2. Macros for greatest-width integer constants */ | |
614 | ||
49e4877c PA |
615 | # ifndef INTMAX_C |
616 | # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | |
617 | # define INTMAX_C(x) x##LL | |
618 | # elif defined GL_INT64_T | |
619 | # define INTMAX_C(x) INT64_C(x) | |
620 | # else | |
621 | # define INTMAX_C(x) x##L | |
622 | # endif | |
770d76d7 | 623 | # endif |
f6ea5628 | 624 | |
49e4877c PA |
625 | # ifndef UINTMAX_C |
626 | # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | |
627 | # define UINTMAX_C(x) x##ULL | |
628 | # elif defined GL_UINT64_T | |
629 | # define UINTMAX_C(x) UINT64_C(x) | |
630 | # else | |
631 | # define UINTMAX_C(x) x##UL | |
632 | # endif | |
770d76d7 | 633 | # endif |
49e4877c PA |
634 | |
635 | #endif /* !@HAVE_C99_STDINT_H@ */ | |
636 | ||
637 | /* Macros specified by ISO/IEC TS 18661-1:2014. */ | |
638 | ||
639 | #if (!defined UINTMAX_WIDTH \ | |
640 | && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) | |
641 | # ifdef INT8_MAX | |
642 | # define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX) | |
643 | # endif | |
644 | # ifdef UINT8_MAX | |
645 | # define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX) | |
646 | # endif | |
647 | # ifdef INT16_MAX | |
648 | # define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX) | |
649 | # endif | |
650 | # ifdef UINT16_MAX | |
651 | # define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX) | |
652 | # endif | |
653 | # ifdef INT32_MAX | |
654 | # define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX) | |
655 | # endif | |
656 | # ifdef UINT32_MAX | |
657 | # define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX) | |
658 | # endif | |
659 | # ifdef INT64_MAX | |
660 | # define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX) | |
661 | # endif | |
662 | # ifdef UINT64_MAX | |
663 | # define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX) | |
664 | # endif | |
665 | # define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX) | |
666 | # define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX) | |
667 | # define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX) | |
668 | # define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX) | |
669 | # define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX) | |
670 | # define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX) | |
671 | # define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX) | |
672 | # define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX) | |
673 | # define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX) | |
674 | # define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX) | |
675 | # define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX) | |
676 | # define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX) | |
677 | # define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX) | |
678 | # define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX) | |
679 | # define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX) | |
680 | # define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX) | |
681 | # define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX) | |
682 | # define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX) | |
683 | # define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX) | |
684 | # define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX) | |
685 | # define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX) | |
686 | # define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX) | |
687 | # define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX) | |
688 | # ifdef WINT_MAX | |
689 | # define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX) | |
690 | # endif | |
691 | # ifdef SIG_ATOMIC_MAX | |
692 | # define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX) | |
693 | # endif | |
694 | #endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ | |
f6ea5628 | 695 | |
770d76d7 PA |
696 | #endif /* _@GUARD_PREFIX@_STDINT_H */ |
697 | #endif /* !(defined __ANDROID__ && ...) */ | |
698 | #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ |