master
  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
 17extern	"C"	{
 18#endif
 19
 20typedef 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 * crtdll.dll and msvcrt10.dll do not support any 64-bit modifier.
 32 */
 33#if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
 34#define PRId64 "lld"
 35#define PRIi64 "lli"
 36#define PRIo64 "llo"
 37#define PRIu64 "llu"
 38#define PRIx64 "llx"
 39#define PRIX64 "llX"
 40#elif !defined(__CRTDLL__) && __MSVCRT_VERSION__ >= 0x200
 41#define PRId64 "I64d"
 42#define PRIi64 "I64i"
 43#define PRIo64 "I64o"
 44#define PRIu64 "I64u"
 45#define PRIx64 "I64x"
 46#define PRIX64 "I64X"
 47#endif
 48
 49/* fprintf macros for signed types */
 50#define PRId8 "d"
 51#define PRId16 "d"
 52#define PRId32 "d"
 53
 54#define PRIdLEAST8 "d"
 55#define PRIdLEAST16 "d"
 56#define PRIdLEAST32 "d"
 57#define PRIdLEAST64 PRId64
 58
 59#define PRIdFAST8 "d"
 60#define PRIdFAST16 "d"
 61#define PRIdFAST32 "d"
 62#define PRIdFAST64 PRId64
 63
 64#define PRIdMAX PRId64
 65
 66#define PRIi8 "i"
 67#define PRIi16 "i"
 68#define PRIi32 "i"
 69
 70#define PRIiLEAST8 "i"
 71#define PRIiLEAST16 "i"
 72#define PRIiLEAST32 "i"
 73#define PRIiLEAST64 PRIi64
 74
 75#define PRIiFAST8 "i"
 76#define PRIiFAST16 "i"
 77#define PRIiFAST32 "i"
 78#define PRIiFAST64 PRIi64
 79
 80#define PRIiMAX PRIi64
 81
 82#define PRIo8 "o"
 83#define PRIo16 "o"
 84#define PRIo32 "o"
 85
 86#define PRIoLEAST8 "o"
 87#define PRIoLEAST16 "o"
 88#define PRIoLEAST32 "o"
 89#define PRIoLEAST64 PRIo64
 90
 91#define PRIoFAST8 "o"
 92#define PRIoFAST16 "o"
 93#define PRIoFAST32 "o"
 94#define PRIoFAST64 PRIo64
 95
 96#define PRIoMAX PRIo64
 97
 98/* fprintf macros for unsigned types */
 99#define PRIu8 "u"
100#define PRIu16 "u"
101#define PRIu32 "u"
102
103
104#define PRIuLEAST8 "u"
105#define PRIuLEAST16 "u"
106#define PRIuLEAST32 "u"
107#define PRIuLEAST64 PRIu64
108
109#define PRIuFAST8 "u"
110#define PRIuFAST16 "u"
111#define PRIuFAST32 "u"
112#define PRIuFAST64 PRIu64
113
114#define PRIuMAX PRIu64
115
116#define PRIx8 "x"
117#define PRIx16 "x"
118#define PRIx32 "x"
119
120#define PRIxLEAST8 "x"
121#define PRIxLEAST16 "x"
122#define PRIxLEAST32 "x"
123#define PRIxLEAST64 PRIx64
124
125#define PRIxFAST8 "x"
126#define PRIxFAST16 "x"
127#define PRIxFAST32 "x"
128#define PRIxFAST64 PRIx64
129
130#define PRIxMAX PRIx64
131
132#define PRIX8 "X"
133#define PRIX16 "X"
134#define PRIX32 "X"
135
136#define PRIXLEAST8 "X"
137#define PRIXLEAST16 "X"
138#define PRIXLEAST32 "X"
139#define PRIXLEAST64 PRIX64
140
141#define PRIXFAST8 "X"
142#define PRIXFAST16 "X"
143#define PRIXFAST32 "X"
144#define PRIXFAST64 PRIX64
145
146#define PRIXMAX PRIX64
147
148/*
149 *   fscanf macros for signed int types
150 *   NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
151 *   (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
152 *   no length identifiers
153 */
154
155#define SCNd16 "hd"
156#define SCNd32 "d"
157#define SCNd64 PRId64
158
159#define SCNdLEAST16 "hd"
160#define SCNdLEAST32 "d"
161#define SCNdLEAST64 PRId64
162
163#define SCNdFAST16 "hd"
164#define SCNdFAST32 "d"
165#define SCNdFAST64 PRId64
166
167#define SCNdMAX PRId64
168
169#define SCNi16 "hi"
170#define SCNi32 "i"
171#define SCNi64 PRIi64
172
173#define SCNiLEAST16 "hi"
174#define SCNiLEAST32 "i"
175#define SCNiLEAST64 PRIi64
176
177#define SCNiFAST16 "hi"
178#define SCNiFAST32 "i"
179#define SCNiFAST64 PRIi64
180
181#define SCNiMAX PRIi64
182
183#define SCNo16 "ho"
184#define SCNo32 "o"
185#define SCNo64 PRIo64
186
187#define SCNoLEAST16 "ho"
188#define SCNoLEAST32 "o"
189#define SCNoLEAST64 PRIo64
190
191#define SCNoFAST16 "ho"
192#define SCNoFAST32 "o"
193#define SCNoFAST64 PRIo64
194
195#define SCNoMAX PRIo64
196
197#define SCNx16 "hx"
198#define SCNx32 "x"
199#define SCNx64 PRIx64
200
201#define SCNxLEAST16 "hx"
202#define SCNxLEAST32 "x"
203#define SCNxLEAST64 PRIx64
204
205#define SCNxFAST16 "hx"
206#define SCNxFAST32 "x"
207#define SCNxFAST64 PRIx64
208
209#define SCNxMAX PRIx64
210
211/* fscanf macros for unsigned int types */
212
213#define SCNu16 "hu"
214#define SCNu32 "u"
215#define SCNu64 PRIu64
216
217#define SCNuLEAST16 "hu"
218#define SCNuLEAST32 "u"
219#define SCNuLEAST64 PRIu64
220
221#define SCNuFAST16 "hu"
222#define SCNuFAST32 "u"
223#define SCNuFAST64 PRIu64
224
225#define SCNuMAX PRIu64
226
227#ifdef _WIN64
228#define PRIdPTR PRId64
229#define PRIiPTR PRIi64
230#define PRIoPTR PRIo64
231#define PRIuPTR PRIu64
232#define PRIxPTR PRIx64
233#define PRIXPTR PRIX64
234#define SCNdPTR PRId64
235#define SCNiPTR PRIi64
236#define SCNoPTR PRIo64
237#define SCNxPTR PRIx64
238#define SCNuPTR PRIu64
239#else
240#define PRIdPTR "d"
241#define PRIiPTR "i"
242#define PRIoPTR "o"
243#define PRIuPTR "u"
244#define PRIxPTR "x"
245#define PRIXPTR "X"
246#define SCNdPTR "d"
247#define SCNiPTR "i"
248#define SCNoPTR "o"
249#define SCNxPTR "x"
250 #define SCNuPTR "u"
251#endif
252
253#if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
254/*
255 * no length modifier for char types prior to C9x
256 * MS runtime  scanf appears to treat "hh" as "h" 
257 */
258
259/* signed char */
260#define SCNd8 "hhd"
261#define SCNdLEAST8 "hhd"
262#define SCNdFAST8 "hhd"
263
264#define SCNi8 "hhi"
265#define SCNiLEAST8 "hhi"
266#define SCNiFAST8 "hhi"
267
268#define SCNo8 "hho"
269#define SCNoLEAST8 "hho"
270#define SCNoFAST8 "hho"
271
272#define SCNx8 "hhx"
273#define SCNxLEAST8 "hhx"
274#define SCNxFAST8 "hhx"
275
276/* unsigned char */
277#define SCNu8 "hhu"
278#define SCNuLEAST8 "hhu"
279#define SCNuFAST8 "hhu"
280#endif /* __STDC_VERSION__ >= 199901 */
281
282#if (defined(__CRTDLL__) || __MSVCRT_VERSION__ < 0x200) && __USE_MINGW_ANSI_STDIO == 0
283/*
284 * crtdll.dll and msvcrt10.dll do not support any 64-bit modifier.
285 * Undef all previously defined 64-bit modifiers.
286 */
287#undef PRIdLEAST64
288#undef PRIdFAST64
289#undef PRIdMAX
290#undef PRIiLEAST64
291#undef PRIiFAST64
292#undef PRIiMAX
293#undef PRIoLEAST64
294#undef PRIoFAST64
295#undef PRIoMAX
296#undef PRIuLEAST64
297#undef PRIuFAST64
298#undef PRIuMAX
299#undef PRIxLEAST64
300#undef PRIxFAST64
301#undef PRIxMAX
302#undef PRIXLEAST64
303#undef PRIXFAST64
304#undef PRIXMAX
305#undef SCNd64
306#undef SCNdLEAST64
307#undef SCNdFAST64
308#undef SCNdMAX
309#undef SCNi64
310#undef SCNiLEAST64
311#undef SCNiFAST64
312#undef SCNiMAX
313#undef SCNo64
314#undef SCNoLEAST64
315#undef SCNoFAST64
316#undef SCNoMAX
317#undef SCNx64
318#undef SCNxLEAST64
319#undef SCNxFAST64
320#undef SCNxMAX
321#undef SCNu64
322#undef SCNuLEAST64
323#undef SCNuFAST64
324#undef SCNuMAX
325#endif
326
327intmax_t __cdecl imaxabs (intmax_t j);
328#ifndef __CRT__NO_INLINE
329__CRT_INLINE intmax_t __cdecl imaxabs (intmax_t j)
330	{return	(j >= 0 ? j : -j);}
331#endif
332imaxdiv_t __cdecl imaxdiv (intmax_t numer, intmax_t denom);
333
334/* 7.8.2 Conversion functions for greatest-width integer types */
335
336intmax_t __cdecl strtoimax (const char* __restrict__ nptr,
337                            char** __restrict__ endptr, int base);
338uintmax_t __cdecl strtoumax (const char* __restrict__ nptr,
339			     char** __restrict__ endptr, int base);
340
341intmax_t __cdecl wcstoimax (const wchar_t* __restrict__ nptr,
342                            wchar_t** __restrict__ endptr, int base);
343uintmax_t __cdecl wcstoumax (const wchar_t* __restrict__ nptr,
344			     wchar_t** __restrict__ endptr, int base);
345
346#ifdef	__cplusplus
347}
348#endif
349
350#endif /* ndef _INTTYPES_H */