Home | History | Annotate | Download | only in os-win32
      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 INTTYPES_WIN32_H
     33 #define INTTYPES_WIN32_H
     34 
     35 #include <wtf/Platform.h>
     36 
     37 #if !COMPILER(MSVC)
     38 #error "This inttypes.h file should only be compiled with MSVC"
     39 #endif
     40 
     41 #if _MSC_VER > 1000
     42 #pragma once
     43 #endif
     44 
     45 #include "stdint.h"
     46 
     47 // 7.8.1 Macros for format specifiers
     48 
     49 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
     50 
     51 // The fprintf macros for signed integers are:
     52 #define PRId8       "d"
     53 #define PRIi8       "i"
     54 #define PRIdLEAST8  "d"
     55 #define PRIiLEAST8  "i"
     56 #define PRIdFAST8   "d"
     57 #define PRIiFAST8   "i"
     58 
     59 #define PRId16       "hd"
     60 #define PRIi16       "hi"
     61 #define PRIdLEAST16  "hd"
     62 #define PRIiLEAST16  "hi"
     63 #define PRIdFAST16   "hd"
     64 #define PRIiFAST16   "hi"
     65 
     66 #define PRId32       "I32d"
     67 #define PRIi32       "I32i"
     68 #define PRIdLEAST32  "I32d"
     69 #define PRIiLEAST32  "I32i"
     70 #define PRIdFAST32   "I32d"
     71 #define PRIiFAST32   "I32i"
     72 
     73 #define PRId64       "I64d"
     74 #define PRIi64       "I64i"
     75 #define PRIdLEAST64  "I64d"
     76 #define PRIiLEAST64  "I64i"
     77 #define PRIdFAST64   "I64d"
     78 #define PRIiFAST64   "I64i"
     79 
     80 #define PRIdMAX     "I64d"
     81 #define PRIiMAX     "I64i"
     82 
     83 #define PRIdPTR     "Id"
     84 #define PRIiPTR     "Ii"
     85 
     86 // The fprintf macros for unsigned integers are:
     87 #define PRIo8       "o"
     88 #define PRIu8       "u"
     89 #define PRIx8       "x"
     90 #define PRIX8       "X"
     91 #define PRIoLEAST8  "o"
     92 #define PRIuLEAST8  "u"
     93 #define PRIxLEAST8  "x"
     94 #define PRIXLEAST8  "X"
     95 #define PRIoFAST8   "o"
     96 #define PRIuFAST8   "u"
     97 #define PRIxFAST8   "x"
     98 #define PRIXFAST8   "X"
     99 
    100 #define PRIo16       "ho"
    101 #define PRIu16       "hu"
    102 #define PRIx16       "hx"
    103 #define PRIX16       "hX"
    104 #define PRIoLEAST16  "ho"
    105 #define PRIuLEAST16  "hu"
    106 #define PRIxLEAST16  "hx"
    107 #define PRIXLEAST16  "hX"
    108 #define PRIoFAST16   "ho"
    109 #define PRIuFAST16   "hu"
    110 #define PRIxFAST16   "hx"
    111 #define PRIXFAST16   "hX"
    112 
    113 #define PRIo32       "I32o"
    114 #define PRIu32       "I32u"
    115 #define PRIx32       "I32x"
    116 #define PRIX32       "I32X"
    117 #define PRIoLEAST32  "I32o"
    118 #define PRIuLEAST32  "I32u"
    119 #define PRIxLEAST32  "I32x"
    120 #define PRIXLEAST32  "I32X"
    121 #define PRIoFAST32   "I32o"
    122 #define PRIuFAST32   "I32u"
    123 #define PRIxFAST32   "I32x"
    124 #define PRIXFAST32   "I32X"
    125 
    126 #define PRIo64       "I64o"
    127 #define PRIu64       "I64u"
    128 #define PRIx64       "I64x"
    129 #define PRIX64       "I64X"
    130 #define PRIoLEAST64  "I64o"
    131 #define PRIuLEAST64  "I64u"
    132 #define PRIxLEAST64  "I64x"
    133 #define PRIXLEAST64  "I64X"
    134 #define PRIoFAST64   "I64o"
    135 #define PRIuFAST64   "I64u"
    136 #define PRIxFAST64   "I64x"
    137 #define PRIXFAST64   "I64X"
    138 
    139 #define PRIoMAX     "I64o"
    140 #define PRIuMAX     "I64u"
    141 #define PRIxMAX     "I64x"
    142 #define PRIXMAX     "I64X"
    143 
    144 #define PRIoPTR     "Io"
    145 #define PRIuPTR     "Iu"
    146 #define PRIxPTR     "Ix"
    147 #define PRIXPTR     "IX"
    148 
    149 // The fscanf macros for signed integers are:
    150 #define SCNd8       "d"
    151 #define SCNi8       "i"
    152 #define SCNdLEAST8  "d"
    153 #define SCNiLEAST8  "i"
    154 #define SCNdFAST8   "d"
    155 #define SCNiFAST8   "i"
    156 
    157 #define SCNd16       "hd"
    158 #define SCNi16       "hi"
    159 #define SCNdLEAST16  "hd"
    160 #define SCNiLEAST16  "hi"
    161 #define SCNdFAST16   "hd"
    162 #define SCNiFAST16   "hi"
    163 
    164 #define SCNd32       "ld"
    165 #define SCNi32       "li"
    166 #define SCNdLEAST32  "ld"
    167 #define SCNiLEAST32  "li"
    168 #define SCNdFAST32   "ld"
    169 #define SCNiFAST32   "li"
    170 
    171 #define SCNd64       "I64d"
    172 #define SCNi64       "I64i"
    173 #define SCNdLEAST64  "I64d"
    174 #define SCNiLEAST64  "I64i"
    175 #define SCNdFAST64   "I64d"
    176 #define SCNiFAST64   "I64i"
    177 
    178 #define SCNdMAX     "I64d"
    179 #define SCNiMAX     "I64i"
    180 
    181 #ifdef _WIN64
    182 #  define SCNdPTR     "I64d"
    183 #  define SCNiPTR     "I64i"
    184 #else
    185 #  define SCNdPTR     "ld"
    186 #  define SCNiPTR     "li"
    187 #endif
    188 
    189 // The fscanf macros for unsigned integers are:
    190 #define SCNo8       "o"
    191 #define SCNu8       "u"
    192 #define SCNx8       "x"
    193 #define SCNX8       "X"
    194 #define SCNoLEAST8  "o"
    195 #define SCNuLEAST8  "u"
    196 #define SCNxLEAST8  "x"
    197 #define SCNXLEAST8  "X"
    198 #define SCNoFAST8   "o"
    199 #define SCNuFAST8   "u"
    200 #define SCNxFAST8   "x"
    201 #define SCNXFAST8   "X"
    202 
    203 #define SCNo16       "ho"
    204 #define SCNu16       "hu"
    205 #define SCNx16       "hx"
    206 #define SCNX16       "hX"
    207 #define SCNoLEAST16  "ho"
    208 #define SCNuLEAST16  "hu"
    209 #define SCNxLEAST16  "hx"
    210 #define SCNXLEAST16  "hX"
    211 #define SCNoFAST16   "ho"
    212 #define SCNuFAST16   "hu"
    213 #define SCNxFAST16   "hx"
    214 #define SCNXFAST16   "hX"
    215 
    216 #define SCNo32       "lo"
    217 #define SCNu32       "lu"
    218 #define SCNx32       "lx"
    219 #define SCNX32       "lX"
    220 #define SCNoLEAST32  "lo"
    221 #define SCNuLEAST32  "lu"
    222 #define SCNxLEAST32  "lx"
    223 #define SCNXLEAST32  "lX"
    224 #define SCNoFAST32   "lo"
    225 #define SCNuFAST32   "lu"
    226 #define SCNxFAST32   "lx"
    227 #define SCNXFAST32   "lX"
    228 
    229 #define SCNo64       "I64o"
    230 #define SCNu64       "I64u"
    231 #define SCNx64       "I64x"
    232 #define SCNX64       "I64X"
    233 #define SCNoLEAST64  "I64o"
    234 #define SCNuLEAST64  "I64u"
    235 #define SCNxLEAST64  "I64x"
    236 #define SCNXLEAST64  "I64X"
    237 #define SCNoFAST64   "I64o"
    238 #define SCNuFAST64   "I64u"
    239 #define SCNxFAST64   "I64x"
    240 #define SCNXFAST64   "I64X"
    241 
    242 #define SCNoMAX     "I64o"
    243 #define SCNuMAX     "I64u"
    244 #define SCNxMAX     "I64x"
    245 #define SCNXMAX     "I64X"
    246 
    247 #ifdef _WIN64
    248 #  define SCNoPTR     "I64o"
    249 #  define SCNuPTR     "I64u"
    250 #  define SCNxPTR     "I64x"
    251 #  define SCNXPTR     "I64X"
    252 #else
    253 #  define SCNoPTR     "lo"
    254 #  define SCNuPTR     "lu"
    255 #  define SCNxPTR     "lx"
    256 #  define SCNXPTR     "lX"
    257 #endif
    258 
    259 #endif
    260 
    261 #endif
    262