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