universe@102: // ISO C9x compliant stdint.h for Microsoft Visual Studio universe@102: // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 universe@102: // universe@102: // Copyright (c) 2006-2008 Alexander Chemeris universe@102: // universe@102: // Redistribution and use in source and binary forms, with or without universe@102: // modification, are permitted provided that the following conditions are met: universe@102: // universe@102: // 1. Redistributions of source code must retain the above copyright notice, universe@102: // this list of conditions and the following disclaimer. universe@102: // universe@102: // 2. Redistributions in binary form must reproduce the above copyright universe@102: // notice, this list of conditions and the following disclaimer in the universe@102: // documentation and/or other materials provided with the distribution. universe@102: // universe@102: // 3. The name of the author may be used to endorse or promote products universe@102: // derived from this software without specific prior written permission. universe@102: // universe@102: // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED universe@102: // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF universe@102: // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO universe@102: // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, universe@102: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, universe@102: // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; universe@102: // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, universe@102: // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR universe@102: // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF universe@102: // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. universe@102: // universe@102: /////////////////////////////////////////////////////////////////////////////// universe@102: universe@102: #ifndef _MSC_VER // [ universe@102: #error "Use this header only with Microsoft Visual C++ compilers!" universe@102: #endif // _MSC_VER ] universe@102: universe@102: #ifndef _MSC_STDINT_H_ // [ universe@102: #define _MSC_STDINT_H_ universe@102: universe@102: #if _MSC_VER > 1000 universe@102: #pragma once universe@102: #endif universe@102: universe@102: #include universe@102: universe@102: // For Visual Studio 6 in C++ mode and for many Visual Studio versions when universe@102: // compiling for ARM we should wrap include with 'extern "C++" {}' universe@102: // or compiler give many errors like this: universe@102: // error C2733: second C linkage of overloaded function 'wmemchr' not allowed universe@102: #ifdef __cplusplus universe@102: extern "C" { universe@102: #endif universe@102: # include universe@102: #ifdef __cplusplus universe@102: } universe@102: #endif universe@102: universe@102: // Define _W64 macros to mark types changing their size, like intptr_t. universe@102: #ifndef _W64 universe@102: # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 universe@102: # define _W64 __w64 universe@102: # else universe@102: # define _W64 universe@102: # endif universe@102: #endif universe@102: universe@102: universe@102: // 7.18.1 Integer types universe@102: universe@102: // 7.18.1.1 Exact-width integer types universe@102: universe@102: // Visual Studio 6 and Embedded Visual C++ 4 doesn't universe@102: // realize that, e.g. char has the same size as __int8 universe@102: // so we give up on __intX for them. universe@102: #if (_MSC_VER < 1300) universe@102: typedef signed char int8_t; universe@102: typedef signed short int16_t; universe@102: typedef signed int int32_t; universe@102: typedef unsigned char uint8_t; universe@102: typedef unsigned short uint16_t; universe@102: typedef unsigned int uint32_t; universe@102: #else universe@102: typedef signed __int8 int8_t; universe@102: typedef signed __int16 int16_t; universe@102: typedef signed __int32 int32_t; universe@102: typedef unsigned __int8 uint8_t; universe@102: typedef unsigned __int16 uint16_t; universe@102: typedef unsigned __int32 uint32_t; universe@102: #endif universe@102: typedef signed __int64 int64_t; universe@102: typedef unsigned __int64 uint64_t; universe@102: universe@102: universe@102: // 7.18.1.2 Minimum-width integer types universe@102: typedef int8_t int_least8_t; universe@102: typedef int16_t int_least16_t; universe@102: typedef int32_t int_least32_t; universe@102: typedef int64_t int_least64_t; universe@102: typedef uint8_t uint_least8_t; universe@102: typedef uint16_t uint_least16_t; universe@102: typedef uint32_t uint_least32_t; universe@102: typedef uint64_t uint_least64_t; universe@102: universe@102: // 7.18.1.3 Fastest minimum-width integer types universe@102: typedef int8_t int_fast8_t; universe@102: typedef int16_t int_fast16_t; universe@102: typedef int32_t int_fast32_t; universe@102: typedef int64_t int_fast64_t; universe@102: typedef uint8_t uint_fast8_t; universe@102: typedef uint16_t uint_fast16_t; universe@102: typedef uint32_t uint_fast32_t; universe@102: typedef uint64_t uint_fast64_t; universe@102: universe@102: // 7.18.1.4 Integer types capable of holding object pointers universe@102: #ifdef _WIN64 // [ universe@102: typedef signed __int64 intptr_t; universe@102: typedef unsigned __int64 uintptr_t; universe@102: #else // _WIN64 ][ universe@102: typedef _W64 signed int intptr_t; universe@102: typedef _W64 unsigned int uintptr_t; universe@102: #endif // _WIN64 ] universe@102: universe@102: // 7.18.1.5 Greatest-width integer types universe@102: typedef int64_t intmax_t; universe@102: typedef uint64_t uintmax_t; universe@102: universe@102: universe@102: // 7.18.2 Limits of specified-width integer types universe@102: universe@102: #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 universe@102: universe@102: // 7.18.2.1 Limits of exact-width integer types universe@102: #define INT8_MIN ((int8_t)_I8_MIN) universe@102: #define INT8_MAX _I8_MAX universe@102: #define INT16_MIN ((int16_t)_I16_MIN) universe@102: #define INT16_MAX _I16_MAX universe@102: #define INT32_MIN ((int32_t)_I32_MIN) universe@102: #define INT32_MAX _I32_MAX universe@102: #define INT64_MIN ((int64_t)_I64_MIN) universe@102: #define INT64_MAX _I64_MAX universe@102: #define UINT8_MAX _UI8_MAX universe@102: #define UINT16_MAX _UI16_MAX universe@102: #define UINT32_MAX _UI32_MAX universe@102: #define UINT64_MAX _UI64_MAX universe@102: universe@102: // 7.18.2.2 Limits of minimum-width integer types universe@102: #define INT_LEAST8_MIN INT8_MIN universe@102: #define INT_LEAST8_MAX INT8_MAX universe@102: #define INT_LEAST16_MIN INT16_MIN universe@102: #define INT_LEAST16_MAX INT16_MAX universe@102: #define INT_LEAST32_MIN INT32_MIN universe@102: #define INT_LEAST32_MAX INT32_MAX universe@102: #define INT_LEAST64_MIN INT64_MIN universe@102: #define INT_LEAST64_MAX INT64_MAX universe@102: #define UINT_LEAST8_MAX UINT8_MAX universe@102: #define UINT_LEAST16_MAX UINT16_MAX universe@102: #define UINT_LEAST32_MAX UINT32_MAX universe@102: #define UINT_LEAST64_MAX UINT64_MAX universe@102: universe@102: // 7.18.2.3 Limits of fastest minimum-width integer types universe@102: #define INT_FAST8_MIN INT8_MIN universe@102: #define INT_FAST8_MAX INT8_MAX universe@102: #define INT_FAST16_MIN INT16_MIN universe@102: #define INT_FAST16_MAX INT16_MAX universe@102: #define INT_FAST32_MIN INT32_MIN universe@102: #define INT_FAST32_MAX INT32_MAX universe@102: #define INT_FAST64_MIN INT64_MIN universe@102: #define INT_FAST64_MAX INT64_MAX universe@102: #define UINT_FAST8_MAX UINT8_MAX universe@102: #define UINT_FAST16_MAX UINT16_MAX universe@102: #define UINT_FAST32_MAX UINT32_MAX universe@102: #define UINT_FAST64_MAX UINT64_MAX universe@102: universe@102: // 7.18.2.4 Limits of integer types capable of holding object pointers universe@102: #ifdef _WIN64 // [ universe@102: # define INTPTR_MIN INT64_MIN universe@102: # define INTPTR_MAX INT64_MAX universe@102: # define UINTPTR_MAX UINT64_MAX universe@102: #else // _WIN64 ][ universe@102: # define INTPTR_MIN INT32_MIN universe@102: # define INTPTR_MAX INT32_MAX universe@102: # define UINTPTR_MAX UINT32_MAX universe@102: #endif // _WIN64 ] universe@102: universe@102: // 7.18.2.5 Limits of greatest-width integer types universe@102: #define INTMAX_MIN INT64_MIN universe@102: #define INTMAX_MAX INT64_MAX universe@102: #define UINTMAX_MAX UINT64_MAX universe@102: universe@102: // 7.18.3 Limits of other integer types universe@102: universe@102: #ifdef _WIN64 // [ universe@102: # define PTRDIFF_MIN _I64_MIN universe@102: # define PTRDIFF_MAX _I64_MAX universe@102: #else // _WIN64 ][ universe@102: # define PTRDIFF_MIN _I32_MIN universe@102: # define PTRDIFF_MAX _I32_MAX universe@102: #endif // _WIN64 ] universe@102: universe@102: #define SIG_ATOMIC_MIN INT_MIN universe@102: #define SIG_ATOMIC_MAX INT_MAX universe@102: universe@102: #ifndef SIZE_MAX // [ universe@102: # ifdef _WIN64 // [ universe@102: # define SIZE_MAX _UI64_MAX universe@102: # else // _WIN64 ][ universe@102: # define SIZE_MAX _UI32_MAX universe@102: # endif // _WIN64 ] universe@102: #endif // SIZE_MAX ] universe@102: universe@102: // WCHAR_MIN and WCHAR_MAX are also defined in universe@102: #ifndef WCHAR_MIN // [ universe@102: # define WCHAR_MIN 0 universe@102: #endif // WCHAR_MIN ] universe@102: #ifndef WCHAR_MAX // [ universe@102: # define WCHAR_MAX _UI16_MAX universe@102: #endif // WCHAR_MAX ] universe@102: universe@102: #define WINT_MIN 0 universe@102: #define WINT_MAX _UI16_MAX universe@102: universe@102: #endif // __STDC_LIMIT_MACROS ] universe@102: universe@102: universe@102: // 7.18.4 Limits of other integer types universe@102: universe@102: #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 universe@102: universe@102: // 7.18.4.1 Macros for minimum-width integer constants universe@102: universe@102: #define INT8_C(val) val##i8 universe@102: #define INT16_C(val) val##i16 universe@102: #define INT32_C(val) val##i32 universe@102: #define INT64_C(val) val##i64 universe@102: universe@102: #define UINT8_C(val) val##ui8 universe@102: #define UINT16_C(val) val##ui16 universe@102: #define UINT32_C(val) val##ui32 universe@102: #define UINT64_C(val) val##ui64 universe@102: universe@102: // 7.18.4.2 Macros for greatest-width integer constants universe@102: #define INTMAX_C INT64_C universe@102: #define UINTMAX_C UINT64_C universe@102: universe@102: #endif // __STDC_CONSTANT_MACROS ] universe@102: universe@102: universe@102: #endif // _MSC_STDINT_H_ ]