1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 /* 7.8 Format conversion of integer types <inttypes.h> */
7 
8 #ifndef _INTTYPES_H_
9 #define _INTTYPES_H_
10 
11 #include <crtdefs.h>
12 #include <stdint.h>
13 #define __need_wchar_t
14 #include <stddef.h>
15 
16 #ifdef	__cplusplus
17 extern	"C"	{
18 #endif
19 
20 typedef struct {
21 	intmax_t quot;
22 	intmax_t rem;
23 	} imaxdiv_t;
24 
25 /* 7.8.1 Macros for format specifiers
26  *
27  * MS runtime does not yet understand C9x standard "ll"
28  * length specifier. It appears to treat "ll" as "l".
29  * The non-standard I64 length specifier causes warning in GCC,
30  * but understood by MS runtime functions.
31  */
32 #if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
33 #define PRId64 "lld"
34 #define PRIi64 "lli"
35 #define PRIo64 "llo"
36 #define PRIu64 "llu"
37 #define PRIx64 "llx"
38 #define PRIX64 "llX"
39 #else
40 #define PRId64 "I64d"
41 #define PRIi64 "I64i"
42 #define PRIo64 "I64o"
43 #define PRIu64 "I64u"
44 #define PRIx64 "I64x"
45 #define PRIX64 "I64X"
46 #endif
47 
48 /* fprintf macros for signed types */
49 #define PRId8 "d"
50 #define PRId16 "d"
51 #define PRId32 "d"
52 
53 #define PRIdLEAST8 "d"
54 #define PRIdLEAST16 "d"
55 #define PRIdLEAST32 "d"
56 #define PRIdLEAST64 PRId64
57 
58 #define PRIdFAST8 "d"
59 #define PRIdFAST16 "d"
60 #define PRIdFAST32 "d"
61 #define PRIdFAST64 PRId64
62 
63 #define PRIdMAX PRId64
64 
65 #define PRIi8 "i"
66 #define PRIi16 "i"
67 #define PRIi32 "i"
68 
69 #define PRIiLEAST8 "i"
70 #define PRIiLEAST16 "i"
71 #define PRIiLEAST32 "i"
72 #define PRIiLEAST64 PRIi64
73 
74 #define PRIiFAST8 "i"
75 #define PRIiFAST16 "i"
76 #define PRIiFAST32 "i"
77 #define PRIiFAST64 PRIi64
78 
79 #define PRIiMAX PRIi64
80 
81 #define PRIo8 "o"
82 #define PRIo16 "o"
83 #define PRIo32 "o"
84 
85 #define PRIoLEAST8 "o"
86 #define PRIoLEAST16 "o"
87 #define PRIoLEAST32 "o"
88 #define PRIoLEAST64 PRIo64
89 
90 #define PRIoFAST8 "o"
91 #define PRIoFAST16 "o"
92 #define PRIoFAST32 "o"
93 #define PRIoFAST64 PRIo64
94 
95 #define PRIoMAX PRIo64
96 
97 /* fprintf macros for unsigned types */
98 #define PRIu8 "u"
99 #define PRIu16 "u"
100 #define PRIu32 "u"
101 
102 
103 #define PRIuLEAST8 "u"
104 #define PRIuLEAST16 "u"
105 #define PRIuLEAST32 "u"
106 #define PRIuLEAST64 PRIu64
107 
108 #define PRIuFAST8 "u"
109 #define PRIuFAST16 "u"
110 #define PRIuFAST32 "u"
111 #define PRIuFAST64 PRIu64
112 
113 #define PRIuMAX PRIu64
114 
115 #define PRIx8 "x"
116 #define PRIx16 "x"
117 #define PRIx32 "x"
118 
119 #define PRIxLEAST8 "x"
120 #define PRIxLEAST16 "x"
121 #define PRIxLEAST32 "x"
122 #define PRIxLEAST64 PRIx64
123 
124 #define PRIxFAST8 "x"
125 #define PRIxFAST16 "x"
126 #define PRIxFAST32 "x"
127 #define PRIxFAST64 PRIx64
128 
129 #define PRIxMAX PRIx64
130 
131 #define PRIX8 "X"
132 #define PRIX16 "X"
133 #define PRIX32 "X"
134 
135 #define PRIXLEAST8 "X"
136 #define PRIXLEAST16 "X"
137 #define PRIXLEAST32 "X"
138 #define PRIXLEAST64 PRIX64
139 
140 #define PRIXFAST8 "X"
141 #define PRIXFAST16 "X"
142 #define PRIXFAST32 "X"
143 #define PRIXFAST64 PRIX64
144 
145 #define PRIXMAX PRIX64
146 
147 /*
148  *   fscanf macros for signed int types
149  *   NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
150  *   (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
151  *   no length identifiers
152  */
153 
154 #define SCNd16 "hd"
155 #define SCNd32 "d"
156 #define SCNd64 PRId64
157 
158 #define SCNdLEAST16 "hd"
159 #define SCNdLEAST32 "d"
160 #define SCNdLEAST64 PRId64
161 
162 #define SCNdFAST16 "hd"
163 #define SCNdFAST32 "d"
164 #define SCNdFAST64 PRId64
165 
166 #define SCNdMAX PRId64
167 
168 #define SCNi16 "hi"
169 #define SCNi32 "i"
170 #define SCNi64 PRIi64
171 
172 #define SCNiLEAST16 "hi"
173 #define SCNiLEAST32 "i"
174 #define SCNiLEAST64 PRIi64
175 
176 #define SCNiFAST16 "hi"
177 #define SCNiFAST32 "i"
178 #define SCNiFAST64 PRIi64
179 
180 #define SCNiMAX PRIi64
181 
182 #define SCNo16 "ho"
183 #define SCNo32 "o"
184 #define SCNo64 PRIo64
185 
186 #define SCNoLEAST16 "ho"
187 #define SCNoLEAST32 "o"
188 #define SCNoLEAST64 PRIo64
189 
190 #define SCNoFAST16 "ho"
191 #define SCNoFAST32 "o"
192 #define SCNoFAST64 PRIo64
193 
194 #define SCNoMAX PRIo64
195 
196 #define SCNx16 "hx"
197 #define SCNx32 "x"
198 #define SCNx64 PRIx64
199 
200 #define SCNxLEAST16 "hx"
201 #define SCNxLEAST32 "x"
202 #define SCNxLEAST64 PRIx64
203 
204 #define SCNxFAST16 "hx"
205 #define SCNxFAST32 "x"
206 #define SCNxFAST64 PRIx64
207 
208 #define SCNxMAX PRIx64
209 
210 /* fscanf macros for unsigned int types */
211 
212 #define SCNu16 "hu"
213 #define SCNu32 "u"
214 #define SCNu64 PRIu64
215 
216 #define SCNuLEAST16 "hu"
217 #define SCNuLEAST32 "u"
218 #define SCNuLEAST64 PRIu64
219 
220 #define SCNuFAST16 "hu"
221 #define SCNuFAST32 "u"
222 #define SCNuFAST64 PRIu64
223 
224 #define SCNuMAX PRIu64
225 
226 #ifdef _WIN64
227 #define PRIdPTR PRId64
228 #define PRIiPTR PRIi64
229 #define PRIoPTR PRIo64
230 #define PRIuPTR PRIu64
231 #define PRIxPTR PRIx64
232 #define PRIXPTR PRIX64
233 #define SCNdPTR PRId64
234 #define SCNiPTR PRIi64
235 #define SCNoPTR PRIo64
236 #define SCNxPTR PRIx64
237 #define SCNuPTR PRIu64
238 #else
239 #define PRIdPTR "d"
240 #define PRIiPTR "i"
241 #define PRIoPTR "o"
242 #define PRIuPTR "u"
243 #define PRIxPTR "x"
244 #define PRIXPTR "X"
245 #define SCNdPTR "d"
246 #define SCNiPTR "i"
247 #define SCNoPTR "o"
248 #define SCNxPTR "x"
249  #define SCNuPTR "u"
250 #endif
251 
252 #if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
253 /*
254  * no length modifier for char types prior to C9x
255  * MS runtime  scanf appears to treat "hh" as "h"
256  */
257 
258 /* signed char */
259 #define SCNd8 "hhd"
260 #define SCNdLEAST8 "hhd"
261 #define SCNdFAST8 "hhd"
262 
263 #define SCNi8 "hhi"
264 #define SCNiLEAST8 "hhi"
265 #define SCNiFAST8 "hhi"
266 
267 #define SCNo8 "hho"
268 #define SCNoLEAST8 "hho"
269 #define SCNoFAST8 "hho"
270 
271 #define SCNx8 "hhx"
272 #define SCNxLEAST8 "hhx"
273 #define SCNxFAST8 "hhx"
274 
275 /* unsigned char */
276 #define SCNu8 "hhu"
277 #define SCNuLEAST8 "hhu"
278 #define SCNuFAST8 "hhu"
279 #endif /* __STDC_VERSION__ >= 199901 */
280 
281 intmax_t __cdecl imaxabs (intmax_t j);
282 #ifndef __CRT__NO_INLINE
imaxabs(intmax_t j)283 __CRT_INLINE intmax_t __cdecl imaxabs (intmax_t j)
284 	{return	(j >= 0 ? j : -j);}
285 #endif
286 imaxdiv_t __cdecl imaxdiv (intmax_t numer, intmax_t denom);
287 
288 /* 7.8.2 Conversion functions for greatest-width integer types */
289 
290 intmax_t __cdecl strtoimax (const char* __restrict__ nptr,
291                             char** __restrict__ endptr, int base);
292 uintmax_t __cdecl strtoumax (const char* __restrict__ nptr,
293 			     char** __restrict__ endptr, int base);
294 
295 intmax_t __cdecl wcstoimax (const wchar_t* __restrict__ nptr,
296                             wchar_t** __restrict__ endptr, int base);
297 uintmax_t __cdecl wcstoumax (const wchar_t* __restrict__ nptr,
298 			     wchar_t** __restrict__ endptr, int base);
299 
300 #ifdef	__cplusplus
301 }
302 #endif
303 
304 #endif /* ndef _INTTYPES_H */
305