blob: c76e5c6f265b0d5a39a2b0ff263f7b5cb9896812 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
/** @file
* IPRT - stdint.h wrapper (for backlevel compilers like MSC).
*/
/*
* Copyright (C) 2009-2022 Oracle and/or its affiliates.
*
* This file is part of VirtualBox base platform packages, as
* available from https://www.virtualbox.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, in version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses>.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
* in the VirtualBox distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
*/
#ifndef IPRT_INCLUDED_stdint_h
#define IPRT_INCLUDED_stdint_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
#include <iprt/cdefs.h>
/*
* Use the stdint.h on systems that have one.
*/
#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
&& !(defined(RT_OS_FREEBSD) && defined(_KERNEL)) \
&& !(defined(RT_OS_NETBSD) && defined(_KERNEL)) \
&& RT_MSC_PREREQ_EX(RT_MSC_VER_VS2010, 1 /*non-msc*/) \
&& !defined(__IBMC__) \
&& !defined(__IBMCPP__) \
&& !defined(IPRT_NO_CRT) \
&& !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
&& !defined(DOXYGEN_RUNNING)
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# endif
# ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4668)
# endif
# include <stdint.h>
# ifdef _MSC_VER
# pragma warning(pop)
# endif
# if defined(RT_OS_DARWIN) && defined(KERNEL) && defined(RT_ARCH_AMD64)
/*
* Kludge to fix the incorrect 32-bit constant macros in
* Kernel.framework/Headers/stdin.h. uint32_t and int32_t are
* int not long as these macros use, which is significant when
* targeting AMD64. (10a222)
*/
# undef INT32_C
# define INT32_C(Value) (Value)
# undef UINT32_C
# define UINT32_C(Value) (Value ## U)
# endif /* 64-bit darwin kludge. */
#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# endif
# include <sys/stdint.h>
#elif defined(RT_OS_NETBSD) && defined(_KERNEL)
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# endif
# include <sys/stdint.h>
#else /* No system stdint.h */
/*
* Define the types we use.
* The linux kernel defines all these in linux/types.h, so skip it.
*/
# if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
|| defined(IPRT_NO_CRT) \
|| defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
|| defined(DOXGEN_RUNNING)
/* Simplify the [u]int64_t type detection mess. */
# undef IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# ifdef __IBMCPP__
# if __IBMCPP__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
# define IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
# ifdef __IBMC__
# if __IBMC__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
# define IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
/* x-bit types */
# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) \
|| defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64) \
|| defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
# if !defined(_INT8_T_DECLARED) && !defined(_INT8_T)
typedef signed char int8_t;
# endif
# if !defined(_UINT8_T_DECLARED) && !defined(_UINT8_T)
typedef unsigned char uint8_t;
# endif
# if !defined(_INT16_T_DECLARED) && !defined(_INT16_T)
typedef signed short int16_t;
# endif
# if !defined(_UINT16_T_DECLARED) && !defined(_UINT16_T)
typedef unsigned short uint16_t;
# endif
# if !defined(_INT32_T_DECLARED) && !defined(_INT32_T)
# if ARCH_BITS != 16
typedef signed int int32_t;
# else
typedef signed long int32_t;
# endif
# endif
# if !defined(_UINT32_T_DECLARED) && !defined(_UINT32_T)
# if ARCH_BITS != 16
typedef unsigned int uint32_t;
# else
typedef unsigned long uint32_t;
# endif
# endif
# if defined(_MSC_VER)
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
typedef signed _int64 int64_t;
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
typedef unsigned _int64 uint64_t;
# endif
# elif defined(__WATCOMC__)
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
typedef signed __int64 int64_t;
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
typedef unsigned __int64 uint64_t;
# endif
# elif defined(IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES)
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
typedef struct { uint32_t lo; int32_t hi; } int64_t;
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
typedef struct { uint32_t lo; uint32_t hi; } uint64_t;
# endif
# else /* Use long long for 64-bit types */
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
typedef signed long long int64_t;
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
typedef unsigned long long uint64_t;
# endif
# endif
/* max integer types */
# if !defined(_INTMAX_T_DECLARED) && !defined(_INTMAX_T)
typedef int64_t intmax_t;
# endif
# if !defined(_UINTMAX_T_DECLARED) && !defined(_UINTMAX_T)
typedef uint64_t uintmax_t;
# endif
/* smallest minimum-width integer types - assumes to be the same as above! */
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
# define INT_LEAST8_MIN INT8_MIN
# define INT_LEAST8_MAX INT8_MAX
# define UINT_LEAST8_MAX UINT8_MAX
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
# define INT_LEAST16_MIN INT16_MIN
# define INT_LEAST16_MAX INT16_MAX
# define UINT_LEAST16_MAX UINT16_MAX
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
# define INT_LEAST32_MIN INT32_MIN
# define INT_LEAST32_MAX INT32_MAX
# define UINT_LEAST32_MAX UINT32_MAX
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
# define INT_LEAST64_MIN INT64_MIN
# define INT_LEAST64_MAX INT64_MAX
# define UINT_LEAST64_MAX UINT64_MAX
/* fastest minimum-width integer types */
typedef signed char int_fast8_t;
typedef unsigned char uint_fast8_t;
# define INT_FAST8_MIN INT8_MIN
# define INT_FAST8_MAX INT8_MAX
# define UINT_FAST8_MAX UINT8_MAX
typedef signed int int_fast16_t;
typedef unsigned int uint_fast16_t;
# if ARCH_BITS == 16
# define INT_FAST16_MIN INT16_MIN
# define INT_FAST16_MAX INT16_MAX
# define UINT_FAST16_MAX UINT16_MAX
# else
# define INT_FAST16_MIN INT32_MIN
# define INT_FAST16_MAX INT32_MAX
# define UINT_FAST16_MAX UINT32_MAX
# endif
typedef int32_t int_fast32_t;
typedef uint32_t uint_fast32_t;
# define INT_FAST32_MIN INT32_MIN
# define INT_FAST32_MAX INT32_MAX
# define UINT_FAST32_MAX UINT32_MAX
typedef int64_t int_fast64_t;
typedef uint64_t uint_fast64_t;
# define INT_FAST64_MIN INT64_MIN
# define INT_FAST64_MAX INT64_MAX
# define UINT_FAST64_MAX UINT64_MAX
# else
# error "PORTME: Add architecture. Don't forget to check the [U]INTx_C() and [U]INTMAX_MIN/MAX macros."
# endif
# endif /* !linux kernel or stuff */
/* pointer <-> integer types */
# if (!defined(_MSC_VER) && !defined(__WATCOMC__)) || defined(DOXYGEN_RUNNING)
# if ARCH_BITS == 32 \
|| defined(RT_OS_LINUX) \
|| defined(RT_OS_FREEBSD)
# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T) && !defined(_INTPTR_T_DEFINED)
typedef signed long intptr_t;
# endif
# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED)
typedef unsigned long uintptr_t;
# endif
# else
# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T) && !defined(_INTPTR_T_DEFINED)
typedef int64_t intptr_t;
# endif
# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED)
typedef uint64_t uintptr_t;
# endif
# endif
# endif /* !_MSC_VER */
#endif /* no system stdint.h */
/*
* Make sure the [U]INTx_C(c) macros are present.
* For In C++ source the system stdint.h may have skipped these if it was
* included before we managed to define __STDC_CONSTANT_MACROS. (Kludge alert!)
*/
#if !defined(INT8_C) \
|| !defined(INT16_C) \
|| !defined(INT32_C) \
|| !defined(INT64_C) \
|| !defined(INTMAX_C) \
|| !defined(UINT8_C) \
|| !defined(UINT16_C) \
|| !defined(UINT32_C) \
|| !defined(UINT64_C) \
|| !defined(UINTMAX_C)
# define INT8_C(Value) (Value)
# define INT16_C(Value) (Value)
# define UINT8_C(Value) (Value)
# define UINT16_C(Value) (Value)
# if ARCH_BITS != 16
# define INT32_C(Value) (Value)
# define UINT32_C(Value) (Value ## U)
# define INT64_C(Value) (Value ## LL)
# define UINT64_C(Value) (Value ## ULL)
# else
# define INT32_C(Value) (Value ## L)
# define UINT32_C(Value) (Value ## UL)
# define INT64_C(Value) (Value ## LL)
# define UINT64_C(Value) (Value ## ULL)
# endif
# define INTMAX_C(Value) INT64_C(Value)
# define UINTMAX_C(Value) UINT64_C(Value)
#endif
/*
* Make sure the INTx_MIN and [U]INTx_MAX macros are present.
* For In C++ source the system stdint.h may have skipped these if it was
* included before we managed to define __STDC_LIMIT_MACROS. (Kludge alert!)
*/
#if !defined(INT8_MIN) \
|| !defined(INT16_MIN) \
|| !defined(INT32_MIN) \
|| !defined(INT64_MIN) \
|| !defined(INT8_MAX) \
|| !defined(INT16_MAX) \
|| !defined(INT32_MAX) \
|| !defined(INT64_MAX) \
|| !defined(UINT8_MAX) \
|| !defined(UINT16_MAX) \
|| !defined(UINT32_MAX) \
|| !defined(UINT64_MAX)
# define INT8_MIN (INT8_C(-0x7f) - 1)
# define INT16_MIN (INT16_C(-0x7fff) - 1)
# define INT32_MIN (INT32_C(-0x7fffffff) - 1)
# define INT64_MIN (INT64_C(-0x7fffffffffffffff) - 1)
# define INT8_MAX INT8_C(0x7f)
# define INT16_MAX INT16_C(0x7fff)
# define INT32_MAX INT32_C(0x7fffffff)
# define INT64_MAX INT64_C(0x7fffffffffffffff)
# define UINT8_MAX UINT8_C(0xff)
# define UINT16_MAX UINT16_C(0xffff)
# define UINT32_MAX UINT32_C(0xffffffff)
# define UINT64_MAX UINT64_C(0xffffffffffffffff)
# define INTMAX_MIN INT64_MIN
# define INTMAX_MAX INT64_MAX
# define UINTMAX_MAX UINT64_MAX
#endif
#endif /* !IPRT_INCLUDED_stdint_h */
|