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