root/win32/php_inttypes.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 // ISO C9x  compliant inttypes.h for Microsoft Visual Studio
   2 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
   3 //
   4 //  Copyright (c) 2006 Alexander Chemeris
   5 //
   6 // Redistribution and use in source and binary forms, with or without
   7 // modification, are permitted provided that the following conditions are met:
   8 //
   9 //   1. Redistributions of source code must retain the above copyright notice,
  10 //      this list of conditions and the following disclaimer.
  11 //
  12 //   2. Redistributions in binary form must reproduce the above copyright
  13 //      notice, this list of conditions and the following disclaimer in the
  14 //      documentation and/or other materials provided with the distribution.
  15 //
  16 //   3. The name of the author may be used to endorse or promote products
  17 //      derived from this software without specific prior written permission.
  18 //
  19 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  22 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29 //
  30 ///////////////////////////////////////////////////////////////////////////////
  31 
  32 #ifndef _MSC_VER // [
  33 #error "Use this header only with Microsoft Visual C++ compilers!"
  34 #endif // _MSC_VER ]
  35 
  36 // Starting with vc14, many of the C11 features are now included, so we only
  37 // need many of these typedefs and defines for older VS suites
  38 #if _MSC_VER < 1900
  39 
  40 #ifndef _MSC_INTTYPES_H_ // [
  41 #define _MSC_INTTYPES_H_
  42 
  43 #if _MSC_VER > 1000
  44 #pragma once
  45 #endif
  46 
  47 #include "stdint.h"
  48 
  49 // 7.8 Format conversion of integer types
  50 
  51 typedef struct {
  52    intmax_t quot;
  53    intmax_t rem;
  54 } imaxdiv_t;
  55 
  56 // 7.8.1 Macros for format specifiers
  57 
  58 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198
  59 
  60 // The fprintf macros for signed integers are:
  61 #define PRId8       "d"
  62 #define PRIi8       "i"
  63 #define PRIdLEAST8  "d"
  64 #define PRIiLEAST8  "i"
  65 #define PRIdFAST8   "d"
  66 #define PRIiFAST8   "i"
  67 
  68 #define PRId16       "hd"
  69 #define PRIi16       "hi"
  70 #define PRIdLEAST16  "hd"
  71 #define PRIiLEAST16  "hi"
  72 #define PRIdFAST16   "hd"
  73 #define PRIiFAST16   "hi"
  74 
  75 #define PRId32       "I32d"
  76 #define PRIi32       "I32i"
  77 #define PRIdLEAST32  "I32d"
  78 #define PRIiLEAST32  "I32i"
  79 #define PRIdFAST32   "I32d"
  80 #define PRIiFAST32   "I32i"
  81 
  82 #define PRId64       "I64d"
  83 #define PRIi64       "I64i"
  84 #define PRIdLEAST64  "I64d"
  85 #define PRIiLEAST64  "I64i"
  86 #define PRIdFAST64   "I64d"
  87 #define PRIiFAST64   "I64i"
  88 
  89 #define PRIdMAX     "I64d"
  90 #define PRIiMAX     "I64i"
  91 
  92 #define PRIdPTR     "Id"
  93 #define PRIiPTR     "Ii"
  94 
  95 // The fprintf macros for unsigned integers are:
  96 #define PRIo8       "o"
  97 #define PRIu8       "u"
  98 #define PRIx8       "x"
  99 #define PRIX8       "X"
 100 #define PRIoLEAST8  "o"
 101 #define PRIuLEAST8  "u"
 102 #define PRIxLEAST8  "x"
 103 #define PRIXLEAST8  "X"
 104 #define PRIoFAST8   "o"
 105 #define PRIuFAST8   "u"
 106 #define PRIxFAST8   "x"
 107 #define PRIXFAST8   "X"
 108 
 109 #define PRIo16       "ho"
 110 #define PRIu16       "hu"
 111 #define PRIx16       "hx"
 112 #define PRIX16       "hX"
 113 #define PRIoLEAST16  "ho"
 114 #define PRIuLEAST16  "hu"
 115 #define PRIxLEAST16  "hx"
 116 #define PRIXLEAST16  "hX"
 117 #define PRIoFAST16   "ho"
 118 #define PRIuFAST16   "hu"
 119 #define PRIxFAST16   "hx"
 120 #define PRIXFAST16   "hX"
 121 
 122 #define PRIo32       "I32o"
 123 #define PRIu32       "I32u"
 124 #define PRIx32       "I32x"
 125 #define PRIX32       "I32X"
 126 #define PRIoLEAST32  "I32o"
 127 #define PRIuLEAST32  "I32u"
 128 #define PRIxLEAST32  "I32x"
 129 #define PRIXLEAST32  "I32X"
 130 #define PRIoFAST32   "I32o"
 131 #define PRIuFAST32   "I32u"
 132 #define PRIxFAST32   "I32x"
 133 #define PRIXFAST32   "I32X"
 134 
 135 #define PRIo64       "I64o"
 136 #define PRIu64       "I64u"
 137 #define PRIx64       "I64x"
 138 #define PRIX64       "I64X"
 139 #define PRIoLEAST64  "I64o"
 140 #define PRIuLEAST64  "I64u"
 141 #define PRIxLEAST64  "I64x"
 142 #define PRIXLEAST64  "I64X"
 143 #define PRIoFAST64   "I64o"
 144 #define PRIuFAST64   "I64u"
 145 #define PRIxFAST64   "I64x"
 146 #define PRIXFAST64   "I64X"
 147 
 148 #define PRIoMAX     "I64o"
 149 #define PRIuMAX     "I64u"
 150 #define PRIxMAX     "I64x"
 151 #define PRIXMAX     "I64X"
 152 
 153 #define PRIoPTR     "Io"
 154 #define PRIuPTR     "Iu"
 155 #define PRIxPTR     "Ix"
 156 #define PRIXPTR     "IX"
 157 
 158 // The fscanf macros for signed integers are:
 159 #define SCNd8       "d"
 160 #define SCNi8       "i"
 161 #define SCNdLEAST8  "d"
 162 #define SCNiLEAST8  "i"
 163 #define SCNdFAST8   "d"
 164 #define SCNiFAST8   "i"
 165 
 166 #define SCNd16       "hd"
 167 #define SCNi16       "hi"
 168 #define SCNdLEAST16  "hd"
 169 #define SCNiLEAST16  "hi"
 170 #define SCNdFAST16   "hd"
 171 #define SCNiFAST16   "hi"
 172 
 173 #define SCNd32       "ld"
 174 #define SCNi32       "li"
 175 #define SCNdLEAST32  "ld"
 176 #define SCNiLEAST32  "li"
 177 #define SCNdFAST32   "ld"
 178 #define SCNiFAST32   "li"
 179 
 180 #define SCNd64       "I64d"
 181 #define SCNi64       "I64i"
 182 #define SCNdLEAST64  "I64d"
 183 #define SCNiLEAST64  "I64i"
 184 #define SCNdFAST64   "I64d"
 185 #define SCNiFAST64   "I64i"
 186 
 187 #define SCNdMAX     "I64d"
 188 #define SCNiMAX     "I64i"
 189 
 190 #ifdef _WIN64 // [
 191 #  define SCNdPTR     "I64d"
 192 #  define SCNiPTR     "I64i"
 193 #else  // _WIN64 ][
 194 #  define SCNdPTR     "ld"
 195 #  define SCNiPTR     "li"
 196 #endif  // _WIN64 ]
 197 
 198 // The fscanf macros for unsigned integers are:
 199 #define SCNo8       "o"
 200 #define SCNu8       "u"
 201 #define SCNx8       "x"
 202 #define SCNX8       "X"
 203 #define SCNoLEAST8  "o"
 204 #define SCNuLEAST8  "u"
 205 #define SCNxLEAST8  "x"
 206 #define SCNXLEAST8  "X"
 207 #define SCNoFAST8   "o"
 208 #define SCNuFAST8   "u"
 209 #define SCNxFAST8   "x"
 210 #define SCNXFAST8   "X"
 211 
 212 #define SCNo16       "ho"
 213 #define SCNu16       "hu"
 214 #define SCNx16       "hx"
 215 #define SCNX16       "hX"
 216 #define SCNoLEAST16  "ho"
 217 #define SCNuLEAST16  "hu"
 218 #define SCNxLEAST16  "hx"
 219 #define SCNXLEAST16  "hX"
 220 #define SCNoFAST16   "ho"
 221 #define SCNuFAST16   "hu"
 222 #define SCNxFAST16   "hx"
 223 #define SCNXFAST16   "hX"
 224 
 225 #define SCNo32       "lo"
 226 #define SCNu32       "lu"
 227 #define SCNx32       "lx"
 228 #define SCNX32       "lX"
 229 #define SCNoLEAST32  "lo"
 230 #define SCNuLEAST32  "lu"
 231 #define SCNxLEAST32  "lx"
 232 #define SCNXLEAST32  "lX"
 233 #define SCNoFAST32   "lo"
 234 #define SCNuFAST32   "lu"
 235 #define SCNxFAST32   "lx"
 236 #define SCNXFAST32   "lX"
 237 
 238 #define SCNo64       "I64o"
 239 #define SCNu64       "I64u"
 240 #define SCNx64       "I64x"
 241 #define SCNX64       "I64X"
 242 #define SCNoLEAST64  "I64o"
 243 #define SCNuLEAST64  "I64u"
 244 #define SCNxLEAST64  "I64x"
 245 #define SCNXLEAST64  "I64X"
 246 #define SCNoFAST64   "I64o"
 247 #define SCNuFAST64   "I64u"
 248 #define SCNxFAST64   "I64x"
 249 #define SCNXFAST64   "I64X"
 250 
 251 #define SCNoMAX     "I64o"
 252 #define SCNuMAX     "I64u"
 253 #define SCNxMAX     "I64x"
 254 #define SCNXMAX     "I64X"
 255 
 256 #ifdef _WIN64 // [
 257 #  define SCNoPTR     "I64o"
 258 #  define SCNuPTR     "I64u"
 259 #  define SCNxPTR     "I64x"
 260 #  define SCNXPTR     "I64X"
 261 #else  // _WIN64 ][
 262 #  define SCNoPTR     "lo"
 263 #  define SCNuPTR     "lu"
 264 #  define SCNxPTR     "lx"
 265 #  define SCNXPTR     "lX"
 266 #endif  // _WIN64 ]
 267 
 268 #endif // __STDC_FORMAT_MACROS ]
 269 
 270 // 7.8.2 Functions for greatest-width integer types
 271 
 272 // 7.8.2.1 The imaxabs function
 273 #define imaxabs _abs64
 274 
 275 // 7.8.2.2 The imaxdiv function
 276 
 277 // This is modified version of div() function from Microsoft's div.c found
 278 // in %MSVC.NET%\crt\src\div.c
 279 #ifdef STATIC_IMAXDIV // [
 280 static
 281 #else // STATIC_IMAXDIV ][
 282 _inline
 283 #endif // STATIC_IMAXDIV ]
 284 imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
 285 {
 286    imaxdiv_t result;
 287 
 288    result.quot = numer / denom;
 289    result.rem = numer % denom;
 290 
 291    if (numer < 0 && result.rem > 0) {
 292       // did division wrong; must fix up
 293       ++result.quot;
 294       result.rem -= denom;
 295    }
 296 
 297    return result;
 298 }
 299 
 300 // 7.8.2.3 The strtoimax and strtoumax functions
 301 #define strtoimax _strtoi64
 302 #define strtoumax _strtoui64
 303 
 304 // 7.8.2.4 The wcstoimax and wcstoumax functions
 305 #define wcstoimax _wcstoi64
 306 #define wcstoumax _wcstoui64
 307 
 308 
 309 #endif // _MSC_INTTYPES_H_ ]
 310 
 311 #else
 312 #include <inttypes.h>
 313 #endif
 314 

/* [<][>][^][v][top][bottom][index][help] */