nuclear@0: /* A portable stdint.h nuclear@0: **************************************************************************** nuclear@0: * BSD License: nuclear@0: **************************************************************************** nuclear@0: * nuclear@0: * Copyright (c) 2005-2007 Paul Hsieh nuclear@0: * All rights reserved. nuclear@0: * nuclear@0: * Redistribution and use in source and binary forms, with or without nuclear@0: * modification, are permitted provided that the following conditions nuclear@0: * are met: nuclear@0: * nuclear@0: * 1. Redistributions of source code must retain the above copyright nuclear@0: * notice, this list of conditions and the following disclaimer. nuclear@0: * 2. Redistributions in binary form must reproduce the above copyright nuclear@0: * notice, this list of conditions and the following disclaimer in the nuclear@0: * documentation and/or other materials provided with the distribution. nuclear@0: * 3. The name of the author may not be used to endorse or promote products nuclear@0: * derived from this software without specific prior written permission. nuclear@0: * nuclear@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR nuclear@0: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES nuclear@0: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. nuclear@0: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, nuclear@0: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT nuclear@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF nuclear@0: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: * nuclear@0: **************************************************************************** nuclear@0: * nuclear@0: * Version 0.1.10 nuclear@0: * nuclear@0: * The ANSI C standard committee, for the C99 standard, specified the nuclear@0: * inclusion of a new standard include file called stdint.h. This is nuclear@0: * a very useful and long desired include file which contains several nuclear@0: * very precise definitions for integer scalar types that is nuclear@0: * critically important for making portable several classes of nuclear@0: * applications including cryptography, hashing, variable length nuclear@0: * integer libraries and so on. But for most developers its likely nuclear@0: * useful just for programming sanity. nuclear@0: * nuclear@0: * The problem is that most compiler vendors have decided not to nuclear@0: * implement the C99 standard, and the next C++ language standard nuclear@0: * (which has a lot more mindshare these days) will be a long time in nuclear@0: * coming and its unknown whether or not it will include stdint.h or nuclear@0: * how much adoption it will have. Either way, it will be a long time nuclear@0: * before all compilers come with a stdint.h and it also does nothing nuclear@0: * for the extremely large number of compilers available today which nuclear@0: * do not include this file, or anything comparable to it. nuclear@0: * nuclear@0: * So that's what this file is all about. Its an attempt to build a nuclear@0: * single universal include file that works on as many platforms as nuclear@0: * possible to deliver what stdint.h is supposed to. A few things nuclear@0: * that should be noted about this file: nuclear@0: * nuclear@0: * 1) It is not guaranteed to be portable and/or present an identical nuclear@0: * interface on all platforms. The extreme variability of the nuclear@0: * ANSI C standard makes this an impossibility right from the nuclear@0: * very get go. Its really only meant to be useful for the vast nuclear@0: * majority of platforms that possess the capability of nuclear@0: * implementing usefully and precisely defined, standard sized nuclear@0: * integer scalars. Systems which are not intrinsically 2s nuclear@0: * complement may produce invalid constants. nuclear@0: * nuclear@0: * 2) There is an unavoidable use of non-reserved symbols. nuclear@0: * nuclear@0: * 3) Other standard include files are invoked. nuclear@0: * nuclear@0: * 4) This file may come in conflict with future platforms that do nuclear@0: * include stdint.h. The hope is that one or the other can be nuclear@0: * used with no real difference. nuclear@0: * nuclear@0: * 5) In the current verison, if your platform can't represent nuclear@0: * int32_t, int16_t and int8_t, it just dumps out with a compiler nuclear@0: * error. nuclear@0: * nuclear@0: * 6) 64 bit integers may or may not be defined. Test for their nuclear@0: * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. nuclear@0: * Note that this is different from the C99 specification which nuclear@0: * requires the existence of 64 bit support in the compiler. If nuclear@0: * this is not defined for your platform, yet it is capable of nuclear@0: * dealing with 64 bits then it is because this file has not yet nuclear@0: * been extended to cover all of your system's capabilities. nuclear@0: * nuclear@0: * 7) (u)intptr_t may or may not be defined. Test for its presence nuclear@0: * with the test: #ifdef PTRDIFF_MAX. If this is not defined nuclear@0: * for your platform, then it is because this file has not yet nuclear@0: * been extended to cover all of your system's capabilities, not nuclear@0: * because its optional. nuclear@0: * nuclear@0: * 8) The following might not been defined even if your platform is nuclear@0: * capable of defining it: nuclear@0: * nuclear@0: * WCHAR_MIN nuclear@0: * WCHAR_MAX nuclear@0: * (u)int64_t nuclear@0: * PTRDIFF_MIN nuclear@0: * PTRDIFF_MAX nuclear@0: * (u)intptr_t nuclear@0: * nuclear@0: * 9) The following have not been defined: nuclear@0: * nuclear@0: * WINT_MIN nuclear@0: * WINT_MAX nuclear@0: * nuclear@0: * 10) The criteria for defining (u)int_least(*)_t isn't clear, nuclear@0: * except for systems which don't have a type that precisely nuclear@0: * defined 8, 16, or 32 bit types (which this include file does nuclear@0: * not support anyways). Default definitions have been given. nuclear@0: * nuclear@0: * 11) The criteria for defining (u)int_fast(*)_t isn't something I nuclear@0: * would trust to any particular compiler vendor or the ANSI C nuclear@0: * committee. It is well known that "compatible systems" are nuclear@0: * commonly created that have very different performance nuclear@0: * characteristics from the systems they are compatible with, nuclear@0: * especially those whose vendors make both the compiler and the nuclear@0: * system. Default definitions have been given, but its strongly nuclear@0: * recommended that users never use these definitions for any nuclear@0: * reason (they do *NOT* deliver any serious guarantee of nuclear@0: * improved performance -- not in this file, nor any vendor's nuclear@0: * stdint.h). nuclear@0: * nuclear@0: * 12) The following macros: nuclear@0: * nuclear@0: * PRINTF_INTMAX_MODIFIER nuclear@0: * PRINTF_INT64_MODIFIER nuclear@0: * PRINTF_INT32_MODIFIER nuclear@0: * PRINTF_INT16_MODIFIER nuclear@0: * PRINTF_LEAST64_MODIFIER nuclear@0: * PRINTF_LEAST32_MODIFIER nuclear@0: * PRINTF_LEAST16_MODIFIER nuclear@0: * PRINTF_INTPTR_MODIFIER nuclear@0: * nuclear@0: * are strings which have been defined as the modifiers required nuclear@0: * for the "d", "u" and "x" printf formats to correctly output nuclear@0: * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, nuclear@0: * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. nuclear@0: * PRINTF_INTPTR_MODIFIER is not defined for some systems which nuclear@0: * provide their own stdint.h. PRINTF_INT64_MODIFIER is not nuclear@0: * defined if INT64_MAX is not defined. These are an extension nuclear@0: * beyond what C99 specifies must be in stdint.h. nuclear@0: * nuclear@0: * In addition, the following macros are defined: nuclear@0: * nuclear@0: * PRINTF_INTMAX_HEX_WIDTH nuclear@0: * PRINTF_INT64_HEX_WIDTH nuclear@0: * PRINTF_INT32_HEX_WIDTH nuclear@0: * PRINTF_INT16_HEX_WIDTH nuclear@0: * PRINTF_INT8_HEX_WIDTH nuclear@0: * PRINTF_INTMAX_DEC_WIDTH nuclear@0: * PRINTF_INT64_DEC_WIDTH nuclear@0: * PRINTF_INT32_DEC_WIDTH nuclear@0: * PRINTF_INT16_DEC_WIDTH nuclear@0: * PRINTF_INT8_DEC_WIDTH nuclear@0: * nuclear@0: * Which specifies the maximum number of characters required to nuclear@0: * print the number of that type in either hexadecimal or decimal. nuclear@0: * These are an extension beyond what C99 specifies must be in nuclear@0: * stdint.h. nuclear@0: * nuclear@0: * Compilers tested (all with 0 warnings at their highest respective nuclear@0: * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 nuclear@0: * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio nuclear@0: * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 nuclear@0: * nuclear@0: * This file should be considered a work in progress. Suggestions for nuclear@0: * improvements, especially those which increase coverage are strongly nuclear@0: * encouraged. nuclear@0: * nuclear@0: * Acknowledgements nuclear@0: * nuclear@0: * The following people have made significant contributions to the nuclear@0: * development and testing of this file: nuclear@0: * nuclear@0: * Chris Howie nuclear@0: * John Steele Scott nuclear@0: * Dave Thorup nuclear@0: * nuclear@0: */ nuclear@0: nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: nuclear@0: /* nuclear@0: * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and nuclear@0: * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. nuclear@0: */ nuclear@0: nuclear@0: #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) && !defined(_STDINT) nuclear@0: #include nuclear@0: #define _PSTDINT_H_INCLUDED nuclear@0: # ifndef PRINTF_INT64_MODIFIER nuclear@0: # define PRINTF_INT64_MODIFIER "ll" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "l" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT16_MODIFIER nuclear@0: # define PRINTF_INT16_MODIFIER "h" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_MODIFIER nuclear@0: # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT64_HEX_WIDTH nuclear@0: # define PRINTF_INT64_HEX_WIDTH "16" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT32_HEX_WIDTH nuclear@0: # define PRINTF_INT32_HEX_WIDTH "8" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT16_HEX_WIDTH nuclear@0: # define PRINTF_INT16_HEX_WIDTH "4" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT8_HEX_WIDTH nuclear@0: # define PRINTF_INT8_HEX_WIDTH "2" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT64_DEC_WIDTH nuclear@0: # define PRINTF_INT64_DEC_WIDTH "20" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT32_DEC_WIDTH nuclear@0: # define PRINTF_INT32_DEC_WIDTH "10" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT16_DEC_WIDTH nuclear@0: # define PRINTF_INT16_DEC_WIDTH "5" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INT8_DEC_WIDTH nuclear@0: # define PRINTF_INT8_DEC_WIDTH "3" nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_HEX_WIDTH nuclear@0: # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_DEC_WIDTH nuclear@0: # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH nuclear@0: # endif nuclear@0: nuclear@0: /* nuclear@0: * Something really weird is going on with Open Watcom. Just pull some of nuclear@0: * these duplicated definitions from Open Watcom's stdint.h file for now. nuclear@0: */ nuclear@0: nuclear@0: # if defined (__WATCOMC__) && __WATCOMC__ >= 1250 nuclear@0: # if !defined (INT64_C) nuclear@0: # define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) nuclear@0: # endif nuclear@0: # if !defined (UINT64_C) nuclear@0: # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) nuclear@0: # endif nuclear@0: # if !defined (INT32_C) nuclear@0: # define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) nuclear@0: # endif nuclear@0: # if !defined (UINT32_C) nuclear@0: # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) nuclear@0: # endif nuclear@0: # if !defined (INT16_C) nuclear@0: # define INT16_C(x) (x) nuclear@0: # endif nuclear@0: # if !defined (UINT16_C) nuclear@0: # define UINT16_C(x) (x) nuclear@0: # endif nuclear@0: # if !defined (INT8_C) nuclear@0: # define INT8_C(x) (x) nuclear@0: # endif nuclear@0: # if !defined (UINT8_C) nuclear@0: # define UINT8_C(x) (x) nuclear@0: # endif nuclear@0: # if !defined (UINT64_MAX) nuclear@0: # define UINT64_MAX 18446744073709551615ULL nuclear@0: # endif nuclear@0: # if !defined (INT64_MAX) nuclear@0: # define INT64_MAX 9223372036854775807LL nuclear@0: # endif nuclear@0: # if !defined (UINT32_MAX) nuclear@0: # define UINT32_MAX 4294967295UL nuclear@0: # endif nuclear@0: # if !defined (INT32_MAX) nuclear@0: # define INT32_MAX 2147483647L nuclear@0: # endif nuclear@0: # if !defined (INTMAX_MAX) nuclear@0: # define INTMAX_MAX INT64_MAX nuclear@0: # endif nuclear@0: # if !defined (INTMAX_MIN) nuclear@0: # define INTMAX_MIN INT64_MIN nuclear@0: # endif nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef _PSTDINT_H_INCLUDED nuclear@0: #define _PSTDINT_H_INCLUDED nuclear@0: nuclear@0: #ifndef SIZE_MAX nuclear@0: # define SIZE_MAX (~(size_t)0) nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Deduce the type assignments from limits.h under the assumption that nuclear@0: * integer sizes in bits are powers of 2, and follow the ANSI nuclear@0: * definitions. nuclear@0: */ nuclear@0: nuclear@0: #ifndef UINT8_MAX nuclear@0: # define UINT8_MAX 0xff nuclear@0: #endif nuclear@0: #ifndef uint8_t nuclear@0: # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) nuclear@0: typedef unsigned char uint8_t; nuclear@0: # define UINT8_C(v) ((uint8_t) v) nuclear@0: # else nuclear@0: # error "Platform not supported" nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef INT8_MAX nuclear@0: # define INT8_MAX 0x7f nuclear@0: #endif nuclear@0: #ifndef INT8_MIN nuclear@0: # define INT8_MIN INT8_C(0x80) nuclear@0: #endif nuclear@0: #ifndef int8_t nuclear@0: # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) nuclear@0: typedef signed char int8_t; nuclear@0: # define INT8_C(v) ((int8_t) v) nuclear@0: # else nuclear@0: # error "Platform not supported" nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef UINT16_MAX nuclear@0: # define UINT16_MAX 0xffff nuclear@0: #endif nuclear@0: #ifndef uint16_t nuclear@0: #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) nuclear@0: typedef unsigned int uint16_t; nuclear@0: # ifndef PRINTF_INT16_MODIFIER nuclear@0: # define PRINTF_INT16_MODIFIER "" nuclear@0: # endif nuclear@0: # define UINT16_C(v) ((uint16_t) (v)) nuclear@0: #elif (USHRT_MAX == UINT16_MAX) nuclear@0: typedef unsigned short uint16_t; nuclear@0: # define UINT16_C(v) ((uint16_t) (v)) nuclear@0: # ifndef PRINTF_INT16_MODIFIER nuclear@0: # define PRINTF_INT16_MODIFIER "h" nuclear@0: # endif nuclear@0: #else nuclear@0: #error "Platform not supported" nuclear@0: #endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef INT16_MAX nuclear@0: # define INT16_MAX 0x7fff nuclear@0: #endif nuclear@0: #ifndef INT16_MIN nuclear@0: # define INT16_MIN INT16_C(0x8000) nuclear@0: #endif nuclear@0: #ifndef int16_t nuclear@0: #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) nuclear@0: typedef signed int int16_t; nuclear@0: # define INT16_C(v) ((int16_t) (v)) nuclear@0: # ifndef PRINTF_INT16_MODIFIER nuclear@0: # define PRINTF_INT16_MODIFIER "" nuclear@0: # endif nuclear@0: #elif (SHRT_MAX == INT16_MAX) nuclear@0: typedef signed short int16_t; nuclear@0: # define INT16_C(v) ((int16_t) (v)) nuclear@0: # ifndef PRINTF_INT16_MODIFIER nuclear@0: # define PRINTF_INT16_MODIFIER "h" nuclear@0: # endif nuclear@0: #else nuclear@0: #error "Platform not supported" nuclear@0: #endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef UINT32_MAX nuclear@0: # define UINT32_MAX (0xffffffffUL) nuclear@0: #endif nuclear@0: #ifndef uint32_t nuclear@0: #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) nuclear@0: typedef unsigned long uint32_t; nuclear@0: # define UINT32_C(v) v ## UL nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "l" nuclear@0: # endif nuclear@0: #elif (UINT_MAX == UINT32_MAX) nuclear@0: typedef unsigned int uint32_t; nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "" nuclear@0: # endif nuclear@0: # define UINT32_C(v) v ## U nuclear@0: #elif (USHRT_MAX == UINT32_MAX) nuclear@0: typedef unsigned short uint32_t; nuclear@0: # define UINT32_C(v) ((unsigned short) (v)) nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "" nuclear@0: # endif nuclear@0: #else nuclear@0: #error "Platform not supported" nuclear@0: #endif nuclear@0: #endif nuclear@0: nuclear@0: #ifndef INT32_MAX nuclear@0: # define INT32_MAX (0x7fffffffL) nuclear@0: #endif nuclear@0: #ifndef INT32_MIN nuclear@0: # define INT32_MIN INT32_C(0x80000000) nuclear@0: #endif nuclear@0: #ifndef int32_t nuclear@0: #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) nuclear@0: typedef signed long int32_t; nuclear@0: # define INT32_C(v) v ## L nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "l" nuclear@0: # endif nuclear@0: #elif (INT_MAX == INT32_MAX) nuclear@0: typedef signed int int32_t; nuclear@0: # define INT32_C(v) v nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "" nuclear@0: # endif nuclear@0: #elif (SHRT_MAX == INT32_MAX) nuclear@0: typedef signed short int32_t; nuclear@0: # define INT32_C(v) ((short) (v)) nuclear@0: # ifndef PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_INT32_MODIFIER "" nuclear@0: # endif nuclear@0: #else nuclear@0: #error "Platform not supported" nuclear@0: #endif nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * The macro stdint_int64_defined is temporarily used to record nuclear@0: * whether or not 64 integer support is available. It must be nuclear@0: * defined for any 64 integer extensions for new platforms that are nuclear@0: * added. nuclear@0: */ nuclear@0: nuclear@0: #undef stdint_int64_defined nuclear@0: #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) nuclear@0: # if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S) nuclear@0: # define stdint_int64_defined nuclear@0: typedef long long int64_t; nuclear@0: typedef unsigned long long uint64_t; nuclear@0: # define UINT64_C(v) v ## ULL nuclear@0: # define INT64_C(v) v ## LL nuclear@0: # ifndef PRINTF_INT64_MODIFIER nuclear@0: # define PRINTF_INT64_MODIFIER "ll" nuclear@0: # endif nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: #if !defined (stdint_int64_defined) nuclear@0: # if defined(__GNUC__) nuclear@0: # define stdint_int64_defined nuclear@0: __extension__ typedef long long int64_t; nuclear@0: __extension__ typedef unsigned long long uint64_t; nuclear@0: # define UINT64_C(v) v ## ULL nuclear@0: # define INT64_C(v) v ## LL nuclear@0: # ifndef PRINTF_INT64_MODIFIER nuclear@0: # define PRINTF_INT64_MODIFIER "ll" nuclear@0: # endif nuclear@0: # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) nuclear@0: # define stdint_int64_defined nuclear@0: typedef long long int64_t; nuclear@0: typedef unsigned long long uint64_t; nuclear@0: # define UINT64_C(v) v ## ULL nuclear@0: # define INT64_C(v) v ## LL nuclear@0: # ifndef PRINTF_INT64_MODIFIER nuclear@0: # define PRINTF_INT64_MODIFIER "ll" nuclear@0: # endif nuclear@0: # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) nuclear@0: # define stdint_int64_defined nuclear@0: typedef __int64 int64_t; nuclear@0: typedef unsigned __int64 uint64_t; nuclear@0: # define UINT64_C(v) v ## UI64 nuclear@0: # define INT64_C(v) v ## I64 nuclear@0: # ifndef PRINTF_INT64_MODIFIER nuclear@0: # define PRINTF_INT64_MODIFIER "I64" nuclear@0: # endif nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: #if !defined (LONG_LONG_MAX) && defined (INT64_C) nuclear@0: # define LONG_LONG_MAX INT64_C (9223372036854775807) nuclear@0: #endif nuclear@0: #ifndef ULONG_LONG_MAX nuclear@0: # define ULONG_LONG_MAX UINT64_C (18446744073709551615) nuclear@0: #endif nuclear@0: nuclear@0: #if !defined (INT64_MAX) && defined (INT64_C) nuclear@0: # define INT64_MAX INT64_C (9223372036854775807) nuclear@0: #endif nuclear@0: #if !defined (INT64_MIN) && defined (INT64_C) nuclear@0: # define INT64_MIN INT64_C (-9223372036854775808) nuclear@0: #endif nuclear@0: #if !defined (UINT64_MAX) && defined (INT64_C) nuclear@0: # define UINT64_MAX UINT64_C (18446744073709551615) nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Width of hexadecimal for number field. nuclear@0: */ nuclear@0: nuclear@0: #ifndef PRINTF_INT64_HEX_WIDTH nuclear@0: # define PRINTF_INT64_HEX_WIDTH "16" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT32_HEX_WIDTH nuclear@0: # define PRINTF_INT32_HEX_WIDTH "8" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT16_HEX_WIDTH nuclear@0: # define PRINTF_INT16_HEX_WIDTH "4" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT8_HEX_WIDTH nuclear@0: # define PRINTF_INT8_HEX_WIDTH "2" nuclear@0: #endif nuclear@0: nuclear@0: #ifndef PRINTF_INT64_DEC_WIDTH nuclear@0: # define PRINTF_INT64_DEC_WIDTH "20" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT32_DEC_WIDTH nuclear@0: # define PRINTF_INT32_DEC_WIDTH "10" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT16_DEC_WIDTH nuclear@0: # define PRINTF_INT16_DEC_WIDTH "5" nuclear@0: #endif nuclear@0: #ifndef PRINTF_INT8_DEC_WIDTH nuclear@0: # define PRINTF_INT8_DEC_WIDTH "3" nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Ok, lets not worry about 128 bit integers for now. Moore's law says nuclear@0: * we don't need to worry about that until about 2040 at which point nuclear@0: * we'll have bigger things to worry about. nuclear@0: */ nuclear@0: nuclear@0: #ifdef stdint_int64_defined nuclear@0: typedef int64_t intmax_t; nuclear@0: typedef uint64_t uintmax_t; nuclear@0: # define INTMAX_MAX INT64_MAX nuclear@0: # define INTMAX_MIN INT64_MIN nuclear@0: # define UINTMAX_MAX UINT64_MAX nuclear@0: # define UINTMAX_C(v) UINT64_C(v) nuclear@0: # define INTMAX_C(v) INT64_C(v) nuclear@0: # ifndef PRINTF_INTMAX_MODIFIER nuclear@0: # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_HEX_WIDTH nuclear@0: # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_DEC_WIDTH nuclear@0: # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH nuclear@0: # endif nuclear@0: #else nuclear@0: typedef int32_t intmax_t; nuclear@0: typedef uint32_t uintmax_t; nuclear@0: # define INTMAX_MAX INT32_MAX nuclear@0: # define UINTMAX_MAX UINT32_MAX nuclear@0: # define UINTMAX_C(v) UINT32_C(v) nuclear@0: # define INTMAX_C(v) INT32_C(v) nuclear@0: # ifndef PRINTF_INTMAX_MODIFIER nuclear@0: # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_HEX_WIDTH nuclear@0: # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH nuclear@0: # endif nuclear@0: # ifndef PRINTF_INTMAX_DEC_WIDTH nuclear@0: # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Because this file currently only supports platforms which have nuclear@0: * precise powers of 2 as bit sizes for the default integers, the nuclear@0: * least definitions are all trivial. Its possible that a future nuclear@0: * version of this file could have different definitions. nuclear@0: */ nuclear@0: nuclear@0: #ifndef stdint_least_defined nuclear@0: typedef int8_t int_least8_t; nuclear@0: typedef uint8_t uint_least8_t; nuclear@0: typedef int16_t int_least16_t; nuclear@0: typedef uint16_t uint_least16_t; nuclear@0: typedef int32_t int_least32_t; nuclear@0: typedef uint32_t uint_least32_t; nuclear@0: # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER nuclear@0: # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER nuclear@0: # define UINT_LEAST8_MAX UINT8_MAX nuclear@0: # define INT_LEAST8_MAX INT8_MAX nuclear@0: # define UINT_LEAST16_MAX UINT16_MAX nuclear@0: # define INT_LEAST16_MAX INT16_MAX nuclear@0: # define UINT_LEAST32_MAX UINT32_MAX nuclear@0: # define INT_LEAST32_MAX INT32_MAX nuclear@0: # define INT_LEAST8_MIN INT8_MIN nuclear@0: # define INT_LEAST16_MIN INT16_MIN nuclear@0: # define INT_LEAST32_MIN INT32_MIN nuclear@0: # ifdef stdint_int64_defined nuclear@0: typedef int64_t int_least64_t; nuclear@0: typedef uint64_t uint_least64_t; nuclear@0: # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER nuclear@0: # define UINT_LEAST64_MAX UINT64_MAX nuclear@0: # define INT_LEAST64_MAX INT64_MAX nuclear@0: # define INT_LEAST64_MIN INT64_MIN nuclear@0: # endif nuclear@0: #endif nuclear@0: #undef stdint_least_defined nuclear@0: nuclear@0: /* nuclear@0: * The ANSI C committee pretending to know or specify anything about nuclear@0: * performance is the epitome of misguided arrogance. The mandate of nuclear@0: * this file is to *ONLY* ever support that absolute minimum nuclear@0: * definition of the fast integer types, for compatibility purposes. nuclear@0: * No extensions, and no attempt to suggest what may or may not be a nuclear@0: * faster integer type will ever be made in this file. Developers are nuclear@0: * warned to stay away from these types when using this or any other nuclear@0: * stdint.h. nuclear@0: */ nuclear@0: nuclear@0: typedef int_least8_t int_fast8_t; nuclear@0: typedef uint_least8_t uint_fast8_t; nuclear@0: typedef int_least16_t int_fast16_t; nuclear@0: typedef uint_least16_t uint_fast16_t; nuclear@0: typedef int_least32_t int_fast32_t; nuclear@0: typedef uint_least32_t uint_fast32_t; nuclear@0: #define UINT_FAST8_MAX UINT_LEAST8_MAX nuclear@0: #define INT_FAST8_MAX INT_LEAST8_MAX nuclear@0: #define UINT_FAST16_MAX UINT_LEAST16_MAX nuclear@0: #define INT_FAST16_MAX INT_LEAST16_MAX nuclear@0: #define UINT_FAST32_MAX UINT_LEAST32_MAX nuclear@0: #define INT_FAST32_MAX INT_LEAST32_MAX nuclear@0: #define INT_FAST8_MIN INT_LEAST8_MIN nuclear@0: #define INT_FAST16_MIN INT_LEAST16_MIN nuclear@0: #define INT_FAST32_MIN INT_LEAST32_MIN nuclear@0: #ifdef stdint_int64_defined nuclear@0: typedef int_least64_t int_fast64_t; nuclear@0: typedef uint_least64_t uint_fast64_t; nuclear@0: # define UINT_FAST64_MAX UINT_LEAST64_MAX nuclear@0: # define INT_FAST64_MAX INT_LEAST64_MAX nuclear@0: # define INT_FAST64_MIN INT_LEAST64_MIN nuclear@0: #endif nuclear@0: nuclear@0: #undef stdint_int64_defined nuclear@0: nuclear@0: /* nuclear@0: * Whatever piecemeal, per compiler thing we can do about the wchar_t nuclear@0: * type limits. nuclear@0: */ nuclear@0: nuclear@0: #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) nuclear@0: # include nuclear@0: # ifndef WCHAR_MIN nuclear@0: # define WCHAR_MIN 0 nuclear@0: # endif nuclear@0: # ifndef WCHAR_MAX nuclear@0: # define WCHAR_MAX ((wchar_t)-1) nuclear@0: # endif nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Whatever piecemeal, per compiler/platform thing we can do about the nuclear@0: * (u)intptr_t types and limits. nuclear@0: */ nuclear@0: nuclear@0: #if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED) nuclear@0: # define STDINT_H_UINTPTR_T_DEFINED nuclear@0: #endif nuclear@0: nuclear@0: #ifndef STDINT_H_UINTPTR_T_DEFINED nuclear@0: # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) nuclear@0: # define stdint_intptr_bits 64 nuclear@0: # elif defined (__WATCOMC__) || defined (__TURBOC__) nuclear@0: # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) nuclear@0: # define stdint_intptr_bits 16 nuclear@0: # else nuclear@0: # define stdint_intptr_bits 32 nuclear@0: # endif nuclear@0: # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) nuclear@0: # define stdint_intptr_bits 32 nuclear@0: # elif defined (__INTEL_COMPILER) nuclear@0: /* TODO -- what will Intel do about x86-64? */ nuclear@0: # endif nuclear@0: nuclear@0: # ifdef stdint_intptr_bits nuclear@0: # define stdint_intptr_glue3_i(a,b,c) a##b##c nuclear@0: # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) nuclear@0: # ifndef PRINTF_INTPTR_MODIFIER nuclear@0: # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) nuclear@0: # endif nuclear@0: # ifndef PTRDIFF_MAX nuclear@0: # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) nuclear@0: # endif nuclear@0: # ifndef PTRDIFF_MIN nuclear@0: # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) nuclear@0: # endif nuclear@0: # ifndef UINTPTR_MAX nuclear@0: # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) nuclear@0: # endif nuclear@0: # ifndef INTPTR_MAX nuclear@0: # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) nuclear@0: # endif nuclear@0: # ifndef INTPTR_MIN nuclear@0: # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) nuclear@0: # endif nuclear@0: # ifndef INTPTR_C nuclear@0: # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) nuclear@0: # endif nuclear@0: # ifndef UINTPTR_C nuclear@0: # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) nuclear@0: # endif nuclear@0: typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; nuclear@0: typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; nuclear@0: # else nuclear@0: /* TODO -- This following is likely wrong for some platforms, and does nuclear@0: nothing for the definition of uintptr_t. */ nuclear@0: typedef ptrdiff_t intptr_t; nuclear@0: # endif nuclear@0: # define STDINT_H_UINTPTR_T_DEFINED nuclear@0: #endif nuclear@0: nuclear@0: /* nuclear@0: * Assumes sig_atomic_t is signed and we have a 2s complement machine. nuclear@0: */ nuclear@0: nuclear@0: #ifndef SIG_ATOMIC_MAX nuclear@0: # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) nuclear@0: #endif nuclear@0: nuclear@0: #endif nuclear@0: