Debian Codegraph @

include/msvc_2010/stdint.h

raw
1 // ISO C9x compliant stdint.h for Microsoft Visual Studio
2 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3 //
4 // Copyright (c) 2006-2013 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. Neither the name of the product nor the names of its contributors may
17 // be used to endorse or promote products derived from this software
18 // without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
23 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //
31 ///////////////////////////////////////////////////////////////////////////////
32
33 #ifndef _MSC_VER // [
34 #error "Use this header only with Microsoft Visual C++ compilers!"
35 #endif // _MSC_VER ]
36
37 #ifndef _MSC_STDINT_H_ // [
38 #define _MSC_STDINT_H_
39
40 #if _MSC_VER > 1000
41 #pragma once
42 #endif
43
44 // We comment out the restriction to use the default stdint.h
45 // This fix is to make sure the stdint we define here is used by appveyor
46 // for msvc 2010. This shouldn't need to be done, but it does. It's
47 // probably safe regardless.
48 //#if _MSC_VER >= 1600 // [
49 //#if _MSC_VER >= 1600
50 //#include <stdint.h>
51 //#else // ] _MSC_VER >= 1600 [
52
53 #include <limits.h>
54
55 // For Visual Studio 6 in C++ mode and for many Visual Studio versions when
56 // compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
57 // or compiler give many errors like this:
58 // error C2733: second C linkage of overloaded function 'wmemchr' not allowed
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 # include <wchar.h>
63 #ifdef __cplusplus
64 }
65 #endif
66
67 // Define _W64 macros to mark types changing their size, like intptr_t.
68 #ifndef _W64
69 # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
70 # define _W64 __w64
71 # else
72 # define _W64
73 # endif
74 #endif
75
76
77 // 7.18.1 Integer types
78
79 // 7.18.1.1 Exact-width integer types
80
81 // Visual Studio 6 and Embedded Visual C++ 4 doesn't
82 // realize that, e.g. char has the same size as __int8
83 // so we give up on __intX for them.
84 #if (_MSC_VER < 1300)
85 typedef signed char int8_t;
86 typedef signed short int16_t;
87 typedef signed int int32_t;
88 typedef unsigned char uint8_t;
89 typedef unsigned short uint16_t;
90 typedef unsigned int uint32_t;
91 #else
92 typedef signed __int8 int8_t;
93 typedef signed __int16 int16_t;
94 typedef signed __int32 int32_t;
95 typedef unsigned __int8 uint8_t;
96 typedef unsigned __int16 uint16_t;
97 typedef unsigned __int32 uint32_t;
98 #endif
99 typedef signed __int64 int64_t;
100 typedef unsigned __int64 uint64_t;
101
102
103 // 7.18.1.2 Minimum-width integer types
104 typedef int8_t int_least8_t;
105 typedef int16_t int_least16_t;
106 typedef int32_t int_least32_t;
107 typedef int64_t int_least64_t;
108 typedef uint8_t uint_least8_t;
109 typedef uint16_t uint_least16_t;
110 typedef uint32_t uint_least32_t;
111 typedef uint64_t uint_least64_t;
112
113 // 7.18.1.3 Fastest minimum-width integer types
114 typedef int8_t int_fast8_t;
115 typedef int16_t int_fast16_t;
116 typedef int32_t int_fast32_t;
117 typedef int64_t int_fast64_t;
118 typedef uint8_t uint_fast8_t;
119 typedef uint16_t uint_fast16_t;
120 typedef uint32_t uint_fast32_t;
121 typedef uint64_t uint_fast64_t;
122
123 // 7.18.1.4 Integer types capable of holding object pointers
124 #ifdef _WIN64 // [
125 typedef signed __int64 intptr_t;
126 typedef unsigned __int64 uintptr_t;
127 #else // _WIN64 ][
128 typedef _W64 signed int intptr_t;
129 typedef _W64 unsigned int uintptr_t;
130 #endif // _WIN64 ]
131
132 // 7.18.1.5 Greatest-width integer types
133 typedef int64_t intmax_t;
134 typedef uint64_t uintmax_t;
135
136
137 // 7.18.2 Limits of specified-width integer types
138
139 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
140
141 // 7.18.2.1 Limits of exact-width integer types
142 #define INT8_MIN ((int8_t)_I8_MIN)
143 #define INT8_MAX _I8_MAX
144 #define INT16_MIN ((int16_t)_I16_MIN)
145 #define INT16_MAX _I16_MAX
146 #define INT32_MIN ((int32_t)_I32_MIN)
147 #define INT32_MAX _I32_MAX
148 #define INT64_MIN ((int64_t)_I64_MIN)
149 #define INT64_MAX _I64_MAX
150 #define UINT8_MAX _UI8_MAX
151 #define UINT16_MAX _UI16_MAX
152 #define UINT32_MAX _UI32_MAX
153 #define UINT64_MAX _UI64_MAX
154
155 // 7.18.2.2 Limits of minimum-width integer types
156 #define INT_LEAST8_MIN INT8_MIN
157 #define INT_LEAST8_MAX INT8_MAX
158 #define INT_LEAST16_MIN INT16_MIN
159 #define INT_LEAST16_MAX INT16_MAX
160 #define INT_LEAST32_MIN INT32_MIN
161 #define INT_LEAST32_MAX INT32_MAX
162 #define INT_LEAST64_MIN INT64_MIN
163 #define INT_LEAST64_MAX INT64_MAX
164 #define UINT_LEAST8_MAX UINT8_MAX
165 #define UINT_LEAST16_MAX UINT16_MAX
166 #define UINT_LEAST32_MAX UINT32_MAX
167 #define UINT_LEAST64_MAX UINT64_MAX
168
169 // 7.18.2.3 Limits of fastest minimum-width integer types
170 #define INT_FAST8_MIN INT8_MIN
171 #define INT_FAST8_MAX INT8_MAX
172 #define INT_FAST16_MIN INT16_MIN
173 #define INT_FAST16_MAX INT16_MAX
174 #define INT_FAST32_MIN INT32_MIN
175 #define INT_FAST32_MAX INT32_MAX
176 #define INT_FAST64_MIN INT64_MIN
177 #define INT_FAST64_MAX INT64_MAX
178 #define UINT_FAST8_MAX UINT8_MAX
179 #define UINT_FAST16_MAX UINT16_MAX
180 #define UINT_FAST32_MAX UINT32_MAX
181 #define UINT_FAST64_MAX UINT64_MAX
182
183 // 7.18.2.4 Limits of integer types capable of holding object pointers
184 #ifdef _WIN64 // [
185 # define INTPTR_MIN INT64_MIN
186 # define INTPTR_MAX INT64_MAX
187 # define UINTPTR_MAX UINT64_MAX
188 #else // _WIN64 ][
189 # define INTPTR_MIN INT32_MIN
190 # define INTPTR_MAX INT32_MAX
191 # define UINTPTR_MAX UINT32_MAX
192 #endif // _WIN64 ]
193
194 // 7.18.2.5 Limits of greatest-width integer types
195 #define INTMAX_MIN INT64_MIN
196 #define INTMAX_MAX INT64_MAX
197 #define UINTMAX_MAX UINT64_MAX
198
199 // 7.18.3 Limits of other integer types
200
201 #ifdef _WIN64 // [
202 # define PTRDIFF_MIN _I64_MIN
203 # define PTRDIFF_MAX _I64_MAX
204 #else // _WIN64 ][
205 # define PTRDIFF_MIN _I32_MIN
206 # define PTRDIFF_MAX _I32_MAX
207 #endif // _WIN64 ]
208
209 #define SIG_ATOMIC_MIN INT_MIN
210 #define SIG_ATOMIC_MAX INT_MAX
211
212 #ifndef SIZE_MAX // [
213 # ifdef _WIN64 // [
214 # define SIZE_MAX _UI64_MAX
215 # else // _WIN64 ][
216 # define SIZE_MAX _UI32_MAX
217 # endif // _WIN64 ]
218 #endif // SIZE_MAX ]
219
220 // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
221 #ifndef WCHAR_MIN // [
222 # define WCHAR_MIN 0
223 #endif // WCHAR_MIN ]
224 #ifndef WCHAR_MAX // [
225 # define WCHAR_MAX _UI16_MAX
226 #endif // WCHAR_MAX ]
227
228 #define WINT_MIN 0
229 #define WINT_MAX _UI16_MAX
230
231 #endif // __STDC_LIMIT_MACROS ]
232
233
234 // 7.18.4 Limits of other integer types
235
236 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
237
238 // 7.18.4.1 Macros for minimum-width integer constants
239
240 #define INT8_C(val) val##i8
241 #define INT16_C(val) val##i16
242 #define INT32_C(val) val##i32
243 #define INT64_C(val) val##i64
244
245 #define UINT8_C(val) val##ui8
246 #define UINT16_C(val) val##ui16
247 #define UINT32_C(val) val##ui32
248 #define UINT64_C(val) val##ui64
249
250 // 7.18.4.2 Macros for greatest-width integer constants
251 // These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
252 // Check out Issue 9 for the details.
253 #ifndef INTMAX_C // [
254 # define INTMAX_C INT64_C
255 #endif // INTMAX_C ]
256 #ifndef UINTMAX_C // [
257 # define UINTMAX_C UINT64_C
258 #endif // UINTMAX_C ]
259
260 #endif // __STDC_CONSTANT_MACROS ]
261
262 //#endif // _MSC_VER >= 1600 ]
263
264 #endif // _MSC_STDINT_H_ ]