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