Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:09:37

0001 // ISO C9x  compliant stdint.h for Microsoft Visual Studio
0002 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
0003 //
0004 //  Copyright (c) 2006-2008 Alexander Chemeris
0005 //
0006 // Redistribution and use in source and binary forms, with or without
0007 // modification, are permitted provided that the following conditions are met:
0008 //
0009 //   1. Redistributions of source code must retain the above copyright notice,
0010 //      this list of conditions and the following disclaimer.
0011 //
0012 //   2. Redistributions in binary form must reproduce the above copyright
0013 //      notice, this list of conditions and the following disclaimer in the
0014 //      documentation and/or other materials provided with the distribution.
0015 //
0016 //   3. The name of the author may be used to endorse or promote products
0017 //      derived from this software without specific prior written permission.
0018 //
0019 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
0020 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
0021 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
0022 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
0025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
0028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0029 //
0030 ///////////////////////////////////////////////////////////////////////////////
0031 
0032 #ifdef _MSC_VER // [
0033 
0034 #ifndef _MSC_STDINT_H_ // [
0035 #define _MSC_STDINT_H_
0036 
0037 #if _MSC_VER > 1000
0038 #pragma once
0039 #endif
0040 
0041 #include <limits.h>
0042 
0043 // For Visual Studio 6 in C++ mode and for many Visual Studio versions when
0044 // compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
0045 // or compiler give many errors like this:
0046 //   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
0047 #ifdef __cplusplus
0048 extern "C" {
0049 #endif
0050 #  include <wchar.h>
0051 #ifdef __cplusplus
0052 }
0053 #endif
0054 
0055 // Define _W64 macros to mark types changing their size, like intptr_t.
0056 #ifndef _W64
0057 #  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
0058 #     define _W64 __w64
0059 #  else
0060 #     define _W64
0061 #  endif
0062 #endif
0063 
0064 
0065 // 7.18.1 Integer types
0066 
0067 // 7.18.1.1 Exact-width integer types
0068 
0069 // Visual Studio 6 and Embedded Visual C++ 4 doesn't
0070 // realize that, e.g. char has the same size as __int8
0071 // so we give up on __intX for them.
0072 #if (_MSC_VER < 1300)
0073    typedef signed char       int8_t;
0074    typedef signed short      int16_t;
0075    typedef signed int        int32_t;
0076    typedef unsigned char     uint8_t;
0077    typedef unsigned short    uint16_t;
0078    typedef unsigned int      uint32_t;
0079 #else
0080    typedef signed __int8     int8_t;
0081    typedef signed __int16    int16_t;
0082    typedef signed __int32    int32_t;
0083    typedef unsigned __int8   uint8_t;
0084    typedef unsigned __int16  uint16_t;
0085    typedef unsigned __int32  uint32_t;
0086 #endif
0087 typedef signed __int64       int64_t;
0088 typedef unsigned __int64     uint64_t;
0089 
0090 
0091 // 7.18.1.2 Minimum-width integer types
0092 typedef int8_t    int_least8_t;
0093 typedef int16_t   int_least16_t;
0094 typedef int32_t   int_least32_t;
0095 typedef int64_t   int_least64_t;
0096 typedef uint8_t   uint_least8_t;
0097 typedef uint16_t  uint_least16_t;
0098 typedef uint32_t  uint_least32_t;
0099 typedef uint64_t  uint_least64_t;
0100 
0101 // 7.18.1.3 Fastest minimum-width integer types
0102 typedef int8_t    int_fast8_t;
0103 typedef int16_t   int_fast16_t;
0104 typedef int32_t   int_fast32_t;
0105 typedef int64_t   int_fast64_t;
0106 typedef uint8_t   uint_fast8_t;
0107 typedef uint16_t  uint_fast16_t;
0108 typedef uint32_t  uint_fast32_t;
0109 typedef uint64_t  uint_fast64_t;
0110 
0111 // 7.18.1.4 Integer types capable of holding object pointers
0112 #ifdef _WIN64 // [
0113    typedef signed __int64    intptr_t;
0114    typedef unsigned __int64  uintptr_t;
0115 #else // _WIN64 ][
0116    typedef _W64 signed int   intptr_t;
0117    typedef _W64 unsigned int uintptr_t;
0118 #endif // _WIN64 ]
0119 
0120 // 7.18.1.5 Greatest-width integer types
0121 typedef int64_t   intmax_t;
0122 typedef uint64_t  uintmax_t;
0123 
0124 
0125 // 7.18.2 Limits of specified-width integer types
0126 
0127 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259
0128 
0129 // 7.18.2.1 Limits of exact-width integer types
0130 #define INT8_MIN     ((int8_t)_I8_MIN)
0131 #define INT8_MAX     _I8_MAX
0132 #define INT16_MIN    ((int16_t)_I16_MIN)
0133 #define INT16_MAX    _I16_MAX
0134 #define INT32_MIN    ((int32_t)_I32_MIN)
0135 #define INT32_MAX    _I32_MAX
0136 #define INT64_MIN    ((int64_t)_I64_MIN)
0137 #define INT64_MAX    _I64_MAX
0138 #define UINT8_MAX    _UI8_MAX
0139 #define UINT16_MAX   _UI16_MAX
0140 #define UINT32_MAX   _UI32_MAX
0141 #define UINT64_MAX   _UI64_MAX
0142 
0143 // 7.18.2.2 Limits of minimum-width integer types
0144 #define INT_LEAST8_MIN    INT8_MIN
0145 #define INT_LEAST8_MAX    INT8_MAX
0146 #define INT_LEAST16_MIN   INT16_MIN
0147 #define INT_LEAST16_MAX   INT16_MAX
0148 #define INT_LEAST32_MIN   INT32_MIN
0149 #define INT_LEAST32_MAX   INT32_MAX
0150 #define INT_LEAST64_MIN   INT64_MIN
0151 #define INT_LEAST64_MAX   INT64_MAX
0152 #define UINT_LEAST8_MAX   UINT8_MAX
0153 #define UINT_LEAST16_MAX  UINT16_MAX
0154 #define UINT_LEAST32_MAX  UINT32_MAX
0155 #define UINT_LEAST64_MAX  UINT64_MAX
0156 
0157 // 7.18.2.3 Limits of fastest minimum-width integer types
0158 #define INT_FAST8_MIN    INT8_MIN
0159 #define INT_FAST8_MAX    INT8_MAX
0160 #define INT_FAST16_MIN   INT16_MIN
0161 #define INT_FAST16_MAX   INT16_MAX
0162 #define INT_FAST32_MIN   INT32_MIN
0163 #define INT_FAST32_MAX   INT32_MAX
0164 #define INT_FAST64_MIN   INT64_MIN
0165 #define INT_FAST64_MAX   INT64_MAX
0166 #define UINT_FAST8_MAX   UINT8_MAX
0167 #define UINT_FAST16_MAX  UINT16_MAX
0168 #define UINT_FAST32_MAX  UINT32_MAX
0169 #define UINT_FAST64_MAX  UINT64_MAX
0170 
0171 // 7.18.2.4 Limits of integer types capable of holding object pointers
0172 #ifdef _WIN64 // [
0173 #  define INTPTR_MIN   INT64_MIN
0174 #  define INTPTR_MAX   INT64_MAX
0175 #  define UINTPTR_MAX  UINT64_MAX
0176 #else // _WIN64 ][
0177 #  define INTPTR_MIN   INT32_MIN
0178 #  define INTPTR_MAX   INT32_MAX
0179 #  define UINTPTR_MAX  UINT32_MAX
0180 #endif // _WIN64 ]
0181 
0182 // 7.18.2.5 Limits of greatest-width integer types
0183 #define INTMAX_MIN   INT64_MIN
0184 #define INTMAX_MAX   INT64_MAX
0185 #define UINTMAX_MAX  UINT64_MAX
0186 
0187 // 7.18.3 Limits of other integer types
0188 
0189 #ifdef _WIN64 // [
0190 #  define PTRDIFF_MIN  _I64_MIN
0191 #  define PTRDIFF_MAX  _I64_MAX
0192 #else  // _WIN64 ][
0193 #  define PTRDIFF_MIN  _I32_MIN
0194 #  define PTRDIFF_MAX  _I32_MAX
0195 #endif  // _WIN64 ]
0196 
0197 #define SIG_ATOMIC_MIN  INT_MIN
0198 #define SIG_ATOMIC_MAX  INT_MAX
0199 
0200 #ifndef SIZE_MAX // [
0201 #  ifdef _WIN64 // [
0202 #     define SIZE_MAX  _UI64_MAX
0203 #  else // _WIN64 ][
0204 #     define SIZE_MAX  _UI32_MAX
0205 #  endif // _WIN64 ]
0206 #endif // SIZE_MAX ]
0207 
0208 // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
0209 #ifndef WCHAR_MIN // [
0210 #  define WCHAR_MIN  0
0211 #endif  // WCHAR_MIN ]
0212 #ifndef WCHAR_MAX // [
0213 #  define WCHAR_MAX  _UI16_MAX
0214 #endif  // WCHAR_MAX ]
0215 
0216 #define WINT_MIN  0
0217 #define WINT_MAX  _UI16_MAX
0218 
0219 #endif // __STDC_LIMIT_MACROS ]
0220 
0221 
0222 // 7.18.4 Limits of other integer types
0223 
0224 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260
0225 
0226 // 7.18.4.1 Macros for minimum-width integer constants
0227 
0228 #define INT8_C(val)  val##i8
0229 #define INT16_C(val) val##i16
0230 #define INT32_C(val) val##i32
0231 #define INT64_C(val) val##i64
0232 
0233 #define UINT8_C(val)  val##ui8
0234 #define UINT16_C(val) val##ui16
0235 #define UINT32_C(val) val##ui32
0236 #define UINT64_C(val) val##ui64
0237 
0238 // 7.18.4.2 Macros for greatest-width integer constants
0239 #define INTMAX_C   INT64_C
0240 #define UINTMAX_C  UINT64_C
0241 
0242 #endif // __STDC_CONSTANT_MACROS ]
0243 
0244 
0245 #endif // _MSC_STDINT_H_ ]
0246 
0247 #endif // _MSC_VER ]