OSDN Git Service

Correct mistyped __MINGW_NOTHROW macro.
[mingw/mingw-org-wsl.git] / include / inttypes.h
1 /**
2  * @file inttypes.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _INTTYPES_H_
25 #define _INTTYPES_H_
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /* 7.8 Format conversion of integer types <inttypes.h> */
30
31 #include <stdint.h>
32 #define __need_wchar_t
33 #include <stddef.h>
34
35 #ifdef  __cplusplus
36 extern  "C"     {
37 #endif
38
39 typedef struct {
40         intmax_t quot;
41         intmax_t rem;
42         } imaxdiv_t;
43
44 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
45
46 /* 7.8.1 Macros for format specifiers
47  * 
48  * MS runtime does not yet understand C9x standard "ll"
49  * length specifier. It appears to treat "ll" as "l".
50  * The non-standard I64 length specifier causes warning in GCC,
51  * but understood by MS runtime functions.
52  */
53
54 /* fprintf macros for signed types */
55 #define PRId8 "d"
56 #define PRId16 "d"
57 #define PRId32 "d"
58 #define PRId64 "I64d"
59
60 #define PRIdLEAST8 "d"
61 #define PRIdLEAST16 "d"
62 #define PRIdLEAST32 "d"
63 #define PRIdLEAST64 "I64d"
64
65 #define PRIdFAST8 "d"
66 #define PRIdFAST16 "d"
67 #define PRIdFAST32 "d"
68 #define PRIdFAST64 "I64d"
69
70 #define PRIdMAX "I64d"
71
72 #define PRIi8 "i"
73 #define PRIi16 "i"
74 #define PRIi32 "i"
75 #define PRIi64 "I64i"
76
77 #define PRIiLEAST8 "i"
78 #define PRIiLEAST16 "i"
79 #define PRIiLEAST32 "i"
80 #define PRIiLEAST64 "I64i"
81
82 #define PRIiFAST8 "i"
83 #define PRIiFAST16 "i"
84 #define PRIiFAST32 "i"
85 #define PRIiFAST64 "I64i"
86
87 #define PRIiMAX "I64i"
88
89 #define PRIo8 "o"
90 #define PRIo16 "o"
91 #define PRIo32 "o"
92 #define PRIo64 "I64o"
93
94 #define PRIoLEAST8 "o"
95 #define PRIoLEAST16 "o"
96 #define PRIoLEAST32 "o"
97 #define PRIoLEAST64 "I64o"
98
99 #define PRIoFAST8 "o"
100 #define PRIoFAST16 "o"
101 #define PRIoFAST32 "o"
102 #define PRIoFAST64 "I64o"
103
104 #define PRIoMAX "I64o"
105
106 /* fprintf macros for unsigned types */
107 #define PRIu8 "u"
108 #define PRIu16 "u"
109 #define PRIu32 "u"
110 #define PRIu64 "I64u"
111
112
113 #define PRIuLEAST8 "u"
114 #define PRIuLEAST16 "u"
115 #define PRIuLEAST32 "u"
116 #define PRIuLEAST64 "I64u"
117
118 #define PRIuFAST8 "u"
119 #define PRIuFAST16 "u"
120 #define PRIuFAST32 "u"
121 #define PRIuFAST64 "I64u"
122
123 #define PRIuMAX "I64u"
124
125 #define PRIx8 "x"
126 #define PRIx16 "x"
127 #define PRIx32 "x"
128 #define PRIx64 "I64x"
129
130 #define PRIxLEAST8 "x"
131 #define PRIxLEAST16 "x"
132 #define PRIxLEAST32 "x"
133 #define PRIxLEAST64 "I64x"
134
135 #define PRIxFAST8 "x"
136 #define PRIxFAST16 "x"
137 #define PRIxFAST32 "x"
138 #define PRIxFAST64 "I64x"
139
140 #define PRIxMAX "I64x"
141
142 #define PRIX8 "X"
143 #define PRIX16 "X"
144 #define PRIX32 "X"
145 #define PRIX64 "I64X"
146
147 #define PRIXLEAST8 "X"
148 #define PRIXLEAST16 "X"
149 #define PRIXLEAST32 "X"
150 #define PRIXLEAST64 "I64X"
151
152 #define PRIXFAST8 "X"
153 #define PRIXFAST16 "X"
154 #define PRIXFAST32 "X"
155 #define PRIXFAST64 "I64X"
156
157 #define PRIXMAX "I64X"
158
159 #ifdef _WIN64
160 #define PRIdPTR "I64d"
161 #define PRIiPTR "I64i"
162 #define PRIoPTR "I64o"
163 #define PRIuPTR "I64u"
164 #define PRIxPTR "I64x"
165 #define PRIXPTR "I64X"
166 #else
167 #define PRIdPTR "d"
168 #define PRIiPTR "i"
169 #define PRIoPTR "o"
170 #define PRIuPTR "u"
171 #define PRIxPTR "x"
172 #define PRIXPTR "X"
173 #endif
174
175 /*
176  *   fscanf macros for signed int types
177  *   NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
178  *   (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
179  *   no length identifiers
180  */
181
182 #define SCNd16 "hd"
183 #define SCNd32 "d"
184 #define SCNd64 "I64d"
185
186 #define SCNdLEAST16 "hd"
187 #define SCNdLEAST32 "d"
188 #define SCNdLEAST64 "I64d"
189
190 #define SCNdFAST16 "hd"
191 #define SCNdFAST32 "d"
192 #define SCNdFAST64 "I64d"
193
194 #define SCNdMAX "I64d"
195
196 #define SCNi16 "hi"
197 #define SCNi32 "i"
198 #define SCNi64 "I64i"
199
200 #define SCNiLEAST16 "hi"
201 #define SCNiLEAST32 "i"
202 #define SCNiLEAST64 "I64i"
203
204 #define SCNiFAST16 "hi"
205 #define SCNiFAST32 "i"
206 #define SCNiFAST64 "I64i"
207
208 #define SCNiMAX "I64i"
209
210 #define SCNo16 "ho"
211 #define SCNo32 "o"
212 #define SCNo64 "I64o"
213
214 #define SCNoLEAST16 "ho"
215 #define SCNoLEAST32 "o"
216 #define SCNoLEAST64 "I64o"
217
218 #define SCNoFAST16 "ho"
219 #define SCNoFAST32 "o"
220 #define SCNoFAST64 "I64o"
221
222 #define SCNoMAX "I64o"
223
224 #define SCNx16 "hx"
225 #define SCNx32 "x"
226 #define SCNx64 "I64x"
227
228 #define SCNxLEAST16 "hx"
229 #define SCNxLEAST32 "x"
230 #define SCNxLEAST64 "I64x"
231
232 #define SCNxFAST16 "hx"
233 #define SCNxFAST32 "x"
234 #define SCNxFAST64 "I64x"
235
236 #define SCNxMAX "I64x"
237
238 /* fscanf macros for unsigned int types */
239
240 #define SCNu16 "hu"
241 #define SCNu32 "u"
242 #define SCNu64 "I64u"
243
244 #define SCNuLEAST16 "hu"
245 #define SCNuLEAST32 "u"
246 #define SCNuLEAST64 "I64u"
247
248 #define SCNuFAST16 "hu"
249 #define SCNuFAST32 "u"
250 #define SCNuFAST64 "I64u"
251
252 #define SCNuMAX "I64u"
253
254 #ifdef _WIN64
255 #define SCNdPTR "I64d"
256 #define SCNiPTR "I64i"
257 #define SCNoPTR "I64o"
258 #define SCNxPTR "I64x"
259 #define SCNuPTR "I64u"
260 #else
261 #define SCNdPTR "d"
262 #define SCNiPTR "i"
263 #define SCNoPTR "o"
264 #define SCNxPTR "x"
265 #define SCNuPTR "u"
266 #endif
267
268 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
269 /*
270  * no length modifier for char types prior to C9x
271  * MS runtime  scanf appears to treat "hh" as "h" 
272  */
273
274 /* signed char */
275 #define SCNd8 "hhd"
276 #define SCNdLEAST8 "hhd"
277 #define SCNdFAST8 "hhd"
278
279 #define SCNi8 "hhi"
280 #define SCNiLEAST8 "hhi"
281 #define SCNiFAST8 "hhi"
282
283 #define SCNo8 "hho"
284 #define SCNoLEAST8 "hho"
285 #define SCNoFAST8 "hho"
286
287 #define SCNx8 "hhx"
288 #define SCNxLEAST8 "hhx"
289 #define SCNxFAST8 "hhx"
290
291 /* unsigned char */
292 #define SCNu8 "hhu"
293 #define SCNuLEAST8 "hhu"
294 #define SCNuFAST8 "hhu"
295 #endif /* __STDC_VERSION__ >= 199901 */
296
297 #endif  /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
298
299 intmax_t __cdecl __MINGW_NOTHROW imaxabs (intmax_t j);
300 #ifndef __NO_INLINE__
301 __CRT_INLINE intmax_t __cdecl __MINGW_NOTHROW imaxabs (intmax_t j)
302         {return (j >= 0 ? j : -j);}
303 #endif
304 imaxdiv_t __cdecl __MINGW_NOTHROW imaxdiv (intmax_t numer, intmax_t denom);
305
306 /* 7.8.2 Conversion functions for greatest-width integer types */
307
308 intmax_t __cdecl __MINGW_NOTHROW strtoimax (const char* __restrict__ nptr,
309                             char** __restrict__ endptr, int base);
310 uintmax_t __cdecl __MINGW_NOTHROW strtoumax (const char* __restrict__ nptr,
311                              char** __restrict__ endptr, int base);
312
313 intmax_t __cdecl __MINGW_NOTHROW wcstoimax (const wchar_t* __restrict__ nptr,
314                             wchar_t** __restrict__ endptr, int base);
315 uintmax_t __cdecl __MINGW_NOTHROW wcstoumax (const wchar_t* __restrict__ nptr,
316                              wchar_t** __restrict__ endptr, int base);
317
318 #ifdef  __cplusplus
319 }
320 #endif
321
322 #endif /* ndef _INTTYPES_H */