Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:52:25

0001 // ISO C9x  compliant inttypes.h for Microsoft Visual Studio
0002 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
0003 // 
0004 //  Copyright (c) 2006-2013 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. Neither the name of the product nor the names of its contributors may
0017 //      be used to endorse or promote products derived from this software
0018 //      without specific prior written permission.
0019 // 
0020 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
0021 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
0022 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
0023 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0025 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
0026 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
0027 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0028 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
0029 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0030 // 
0031 ///////////////////////////////////////////////////////////////////////////////
0032 
0033 // The above software in this distribution may have been modified by 
0034 // THL A29 Limited ("Tencent Modifications"). 
0035 // All Tencent Modifications are Copyright (C) 2015 THL A29 Limited.
0036 
0037 #ifndef _MSC_VER // [
0038 #error "Use this header only with Microsoft Visual C++ compilers!"
0039 #endif // _MSC_VER ]
0040 
0041 #ifndef _MSC_INTTYPES_H_ // [
0042 #define _MSC_INTTYPES_H_
0043 
0044 #if _MSC_VER > 1000
0045 #pragma once
0046 #endif
0047 
0048 #include "stdint.h"
0049 
0050 // miloyip: VC supports inttypes.h since VC2013
0051 #if _MSC_VER >= 1800
0052 #include <inttypes.h>
0053 #else
0054 
0055 // 7.8 Format conversion of integer types
0056 
0057 typedef struct {
0058    intmax_t quot;
0059    intmax_t rem;
0060 } imaxdiv_t;
0061 
0062 // 7.8.1 Macros for format specifiers
0063 
0064 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198
0065 
0066 // The fprintf macros for signed integers are:
0067 #define PRId8       "d"
0068 #define PRIi8       "i"
0069 #define PRIdLEAST8  "d"
0070 #define PRIiLEAST8  "i"
0071 #define PRIdFAST8   "d"
0072 #define PRIiFAST8   "i"
0073 
0074 #define PRId16       "hd"
0075 #define PRIi16       "hi"
0076 #define PRIdLEAST16  "hd"
0077 #define PRIiLEAST16  "hi"
0078 #define PRIdFAST16   "hd"
0079 #define PRIiFAST16   "hi"
0080 
0081 #define PRId32       "I32d"
0082 #define PRIi32       "I32i"
0083 #define PRIdLEAST32  "I32d"
0084 #define PRIiLEAST32  "I32i"
0085 #define PRIdFAST32   "I32d"
0086 #define PRIiFAST32   "I32i"
0087 
0088 #define PRId64       "I64d"
0089 #define PRIi64       "I64i"
0090 #define PRIdLEAST64  "I64d"
0091 #define PRIiLEAST64  "I64i"
0092 #define PRIdFAST64   "I64d"
0093 #define PRIiFAST64   "I64i"
0094 
0095 #define PRIdMAX     "I64d"
0096 #define PRIiMAX     "I64i"
0097 
0098 #define PRIdPTR     "Id"
0099 #define PRIiPTR     "Ii"
0100 
0101 // The fprintf macros for unsigned integers are:
0102 #define PRIo8       "o"
0103 #define PRIu8       "u"
0104 #define PRIx8       "x"
0105 #define PRIX8       "X"
0106 #define PRIoLEAST8  "o"
0107 #define PRIuLEAST8  "u"
0108 #define PRIxLEAST8  "x"
0109 #define PRIXLEAST8  "X"
0110 #define PRIoFAST8   "o"
0111 #define PRIuFAST8   "u"
0112 #define PRIxFAST8   "x"
0113 #define PRIXFAST8   "X"
0114 
0115 #define PRIo16       "ho"
0116 #define PRIu16       "hu"
0117 #define PRIx16       "hx"
0118 #define PRIX16       "hX"
0119 #define PRIoLEAST16  "ho"
0120 #define PRIuLEAST16  "hu"
0121 #define PRIxLEAST16  "hx"
0122 #define PRIXLEAST16  "hX"
0123 #define PRIoFAST16   "ho"
0124 #define PRIuFAST16   "hu"
0125 #define PRIxFAST16   "hx"
0126 #define PRIXFAST16   "hX"
0127 
0128 #define PRIo32       "I32o"
0129 #define PRIu32       "I32u"
0130 #define PRIx32       "I32x"
0131 #define PRIX32       "I32X"
0132 #define PRIoLEAST32  "I32o"
0133 #define PRIuLEAST32  "I32u"
0134 #define PRIxLEAST32  "I32x"
0135 #define PRIXLEAST32  "I32X"
0136 #define PRIoFAST32   "I32o"
0137 #define PRIuFAST32   "I32u"
0138 #define PRIxFAST32   "I32x"
0139 #define PRIXFAST32   "I32X"
0140 
0141 #define PRIo64       "I64o"
0142 #define PRIu64       "I64u"
0143 #define PRIx64       "I64x"
0144 #define PRIX64       "I64X"
0145 #define PRIoLEAST64  "I64o"
0146 #define PRIuLEAST64  "I64u"
0147 #define PRIxLEAST64  "I64x"
0148 #define PRIXLEAST64  "I64X"
0149 #define PRIoFAST64   "I64o"
0150 #define PRIuFAST64   "I64u"
0151 #define PRIxFAST64   "I64x"
0152 #define PRIXFAST64   "I64X"
0153 
0154 #define PRIoMAX     "I64o"
0155 #define PRIuMAX     "I64u"
0156 #define PRIxMAX     "I64x"
0157 #define PRIXMAX     "I64X"
0158 
0159 #define PRIoPTR     "Io"
0160 #define PRIuPTR     "Iu"
0161 #define PRIxPTR     "Ix"
0162 #define PRIXPTR     "IX"
0163 
0164 // The fscanf macros for signed integers are:
0165 #define SCNd8       "d"
0166 #define SCNi8       "i"
0167 #define SCNdLEAST8  "d"
0168 #define SCNiLEAST8  "i"
0169 #define SCNdFAST8   "d"
0170 #define SCNiFAST8   "i"
0171 
0172 #define SCNd16       "hd"
0173 #define SCNi16       "hi"
0174 #define SCNdLEAST16  "hd"
0175 #define SCNiLEAST16  "hi"
0176 #define SCNdFAST16   "hd"
0177 #define SCNiFAST16   "hi"
0178 
0179 #define SCNd32       "ld"
0180 #define SCNi32       "li"
0181 #define SCNdLEAST32  "ld"
0182 #define SCNiLEAST32  "li"
0183 #define SCNdFAST32   "ld"
0184 #define SCNiFAST32   "li"
0185 
0186 #define SCNd64       "I64d"
0187 #define SCNi64       "I64i"
0188 #define SCNdLEAST64  "I64d"
0189 #define SCNiLEAST64  "I64i"
0190 #define SCNdFAST64   "I64d"
0191 #define SCNiFAST64   "I64i"
0192 
0193 #define SCNdMAX     "I64d"
0194 #define SCNiMAX     "I64i"
0195 
0196 #ifdef _WIN64 // [
0197 #  define SCNdPTR     "I64d"
0198 #  define SCNiPTR     "I64i"
0199 #else  // _WIN64 ][
0200 #  define SCNdPTR     "ld"
0201 #  define SCNiPTR     "li"
0202 #endif  // _WIN64 ]
0203 
0204 // The fscanf macros for unsigned integers are:
0205 #define SCNo8       "o"
0206 #define SCNu8       "u"
0207 #define SCNx8       "x"
0208 #define SCNX8       "X"
0209 #define SCNoLEAST8  "o"
0210 #define SCNuLEAST8  "u"
0211 #define SCNxLEAST8  "x"
0212 #define SCNXLEAST8  "X"
0213 #define SCNoFAST8   "o"
0214 #define SCNuFAST8   "u"
0215 #define SCNxFAST8   "x"
0216 #define SCNXFAST8   "X"
0217 
0218 #define SCNo16       "ho"
0219 #define SCNu16       "hu"
0220 #define SCNx16       "hx"
0221 #define SCNX16       "hX"
0222 #define SCNoLEAST16  "ho"
0223 #define SCNuLEAST16  "hu"
0224 #define SCNxLEAST16  "hx"
0225 #define SCNXLEAST16  "hX"
0226 #define SCNoFAST16   "ho"
0227 #define SCNuFAST16   "hu"
0228 #define SCNxFAST16   "hx"
0229 #define SCNXFAST16   "hX"
0230 
0231 #define SCNo32       "lo"
0232 #define SCNu32       "lu"
0233 #define SCNx32       "lx"
0234 #define SCNX32       "lX"
0235 #define SCNoLEAST32  "lo"
0236 #define SCNuLEAST32  "lu"
0237 #define SCNxLEAST32  "lx"
0238 #define SCNXLEAST32  "lX"
0239 #define SCNoFAST32   "lo"
0240 #define SCNuFAST32   "lu"
0241 #define SCNxFAST32   "lx"
0242 #define SCNXFAST32   "lX"
0243 
0244 #define SCNo64       "I64o"
0245 #define SCNu64       "I64u"
0246 #define SCNx64       "I64x"
0247 #define SCNX64       "I64X"
0248 #define SCNoLEAST64  "I64o"
0249 #define SCNuLEAST64  "I64u"
0250 #define SCNxLEAST64  "I64x"
0251 #define SCNXLEAST64  "I64X"
0252 #define SCNoFAST64   "I64o"
0253 #define SCNuFAST64   "I64u"
0254 #define SCNxFAST64   "I64x"
0255 #define SCNXFAST64   "I64X"
0256 
0257 #define SCNoMAX     "I64o"
0258 #define SCNuMAX     "I64u"
0259 #define SCNxMAX     "I64x"
0260 #define SCNXMAX     "I64X"
0261 
0262 #ifdef _WIN64 // [
0263 #  define SCNoPTR     "I64o"
0264 #  define SCNuPTR     "I64u"
0265 #  define SCNxPTR     "I64x"
0266 #  define SCNXPTR     "I64X"
0267 #else  // _WIN64 ][
0268 #  define SCNoPTR     "lo"
0269 #  define SCNuPTR     "lu"
0270 #  define SCNxPTR     "lx"
0271 #  define SCNXPTR     "lX"
0272 #endif  // _WIN64 ]
0273 
0274 #endif // __STDC_FORMAT_MACROS ]
0275 
0276 // 7.8.2 Functions for greatest-width integer types
0277 
0278 // 7.8.2.1 The imaxabs function
0279 #define imaxabs _abs64
0280 
0281 // 7.8.2.2 The imaxdiv function
0282 
0283 // This is modified version of div() function from Microsoft's div.c found
0284 // in %MSVC.NET%\crt\src\div.c
0285 #ifdef STATIC_IMAXDIV // [
0286 static
0287 #else // STATIC_IMAXDIV ][
0288 _inline
0289 #endif // STATIC_IMAXDIV ]
0290 imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
0291 {
0292    imaxdiv_t result;
0293 
0294    result.quot = numer / denom;
0295    result.rem = numer % denom;
0296 
0297    if (numer < 0 && result.rem > 0) {
0298       // did division wrong; must fix up
0299       ++result.quot;
0300       result.rem -= denom;
0301    }
0302 
0303    return result;
0304 }
0305 
0306 // 7.8.2.3 The strtoimax and strtoumax functions
0307 #define strtoimax _strtoi64
0308 #define strtoumax _strtoui64
0309 
0310 // 7.8.2.4 The wcstoimax and wcstoumax functions
0311 #define wcstoimax _wcstoi64
0312 #define wcstoumax _wcstoui64
0313 
0314 #endif // _MSC_VER >= 1800
0315 
0316 #endif // _MSC_INTTYPES_H_ ]