Take into account ISO C 99 TC1.
[pspp] / lib / stdint_.h
1 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
2    Written by 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
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 General Public License for more details.
14
15    You should have received a copy of the GNU 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 #ifndef _STDINT_H
20 #define _STDINT_H
21
22 /*
23  * ISO C 99 <stdint.h> for platforms that lack it.
24  * <http://www.opengroup.org/susv3xbd/stdint.h.html>
25  */
26
27 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX.  */
28 #include <stddef.h>
29 /* Get LONG_MIN, LONG_MAX, ULONG_MAX.  */
30 #include <limits.h>
31
32 /* Get those types that are already defined in other system include files.  */
33 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)
34 # include <sys/inttypes.h>
35 #endif
36 #if defined(__OpenBSD__)
37   /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines
38      int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
39      <inttypes.h> includes <machine/types.h> and also defines intptr_t and
40      uintptr_t.  */
41 # include <sys/types.h>
42 # if @HAVE_INTTYPES_H@
43 #  include @FULL_PATH_INTTYPES_H@
44 # endif
45 #endif
46 #if defined(__linux__) && @HAVE_SYS_BITYPES_H@
47   /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
48      int{8,16,32,64}_t and __BIT_TYPES_DEFINED__.  In libc5 >= 5.2.2 it is
49      included by <sys/types.h>.  */
50 # include <sys/bitypes.h>
51 #endif
52 #if defined(__sun) && @HAVE_SYS_INTTYPES_H@
53   /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
54      the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
55      But note that <sys/int_types.h> contains only the type definitions!  */
56 # include <sys/inttypes.h>
57 #endif
58 #if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@
59   /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
60      UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX.  */
61   /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
62      UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX.  */
63 # include @FULL_PATH_INTTYPES_H@
64 #endif
65 #if @HAVE_STDINT_H@
66   /* Other systems may have an incomplete <stdint.h>.  */
67 # include @FULL_PATH_STDINT_H@
68 #endif
69
70 /* 7.18.1.1. Exact-width integer types */
71
72 /* Here we assume a standard architecture where the hardware integer
73    types have 8, 16, 32, optionally 64 bits.  */
74
75 #if !@HAVE_INT8_T@
76 typedef signed char    int8_t;
77 #endif
78 #if !@HAVE_UINT8_T@
79 typedef unsigned char  uint8_t;
80 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
81 #endif
82
83 #if !@HAVE_INT16_T@
84 typedef short          int16_t;
85 #endif
86 #if !@HAVE_UINT16_T@
87 typedef unsigned short uint16_t;
88 #endif
89
90 #if !@HAVE_INT32_T@
91 typedef int            int32_t;
92 #endif
93 #if !@HAVE_UINT32_T@
94 typedef unsigned int   uint32_t;
95 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
96 #endif
97
98 #if @HAVE_INT64_T@
99 # define _STDINT_H_HAVE_INT64 1
100 #else
101 # if @HAVE_LONG_64BIT@
102 typedef long           int64_t;
103 #  define _STDINT_H_HAVE_INT64 1
104 # elif @HAVE_LONG_LONG_64BIT@
105 typedef long long      int64_t;
106 #  define _STDINT_H_HAVE_INT64 1
107 # elif defined _MSC_VER
108 typedef __int64        int64_t;
109 #  define _STDINT_H_HAVE_INT64 1
110 # endif
111 #endif
112 #if @HAVE_UINT64_T@
113 # define _STDINT_H_HAVE_UINT64 1
114 #else
115 # if @HAVE_LONG_64BIT@
116 typedef unsigned long      uint64_t;
117 #  define _STDINT_H_HAVE_UINT64 1
118 # elif @HAVE_LONG_LONG_64BIT@
119 typedef unsigned long long uint64_t;
120 #  define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
121 #  define _STDINT_H_HAVE_UINT64 1
122 # elif defined _MSC_VER
123 typedef unsigned __int64   uint64_t;
124 #  define _STDINT_H_HAVE_UINT64 1
125 # endif
126 #endif
127
128 /* 7.18.1.2. Minimum-width integer types */
129
130 /* Here we assume a standard architecture where the hardware integer
131    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
132    are the same as the corresponding N_t types.  */
133
134 #if !@HAVE_INT_LEAST8_T@
135 typedef int8_t   int_least8_t;
136 #endif
137 #if !@HAVE_UINT_LEAST8_T@
138 typedef uint8_t  uint_least8_t;
139 #endif
140
141 #if !@HAVE_INT_LEAST16_T@
142 typedef int16_t  int_least16_t;
143 #endif
144 #if !@HAVE_UINT_LEAST16_T@
145 typedef uint16_t uint_least16_t;
146 #endif
147
148 #if !@HAVE_INT_LEAST32_T@
149 typedef int32_t  int_least32_t;
150 #endif
151 #if !@HAVE_UINT_LEAST32_T@
152 typedef uint32_t uint_least32_t;
153 #endif
154
155 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
156 typedef int64_t  int_least64_t;
157 #endif
158 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
159 typedef uint64_t uint_least64_t;
160 #endif
161
162 /* 7.18.1.3. Fastest minimum-width integer types */
163
164 /* Note: Other <stdint.h> substitutes may define these types differently.
165    It is not recommended to use these types in public header files. */
166
167 /* Here we assume a standard architecture where the hardware integer
168    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
169    are taken from the same list of types.  */
170
171 /* On alpha processors, int32_t variables are slower than int64_t variables,
172    due to the necessary zap instructions.  */
173 #if defined __alpha
174 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
175 #endif
176
177 #if !@HAVE_INT_FAST8_T@
178 # if _STDINT_H_INT64_FASTER_THAN_INT32
179 typedef int64_t  int_fast8_t;
180 # else
181 typedef int32_t  int_fast8_t;
182 # endif
183 #endif
184 #if !@HAVE_UINT_FAST8_T@
185 # if _STDINT_H_INT64_FASTER_THAN_INT32
186 typedef uint64_t uint_fast8_t;
187 # else
188 typedef uint32_t uint_fast8_t;
189 # endif
190 #endif
191
192 #if !@HAVE_INT_FAST16_T@
193 # if _STDINT_H_INT64_FASTER_THAN_INT32
194 typedef int64_t  int_fast16_t;
195 # else
196 typedef int32_t  int_fast16_t;
197 # endif
198 #endif
199 #if !@HAVE_UINT_FAST16_T@
200 # if _STDINT_H_INT64_FASTER_THAN_INT32
201 typedef uint64_t uint_fast16_t;
202 # else
203 typedef uint32_t uint_fast16_t;
204 # endif
205 #endif
206
207 #if !@HAVE_INT_FAST32_T@
208 # if _STDINT_H_INT64_FASTER_THAN_INT32
209 typedef int64_t  int_fast32_t;
210 # else
211 typedef int32_t  int_fast32_t;
212 # endif
213 #endif
214 #if !@HAVE_UINT_FAST32_T@
215 # if _STDINT_H_INT64_FASTER_THAN_INT32
216 typedef uint64_t uint_fast32_t;
217 # else
218 typedef uint32_t uint_fast32_t;
219 # endif
220 #endif
221
222 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
223 typedef int64_t  int_fast64_t;
224 #endif
225 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
226 typedef uint64_t uint_fast64_t;
227 #endif
228
229 /* 7.18.1.4. Integer types capable of holding object pointers */
230
231 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
232    but this doesn't matter here.  */
233 #if !@HAVE_INTPTR_T@
234 typedef long          intptr_t;
235 #endif
236 #if !@HAVE_UINTPTR_T@
237 typedef unsigned long uintptr_t;
238 #endif
239
240 /* 7.18.1.5. Greatest-width integer types */
241
242 /* Note: These types are compiler dependent. It may be unwise to use them in
243    public header files. */
244
245 #if !@HAVE_INTMAX_T@
246 # ifdef _STDINT_H_HAVE_INT64
247 typedef int64_t  intmax_t;
248 # else
249 typedef int32_t  intmax_t;
250 # endif
251 #endif
252 #if !@HAVE_UINTMAX_T@
253 # ifdef _STDINT_H_HAVE_UINT64
254 typedef uint64_t uintmax_t;
255 # else
256 typedef uint32_t uintmax_t;
257 # endif
258 #endif
259
260 /* 7.18.2. Limits of specified-width integer types */
261
262 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
263
264 /* 7.18.2.1. Limits of exact-width integer types */
265
266 /* Here we assume a standard architecture where the hardware integer
267    types have 8, 16, 32, optionally 64 bits.  */
268
269 #if @HAVE_INT8_T@
270 # ifndef INT8_MIN
271 #  define INT8_MIN  (-1 << (@BITSIZEOF_INT8_T@ - 1))
272 # endif
273 #else
274 # define INT8_MIN  -128
275 #endif
276 #if @HAVE_INT8_T@
277 # ifndef INT8_MAX
278 #  define INT8_MAX  (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
279 # endif
280 #else
281 # define INT8_MAX  127
282 #endif
283 #if @HAVE_UINT8_T@
284 # ifndef UINT8_MAX
285 #  if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
286 #   define UINT8_MAX  (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
287 #  else
288 #   define UINT8_MAX  (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
289 #  endif
290 # endif
291 #else
292 # define UINT8_MAX  255
293 #endif
294
295 #if @HAVE_INT16_T@
296 # ifndef INT16_MIN
297 #  define INT16_MIN  (-1 << (@BITSIZEOF_INT16_T@ - 1))
298 # endif
299 #else
300 # define INT16_MIN  -32768
301 #endif
302 #if @HAVE_INT16_T@
303 # ifndef INT16_MAX
304 #  define INT16_MAX  (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
305 # endif
306 #else
307 # define INT16_MAX  32767
308 #endif
309 #if @HAVE_UINT16_T@
310 # ifndef UINT16_MAX
311 #  if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
312 #   define UINT16_MAX  (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
313 #  else
314 #   define UINT16_MAX  (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
315 #  endif
316 # endif
317 #else
318 # define UINT16_MAX  65535
319 #endif
320
321 #if @HAVE_INT32_T@
322 # ifndef INT32_MIN
323 #  define INT32_MIN  (-1 << (@BITSIZEOF_INT32_T@ - 1))
324 # endif
325 #else
326 # define INT32_MIN  (~INT32_MAX)
327 #endif
328 #if @HAVE_INT32_T@
329 # ifndef INT32_MAX
330 #  define INT32_MAX  (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
331 # endif
332 #else
333 # define INT32_MAX  2147483647
334 #endif
335 #if @HAVE_UINT32_T@
336 # ifndef UINT32_MAX
337 #  if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
338 #   define UINT32_MAX  (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
339 #  else
340 #   define UINT32_MAX  (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
341 #  endif
342 # endif
343 #else
344 # define UINT32_MAX  4294967295U
345 #endif
346
347 #if @HAVE_INT64_T@
348 # ifndef INT64_MIN
349 #  if @HAVE_LONG_64BIT@
350 #   define INT64_MIN  (-1L << (@BITSIZEOF_INT64_T@ - 1))
351 #  elif @HAVE_LONG_LONG_64BIT@
352 #   define INT64_MIN  (-1LL << (@BITSIZEOF_INT64_T@ - 1))
353 #  elif defined _MSC_VER
354 #   define INT64_MIN  (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
355 #  endif
356 # endif
357 #else
358 # ifdef _STDINT_H_HAVE_INT64
359 #  define INT64_MIN  (~INT64_MAX)
360 # endif
361 #endif
362 #if @HAVE_INT64_T@
363 # ifndef INT64_MAX
364 #  if @HAVE_LONG_64BIT@
365 #   define INT64_MAX  (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
366 #  elif @HAVE_LONG_LONG_64BIT@
367 #   define INT64_MAX  (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
368 #  elif defined _MSC_VER
369 #   define INT64_MAX  (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
370 #  endif
371 # endif
372 #else
373 # ifdef _STDINT_H_HAVE_INT64
374 #  if @HAVE_LONG_64BIT@
375 #   define INT64_MAX  9223372036854775807L
376 #  elif @HAVE_LONG_LONG_64BIT@
377 #   define INT64_MAX  9223372036854775807LL
378 #  elif defined _MSC_VER
379 #   define INT64_MAX  9223372036854775807i64
380 #  endif
381 # endif
382 #endif
383 #if @HAVE_UINT64_T@
384 # ifndef UINT64_MAX
385 #  if @HAVE_LONG_64BIT@
386 #   define UINT64_MAX  (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
387 #  elif @HAVE_LONG_LONG_64BIT@
388 #   define UINT64_MAX  (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
389 #  elif defined _MSC_VER
390 #   define UINT64_MAX  (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
391 #  endif
392 # endif
393 #else
394 # ifdef _STDINT_H_HAVE_UINT64
395 #  if @HAVE_LONG_64BIT@
396 #   define UINT64_MAX 18446744073709551615UL
397 #  elif @HAVE_LONG_LONG_64BIT@
398 #   define UINT64_MAX 18446744073709551615ULL
399 #  elif defined _MSC_VER
400 #   define UINT64_MAX 18446744073709551615ui64
401 #  endif
402 # endif
403 #endif
404
405 /* 7.18.2.2. Limits of minimum-width integer types */
406
407 /* Here we assume a standard architecture where the hardware integer
408    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
409    are the same as the corresponding N_t types.  */
410
411 #if @HAVE_INT_LEAST8_T@
412 # ifndef INT_LEAST8_MIN
413 #  define INT_LEAST8_MIN  (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
414 # endif
415 #else
416 # define INT_LEAST8_MIN  INT8_MIN
417 #endif
418 #if @HAVE_INT_LEAST8_T@
419 # ifndef INT_LEAST8_MAX
420 #  define INT_LEAST8_MAX  (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
421 # endif
422 #else
423 # define INT_LEAST8_MAX  INT8_MAX
424 #endif
425 #if @HAVE_UINT_LEAST8_T@
426 # ifndef UINT_LEAST8_MAX
427 #  if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
428 #   define UINT_LEAST8_MAX  (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
429 #  else
430 #   define UINT_LEAST8_MAX  (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
431 #  endif
432 # endif
433 #else
434 # define UINT_LEAST8_MAX  UINT8_MAX
435 #endif
436
437 #if @HAVE_INT_LEAST16_T@
438 # ifndef INT_LEAST16_MIN
439 #  define INT_LEAST16_MIN  (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
440 # endif
441 #else
442 # define INT_LEAST16_MIN  INT16_MIN
443 #endif
444 #if @HAVE_INT_LEAST16_T@
445 # ifndef INT_LEAST16_MAX
446 #  define INT_LEAST16_MAX  (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
447 # endif
448 #else
449 # define INT_LEAST16_MAX  INT16_MAX
450 #endif
451 #if @HAVE_UINT_LEAST16_T@
452 # ifndef UINT_LEAST16_MAX
453 #  if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
454 #   define UINT_LEAST16_MAX  (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
455 #  else
456 #   define UINT_LEAST16_MAX  (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
457 #  endif
458 # endif
459 #else
460 # define UINT_LEAST16_MAX  UINT16_MAX
461 #endif
462
463 #if @HAVE_INT_LEAST32_T@
464 # ifndef INT_LEAST32_MIN
465 #  define INT_LEAST32_MIN  (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
466 # endif
467 #else
468 # define INT_LEAST32_MIN  INT32_MIN
469 #endif
470 #if @HAVE_INT_LEAST32_T@
471 # ifndef INT_LEAST32_MAX
472 #  define INT_LEAST32_MAX  (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
473 # endif
474 #else
475 # define INT_LEAST32_MAX  INT32_MAX
476 #endif
477 #if @HAVE_UINT_LEAST32_T@
478 # ifndef UINT_LEAST32_MAX
479 #  if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
480 #   define UINT_LEAST32_MAX  (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
481 #  else
482 #   define UINT_LEAST32_MAX  (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
483 #  endif
484 # endif
485 #else
486 # define UINT_LEAST32_MAX  UINT32_MAX
487 #endif
488
489 #if @HAVE_INT_LEAST64_T@
490 # ifndef INT_LEAST64_MIN
491 #  if @HAVE_LONG_64BIT@
492 #   define INT_LEAST64_MIN  (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
493 #  elif @HAVE_LONG_LONG_64BIT@
494 #   define INT_LEAST64_MIN  (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
495 #  elif defined _MSC_VER
496 #   define INT_LEAST64_MIN  (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
497 #  endif
498 # endif
499 #else
500 # ifdef _STDINT_H_HAVE_INT64
501 #  define INT_LEAST64_MIN  INT64_MIN
502 # endif
503 #endif
504 #if @HAVE_INT_LEAST64_T@
505 # ifndef INT_LEAST64_MAX
506 #  if @HAVE_LONG_64BIT@
507 #   define INT_LEAST64_MAX  (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
508 #  elif @HAVE_LONG_LONG_64BIT@
509 #   define INT_LEAST64_MAX  (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
510 #  elif defined _MSC_VER
511 #   define INT_LEAST64_MAX  (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
512 #  endif
513 # endif
514 #else
515 # ifdef _STDINT_H_HAVE_INT64
516 #  define INT_LEAST64_MAX  INT64_MAX
517 # endif
518 #endif
519 #if @HAVE_UINT_LEAST64_T@
520 # ifndef UINT_LEAST64_MAX
521 #  if @HAVE_LONG_64BIT@
522 #   define UINT_LEAST64_MAX  (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
523 #  elif @HAVE_LONG_LONG_64BIT@
524 #   define UINT_LEAST64_MAX  (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
525 #  elif defined _MSC_VER
526 #   define UINT_LEAST64_MAX  (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
527 #  endif
528 # endif
529 #else
530 # ifdef _STDINT_H_HAVE_UINT64
531 #  define UINT_LEAST64_MAX  UINT64_MAX
532 # endif
533 #endif
534
535 /* 7.18.2.3. Limits of fastest minimum-width integer types */
536
537 /* Here we assume a standard architecture where the hardware integer
538    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
539    are taken from the same list of types.  */
540
541 #if @HAVE_INT_FAST8_T@
542 # ifndef INT_FAST8_MIN
543 #  define INT_FAST8_MIN  (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
544 # endif
545 #else
546 # if _STDINT_H_INT64_FASTER_THAN_INT32
547 #  define INT_FAST8_MIN  INT64_MIN
548 # else
549 #  define INT_FAST8_MIN  INT32_MIN
550 # endif
551 #endif
552 #if @HAVE_INT_FAST8_T@
553 # ifndef INT_FAST8_MAX
554 #  define INT_FAST8_MAX  (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
555 # endif
556 #else
557 # if _STDINT_H_INT64_FASTER_THAN_INT32
558 #  define INT_FAST8_MAX  INT64_MAX
559 # else
560 #  define INT_FAST8_MAX  INT32_MAX
561 # endif
562 #endif
563 #if @HAVE_UINT_FAST8_T@
564 # ifndef UINT_FAST8_MAX
565 #  if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
566 #   define UINT_FAST8_MAX  (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
567 #  else
568 #   define UINT_FAST8_MAX  (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
569 #  endif
570 # endif
571 #else
572 # if _STDINT_H_INT64_FASTER_THAN_INT32
573 #  define UINT_FAST8_MAX  UINT64_MAX
574 # else
575 #  define UINT_FAST8_MAX  UINT32_MAX
576 # endif
577 #endif
578
579 #if @HAVE_INT_FAST16_T@
580 # ifndef INT_FAST16_MIN
581 #  define INT_FAST16_MIN  (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
582 # endif
583 #else
584 # if _STDINT_H_INT64_FASTER_THAN_INT32
585 #  define INT_FAST16_MIN  INT64_MIN
586 # else
587 #  define INT_FAST16_MIN  INT32_MIN
588 # endif
589 #endif
590 #if @HAVE_INT_FAST16_T@
591 # ifndef INT_FAST16_MAX
592 #  define INT_FAST16_MAX  (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
593 # endif
594 #else
595 # if _STDINT_H_INT64_FASTER_THAN_INT32
596 #  define INT_FAST16_MAX  INT64_MAX
597 # else
598 #  define INT_FAST16_MAX  INT32_MAX
599 # endif
600 #endif
601 #if @HAVE_UINT_FAST16_T@
602 # ifndef UINT_FAST16_MAX
603 #  if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
604 #   define UINT_FAST16_MAX  (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
605 #  else
606 #   define UINT_FAST16_MAX  (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
607 #  endif
608 # endif
609 #else
610 # if _STDINT_H_INT64_FASTER_THAN_INT32
611 #  define UINT_FAST16_MAX  UINT64_MAX
612 # else
613 #  define UINT_FAST16_MAX  UINT32_MAX
614 # endif
615 #endif
616
617 #if @HAVE_INT_FAST32_T@
618 # ifndef INT_FAST32_MIN
619 #  define INT_FAST32_MIN  (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
620 # endif
621 #else
622 # if _STDINT_H_INT64_FASTER_THAN_INT32
623 #  define INT_FAST32_MIN  INT64_MIN
624 # else
625 #  define INT_FAST32_MIN  INT32_MIN
626 # endif
627 #endif
628 #if @HAVE_INT_FAST32_T@
629 # ifndef INT_FAST32_MAX
630 #  define INT_FAST32_MAX  (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
631 # endif
632 #else
633 # if _STDINT_H_INT64_FASTER_THAN_INT32
634 #  define INT_FAST32_MAX  INT64_MAX
635 # else
636 #  define INT_FAST32_MAX  INT32_MAX
637 # endif
638 #endif
639 #if @HAVE_UINT_FAST32_T@
640 # ifndef UINT_FAST32_MAX
641 #  if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
642 #   define UINT_FAST32_MAX  (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
643 #  else
644 #   define UINT_FAST32_MAX  (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
645 #  endif
646 # endif
647 #else
648 # if _STDINT_H_INT64_FASTER_THAN_INT32
649 #  define UINT_FAST32_MAX  UINT64_MAX
650 # else
651 #  define UINT_FAST32_MAX  UINT32_MAX
652 # endif
653 #endif
654
655 #if @HAVE_INT_FAST64_T@
656 # ifndef INT_FAST64_MIN
657 #  if @HAVE_LONG_64BIT@
658 #   define INT_FAST64_MIN  (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
659 #  elif @HAVE_LONG_LONG_64BIT@
660 #   define INT_FAST64_MIN  (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
661 #  elif defined _MSC_VER
662 #   define INT_FAST64_MIN  (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
663 #  endif
664 # endif
665 #else
666 # ifdef _STDINT_H_HAVE_INT64
667 #  define INT_FAST64_MIN  INT64_MIN
668 # endif
669 #endif
670 #if @HAVE_INT_FAST64_T@
671 # ifndef INT_FAST64_MAX
672 #  if @HAVE_LONG_64BIT@
673 #   define INT_FAST64_MAX  (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
674 #  elif @HAVE_LONG_LONG_64BIT@
675 #   define INT_FAST64_MAX  (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
676 #  elif defined _MSC_VER
677 #   define INT_FAST64_MAX  (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
678 #  endif
679 # endif
680 #else
681 # ifdef _STDINT_H_HAVE_INT64
682 #  define INT_FAST64_MAX  INT64_MAX
683 # endif
684 #endif
685 #if @HAVE_UINT_FAST64_T@
686 # ifndef UINT_FAST64_MAX
687 #  if @HAVE_LONG_64BIT@
688 #   define UINT_FAST64_MAX  (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
689 #  elif @HAVE_LONG_LONG_64BIT@
690 #   define UINT_FAST64_MAX  (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
691 #  elif defined _MSC_VER
692 #   define UINT_FAST64_MAX  (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
693 #  endif
694 # endif
695 #else
696 # ifdef _STDINT_H_HAVE_UINT64
697 #  define UINT_FAST64_MAX  UINT64_MAX
698 # endif
699 #endif
700
701 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
702
703 #if @HAVE_INTPTR_T@
704 # ifndef INTPTR_MIN
705 #  if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
706 #   define INTPTR_MIN  (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
707 #  else
708 #   define INTPTR_MIN  (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
709 #  endif
710 # endif
711 #else
712 # define INTPTR_MIN  LONG_MIN
713 #endif
714 #if @HAVE_INTPTR_T@
715 # ifndef INTPTR_MAX
716 #  if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
717 #   define INTPTR_MAX  (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
718 #  else
719 #   define INTPTR_MAX  (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
720 #  endif
721 # endif
722 #else
723 # define INTPTR_MAX  LONG_MAX
724 #endif
725 #if @HAVE_UINTPTR_T@
726 # ifndef UINTPTR_MAX
727 #  if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
728 #   define UINTPTR_MAX  (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
729 #  else
730 #   define UINTPTR_MAX  (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
731 #  endif
732 # endif
733 #else
734 # define UINTPTR_MAX  ULONG_MAX
735 #endif
736
737 /* 7.18.2.5. Limits of greatest-width integer types */
738
739 #if @HAVE_INTMAX_T@
740 # ifndef INTMAX_MIN
741 #  if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
742 #   define INTMAX_MIN  (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
743 #  else
744 #   define INTMAX_MIN  (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
745 #  endif
746 # endif
747 #else
748 # ifdef _STDINT_H_HAVE_INT64
749 #  define INTMAX_MIN  INT64_MIN
750 # else
751 #  define INTMAX_MIN  INT32_MIN
752 # endif
753 #endif
754 #if @HAVE_INTMAX_T@
755 # ifndef INTMAX_MAX
756 #  if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
757 #   define INTMAX_MAX  (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
758 #  else
759 #   define INTMAX_MAX  (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
760 #  endif
761 # endif
762 #else
763 # ifdef _STDINT_H_HAVE_INT64
764 #  define INTMAX_MAX  INT64_MAX
765 # else
766 #  define INTMAX_MAX  INT32_MAX
767 # endif
768 #endif
769 #if @HAVE_UINTMAX_T@
770 # ifndef UINTMAX_MAX
771 #  if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
772 #   define UINTMAX_MAX  (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
773 #  else
774 #   define UINTMAX_MAX  (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
775 #  endif
776 # endif
777 #else
778 # ifdef _STDINT_H_HAVE_INT64
779 #  define UINTMAX_MAX  UINT64_MAX
780 # else
781 #  define UINTMAX_MAX  UINT32_MAX
782 # endif
783 #endif
784
785 /* 7.18.3. Limits of other integer types */
786
787 /* ptrdiff_t limits */
788 #ifndef PTRDIFF_MIN
789 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
790 #  define PTRDIFF_MIN  (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
791 # else
792 #  define PTRDIFF_MIN  (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
793 # endif
794 #endif
795 #ifndef PTRDIFF_MAX
796 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
797 #  define PTRDIFF_MAX  (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
798 # else
799 #  define PTRDIFF_MAX  (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
800 # endif
801 #endif
802
803 /* sig_atomic_t limits */
804 #ifndef SIG_ATOMIC_MIN
805 # if @HAVE_SIGNED_SIG_ATOMIC_T@
806 #  if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
807 #   define SIG_ATOMIC_MIN  (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
808 #  else
809 #   define SIG_ATOMIC_MIN  (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
810 #  endif
811 # else
812 #  if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
813 #   define SIG_ATOMIC_MIN  0UL
814 #  elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
815 #   define SIG_ATOMIC_MIN  0U
816 #  else
817 #   define SIG_ATOMIC_MIN  0
818 #  endif
819 # endif
820 #endif
821 #ifndef SIG_ATOMIC_MAX
822 # if @HAVE_SIGNED_SIG_ATOMIC_T@
823 #  if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
824 #   define SIG_ATOMIC_MAX  (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
825 #  else
826 #   define SIG_ATOMIC_MAX  (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
827 #  endif
828 # else
829 #  if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
830 #   define SIG_ATOMIC_MAX  (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
831 #  elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
832 #   define SIG_ATOMIC_MAX  (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
833 #  else
834 #   define SIG_ATOMIC_MAX  (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
835 #  endif
836 # endif
837 #endif
838
839 /* size_t limit */
840 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
841 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
842 #  define SIZE_MAX  (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
843 # else
844 #  define SIZE_MAX  (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
845 # endif
846 #endif
847
848 /* wchar_t limits may already be defined in <stddef.h>.  */
849 #ifndef WCHAR_MIN
850 # if @HAVE_SIGNED_WCHAR_T@
851 #  if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
852 #   define WCHAR_MIN  (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
853 #  else
854 #   define WCHAR_MIN  (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
855 #  endif
856 # else
857 #  if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
858 #   define WCHAR_MIN  0UL
859 #  elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
860 #   define WCHAR_MIN  0U
861 #  else
862 #   define WCHAR_MIN  0
863 #  endif
864 # endif
865 #endif
866 #ifndef WCHAR_MAX
867 # if @HAVE_SIGNED_WCHAR_T@
868 #  if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
869 #   define WCHAR_MAX  (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
870 #  else
871 #   define WCHAR_MAX  (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
872 #  endif
873 # else
874 #  if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
875 #   define WCHAR_MAX  (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
876 #  elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
877 #   define WCHAR_MAX  (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
878 #  else
879 #   define WCHAR_MAX  (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
880 #  endif
881 # endif
882 #endif
883
884 /* wint_t limits */
885 #ifndef WINT_MIN
886 # if @HAVE_SIGNED_WINT_T@
887 #  if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
888 #   define WINT_MIN  (-1L << (@BITSIZEOF_WINT_T@ - 1))
889 #  else
890 #   define WINT_MIN  (-1 << (@BITSIZEOF_WINT_T@ - 1))
891 #  endif
892 # else
893 #  if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
894 #   define WINT_MIN  0UL
895 #  elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
896 #   define WINT_MIN  0U
897 #  else
898 #   define WINT_MIN  0
899 #  endif
900 # endif
901 #endif
902 #ifndef WINT_MAX
903 # if @HAVE_SIGNED_WINT_T@
904 #  if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
905 #   define WINT_MAX  (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
906 #  else
907 #   define WINT_MAX  (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
908 #  endif
909 # else
910 #  if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
911 #   define WINT_MAX  (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
912 #  elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
913 #   define WINT_MAX  (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
914 #  else
915 #   define WINT_MAX  (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
916 #  endif
917 # endif
918 #endif
919
920 #endif
921
922 /* 7.18.4. Macros for integer constants */
923
924 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
925
926 /* 7.18.4.1. Macros for minimum-width integer constants */
927 /* According to ISO C 99 Technical Corrigendum 1 */
928
929 #undef INT8_C
930 #undef UINT8_C
931 #define INT8_C(x) x
932 #if @HAVE_UINT8_T@
933 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
934 #  define UINT8_C(x) x
935 # else
936 #  define UINT8_C(x) x##U
937 # endif
938 #else
939 # define UINT8_C(x) x
940 #endif
941
942 #undef INT16_C
943 #undef UINT16_C
944 #define INT16_C(x) x
945 #if @HAVE_UINT16_T@
946 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
947 #  define UINT16_C(x) x
948 # else
949 #  define UINT16_C(x) x##U
950 # endif
951 #else
952 # define UINT16_C(x) x
953 #endif
954
955 #undef INT32_C
956 #undef UINT32_C
957 #define INT32_C(x) x
958 #if @HAVE_UINT32_T@
959 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
960 #  define UINT32_C(x) x
961 # else
962 #  define UINT32_C(x) x##U
963 # endif
964 #else
965 # define UINT32_C(x) x
966 #endif
967
968 #undef INT64_C
969 #undef UINT64_C
970 #if @HAVE_LONG_64BIT@
971 # define INT64_C(x) x##L
972 # define UINT64_C(x) x##UL
973 #elif @HAVE_LONG_LONG_64BIT@
974 # define INT64_C(x) x##LL
975 # define UINT64_C(x) x##ULL
976 #elif defined(_MSC_VER)
977 # define INT64_C(x) x##i64
978 # define UINT64_C(x) x##ui64
979 #endif
980
981 /* 7.18.4.2. Macros for greatest-width integer constants */
982
983 #undef INTMAX_C
984 #undef UINTMAX_C
985 #if @HAVE_LONG_64BIT@
986 # define INTMAX_C(x) x##L
987 # define UINTMAX_C(x) x##UL
988 #elif @HAVE_LONG_LONG_64BIT@
989 # define INTMAX_C(x) x##LL
990 # define UINTMAX_C(x) x##ULL
991 #elif defined(_MSC_VER)
992 # define INTMAX_C(x) x##i64
993 # define UINTMAX_C(x) x##ui64
994 #else
995 # define INTMAX_C(x) x
996 # define UINTMAX_C(x) x##U
997 #endif
998
999 #endif
1000
1001 #endif /* _STDINT_H */