1 /* A portable stdint.h
\r
3 * Copyright (c) 2005-2007 Paul Hsieh
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
9 * Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * Redistributions in binary form must not misrepresent the orignal
\r
13 * source in the documentation and/or other materials provided
\r
14 * with the distribution.
\r
16 * The names of the authors nor its contributors may be used to
\r
17 * endorse or promote products derived from this software without
\r
18 * specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
\r
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
\r
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
\r
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
\r
33 ****************************************************************************
\r
37 * The ANSI C standard committee, for the C99 standard, specified the
\r
38 * inclusion of a new standard include file called stdint.h. This is
\r
39 * a very useful and long desired include file which contains several
\r
40 * very precise definitions for integer scalar types that is
\r
41 * critically important for making portable several classes of
\r
42 * applications including cryptography, hashing, variable length
\r
43 * integer libraries and so on. But for most developers its likely
\r
44 * useful just for programming sanity.
\r
46 * The problem is that most compiler vendors have decided not to
\r
47 * implement the C99 standard, and the next C++ language standard
\r
48 * (which has a lot more mindshare these days) will be a long time in
\r
49 * coming and its unknown whether or not it will include stdint.h or
\r
50 * how much adoption it will have. Either way, it will be a long time
\r
51 * before all compilers come with a stdint.h and it also does nothing
\r
52 * for the extremely large number of compilers available today which
\r
53 * do not include this file, or anything comparable to it.
\r
55 * So that's what this file is all about. Its an attempt to build a
\r
56 * single universal include file that works on as many platforms as
\r
57 * possible to deliver what stdint.h is supposed to. A few things
\r
58 * that should be noted about this file:
\r
60 * 1) It is not guaranteed to be portable and/or present an identical
\r
61 * interface on all platforms. The extreme variability of the
\r
62 * ANSI C standard makes this an impossibility right from the
\r
63 * very get go. Its really only meant to be useful for the vast
\r
64 * majority of platforms that possess the capability of
\r
65 * implementing usefully and precisely defined, standard sized
\r
66 * integer scalars. Systems which are not intrinsically 2s
\r
67 * complement may produce invalid constants.
\r
69 * 2) There is an unavoidable use of non-reserved symbols.
\r
71 * 3) Other standard include files are invoked.
\r
73 * 4) This file may come in conflict with future platforms that do
\r
74 * include stdint.h. The hope is that one or the other can be
\r
75 * used with no real difference.
\r
77 * 5) In the current verison, if your platform can't represent
\r
78 * int32_t, int16_t and int8_t, it just dumps out with a compiler
\r
81 * 6) 64 bit integers may or may not be defined. Test for their
\r
82 * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
\r
83 * Note that this is different from the C99 specification which
\r
84 * requires the existence of 64 bit support in the compiler. If
\r
85 * this is not defined for your platform, yet it is capable of
\r
86 * dealing with 64 bits then it is because this file has not yet
\r
87 * been extended to cover all of your system's capabilities.
\r
89 * 7) (u)intptr_t may or may not be defined. Test for its presence
\r
90 * with the test: #ifdef PTRDIFF_MAX. If this is not defined
\r
91 * for your platform, then it is because this file has not yet
\r
92 * been extended to cover all of your system's capabilities, not
\r
93 * because its optional.
\r
95 * 8) The following might not been defined even if your platform is
\r
96 * capable of defining it:
\r
105 * 9) The following have not been defined:
\r
110 * 10) The criteria for defining (u)int_least(*)_t isn't clear,
\r
111 * except for systems which don't have a type that precisely
\r
112 * defined 8, 16, or 32 bit types (which this include file does
\r
113 * not support anyways). Default definitions have been given.
\r
115 * 11) The criteria for defining (u)int_fast(*)_t isn't something I
\r
116 * would trust to any particular compiler vendor or the ANSI C
\r
117 * committee. It is well known that "compatible systems" are
\r
118 * commonly created that have very different performance
\r
119 * characteristics from the systems they are compatible with,
\r
120 * especially those whose vendors make both the compiler and the
\r
121 * system. Default definitions have been given, but its strongly
\r
122 * recommended that users never use these definitions for any
\r
123 * reason (they do *NOT* deliver any serious guarantee of
\r
124 * improved performance -- not in this file, nor any vendor's
\r
127 * 12) The following macros:
\r
129 * PRINTF_INTMAX_MODIFIER
\r
130 * PRINTF_INT64_MODIFIER
\r
131 * PRINTF_INT32_MODIFIER
\r
132 * PRINTF_INT16_MODIFIER
\r
133 * PRINTF_LEAST64_MODIFIER
\r
134 * PRINTF_LEAST32_MODIFIER
\r
135 * PRINTF_LEAST16_MODIFIER
\r
136 * PRINTF_INTPTR_MODIFIER
\r
138 * are strings which have been defined as the modifiers required
\r
139 * for the "d", "u" and "x" printf formats to correctly output
\r
140 * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
\r
141 * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
\r
142 * PRINTF_INTPTR_MODIFIER is not defined for some systems which
\r
143 * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
\r
144 * defined if INT64_MAX is not defined. These are an extension
\r
145 * beyond what C99 specifies must be in stdint.h.
\r
147 * In addition, the following macros are defined:
\r
149 * PRINTF_INTMAX_HEX_WIDTH
\r
150 * PRINTF_INT64_HEX_WIDTH
\r
151 * PRINTF_INT32_HEX_WIDTH
\r
152 * PRINTF_INT16_HEX_WIDTH
\r
153 * PRINTF_INT8_HEX_WIDTH
\r
154 * PRINTF_INTMAX_DEC_WIDTH
\r
155 * PRINTF_INT64_DEC_WIDTH
\r
156 * PRINTF_INT32_DEC_WIDTH
\r
157 * PRINTF_INT16_DEC_WIDTH
\r
158 * PRINTF_INT8_DEC_WIDTH
\r
160 * Which specifies the maximum number of characters required to
\r
161 * print the number of that type in either hexadecimal or decimal.
\r
162 * These are an extension beyond what C99 specifies must be in
\r
165 * Compilers tested (all with 0 warnings at their highest respective
\r
166 * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
\r
167 * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
\r
168 * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
\r
170 * This file should be considered a work in progress. Suggestions for
\r
171 * improvements, especially those which increase coverage are strongly
\r
176 * The following people have made significant contributions to the
\r
177 * development and testing of this file:
\r
180 * John Steele Scott
\r
185 #include <stddef.h>
\r
186 #include <limits.h>
\r
187 #include <signal.h>
\r
190 * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
\r
191 * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
\r
194 #if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )) && !defined (_PSTDINT_H_INCLUDED)
\r
195 #include <stdint.h>
\r
196 #define _PSTDINT_H_INCLUDED
\r
197 # ifndef PRINTF_INT64_MODIFIER
\r
198 # define PRINTF_INT64_MODIFIER "ll"
\r
200 # ifndef PRINTF_INT32_MODIFIER
\r
201 # define PRINTF_INT32_MODIFIER "l"
\r
203 # ifndef PRINTF_INT16_MODIFIER
\r
204 # define PRINTF_INT16_MODIFIER "h"
\r
206 # ifndef PRINTF_INTMAX_MODIFIER
\r
207 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
\r
209 # ifndef PRINTF_INT64_HEX_WIDTH
\r
210 # define PRINTF_INT64_HEX_WIDTH "16"
\r
212 # ifndef PRINTF_INT32_HEX_WIDTH
\r
213 # define PRINTF_INT32_HEX_WIDTH "8"
\r
215 # ifndef PRINTF_INT16_HEX_WIDTH
\r
216 # define PRINTF_INT16_HEX_WIDTH "4"
\r
218 # ifndef PRINTF_INT8_HEX_WIDTH
\r
219 # define PRINTF_INT8_HEX_WIDTH "2"
\r
221 # ifndef PRINTF_INT64_DEC_WIDTH
\r
222 # define PRINTF_INT64_DEC_WIDTH "20"
\r
224 # ifndef PRINTF_INT32_DEC_WIDTH
\r
225 # define PRINTF_INT32_DEC_WIDTH "10"
\r
227 # ifndef PRINTF_INT16_DEC_WIDTH
\r
228 # define PRINTF_INT16_DEC_WIDTH "5"
\r
230 # ifndef PRINTF_INT8_DEC_WIDTH
\r
231 # define PRINTF_INT8_DEC_WIDTH "3"
\r
233 # ifndef PRINTF_INTMAX_HEX_WIDTH
\r
234 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
\r
236 # ifndef PRINTF_INTMAX_DEC_WIDTH
\r
237 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
\r
241 #ifndef _PSTDINT_H_INCLUDED
\r
242 #define _PSTDINT_H_INCLUDED
\r
245 # define SIZE_MAX (~(size_t)0)
\r
249 * Deduce the type assignments from limits.h under the assumption that
\r
250 * integer sizes in bits are powers of 2, and follow the ANSI
\r
255 # define UINT8_MAX 0xff
\r
258 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
\r
259 typedef unsigned char uint8_t;
\r
260 # define UINT8_C(v) ((uint8_t) v)
\r
262 # error "Platform not supported"
\r
267 # define INT8_MAX 0x7f
\r
270 # define INT8_MIN INT8_C(0x80)
\r
273 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
\r
274 typedef signed char int8_t;
\r
275 # define INT8_C(v) ((int8_t) v)
\r
277 # error "Platform not supported"
\r
282 # define UINT16_MAX 0xffff
\r
285 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
\r
286 typedef unsigned int uint16_t;
\r
287 # ifndef PRINTF_INT16_MODIFIER
\r
288 # define PRINTF_INT16_MODIFIER ""
\r
290 # define UINT16_C(v) ((uint16_t) (v))
\r
291 #elif (USHRT_MAX == UINT16_MAX)
\r
292 typedef unsigned short uint16_t;
\r
293 # define UINT16_C(v) ((uint16_t) (v))
\r
294 # ifndef PRINTF_INT16_MODIFIER
\r
295 # define PRINTF_INT16_MODIFIER "h"
\r
298 #error "Platform not supported"
\r
303 # define INT16_MAX 0x7fff
\r
306 # define INT16_MIN INT16_C(0x8000)
\r
309 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
\r
310 typedef signed int int16_t;
\r
311 # define INT16_C(v) ((int16_t) (v))
\r
312 # ifndef PRINTF_INT16_MODIFIER
\r
313 # define PRINTF_INT16_MODIFIER ""
\r
315 #elif (SHRT_MAX == INT16_MAX)
\r
316 typedef signed short int16_t;
\r
317 # define INT16_C(v) ((int16_t) (v))
\r
318 # ifndef PRINTF_INT16_MODIFIER
\r
319 # define PRINTF_INT16_MODIFIER "h"
\r
322 #error "Platform not supported"
\r
327 # define UINT32_MAX (0xffffffffUL)
\r
330 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
\r
331 typedef unsigned long uint32_t;
\r
332 # define UINT32_C(v) v ## UL
\r
333 # ifndef PRINTF_INT32_MODIFIER
\r
334 # define PRINTF_INT32_MODIFIER "l"
\r
336 #elif (UINT_MAX == UINT32_MAX)
\r
337 typedef unsigned int uint32_t;
\r
338 # ifndef PRINTF_INT32_MODIFIER
\r
339 # define PRINTF_INT32_MODIFIER ""
\r
341 # define UINT32_C(v) v ## U
\r
342 #elif (USHRT_MAX == UINT32_MAX)
\r
343 typedef unsigned short uint32_t;
\r
344 # define UINT32_C(v) ((unsigned short) (v))
\r
345 # ifndef PRINTF_INT32_MODIFIER
\r
346 # define PRINTF_INT32_MODIFIER ""
\r
349 #error "Platform not supported"
\r
354 # define INT32_MAX (0x7fffffffL)
\r
357 # define INT32_MIN INT32_C(0x80000000)
\r
360 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
\r
361 typedef signed long int32_t;
\r
362 # define INT32_C(v) v ## L
\r
363 # ifndef PRINTF_INT32_MODIFIER
\r
364 # define PRINTF_INT32_MODIFIER "l"
\r
366 #elif (INT_MAX == INT32_MAX)
\r
367 typedef signed int int32_t;
\r
368 # define INT32_C(v) v
\r
369 # ifndef PRINTF_INT32_MODIFIER
\r
370 # define PRINTF_INT32_MODIFIER ""
\r
372 #elif (SHRT_MAX == INT32_MAX)
\r
373 typedef signed short int32_t;
\r
374 # define INT32_C(v) ((short) (v))
\r
375 # ifndef PRINTF_INT32_MODIFIER
\r
376 # define PRINTF_INT32_MODIFIER ""
\r
379 #error "Platform not supported"
\r
384 * The macro stdint_int64_defined is temporarily used to record
\r
385 * whether or not 64 integer support is available. It must be
\r
386 * defined for any 64 integer extensions for new platforms that are
\r
390 #undef stdint_int64_defined
\r
391 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
\r
392 # if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
\r
393 # define stdint_int64_defined
\r
394 typedef long long int64_t;
\r
395 typedef unsigned long long uint64_t;
\r
396 # define UINT64_C(v) v ## ULL
\r
397 # define INT64_C(v) v ## LL
\r
398 # ifndef PRINTF_INT64_MODIFIER
\r
399 # define PRINTF_INT64_MODIFIER "ll"
\r
404 #if !defined (stdint_int64_defined)
\r
405 # if defined(__GNUC__)
\r
406 # define stdint_int64_defined
\r
407 __extension__ typedef long long int64_t;
\r
408 __extension__ typedef unsigned long long uint64_t;
\r
409 # define UINT64_C(v) v ## ULL
\r
410 # define INT64_C(v) v ## LL
\r
411 # ifndef PRINTF_INT64_MODIFIER
\r
412 # define PRINTF_INT64_MODIFIER "ll"
\r
414 # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
\r
415 # define stdint_int64_defined
\r
416 typedef long long int64_t;
\r
417 typedef unsigned long long uint64_t;
\r
418 # define UINT64_C(v) v ## ULL
\r
419 # define INT64_C(v) v ## LL
\r
420 # ifndef PRINTF_INT64_MODIFIER
\r
421 # define PRINTF_INT64_MODIFIER "ll"
\r
423 # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
\r
424 # define stdint_int64_defined
\r
425 typedef __int64 int64_t;
\r
426 typedef unsigned __int64 uint64_t;
\r
427 # define UINT64_C(v) v ## UI64
\r
428 # define INT64_C(v) v ## I64
\r
429 # ifndef PRINTF_INT64_MODIFIER
\r
430 # define PRINTF_INT64_MODIFIER "I64"
\r
435 #if !defined (LONG_LONG_MAX) && defined (INT64_C)
\r
436 # define LONG_LONG_MAX INT64_C (9223372036854775807)
\r
438 #ifndef ULONG_LONG_MAX
\r
439 # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
\r
442 #if !defined (INT64_MAX) && defined (INT64_C)
\r
443 # define INT64_MAX INT64_C (9223372036854775807)
\r
445 #if !defined (INT64_MIN) && defined (INT64_C)
\r
446 # define INT64_MIN INT64_C (-9223372036854775808)
\r
448 #if !defined (UINT64_MAX) && defined (INT64_C)
\r
449 # define UINT64_MAX UINT64_C (18446744073709551615)
\r
453 * Width of hexadecimal for number field.
\r
456 #ifndef PRINTF_INT64_HEX_WIDTH
\r
457 # define PRINTF_INT64_HEX_WIDTH "16"
\r
459 #ifndef PRINTF_INT32_HEX_WIDTH
\r
460 # define PRINTF_INT32_HEX_WIDTH "8"
\r
462 #ifndef PRINTF_INT16_HEX_WIDTH
\r
463 # define PRINTF_INT16_HEX_WIDTH "4"
\r
465 #ifndef PRINTF_INT8_HEX_WIDTH
\r
466 # define PRINTF_INT8_HEX_WIDTH "2"
\r
469 #ifndef PRINTF_INT64_DEC_WIDTH
\r
470 # define PRINTF_INT64_DEC_WIDTH "20"
\r
472 #ifndef PRINTF_INT32_DEC_WIDTH
\r
473 # define PRINTF_INT32_DEC_WIDTH "10"
\r
475 #ifndef PRINTF_INT16_DEC_WIDTH
\r
476 # define PRINTF_INT16_DEC_WIDTH "5"
\r
478 #ifndef PRINTF_INT8_DEC_WIDTH
\r
479 # define PRINTF_INT8_DEC_WIDTH "3"
\r
483 * Ok, lets not worry about 128 bit integers for now. Moore's law says
\r
484 * we don't need to worry about that until about 2040 at which point
\r
485 * we'll have bigger things to worry about.
\r
488 #ifdef stdint_int64_defined
\r
489 typedef int64_t intmax_t;
\r
490 typedef uint64_t uintmax_t;
\r
491 # define INTMAX_MAX INT64_MAX
\r
492 # define INTMAX_MIN INT64_MIN
\r
493 # define UINTMAX_MAX UINT64_MAX
\r
494 # define UINTMAX_C(v) UINT64_C(v)
\r
495 # define INTMAX_C(v) INT64_C(v)
\r
496 # ifndef PRINTF_INTMAX_MODIFIER
\r
497 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
\r
499 # ifndef PRINTF_INTMAX_HEX_WIDTH
\r
500 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
\r
502 # ifndef PRINTF_INTMAX_DEC_WIDTH
\r
503 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
\r
506 typedef int32_t intmax_t;
\r
507 typedef uint32_t uintmax_t;
\r
508 # define INTMAX_MAX INT32_MAX
\r
509 # define UINTMAX_MAX UINT32_MAX
\r
510 # define UINTMAX_C(v) UINT32_C(v)
\r
511 # define INTMAX_C(v) INT32_C(v)
\r
512 # ifndef PRINTF_INTMAX_MODIFIER
\r
513 # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
\r
515 # ifndef PRINTF_INTMAX_HEX_WIDTH
\r
516 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
\r
518 # ifndef PRINTF_INTMAX_DEC_WIDTH
\r
519 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
\r
524 * Because this file currently only supports platforms which have
\r
525 * precise powers of 2 as bit sizes for the default integers, the
\r
526 * least definitions are all trivial. Its possible that a future
\r
527 * version of this file could have different definitions.
\r
530 #ifndef stdint_least_defined
\r
531 typedef int8_t int_least8_t;
\r
532 typedef uint8_t uint_least8_t;
\r
533 typedef int16_t int_least16_t;
\r
534 typedef uint16_t uint_least16_t;
\r
535 typedef int32_t int_least32_t;
\r
536 typedef uint32_t uint_least32_t;
\r
537 # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
\r
538 # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
\r
539 # define UINT_LEAST8_MAX UINT8_MAX
\r
540 # define INT_LEAST8_MAX INT8_MAX
\r
541 # define UINT_LEAST16_MAX UINT16_MAX
\r
542 # define INT_LEAST16_MAX INT16_MAX
\r
543 # define UINT_LEAST32_MAX UINT32_MAX
\r
544 # define INT_LEAST32_MAX INT32_MAX
\r
545 # define INT_LEAST8_MIN INT8_MIN
\r
546 # define INT_LEAST16_MIN INT16_MIN
\r
547 # define INT_LEAST32_MIN INT32_MIN
\r
548 # ifdef stdint_int64_defined
\r
549 typedef int64_t int_least64_t;
\r
550 typedef uint64_t uint_least64_t;
\r
551 # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
\r
552 # define UINT_LEAST64_MAX UINT64_MAX
\r
553 # define INT_LEAST64_MAX INT64_MAX
\r
554 # define INT_LEAST64_MIN INT64_MIN
\r
557 #undef stdint_least_defined
\r
560 * The ANSI C committee pretending to know or specify anything about
\r
561 * performance is the epitome of misguided arrogance. The mandate of
\r
562 * this file is to *ONLY* ever support that absolute minimum
\r
563 * definition of the fast integer types, for compatibility purposes.
\r
564 * No extensions, and no attempt to suggest what may or may not be a
\r
565 * faster integer type will ever be made in this file. Developers are
\r
566 * warned to stay away from these types when using this or any other
\r
570 typedef int_least8_t int_fast8_t;
\r
571 typedef uint_least8_t uint_fast8_t;
\r
572 typedef int_least16_t int_fast16_t;
\r
573 typedef uint_least16_t uint_fast16_t;
\r
574 typedef int_least32_t int_fast32_t;
\r
575 typedef uint_least32_t uint_fast32_t;
\r
576 #define UINT_FAST8_MAX UINT_LEAST8_MAX
\r
577 #define INT_FAST8_MAX INT_LEAST8_MAX
\r
578 #define UINT_FAST16_MAX UINT_LEAST16_MAX
\r
579 #define INT_FAST16_MAX INT_LEAST16_MAX
\r
580 #define UINT_FAST32_MAX UINT_LEAST32_MAX
\r
581 #define INT_FAST32_MAX INT_LEAST32_MAX
\r
582 #define INT_FAST8_MIN IN_LEASTT8_MIN
\r
583 #define INT_FAST16_MIN INT_LEAST16_MIN
\r
584 #define INT_FAST32_MIN INT_LEAST32_MIN
\r
585 #ifdef stdint_int64_defined
\r
586 typedef int_least64_t int_fast64_t;
\r
587 typedef uint_least64_t uint_fast64_t;
\r
588 # define UINT_FAST64_MAX UINT_LEAST64_MAX
\r
589 # define INT_FAST64_MAX INT_LEAST64_MAX
\r
590 # define INT_FAST64_MIN INT_LEAST64_MIN
\r
593 #undef stdint_int64_defined
\r
596 * Whatever piecemeal, per compiler thing we can do about the wchar_t
\r
600 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
\r
601 # include <wchar.h>
\r
603 # define WCHAR_MIN 0
\r
606 # define WCHAR_MAX ((wchar_t)-1)
\r
611 * Whatever piecemeal, per compiler/platform thing we can do about the
\r
612 * (u)intptr_t types and limits.
\r
615 #if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
\r
616 # define STDINT_H_UINTPTR_T_DEFINED
\r
619 #ifndef STDINT_H_UINTPTR_T_DEFINED
\r
620 # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
\r
621 # define stdint_intptr_bits 64
\r
622 # elif defined (__WATCOMC__) || defined (__TURBOC__)
\r
623 # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
\r
624 # define stdint_intptr_bits 16
\r
626 # define stdint_intptr_bits 32
\r
628 # elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
\r
629 # define stdint_intptr_bits 32
\r
630 # elif defined (__INTEL_COMPILER)
\r
631 /* TODO -- what will Intel do about x86-64? */
\r
634 # ifdef stdint_intptr_bits
\r
635 # define stdint_intptr_glue3_i(a,b,c) a##b##c
\r
636 # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
\r
637 # ifndef PRINTF_INTPTR_MODIFIER
\r
638 # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
\r
640 # ifndef PTRDIFF_MAX
\r
641 # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
\r
643 # ifndef PTRDIFF_MIN
\r
644 # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
\r
646 # ifndef UINTPTR_MAX
\r
647 # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
\r
649 # ifndef INTPTR_MAX
\r
650 # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
\r
652 # ifndef INTPTR_MIN
\r
653 # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
\r
656 # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
\r
659 # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
\r
661 typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
\r
662 typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
\r
664 /* TODO -- This following is likely wrong for some platforms, and does
\r
665 nothing for the definition of uintptr_t. */
\r
666 typedef ptrdiff_t intptr_t;
\r
668 # define STDINT_H_UINTPTR_T_DEFINED
\r
672 * Assumes sig_atomic_t is signed and we have a 2s complement machine.
\r
675 #ifndef SIG_ATOMIC_MAX
\r
676 # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
\r