1 | /** @file
|
---|
2 | * IPRT - Common C and C++ definitions.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_cdefs_h
|
---|
37 | #define IPRT_INCLUDED_cdefs_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 |
|
---|
43 | /** @defgroup grp_rt_cdefs IPRT Common Definitions and Macros
|
---|
44 | * @{
|
---|
45 | */
|
---|
46 |
|
---|
47 | /** @def RT_C_DECLS_BEGIN
|
---|
48 | * Used to start a block of function declarations which are shared
|
---|
49 | * between C and C++ program.
|
---|
50 | */
|
---|
51 |
|
---|
52 | /** @def RT_C_DECLS_END
|
---|
53 | * Used to end a block of function declarations which are shared
|
---|
54 | * between C and C++ program.
|
---|
55 | */
|
---|
56 |
|
---|
57 | #if defined(__cplusplus)
|
---|
58 | # define RT_C_DECLS_BEGIN extern "C" {
|
---|
59 | # define RT_C_DECLS_END }
|
---|
60 | #else
|
---|
61 | # define RT_C_DECLS_BEGIN
|
---|
62 | # define RT_C_DECLS_END
|
---|
63 | #endif
|
---|
64 |
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * Shut up DOXYGEN warnings and guide it properly thru the code.
|
---|
68 | */
|
---|
69 | #ifdef DOXYGEN_RUNNING
|
---|
70 | # define __AMD64__
|
---|
71 | # define __X86__
|
---|
72 | # define RT_ARCH_AMD64
|
---|
73 | # define RT_ARCH_X86
|
---|
74 | # define RT_ARCH_SPARC
|
---|
75 | # define RT_ARCH_SPARC64
|
---|
76 | # define RT_ARCH_ARM32
|
---|
77 | # define RT_ARCH_ARM64
|
---|
78 | # define IN_RING0
|
---|
79 | # define IN_RING3
|
---|
80 | # define IN_RC
|
---|
81 | # define IN_RT_RC
|
---|
82 | # define IN_RT_R0
|
---|
83 | # define IN_RT_R3
|
---|
84 | # define IN_RT_STATIC
|
---|
85 | # define RT_STRICT
|
---|
86 | # define RT_NO_STRICT
|
---|
87 | # define RT_LOCK_STRICT
|
---|
88 | # define RT_LOCK_NO_STRICT
|
---|
89 | # define RT_LOCK_STRICT_ORDER
|
---|
90 | # define RT_LOCK_NO_STRICT_ORDER
|
---|
91 | # define RT_BREAKPOINT
|
---|
92 | # define RT_NO_DEPRECATED_MACROS
|
---|
93 | # define RT_EXCEPTIONS_ENABLED
|
---|
94 | # define RT_BIG_ENDIAN
|
---|
95 | # define RT_LITTLE_ENDIAN
|
---|
96 | # define RT_COMPILER_GROKS_64BIT_BITFIELDS
|
---|
97 | # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
98 | # define RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
99 | # define RT_COMPILER_WITH_128BIT_INT_TYPES
|
---|
100 | # define RT_NO_VISIBILITY_HIDDEN
|
---|
101 | # define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
|
---|
102 | # define RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
103 | # define RT_COMPILER_SUPPORTS_LAMBDA
|
---|
104 | #endif /* DOXYGEN_RUNNING */
|
---|
105 |
|
---|
106 | /** @def RT_ARCH_X86
|
---|
107 | * Indicates that we're compiling for the X86 architecture.
|
---|
108 | */
|
---|
109 |
|
---|
110 | /** @def RT_ARCH_AMD64
|
---|
111 | * Indicates that we're compiling for the AMD64 architecture.
|
---|
112 | */
|
---|
113 |
|
---|
114 | /** @def RT_ARCH_SPARC
|
---|
115 | * Indicates that we're compiling for the SPARC V8 architecture (32-bit).
|
---|
116 | */
|
---|
117 |
|
---|
118 | /** @def RT_ARCH_SPARC64
|
---|
119 | * Indicates that we're compiling for the SPARC V9 architecture (64-bit).
|
---|
120 | */
|
---|
121 |
|
---|
122 | /** @def RT_ARCH_ARM32
|
---|
123 | * Indicates that we're compiling for the 32-bit ARM architecture, the value
|
---|
124 | * is the version (i.e. 6 for ARMv6).
|
---|
125 | */
|
---|
126 |
|
---|
127 | /** @def RT_ARCH_ARM64
|
---|
128 | * Indicates that we're compiling for the 64-bit ARM architecture.
|
---|
129 | */
|
---|
130 |
|
---|
131 | #if !defined(RT_ARCH_X86) \
|
---|
132 | && !defined(RT_ARCH_AMD64) \
|
---|
133 | && !defined(RT_ARCH_SPARC) \
|
---|
134 | && !defined(RT_ARCH_SPARC64) \
|
---|
135 | && !defined(RT_ARCH_ARM32) \
|
---|
136 | && !defined(RT_ARCH_ARM64)
|
---|
137 | # if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || defined(__AMD64__)
|
---|
138 | # define RT_ARCH_AMD64
|
---|
139 | # elif defined(__i386__) || defined(_M_IX86) || defined(__X86__)
|
---|
140 | # define RT_ARCH_X86
|
---|
141 | # elif defined(__sparcv9)
|
---|
142 | # define RT_ARCH_SPARC64
|
---|
143 | # elif defined(__sparc__)
|
---|
144 | # define RT_ARCH_SPARC
|
---|
145 | # elif defined(__arm64__) || defined(__aarch64__)
|
---|
146 | # define RT_ARCH_ARM64 __ARM_ARCH
|
---|
147 | # elif defined(__arm__)
|
---|
148 | # define RT_ARCH_ARM32 __ARM_ARCH
|
---|
149 | # elif defined(__arm32__)
|
---|
150 | # define RT_ARCH_ARM32 __ARM_ARCH
|
---|
151 | # else /* PORTME: append test for new archs. */
|
---|
152 | # error "Check what predefined macros your compiler uses to indicate architecture."
|
---|
153 | # endif
|
---|
154 | /* PORTME: append new archs checks. */
|
---|
155 | #elif defined(RT_ARCH_X86) && defined(RT_ARCH_AMD64)
|
---|
156 | # error "Both RT_ARCH_X86 and RT_ARCH_AMD64 cannot be defined at the same time!"
|
---|
157 | #elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC)
|
---|
158 | # error "Both RT_ARCH_X86 and RT_ARCH_SPARC cannot be defined at the same time!"
|
---|
159 | #elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC64)
|
---|
160 | # error "Both RT_ARCH_X86 and RT_ARCH_SPARC64 cannot be defined at the same time!"
|
---|
161 | #elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC)
|
---|
162 | # error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC cannot be defined at the same time!"
|
---|
163 | #elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC64)
|
---|
164 | # error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC64 cannot be defined at the same time!"
|
---|
165 | #elif defined(RT_ARCH_SPARC) && defined(RT_ARCH_SPARC64)
|
---|
166 | # error "Both RT_ARCH_SPARC and RT_ARCH_SPARC64 cannot be defined at the same time!"
|
---|
167 | #elif defined(RT_ARCH_ARM32) && defined(RT_ARCH_AMD64)
|
---|
168 | # error "Both RT_ARCH_ARM32 and RT_ARCH_AMD64 cannot be defined at the same time!"
|
---|
169 | #elif defined(RT_ARCH_ARM32) && defined(RT_ARCH_X86)
|
---|
170 | # error "Both RT_ARCH_ARM32 and RT_ARCH_X86 cannot be defined at the same time!"
|
---|
171 | #elif defined(RT_ARCH_ARM32) && defined(RT_ARCH_SPARC64)
|
---|
172 | # error "Both RT_ARCH_ARM32 and RT_ARCH_SPARC64 cannot be defined at the same time!"
|
---|
173 | #elif defined(RT_ARCH_ARM32) && defined(RT_ARCH_SPARC)
|
---|
174 | # error "Both RT_ARCH_ARM32 and RT_ARCH_SPARC cannot be defined at the same time!"
|
---|
175 | #elif defined(RT_ARCH_ARM64) && defined(RT_ARCH_AMD64)
|
---|
176 | # error "Both RT_ARCH_ARM64 and RT_ARCH_AMD64 cannot be defined at the same time!"
|
---|
177 | #elif defined(RT_ARCH_ARM64) && defined(RT_ARCH_X86)
|
---|
178 | # error "Both RT_ARCH_ARM64 and RT_ARCH_X86 cannot be defined at the same time!"
|
---|
179 | #elif defined(RT_ARCH_ARM64) && defined(RT_ARCH_SPARC64)
|
---|
180 | # error "Both RT_ARCH_ARM64 and RT_ARCH_SPARC64 cannot be defined at the same time!"
|
---|
181 | #elif defined(RT_ARCH_ARM64) && defined(RT_ARCH_SPARC)
|
---|
182 | # error "Both RT_ARCH_ARM64 and RT_ARCH_SPARC cannot be defined at the same time!"
|
---|
183 | #elif defined(RT_ARCH_ARM64) && defined(RT_ARCH_ARM32)
|
---|
184 | # error "Both RT_ARCH_ARM64 and RT_ARCH_ARM32 cannot be defined at the same time!"
|
---|
185 | #endif
|
---|
186 | #ifdef RT_ARCH_ARM
|
---|
187 | # error "RT_ARCH_ARM is now RT_ARCH_ARM32!"
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | /* Final check (PORTME). */
|
---|
191 | #if (defined(RT_ARCH_X86) != 0) \
|
---|
192 | + (defined(RT_ARCH_AMD64) != 0) \
|
---|
193 | + (defined(RT_ARCH_SPARC) != 0) \
|
---|
194 | + (defined(RT_ARCH_SPARC64) != 0) \
|
---|
195 | + (defined(RT_ARCH_ARM32) != 0) \
|
---|
196 | + (defined(RT_ARCH_ARM64) != 0) \
|
---|
197 | != 1
|
---|
198 | # error "Exactly one RT_ARCH_XXX macro shall be defined"
|
---|
199 | #endif
|
---|
200 |
|
---|
201 | /** @def RT_CPLUSPLUS_PREREQ
|
---|
202 | * Require a minimum __cplusplus value, simplifying dealing with non-C++ code.
|
---|
203 | *
|
---|
204 | * @param a_Min The minimum version, e.g. 201100.
|
---|
205 | */
|
---|
206 | #ifdef __cplusplus
|
---|
207 | # define RT_CPLUSPLUS_PREREQ(a_Min) (__cplusplus >= (a_Min))
|
---|
208 | #else
|
---|
209 | # define RT_CPLUSPLUS_PREREQ(a_Min) (0)
|
---|
210 | #endif
|
---|
211 |
|
---|
212 | /** @def RT_GNUC_PREREQ
|
---|
213 | * Shorter than fiddling with __GNUC__ and __GNUC_MINOR__.
|
---|
214 | *
|
---|
215 | * @param a_MinMajor Minimum major version
|
---|
216 | * @param a_MinMinor The minor version number part.
|
---|
217 | */
|
---|
218 | #define RT_GNUC_PREREQ(a_MinMajor, a_MinMinor) RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
|
---|
219 | /** @def RT_GNUC_PREREQ_EX
|
---|
220 | * Simplified way of checking __GNUC__ and __GNUC_MINOR__ regardless of actual
|
---|
221 | * compiler used, returns @a a_OtherRet for other compilers.
|
---|
222 | *
|
---|
223 | * @param a_MinMajor Minimum major version
|
---|
224 | * @param a_MinMinor The minor version number part.
|
---|
225 | * @param a_OtherRet What to return for non-GCC compilers.
|
---|
226 | */
|
---|
227 | #if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
---|
228 | # define RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) \
|
---|
229 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((a_MinMajor) << 16) + (a_MinMinor))
|
---|
230 | #else
|
---|
231 | # define RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | /** @def RT_MSC_PREREQ
|
---|
235 | * Convenient way of checking _MSC_VER regardless of actual compiler used
|
---|
236 | * (returns false if not MSC).
|
---|
237 | *
|
---|
238 | * @param a_MinVer Preferably a RT_MSC_VER_XXX value.
|
---|
239 | */
|
---|
240 | #define RT_MSC_PREREQ(a_MinVer) RT_MSC_PREREQ_EX(a_MinVer, 0)
|
---|
241 | /** @def RT_MSC_PREREQ_EX
|
---|
242 | * Convenient way of checking _MSC_VER regardless of actual compiler used,
|
---|
243 | * returns @a a_OtherRet for other compilers.
|
---|
244 | *
|
---|
245 | * @param a_MinVer Preferably a RT_MSC_VER_XXX value.
|
---|
246 | * @param a_OtherRet What to return for non-MSC compilers.
|
---|
247 | */
|
---|
248 | #if defined(_MSC_VER)
|
---|
249 | # define RT_MSC_PREREQ_EX(a_MinVer, a_OtherRet) ( (_MSC_VER) >= (a_MinVer) )
|
---|
250 | #else
|
---|
251 | # define RT_MSC_PREREQ_EX(a_MinVer, a_OtherRet) (a_OtherRet)
|
---|
252 | #endif
|
---|
253 | /** @name RT_MSC_VER_XXX - _MSC_VER values to use with RT_MSC_PREREQ.
|
---|
254 | * @remarks The VCxxx values are derived from the CRT DLLs shipping with the
|
---|
255 | * compilers.
|
---|
256 | * @{ */
|
---|
257 | #define RT_MSC_VER_VC50 (1100) /**< Visual C++ 5.0. */
|
---|
258 | #define RT_MSC_VER_VC60 (1200) /**< Visual C++ 6.0. */
|
---|
259 | #define RT_MSC_VER_VC70 (1300) /**< Visual C++ 7.0. */
|
---|
260 | #define RT_MSC_VER_VC70 (1300) /**< Visual C++ 7.0. */
|
---|
261 | #define RT_MSC_VER_VS2003 (1310) /**< Visual Studio 2003, aka Visual C++ 7.1. */
|
---|
262 | #define RT_MSC_VER_VC71 RT_MSC_VER_VS2003 /**< Visual C++ 7.1, aka Visual Studio 2003. */
|
---|
263 | #define RT_MSC_VER_VS2005 (1400) /**< Visual Studio 2005. */
|
---|
264 | #define RT_MSC_VER_VC80 RT_MSC_VER_VS2005 /**< Visual C++ 8.0, aka Visual Studio 2008. */
|
---|
265 | #define RT_MSC_VER_VS2008 (1500) /**< Visual Studio 2008. */
|
---|
266 | #define RT_MSC_VER_VC90 RT_MSC_VER_VS2008 /**< Visual C++ 9.0, aka Visual Studio 2008. */
|
---|
267 | #define RT_MSC_VER_VS2010 (1600) /**< Visual Studio 2010. */
|
---|
268 | #define RT_MSC_VER_VC100 RT_MSC_VER_VS2010 /**< Visual C++ 10.0, aka Visual Studio 2010. */
|
---|
269 | #define RT_MSC_VER_VS2012 (1700) /**< Visual Studio 2012. */
|
---|
270 | #define RT_MSC_VER_VC110 RT_MSC_VER_VS2012 /**< Visual C++ 11.0, aka Visual Studio 2012. */
|
---|
271 | #define RT_MSC_VER_VS2013 (1800) /**< Visual Studio 2013. */
|
---|
272 | #define RT_MSC_VER_VC120 RT_MSC_VER_VS2013 /**< Visual C++ 12.0, aka Visual Studio 2013. */
|
---|
273 | #define RT_MSC_VER_VS2015 (1900) /**< Visual Studio 2015. */
|
---|
274 | #define RT_MSC_VER_VC140 RT_MSC_VER_VS2015 /**< Visual C++ 14.0, aka Visual Studio 2015. */
|
---|
275 | #define RT_MSC_VER_VS2017 (1910) /**< Visual Studio 2017. */
|
---|
276 | #define RT_MSC_VER_VC141 RT_MSC_VER_VS2017 /**< Visual C++ 14.1, aka Visual Studio 2017. */
|
---|
277 | #define RT_MSC_VER_VS2019 (1920) /**< Visual Studio 2019. */
|
---|
278 | #define RT_MSC_VER_VC142 RT_MSC_VER_VS2019 /**< Visual C++ 14.2, aka Visual Studio 2019. */
|
---|
279 | #define RT_MSC_VER_VS2019_U6 (1926) /**< Visual Studio 2019, update 6. */
|
---|
280 | #define RT_MSC_VER_VC142_U6 RT_MSC_VER_VS2019_U6 /**< Visual C++ 14.2 update 6. */
|
---|
281 | #define RT_MSC_VER_VS2019_U8 (1928) /**< Visual Studio 2019, update 8. */
|
---|
282 | #define RT_MSC_VER_VC142_U8 RT_MSC_VER_VS2019_U8 /**< Visual C++ 14.2 update 8. */
|
---|
283 | #define RT_MSC_VER_VS2019_U11 (1929) /**< Visual Studio 2019, update 11. */
|
---|
284 | #define RT_MSC_VER_VC142_U11 RT_MSC_VER_VS2019_U11 /**< Visual C++ 14.2 update 11. */
|
---|
285 | /** @} */
|
---|
286 |
|
---|
287 | /** @def RT_CLANG_PREREQ
|
---|
288 | * Shorter than fiddling with __clang_major__ and __clang_minor__.
|
---|
289 | *
|
---|
290 | * @param a_MinMajor Minimum major version
|
---|
291 | * @param a_MinMinor The minor version number part.
|
---|
292 | */
|
---|
293 | #define RT_CLANG_PREREQ(a_MinMajor, a_MinMinor) RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
|
---|
294 | /** @def RT_CLANG_PREREQ_EX
|
---|
295 | * Simplified way of checking __clang_major__ and __clang_minor__ regardless of
|
---|
296 | * actual compiler used, returns @a a_OtherRet for other compilers.
|
---|
297 | *
|
---|
298 | * @param a_MinMajor Minimum major version
|
---|
299 | * @param a_MinMinor The minor version number part.
|
---|
300 | * @param a_OtherRet What to return for non-GCC compilers.
|
---|
301 | */
|
---|
302 | #if defined(__clang_major__) && defined(__clang_minor__)
|
---|
303 | # define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) \
|
---|
304 | ((__clang_major__ << 16) + __clang_minor__ >= ((a_MinMajor) << 16) + (a_MinMinor))
|
---|
305 | #else
|
---|
306 | # define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
|
---|
307 | #endif
|
---|
308 | /** @def RT_CLANG_HAS_FEATURE
|
---|
309 | * Wrapper around clang's __has_feature().
|
---|
310 | *
|
---|
311 | * @param a_Feature The feature to check for.
|
---|
312 | */
|
---|
313 | #if defined(__clang_major__) && defined(__clang_minor__) && defined(__has_feature)
|
---|
314 | # define RT_CLANG_HAS_FEATURE(a_Feature) (__has_feature(a_Feature))
|
---|
315 | #else
|
---|
316 | # define RT_CLANG_HAS_FEATURE(a_Feature) (0)
|
---|
317 | #endif
|
---|
318 |
|
---|
319 |
|
---|
320 | #if !defined(__X86__) && !defined(__AMD64__) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
|
---|
321 | # if defined(RT_ARCH_AMD64)
|
---|
322 | /** Indicates that we're compiling for the AMD64 architecture.
|
---|
323 | * @deprecated
|
---|
324 | */
|
---|
325 | # define __AMD64__
|
---|
326 | # elif defined(RT_ARCH_X86)
|
---|
327 | /** Indicates that we're compiling for the X86 architecture.
|
---|
328 | * @deprecated
|
---|
329 | */
|
---|
330 | # define __X86__
|
---|
331 | # else
|
---|
332 | # error "Check what predefined macros your compiler uses to indicate architecture."
|
---|
333 | # endif
|
---|
334 | #elif defined(__X86__) && defined(__AMD64__)
|
---|
335 | # error "Both __X86__ and __AMD64__ cannot be defined at the same time!"
|
---|
336 | #elif defined(__X86__) && !defined(RT_ARCH_X86)
|
---|
337 | # error "__X86__ without RT_ARCH_X86!"
|
---|
338 | #elif defined(__AMD64__) && !defined(RT_ARCH_AMD64)
|
---|
339 | # error "__AMD64__ without RT_ARCH_AMD64!"
|
---|
340 | #endif
|
---|
341 |
|
---|
342 | /** @def RT_BIG_ENDIAN
|
---|
343 | * Defined if the architecture is big endian. */
|
---|
344 | /** @def RT_LITTLE_ENDIAN
|
---|
345 | * Defined if the architecture is little endian. */
|
---|
346 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64)
|
---|
347 | # define RT_LITTLE_ENDIAN
|
---|
348 | #elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
|
---|
349 | # define RT_BIG_ENDIAN
|
---|
350 | #else
|
---|
351 | # error "PORTME: architecture endianess"
|
---|
352 | #endif
|
---|
353 | #if defined(RT_BIG_ENDIAN) && defined(RT_LITTLE_ENDIAN)
|
---|
354 | # error "Both RT_BIG_ENDIAN and RT_LITTLE_ENDIAN are defined"
|
---|
355 | #endif
|
---|
356 |
|
---|
357 |
|
---|
358 | /** @def IN_RING0
|
---|
359 | * Used to indicate that we're compiling code which is running
|
---|
360 | * in Ring-0 Host Context.
|
---|
361 | */
|
---|
362 |
|
---|
363 | /** @def IN_RING3
|
---|
364 | * Used to indicate that we're compiling code which is running
|
---|
365 | * in Ring-3 Host Context.
|
---|
366 | */
|
---|
367 |
|
---|
368 | /** @def IN_RC
|
---|
369 | * Used to indicate that we're compiling code which is running
|
---|
370 | * in the Raw-mode Context (implies R0).
|
---|
371 | */
|
---|
372 | #if !defined(IN_RING3) && !defined(IN_RING0) && !defined(IN_RC)
|
---|
373 | # error "You must define which context the compiled code should run in; IN_RING3, IN_RING0 or IN_RC"
|
---|
374 | #endif
|
---|
375 | #if (defined(IN_RING3) && (defined(IN_RING0) || defined(IN_RC)) ) \
|
---|
376 | || (defined(IN_RING0) && (defined(IN_RING3) || defined(IN_RC)) ) \
|
---|
377 | || (defined(IN_RC) && (defined(IN_RING3) || defined(IN_RING0)) )
|
---|
378 | # error "Only one of the IN_RING3, IN_RING0, IN_RC defines should be defined."
|
---|
379 | #endif
|
---|
380 |
|
---|
381 |
|
---|
382 | /** @def ARCH_BITS
|
---|
383 | * Defines the bit count of the current context.
|
---|
384 | */
|
---|
385 | #if !defined(ARCH_BITS) || defined(DOXYGEN_RUNNING)
|
---|
386 | # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64) || defined(RT_ARCH_ARM64) || defined(DOXYGEN_RUNNING)
|
---|
387 | # define ARCH_BITS 64
|
---|
388 | # elif !defined(__I86__) || !defined(__WATCOMC__)
|
---|
389 | # define ARCH_BITS 32
|
---|
390 | # else
|
---|
391 | # define ARCH_BITS 16
|
---|
392 | # endif
|
---|
393 | #endif
|
---|
394 |
|
---|
395 | /* ARCH_BITS validation (PORTME). */
|
---|
396 | #if ARCH_BITS == 64
|
---|
397 | #if defined(RT_ARCH_X86) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_ARM32)
|
---|
398 | # error "ARCH_BITS=64 but non-64-bit RT_ARCH_XXX defined."
|
---|
399 | #endif
|
---|
400 | #if !defined(RT_ARCH_AMD64) && !defined(RT_ARCH_SPARC64) && !defined(RT_ARCH_ARM64)
|
---|
401 | # error "ARCH_BITS=64 but no 64-bit RT_ARCH_XXX defined."
|
---|
402 | #endif
|
---|
403 |
|
---|
404 | #elif ARCH_BITS == 32
|
---|
405 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64) || defined(RT_ARCH_ARM64)
|
---|
406 | # error "ARCH_BITS=32 but non-32-bit RT_ARCH_XXX defined."
|
---|
407 | #endif
|
---|
408 | #if !defined(RT_ARCH_X86) && !defined(RT_ARCH_SPARC) && !defined(RT_ARCH_ARM32)
|
---|
409 | # error "ARCH_BITS=32 but no 32-bit RT_ARCH_XXX defined."
|
---|
410 | #endif
|
---|
411 |
|
---|
412 | #elif ARCH_BITS == 16
|
---|
413 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64) || defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64)
|
---|
414 | # error "ARCH_BITS=16 but non-16-bit RT_ARCH_XX defined."
|
---|
415 | #endif
|
---|
416 | #if !defined(RT_ARCH_X86)
|
---|
417 | # error "ARCH_BITS=16 but RT_ARCH_X86 isn't defined."
|
---|
418 | #endif
|
---|
419 |
|
---|
420 | #else
|
---|
421 | # error "Unsupported ARCH_BITS value!"
|
---|
422 | #endif
|
---|
423 |
|
---|
424 | /** @def HC_ARCH_BITS
|
---|
425 | * Defines the host architecture bit count.
|
---|
426 | */
|
---|
427 | #if !defined(HC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
|
---|
428 | # if !defined(IN_RC) || defined(DOXYGEN_RUNNING)
|
---|
429 | # define HC_ARCH_BITS ARCH_BITS
|
---|
430 | # else
|
---|
431 | # define HC_ARCH_BITS 32
|
---|
432 | # endif
|
---|
433 | #endif
|
---|
434 |
|
---|
435 | /** @def GC_ARCH_BITS
|
---|
436 | * Defines the guest architecture bit count.
|
---|
437 | */
|
---|
438 | #if !defined(GC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
|
---|
439 | # if defined(VBOX_WITH_64_BITS_GUESTS) || defined(DOXYGEN_RUNNING)
|
---|
440 | # define GC_ARCH_BITS 64
|
---|
441 | # else
|
---|
442 | # define GC_ARCH_BITS 32
|
---|
443 | # endif
|
---|
444 | #endif
|
---|
445 |
|
---|
446 | /** @def R3_ARCH_BITS
|
---|
447 | * Defines the host ring-3 architecture bit count.
|
---|
448 | */
|
---|
449 | #if !defined(R3_ARCH_BITS) || defined(DOXYGEN_RUNNING)
|
---|
450 | # ifdef IN_RING3
|
---|
451 | # define R3_ARCH_BITS ARCH_BITS
|
---|
452 | # else
|
---|
453 | # define R3_ARCH_BITS HC_ARCH_BITS
|
---|
454 | # endif
|
---|
455 | #endif
|
---|
456 |
|
---|
457 | /** @def R0_ARCH_BITS
|
---|
458 | * Defines the host ring-0 architecture bit count.
|
---|
459 | */
|
---|
460 | #if !defined(R0_ARCH_BITS) || defined(DOXYGEN_RUNNING)
|
---|
461 | # ifdef IN_RING0
|
---|
462 | # define R0_ARCH_BITS ARCH_BITS
|
---|
463 | # else
|
---|
464 | # define R0_ARCH_BITS HC_ARCH_BITS
|
---|
465 | # endif
|
---|
466 | #endif
|
---|
467 |
|
---|
468 |
|
---|
469 |
|
---|
470 | /** @name RT_OPSYS_XXX - Operative System Identifiers.
|
---|
471 | * These are the value that the RT_OPSYS \#define can take. @{
|
---|
472 | */
|
---|
473 | /** Unknown OS. */
|
---|
474 | #define RT_OPSYS_UNKNOWN 0
|
---|
475 | /** OS Agnostic. */
|
---|
476 | #define RT_OPSYS_AGNOSTIC 1
|
---|
477 | /** Darwin - aka Mac OS X. */
|
---|
478 | #define RT_OPSYS_DARWIN 2
|
---|
479 | /** DragonFly BSD. */
|
---|
480 | #define RT_OPSYS_DRAGONFLY 3
|
---|
481 | /** DOS. */
|
---|
482 | #define RT_OPSYS_DOS 4
|
---|
483 | /** FreeBSD. */
|
---|
484 | #define RT_OPSYS_FREEBSD 5
|
---|
485 | /** Haiku. */
|
---|
486 | #define RT_OPSYS_HAIKU 6
|
---|
487 | /** Linux. */
|
---|
488 | #define RT_OPSYS_LINUX 7
|
---|
489 | /** L4. */
|
---|
490 | #define RT_OPSYS_L4 8
|
---|
491 | /** Minix. */
|
---|
492 | #define RT_OPSYS_MINIX 9
|
---|
493 | /** NetBSD. */
|
---|
494 | #define RT_OPSYS_NETBSD 11
|
---|
495 | /** Netware. */
|
---|
496 | #define RT_OPSYS_NETWARE 12
|
---|
497 | /** NT (native). */
|
---|
498 | #define RT_OPSYS_NT 13
|
---|
499 | /** OpenBSD. */
|
---|
500 | #define RT_OPSYS_OPENBSD 14
|
---|
501 | /** OS/2. */
|
---|
502 | #define RT_OPSYS_OS2 15
|
---|
503 | /** Plan 9. */
|
---|
504 | #define RT_OPSYS_PLAN9 16
|
---|
505 | /** QNX. */
|
---|
506 | #define RT_OPSYS_QNX 17
|
---|
507 | /** Solaris. */
|
---|
508 | #define RT_OPSYS_SOLARIS 18
|
---|
509 | /** UEFI. */
|
---|
510 | #define RT_OPSYS_UEFI 19
|
---|
511 | /** Windows. */
|
---|
512 | #define RT_OPSYS_WINDOWS 20
|
---|
513 | /** The max RT_OPSYS_XXX value (exclusive). */
|
---|
514 | #define RT_OPSYS_MAX 21
|
---|
515 | /** @} */
|
---|
516 |
|
---|
517 | /** @def RT_OPSYS
|
---|
518 | * Indicates which OS we're targeting. It's a \#define with is
|
---|
519 | * assigned one of the RT_OPSYS_XXX defines above.
|
---|
520 | *
|
---|
521 | * So to test if we're on FreeBSD do the following:
|
---|
522 | * @code
|
---|
523 | * #if RT_OPSYS == RT_OPSYS_FREEBSD
|
---|
524 | * some_funky_freebsd_specific_stuff();
|
---|
525 | * #endif
|
---|
526 | * @endcode
|
---|
527 | */
|
---|
528 |
|
---|
529 | /*
|
---|
530 | * Set RT_OPSYS_XXX according to RT_OS_XXX.
|
---|
531 | *
|
---|
532 | * Search: #define RT_OPSYS_([A-Z0-9]+) .*
|
---|
533 | * Replace: # elif defined(RT_OS_\1)\n# define RT_OPSYS RT_OPSYS_\1
|
---|
534 | */
|
---|
535 | #ifndef RT_OPSYS
|
---|
536 | # if defined(RT_OS_UNKNOWN) || defined(DOXYGEN_RUNNING)
|
---|
537 | # define RT_OPSYS RT_OPSYS_UNKNOWN
|
---|
538 | # elif defined(RT_OS_AGNOSTIC)
|
---|
539 | # define RT_OPSYS RT_OPSYS_AGNOSTIC
|
---|
540 | # elif defined(RT_OS_DARWIN)
|
---|
541 | # define RT_OPSYS RT_OPSYS_DARWIN
|
---|
542 | # elif defined(RT_OS_DRAGONFLY)
|
---|
543 | # define RT_OPSYS RT_OPSYS_DRAGONFLY
|
---|
544 | # elif defined(RT_OS_DOS)
|
---|
545 | # define RT_OPSYS RT_OPSYS_DOS
|
---|
546 | # elif defined(RT_OS_FREEBSD)
|
---|
547 | # define RT_OPSYS RT_OPSYS_FREEBSD
|
---|
548 | # elif defined(RT_OS_HAIKU)
|
---|
549 | # define RT_OPSYS RT_OPSYS_HAIKU
|
---|
550 | # elif defined(RT_OS_LINUX)
|
---|
551 | # define RT_OPSYS RT_OPSYS_LINUX
|
---|
552 | # elif defined(RT_OS_L4)
|
---|
553 | # define RT_OPSYS RT_OPSYS_L4
|
---|
554 | # elif defined(RT_OS_MINIX)
|
---|
555 | # define RT_OPSYS RT_OPSYS_MINIX
|
---|
556 | # elif defined(RT_OS_NETBSD)
|
---|
557 | # define RT_OPSYS RT_OPSYS_NETBSD
|
---|
558 | # elif defined(RT_OS_NETWARE)
|
---|
559 | # define RT_OPSYS RT_OPSYS_NETWARE
|
---|
560 | # elif defined(RT_OS_NT)
|
---|
561 | # define RT_OPSYS RT_OPSYS_NT
|
---|
562 | # elif defined(RT_OS_OPENBSD)
|
---|
563 | # define RT_OPSYS RT_OPSYS_OPENBSD
|
---|
564 | # elif defined(RT_OS_OS2)
|
---|
565 | # define RT_OPSYS RT_OPSYS_OS2
|
---|
566 | # elif defined(RT_OS_PLAN9)
|
---|
567 | # define RT_OPSYS RT_OPSYS_PLAN9
|
---|
568 | # elif defined(RT_OS_QNX)
|
---|
569 | # define RT_OPSYS RT_OPSYS_QNX
|
---|
570 | # elif defined(RT_OS_SOLARIS)
|
---|
571 | # define RT_OPSYS RT_OPSYS_SOLARIS
|
---|
572 | # elif defined(RT_OS_UEFI)
|
---|
573 | # define RT_OPSYS RT_OPSYS_UEFI
|
---|
574 | # elif defined(RT_OS_WINDOWS)
|
---|
575 | # define RT_OPSYS RT_OPSYS_WINDOWS
|
---|
576 | # endif
|
---|
577 | #endif
|
---|
578 |
|
---|
579 | /*
|
---|
580 | * Guess RT_OPSYS based on compiler predefined macros.
|
---|
581 | */
|
---|
582 | #ifndef RT_OPSYS
|
---|
583 | # if defined(__APPLE__)
|
---|
584 | # define RT_OPSYS RT_OPSYS_DARWIN
|
---|
585 | # elif defined(__DragonFly__)
|
---|
586 | # define RT_OPSYS RT_OPSYS_DRAGONFLY
|
---|
587 | # elif defined(__FreeBSD__) /*??*/
|
---|
588 | # define RT_OPSYS RT_OPSYS_FREEBSD
|
---|
589 | # elif defined(__gnu_linux__)
|
---|
590 | # define RT_OPSYS RT_OPSYS_LINUX
|
---|
591 | # elif defined(__NetBSD__) /*??*/
|
---|
592 | # define RT_OPSYS RT_OPSYS_NETBSD
|
---|
593 | # elif defined(__OpenBSD__) /*??*/
|
---|
594 | # define RT_OPSYS RT_OPSYS_OPENBSD
|
---|
595 | # elif defined(__OS2__)
|
---|
596 | # define RT_OPSYS RT_OPSYS_OS2
|
---|
597 | # elif defined(__sun__) || defined(__SunOS__) || defined(__sun) || defined(__SunOS)
|
---|
598 | # define RT_OPSYS RT_OPSYS_SOLARIS
|
---|
599 | # elif defined(_WIN32) || defined(_WIN64)
|
---|
600 | # define RT_OPSYS RT_OPSYS_WINDOWS
|
---|
601 | # elif defined(MSDOS) || defined(_MSDOS) || defined(DOS16RM) /* OW+MSC || MSC || DMC */
|
---|
602 | # define RT_OPSYS RT_OPSYS_DOS
|
---|
603 | # else
|
---|
604 | # error "Port Me"
|
---|
605 | # endif
|
---|
606 | #endif
|
---|
607 |
|
---|
608 | #if RT_OPSYS < RT_OPSYS_UNKNOWN || RT_OPSYS >= RT_OPSYS_MAX
|
---|
609 | # error "Invalid RT_OPSYS value."
|
---|
610 | #endif
|
---|
611 |
|
---|
612 | /*
|
---|
613 | * Do some consistency checks.
|
---|
614 | *
|
---|
615 | * Search: #define RT_OPSYS_([A-Z0-9]+) .*
|
---|
616 | * Replace: #if defined(RT_OS_\1) && RT_OPSYS != RT_OPSYS_\1\n# error RT_OPSYS vs RT_OS_\1\n#endif
|
---|
617 | */
|
---|
618 | #if defined(RT_OS_UNKNOWN) && RT_OPSYS != RT_OPSYS_UNKNOWN
|
---|
619 | # error RT_OPSYS vs RT_OS_UNKNOWN
|
---|
620 | #endif
|
---|
621 | #if defined(RT_OS_AGNOSTIC) && RT_OPSYS != RT_OPSYS_AGNOSTIC
|
---|
622 | # error RT_OPSYS vs RT_OS_AGNOSTIC
|
---|
623 | #endif
|
---|
624 | #if defined(RT_OS_DARWIN) && RT_OPSYS != RT_OPSYS_DARWIN
|
---|
625 | # error RT_OPSYS vs RT_OS_DARWIN
|
---|
626 | #endif
|
---|
627 | #if defined(RT_OS_DRAGONFLY) && RT_OPSYS != RT_OPSYS_DRAGONFLY
|
---|
628 | # error RT_OPSYS vs RT_OS_DRAGONFLY
|
---|
629 | #endif
|
---|
630 | #if defined(RT_OS_DOS) && RT_OPSYS != RT_OPSYS_DOS
|
---|
631 | # error RT_OPSYS vs RT_OS_DOS
|
---|
632 | #endif
|
---|
633 | #if defined(RT_OS_FREEBSD) && RT_OPSYS != RT_OPSYS_FREEBSD
|
---|
634 | # error RT_OPSYS vs RT_OS_FREEBSD
|
---|
635 | #endif
|
---|
636 | #if defined(RT_OS_HAIKU) && RT_OPSYS != RT_OPSYS_HAIKU
|
---|
637 | # error RT_OPSYS vs RT_OS_HAIKU
|
---|
638 | #endif
|
---|
639 | #if defined(RT_OS_LINUX) && RT_OPSYS != RT_OPSYS_LINUX
|
---|
640 | # error RT_OPSYS vs RT_OS_LINUX
|
---|
641 | #endif
|
---|
642 | #if defined(RT_OS_L4) && RT_OPSYS != RT_OPSYS_L4
|
---|
643 | # error RT_OPSYS vs RT_OS_L4
|
---|
644 | #endif
|
---|
645 | #if defined(RT_OS_MINIX) && RT_OPSYS != RT_OPSYS_MINIX
|
---|
646 | # error RT_OPSYS vs RT_OS_MINIX
|
---|
647 | #endif
|
---|
648 | #if defined(RT_OS_NETBSD) && RT_OPSYS != RT_OPSYS_NETBSD
|
---|
649 | # error RT_OPSYS vs RT_OS_NETBSD
|
---|
650 | #endif
|
---|
651 | #if defined(RT_OS_NETWARE) && RT_OPSYS != RT_OPSYS_NETWARE
|
---|
652 | # error RT_OPSYS vs RT_OS_NETWARE
|
---|
653 | #endif
|
---|
654 | #if defined(RT_OS_NT) && RT_OPSYS != RT_OPSYS_NT
|
---|
655 | # error RT_OPSYS vs RT_OS_NT
|
---|
656 | #endif
|
---|
657 | #if defined(RT_OS_OPENBSD) && RT_OPSYS != RT_OPSYS_OPENBSD
|
---|
658 | # error RT_OPSYS vs RT_OS_OPENBSD
|
---|
659 | #endif
|
---|
660 | #if defined(RT_OS_OS2) && RT_OPSYS != RT_OPSYS_OS2
|
---|
661 | # error RT_OPSYS vs RT_OS_OS2
|
---|
662 | #endif
|
---|
663 | #if defined(RT_OS_PLAN9) && RT_OPSYS != RT_OPSYS_PLAN9
|
---|
664 | # error RT_OPSYS vs RT_OS_PLAN9
|
---|
665 | #endif
|
---|
666 | #if defined(RT_OS_QNX) && RT_OPSYS != RT_OPSYS_QNX
|
---|
667 | # error RT_OPSYS vs RT_OS_QNX
|
---|
668 | #endif
|
---|
669 | #if defined(RT_OS_SOLARIS) && RT_OPSYS != RT_OPSYS_SOLARIS
|
---|
670 | # error RT_OPSYS vs RT_OS_SOLARIS
|
---|
671 | #endif
|
---|
672 | #if defined(RT_OS_UEFI) && RT_OPSYS != RT_OPSYS_UEFI
|
---|
673 | # error RT_OPSYS vs RT_OS_UEFI
|
---|
674 | #endif
|
---|
675 | #if defined(RT_OS_WINDOWS) && RT_OPSYS != RT_OPSYS_WINDOWS
|
---|
676 | # error RT_OPSYS vs RT_OS_WINDOWS
|
---|
677 | #endif
|
---|
678 |
|
---|
679 | /*
|
---|
680 | * Make sure the RT_OS_XXX macro is defined.
|
---|
681 | *
|
---|
682 | * Search: #define RT_OPSYS_([A-Z0-9]+) .*
|
---|
683 | * Replace: #elif RT_OPSYS == RT_OPSYS_\1\n# ifndef RT_OS_\1\n# define RT_OS_\1\n# endif
|
---|
684 | */
|
---|
685 | #if RT_OPSYS == RT_OPSYS_UNKNOWN
|
---|
686 | # ifndef RT_OS_UNKNOWN
|
---|
687 | # define RT_OS_UNKNOWN
|
---|
688 | # endif
|
---|
689 | #elif RT_OPSYS == RT_OPSYS_AGNOSTIC
|
---|
690 | # ifndef RT_OS_AGNOSTIC
|
---|
691 | # define RT_OS_AGNOSTIC
|
---|
692 | # endif
|
---|
693 | #elif RT_OPSYS == RT_OPSYS_DARWIN
|
---|
694 | # ifndef RT_OS_DARWIN
|
---|
695 | # define RT_OS_DARWIN
|
---|
696 | # endif
|
---|
697 | #elif RT_OPSYS == RT_OPSYS_DRAGONFLY
|
---|
698 | # ifndef RT_OS_DRAGONFLY
|
---|
699 | # define RT_OS_DRAGONFLY
|
---|
700 | # endif
|
---|
701 | #elif RT_OPSYS == RT_OPSYS_DOS
|
---|
702 | # ifndef RT_OS_DOS
|
---|
703 | # define RT_OS_DOS
|
---|
704 | # endif
|
---|
705 | #elif RT_OPSYS == RT_OPSYS_FREEBSD
|
---|
706 | # ifndef RT_OS_FREEBSD
|
---|
707 | # define RT_OS_FREEBSD
|
---|
708 | # endif
|
---|
709 | #elif RT_OPSYS == RT_OPSYS_HAIKU
|
---|
710 | # ifndef RT_OS_HAIKU
|
---|
711 | # define RT_OS_HAIKU
|
---|
712 | # endif
|
---|
713 | #elif RT_OPSYS == RT_OPSYS_LINUX
|
---|
714 | # ifndef RT_OS_LINUX
|
---|
715 | # define RT_OS_LINUX
|
---|
716 | # endif
|
---|
717 | #elif RT_OPSYS == RT_OPSYS_L4
|
---|
718 | # ifndef RT_OS_L4
|
---|
719 | # define RT_OS_L4
|
---|
720 | # endif
|
---|
721 | #elif RT_OPSYS == RT_OPSYS_MINIX
|
---|
722 | # ifndef RT_OS_MINIX
|
---|
723 | # define RT_OS_MINIX
|
---|
724 | # endif
|
---|
725 | #elif RT_OPSYS == RT_OPSYS_NETBSD
|
---|
726 | # ifndef RT_OS_NETBSD
|
---|
727 | # define RT_OS_NETBSD
|
---|
728 | # endif
|
---|
729 | #elif RT_OPSYS == RT_OPSYS_NETWARE
|
---|
730 | # ifndef RT_OS_NETWARE
|
---|
731 | # define RT_OS_NETWARE
|
---|
732 | # endif
|
---|
733 | #elif RT_OPSYS == RT_OPSYS_NT
|
---|
734 | # ifndef RT_OS_NT
|
---|
735 | # define RT_OS_NT
|
---|
736 | # endif
|
---|
737 | #elif RT_OPSYS == RT_OPSYS_OPENBSD
|
---|
738 | # ifndef RT_OS_OPENBSD
|
---|
739 | # define RT_OS_OPENBSD
|
---|
740 | # endif
|
---|
741 | #elif RT_OPSYS == RT_OPSYS_OS2
|
---|
742 | # ifndef RT_OS_OS2
|
---|
743 | # define RT_OS_OS2
|
---|
744 | # endif
|
---|
745 | #elif RT_OPSYS == RT_OPSYS_PLAN9
|
---|
746 | # ifndef RT_OS_PLAN9
|
---|
747 | # define RT_OS_PLAN9
|
---|
748 | # endif
|
---|
749 | #elif RT_OPSYS == RT_OPSYS_QNX
|
---|
750 | # ifndef RT_OS_QNX
|
---|
751 | # define RT_OS_QNX
|
---|
752 | # endif
|
---|
753 | #elif RT_OPSYS == RT_OPSYS_SOLARIS
|
---|
754 | # ifndef RT_OS_SOLARIS
|
---|
755 | # define RT_OS_SOLARIS
|
---|
756 | # endif
|
---|
757 | #elif RT_OPSYS == RT_OPSYS_UEFI
|
---|
758 | # ifndef RT_OS_UEFI
|
---|
759 | # define RT_OS_UEFI
|
---|
760 | # endif
|
---|
761 | #elif RT_OPSYS == RT_OPSYS_WINDOWS
|
---|
762 | # ifndef RT_OS_WINDOWS
|
---|
763 | # define RT_OS_WINDOWS
|
---|
764 | # endif
|
---|
765 | #else
|
---|
766 | # error "Bad RT_OPSYS value."
|
---|
767 | #endif
|
---|
768 |
|
---|
769 |
|
---|
770 | /**
|
---|
771 | * Checks whether the given OpSys uses DOS-style paths or not.
|
---|
772 | *
|
---|
773 | * By DOS-style paths we include drive lettering and UNC paths.
|
---|
774 | *
|
---|
775 | * @returns true / false
|
---|
776 | * @param a_OpSys The RT_OPSYS_XXX value to check, will be reference
|
---|
777 | * multiple times.
|
---|
778 | */
|
---|
779 | #define RT_OPSYS_USES_DOS_PATHS(a_OpSys) \
|
---|
780 | ( (a_OpSys) == RT_OPSYS_WINDOWS \
|
---|
781 | || (a_OpSys) == RT_OPSYS_OS2 \
|
---|
782 | || (a_OpSys) == RT_OPSYS_DOS )
|
---|
783 |
|
---|
784 |
|
---|
785 |
|
---|
786 | /** @def CTXTYPE
|
---|
787 | * Declare a type differently in GC, R3 and R0.
|
---|
788 | *
|
---|
789 | * @param a_GCType The GC type.
|
---|
790 | * @param a_R3Type The R3 type.
|
---|
791 | * @param a_R0Type The R0 type.
|
---|
792 | * @remark For pointers used only in one context use RCPTRTYPE(), R3R0PTRTYPE(), R3PTRTYPE() or R0PTRTYPE().
|
---|
793 | */
|
---|
794 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
795 | # define CTXTYPE(a_GCType, a_R3Type, a_R0Type) a_GCType
|
---|
796 | #elif defined(IN_RING3) || defined(DOXYGEN_RUNNING)
|
---|
797 | # define CTXTYPE(a_GCType, a_R3Type, a_R0Type) a_R3Type
|
---|
798 | #else
|
---|
799 | # define CTXTYPE(a_GCType, a_R3Type, a_R0Type) a_R0Type
|
---|
800 | #endif
|
---|
801 |
|
---|
802 | /** @def CTX_EXPR
|
---|
803 | * Expression selector for avoiding \#ifdef's.
|
---|
804 | *
|
---|
805 | * @param a_R3Expr The R3 expression.
|
---|
806 | * @param a_R0Expr The R0 expression.
|
---|
807 | * @param a_RCExpr The RC expression.
|
---|
808 | */
|
---|
809 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
810 | # define CTX_EXPR(a_R3Expr, a_R0Expr, a_RCExpr) a_RCExpr
|
---|
811 | #elif defined(IN_RING0) && !defined(DOXYGEN_RUNNING)
|
---|
812 | # define CTX_EXPR(a_R3Expr, a_R0Expr, a_RCExpr) a_R0Expr
|
---|
813 | #else
|
---|
814 | # define CTX_EXPR(a_R3Expr, a_R0Expr, a_RCExpr) a_R3Expr
|
---|
815 | #endif
|
---|
816 |
|
---|
817 | /** @def RCPTRTYPE
|
---|
818 | * Declare a pointer which is used in the raw mode context but appears in structure(s) used by
|
---|
819 | * both HC and RC. The main purpose is to make sure structures have the same
|
---|
820 | * size when built for different architectures.
|
---|
821 | *
|
---|
822 | * @param a_RCType The RC type.
|
---|
823 | */
|
---|
824 | #define RCPTRTYPE(a_RCType) CTXTYPE(a_RCType, RTRCPTR, RTRCPTR)
|
---|
825 |
|
---|
826 | /** @def RGPTRTYPE
|
---|
827 | * This will become RCPTRTYPE once we've converted all uses of RCPTRTYPE to this.
|
---|
828 | *
|
---|
829 | * @param a_RCType The RC type.
|
---|
830 | */
|
---|
831 | #define RGPTRTYPE(a_RCType) CTXTYPE(a_RCType, RTGCPTR, RTGCPTR)
|
---|
832 |
|
---|
833 | /** @def R3R0PTRTYPE
|
---|
834 | * Declare a pointer which is used in HC, is explicitly valid in ring 3 and 0,
|
---|
835 | * but appears in structure(s) used by both HC and GC. The main purpose is to
|
---|
836 | * make sure structures have the same size when built for different architectures.
|
---|
837 | *
|
---|
838 | * @param a_R3R0Type The R3R0 type.
|
---|
839 | * @remarks This used to be called HCPTRTYPE.
|
---|
840 | */
|
---|
841 | #define R3R0PTRTYPE(a_R3R0Type) CTXTYPE(RTHCPTR, a_R3R0Type, a_R3R0Type)
|
---|
842 |
|
---|
843 | /** @def R3PTRTYPE
|
---|
844 | * Declare a pointer which is used in R3 but appears in structure(s) used by
|
---|
845 | * both HC and GC. The main purpose is to make sure structures have the same
|
---|
846 | * size when built for different architectures.
|
---|
847 | *
|
---|
848 | * @param a_R3Type The R3 type.
|
---|
849 | */
|
---|
850 | #define R3PTRTYPE(a_R3Type) CTXTYPE(RTHCUINTPTR, a_R3Type, RTHCUINTPTR)
|
---|
851 |
|
---|
852 | /** @def R0PTRTYPE
|
---|
853 | * Declare a pointer which is used in R0 but appears in structure(s) used by
|
---|
854 | * both HC and GC. The main purpose is to make sure structures have the same
|
---|
855 | * size when built for different architectures.
|
---|
856 | *
|
---|
857 | * @param a_R0Type The R0 type.
|
---|
858 | */
|
---|
859 | #define R0PTRTYPE(a_R0Type) CTXTYPE(RTHCUINTPTR, RTHCUINTPTR, a_R0Type)
|
---|
860 |
|
---|
861 | /** @def CTXSUFF
|
---|
862 | * Adds the suffix of the current context to the passed in
|
---|
863 | * identifier name. The suffix is HC or GC.
|
---|
864 | *
|
---|
865 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
866 | * @param a_Var Identifier name.
|
---|
867 | * @deprecated Use CTX_SUFF. Do NOT use this for new code.
|
---|
868 | */
|
---|
869 | /** @def OTHERCTXSUFF
|
---|
870 | * Adds the suffix of the other context to the passed in
|
---|
871 | * identifier name. The suffix is HC or GC.
|
---|
872 | *
|
---|
873 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
874 | * @param a_Var Identifier name.
|
---|
875 | * @deprecated Use CTX_SUFF. Do NOT use this for new code.
|
---|
876 | */
|
---|
877 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
878 | # define CTXSUFF(a_Var) a_Var##GC
|
---|
879 | # define OTHERCTXSUFF(a_Var) a_Var##HC
|
---|
880 | #else
|
---|
881 | # define CTXSUFF(a_Var) a_Var##HC
|
---|
882 | # define OTHERCTXSUFF(a_Var) a_Var##GC
|
---|
883 | #endif
|
---|
884 |
|
---|
885 | /** @def CTXALLSUFF
|
---|
886 | * Adds the suffix of the current context to the passed in
|
---|
887 | * identifier name. The suffix is R3, R0 or GC.
|
---|
888 | *
|
---|
889 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
890 | * @param a_Var Identifier name.
|
---|
891 | * @deprecated Use CTX_SUFF. Do NOT use this for new code.
|
---|
892 | */
|
---|
893 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
894 | # define CTXALLSUFF(a_Var) a_Var##GC
|
---|
895 | #elif defined(IN_RING0) && !defined(DOXYGEN_RUNNING)
|
---|
896 | # define CTXALLSUFF(a_Var) a_Var##R0
|
---|
897 | #else
|
---|
898 | # define CTXALLSUFF(a_Var) a_Var##R3
|
---|
899 | #endif
|
---|
900 |
|
---|
901 | /** @def CTX_SUFF
|
---|
902 | * Adds the suffix of the current context to the passed in
|
---|
903 | * identifier name. The suffix is R3, R0 or RC.
|
---|
904 | *
|
---|
905 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
906 | * @param a_Var Identifier name.
|
---|
907 | *
|
---|
908 | * @remark This will replace CTXALLSUFF and CTXSUFF before long.
|
---|
909 | */
|
---|
910 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
911 | # define CTX_SUFF(a_Var) a_Var##RC
|
---|
912 | #elif defined(IN_RING0) && !defined(DOXYGEN_RUNNING)
|
---|
913 | # define CTX_SUFF(a_Var) a_Var##R0
|
---|
914 | #else
|
---|
915 | # define CTX_SUFF(a_Var) a_Var##R3
|
---|
916 | #endif
|
---|
917 |
|
---|
918 | /** @def CTX_SUFF_Z
|
---|
919 | * Adds the suffix of the current context to the passed in
|
---|
920 | * identifier name, combining RC and R0 into RZ.
|
---|
921 | * The suffix thus is R3 or RZ.
|
---|
922 | *
|
---|
923 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
924 | * @param a_Var Identifier name.
|
---|
925 | *
|
---|
926 | * @remark This will replace CTXALLSUFF and CTXSUFF before long.
|
---|
927 | */
|
---|
928 | #if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
|
---|
929 | # define CTX_SUFF_Z(a_Var) a_Var##R3
|
---|
930 | #else
|
---|
931 | # define CTX_SUFF_Z(a_Var) a_Var##RZ
|
---|
932 | #endif
|
---|
933 |
|
---|
934 |
|
---|
935 | /** @def CTXMID
|
---|
936 | * Adds the current context as a middle name of an identifier name
|
---|
937 | * The middle name is HC or GC.
|
---|
938 | *
|
---|
939 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
940 | * @param a_First First name.
|
---|
941 | * @param a_Last Surname.
|
---|
942 | */
|
---|
943 | /** @def OTHERCTXMID
|
---|
944 | * Adds the other context as a middle name of an identifier name
|
---|
945 | * The middle name is HC or GC.
|
---|
946 | *
|
---|
947 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
948 | * @param a_First First name.
|
---|
949 | * @param a_Last Surname.
|
---|
950 | * @deprecated use CTX_MID or CTX_MID_Z
|
---|
951 | */
|
---|
952 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
953 | # define CTXMID(a_First, a_Last) a_First##GC##a_Last
|
---|
954 | # define OTHERCTXMID(a_First, a_Last) a_First##HC##a_Last
|
---|
955 | #else
|
---|
956 | # define CTXMID(a_First, a_Last) a_First##HC##a_Last
|
---|
957 | # define OTHERCTXMID(a_First, a_Last) a_First##GC##a_Last
|
---|
958 | #endif
|
---|
959 |
|
---|
960 | /** @def CTXALLMID
|
---|
961 | * Adds the current context as a middle name of an identifier name.
|
---|
962 | * The middle name is R3, R0 or GC.
|
---|
963 | *
|
---|
964 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
965 | * @param a_First First name.
|
---|
966 | * @param a_Last Surname.
|
---|
967 | * @deprecated use CTX_MID or CTX_MID_Z
|
---|
968 | */
|
---|
969 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
970 | # define CTXALLMID(a_First, a_Last) a_First##GC##a_Last
|
---|
971 | #elif defined(IN_RING0) && !defined(DOXYGEN_RUNNING)
|
---|
972 | # define CTXALLMID(a_First, a_Last) a_First##R0##a_Last
|
---|
973 | #else
|
---|
974 | # define CTXALLMID(a_First, a_Last) a_First##R3##a_Last
|
---|
975 | #endif
|
---|
976 |
|
---|
977 | /** @def CTX_MID
|
---|
978 | * Adds the current context as a middle name of an identifier name.
|
---|
979 | * The middle name is R3, R0 or RC.
|
---|
980 | *
|
---|
981 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
982 | * @param a_First First name.
|
---|
983 | * @param a_Last Surname.
|
---|
984 | */
|
---|
985 | #if defined(IN_RC) && !defined(DOXYGEN_RUNNING)
|
---|
986 | # define CTX_MID(a_First, a_Last) a_First##RC##a_Last
|
---|
987 | #elif defined(IN_RING0) && !defined(DOXYGEN_RUNNING)
|
---|
988 | # define CTX_MID(a_First, a_Last) a_First##R0##a_Last
|
---|
989 | #else
|
---|
990 | # define CTX_MID(a_First, a_Last) a_First##R3##a_Last
|
---|
991 | #endif
|
---|
992 |
|
---|
993 | /** @def CTX_MID_Z
|
---|
994 | * Adds the current context as a middle name of an identifier name, combining RC
|
---|
995 | * and R0 into RZ.
|
---|
996 | * The middle name thus is either R3 or RZ.
|
---|
997 | *
|
---|
998 | * This is macro should only be used in shared code to avoid a forest of ifdefs.
|
---|
999 | * @param a_First First name.
|
---|
1000 | * @param a_Last Surname.
|
---|
1001 | */
|
---|
1002 | #ifdef IN_RING3
|
---|
1003 | # define CTX_MID_Z(a_First, a_Last) a_First##R3##a_Last
|
---|
1004 | #else
|
---|
1005 | # define CTX_MID_Z(a_First, a_Last) a_First##RZ##a_Last
|
---|
1006 | #endif
|
---|
1007 |
|
---|
1008 |
|
---|
1009 | /** @def R3STRING
|
---|
1010 | * A macro which in GC and R0 will return a dummy string while in R3 it will return
|
---|
1011 | * the parameter.
|
---|
1012 | *
|
---|
1013 | * This is typically used to wrap description strings in structures shared
|
---|
1014 | * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING3 mess.
|
---|
1015 | *
|
---|
1016 | * @param a_pR3String The R3 string. Only referenced in R3.
|
---|
1017 | * @see R0STRING and GCSTRING
|
---|
1018 | */
|
---|
1019 | #ifdef IN_RING3
|
---|
1020 | # define R3STRING(a_pR3String) (a_pR3String)
|
---|
1021 | #else
|
---|
1022 | # define R3STRING(a_pR3String) ("<R3_STRING>")
|
---|
1023 | #endif
|
---|
1024 |
|
---|
1025 | /** @def R0STRING
|
---|
1026 | * A macro which in GC and R3 will return a dummy string while in R0 it will return
|
---|
1027 | * the parameter.
|
---|
1028 | *
|
---|
1029 | * This is typically used to wrap description strings in structures shared
|
---|
1030 | * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING0 mess.
|
---|
1031 | *
|
---|
1032 | * @param a_pR0String The R0 string. Only referenced in R0.
|
---|
1033 | * @see R3STRING and GCSTRING
|
---|
1034 | */
|
---|
1035 | #ifdef IN_RING0
|
---|
1036 | # define R0STRING(a_pR0String) (a_pR0String)
|
---|
1037 | #else
|
---|
1038 | # define R0STRING(a_pR0String) ("<R0_STRING>")
|
---|
1039 | #endif
|
---|
1040 |
|
---|
1041 | /** @def RCSTRING
|
---|
1042 | * A macro which in R3 and R0 will return a dummy string while in RC it will return
|
---|
1043 | * the parameter.
|
---|
1044 | *
|
---|
1045 | * This is typically used to wrap description strings in structures shared
|
---|
1046 | * between R3, R0 and/or RC. The intention is to avoid the \#ifdef IN_RC mess.
|
---|
1047 | *
|
---|
1048 | * @param a_pRCString The RC string. Only referenced in RC.
|
---|
1049 | * @see R3STRING, R0STRING
|
---|
1050 | */
|
---|
1051 | #ifdef IN_RC
|
---|
1052 | # define RCSTRING(a_pRCString) (a_pRCString)
|
---|
1053 | #else
|
---|
1054 | # define RCSTRING(a_pRCString) ("<RC_STRING>")
|
---|
1055 | #endif
|
---|
1056 |
|
---|
1057 |
|
---|
1058 | /** @def RT_NOTHING
|
---|
1059 | * A macro that expands to nothing.
|
---|
1060 | * This is primarily intended as a dummy argument for macros to avoid the
|
---|
1061 | * undefined behavior passing empty arguments to an macro (ISO C90 and C++98,
|
---|
1062 | * gcc v4.4 warns about it).
|
---|
1063 | */
|
---|
1064 | #define RT_NOTHING
|
---|
1065 |
|
---|
1066 | /** @def RT_GCC_EXTENSION
|
---|
1067 | * Macro for shutting up GCC warnings about using language extensions. */
|
---|
1068 | #ifdef __GNUC__
|
---|
1069 | # define RT_GCC_EXTENSION __extension__
|
---|
1070 | #else
|
---|
1071 | # define RT_GCC_EXTENSION
|
---|
1072 | #endif
|
---|
1073 |
|
---|
1074 | /** @def RT_GCC_NO_WARN_DEPRECATED_BEGIN
|
---|
1075 | * Used to start a block of code where GCC and Clang should not warn about
|
---|
1076 | * deprecated declarations. */
|
---|
1077 | /** @def RT_GCC_NO_WARN_DEPRECATED_END
|
---|
1078 | * Used to end a block of code where GCC and Clang should not warn about
|
---|
1079 | * deprecated declarations. */
|
---|
1080 | #if RT_CLANG_PREREQ(4, 0)
|
---|
1081 | # define RT_GCC_NO_WARN_DEPRECATED_BEGIN \
|
---|
1082 | _Pragma("clang diagnostic push") \
|
---|
1083 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
---|
1084 | # define RT_GCC_NO_WARN_DEPRECATED_END \
|
---|
1085 | _Pragma("clang diagnostic pop")
|
---|
1086 |
|
---|
1087 | #elif RT_GNUC_PREREQ(4, 6)
|
---|
1088 | # define RT_GCC_NO_WARN_DEPRECATED_BEGIN \
|
---|
1089 | _Pragma("GCC diagnostic push") \
|
---|
1090 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
---|
1091 | # define RT_GCC_NO_WARN_DEPRECATED_END \
|
---|
1092 | _Pragma("GCC diagnostic pop")
|
---|
1093 | #else
|
---|
1094 | # define RT_GCC_NO_WARN_DEPRECATED_BEGIN
|
---|
1095 | # define RT_GCC_NO_WARN_DEPRECATED_END
|
---|
1096 | #endif
|
---|
1097 |
|
---|
1098 | /** @def RT_GCC_NO_WARN_CONVERSION_BEGIN
|
---|
1099 | * Used to start a block of code where GCC should not warn about implicit
|
---|
1100 | * conversions that may alter a value. */
|
---|
1101 | #if RT_GNUC_PREREQ(4, 6)
|
---|
1102 | # define RT_GCC_NO_WARN_CONVERSION_BEGIN \
|
---|
1103 | _Pragma("GCC diagnostic push") \
|
---|
1104 | _Pragma("GCC diagnostic ignored \"-Wconversion\"")
|
---|
1105 | /** @def RT_GCC_NO_WARN_CONVERSION_END
|
---|
1106 | * Used to end a block of code where GCC should not warn about implicit
|
---|
1107 | * conversions that may alter a value. */
|
---|
1108 | # define RT_GCC_NO_WARN_CONVERSION_END \
|
---|
1109 | _Pragma("GCC diagnostic pop")
|
---|
1110 | #else
|
---|
1111 | # define RT_GCC_NO_WARN_CONVERSION_BEGIN
|
---|
1112 | # define RT_GCC_NO_WARN_CONVERSION_END
|
---|
1113 | #endif
|
---|
1114 |
|
---|
1115 | /** @def RT_COMPILER_GROKS_64BIT_BITFIELDS
|
---|
1116 | * Macro that is defined if the compiler understands 64-bit bitfields. */
|
---|
1117 | #if !defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__))
|
---|
1118 | # if !defined(__WATCOMC__) /* watcom compiler doesn't grok it either. */
|
---|
1119 | # define RT_COMPILER_GROKS_64BIT_BITFIELDS
|
---|
1120 | # endif
|
---|
1121 | #endif
|
---|
1122 |
|
---|
1123 | /** @def RT_COMPILER_LONG_DOUBLE_BITS
|
---|
1124 | * Number of relevant bits in the long double type: 64, 80 or 128 */
|
---|
1125 | /** @def RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1126 | * Macro that is defined if the compiler implements long double as the
|
---|
1127 | * IEEE precision floating. */
|
---|
1128 | /** @def RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1129 | * Macro that is defined if the compiler implements long double as the
|
---|
1130 | * IEEE extended precision floating. */
|
---|
1131 | /** @def RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1132 | * Macro that is defined if the compiler implements long double as the
|
---|
1133 | * IEEE quadruple precision floating (128-bit).
|
---|
1134 | * @note Currently not able to detect this, so must be explicitly defined. */
|
---|
1135 | #if defined(__LDBL_MANT_DIG__) /* GCC & clang have this defined and should be more reliable. */
|
---|
1136 | # if __LDBL_MANT_DIG__ == 53
|
---|
1137 | # define RT_COMPILER_LONG_DOUBLE_BITS 64
|
---|
1138 | # define RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1139 | # undef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1140 | # undef RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1141 | # elif __LDBL_MANT_DIG__ == 64
|
---|
1142 | # define RT_COMPILER_LONG_DOUBLE_BITS 80
|
---|
1143 | # undef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1144 | # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1145 | # undef RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1146 | # elif __LDBL_MANT_DIG__ == 113
|
---|
1147 | # define RT_COMPILER_LONG_DOUBLE_BITS 128
|
---|
1148 | # undef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1149 | # undef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1150 | # define RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1151 | # else
|
---|
1152 | # error "Port me!"
|
---|
1153 | # endif
|
---|
1154 | #elif defined(RT_OS_WINDOWS) || defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) /* the M1 arm64 at least */
|
---|
1155 | # define RT_COMPILER_LONG_DOUBLE_BITS 64
|
---|
1156 | # define RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1157 | # undef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1158 | # undef RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1159 | #elif defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
1160 | # define RT_COMPILER_LONG_DOUBLE_BITS 80
|
---|
1161 | # undef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1162 | # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1163 | # undef RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1164 | #elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
|
---|
1165 | # define RT_COMPILER_LONG_DOUBLE_BITS 128
|
---|
1166 | # undef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1167 | # undef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
1168 | # define RT_COMPILER_WITH_128BIT_LONG_DOUBLE
|
---|
1169 | #else
|
---|
1170 | # error "Port me!"
|
---|
1171 | #endif
|
---|
1172 |
|
---|
1173 | /** @def RT_COMPILER_WITH_128BIT_INT_TYPES
|
---|
1174 | * Defined when uint128_t and int128_t are native integer types. If
|
---|
1175 | * undefined, they are structure with Hi & Lo members. */
|
---|
1176 | #if defined(__SIZEOF_INT128__) || (defined(__GNUC__) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_ARM64)))
|
---|
1177 | # define RT_COMPILER_WITH_128BIT_INT_TYPES
|
---|
1178 | #endif
|
---|
1179 |
|
---|
1180 | /** @def RT_EXCEPTIONS_ENABLED
|
---|
1181 | * Defined when C++ exceptions are enabled.
|
---|
1182 | */
|
---|
1183 | #if !defined(RT_EXCEPTIONS_ENABLED) \
|
---|
1184 | && defined(__cplusplus) \
|
---|
1185 | && ( (defined(_MSC_VER) && defined(_CPPUNWIND)) \
|
---|
1186 | || (defined(__GNUC__) && defined(__EXCEPTIONS)))
|
---|
1187 | # define RT_EXCEPTIONS_ENABLED
|
---|
1188 | #endif
|
---|
1189 |
|
---|
1190 | /** @def DECL_NOTHROW
|
---|
1191 | * How to declare a function which does not throw C++ exceptions.
|
---|
1192 | *
|
---|
1193 | * @param a_Type The return type.
|
---|
1194 | *
|
---|
1195 | * @note This macro can be combined with other macros, for example
|
---|
1196 | * @code
|
---|
1197 | * RTR3DECL(DECL_NOTHROW(void)) foo(void);
|
---|
1198 | * @endcode
|
---|
1199 | *
|
---|
1200 | * @note GCC is currently restricted to 4.2+ given the ominous comments on
|
---|
1201 | * RT_NOTHROW_PROTO.
|
---|
1202 | */
|
---|
1203 | #ifdef __cplusplus
|
---|
1204 | # if RT_MSC_PREREQ(RT_MSC_VER_VS2015) /*?*/
|
---|
1205 | # define DECL_NOTHROW(a_Type) __declspec(nothrow) a_Type
|
---|
1206 | # elif RT_CLANG_PREREQ(6,0) || RT_GNUC_PREREQ(4,2)
|
---|
1207 | # define DECL_NOTHROW(a_Type) __attribute__((__nothrow__)) a_Type
|
---|
1208 | # else
|
---|
1209 | # define DECL_NOTHROW(a_Type) a_Type
|
---|
1210 | # endif
|
---|
1211 | #else
|
---|
1212 | # define DECL_NOTHROW(a_Type) a_Type
|
---|
1213 | #endif
|
---|
1214 |
|
---|
1215 | /** @def RT_NOTHROW_PROTO
|
---|
1216 | * Function does not throw any C++ exceptions, prototype edition.
|
---|
1217 | *
|
---|
1218 | * How to express that a function doesn't throw C++ exceptions and the compiler
|
---|
1219 | * can thus save itself the bother of trying to catch any of them and generate
|
---|
1220 | * unwind info. Put this between the closing parenthesis and the semicolon in
|
---|
1221 | * function prototypes (and implementation if C++).
|
---|
1222 | *
|
---|
1223 | * @note This translates to 'noexcept' when compiling in newer C++ mode.
|
---|
1224 | *
|
---|
1225 | * @remarks The use of the nothrow attribute with GCC is because old compilers
|
---|
1226 | * (4.1.1, 32-bit) leaking the nothrow into global space or something
|
---|
1227 | * when used with RTDECL or similar. Using this forces us to have two
|
---|
1228 | * macros, as the nothrow attribute is not for the function definition.
|
---|
1229 | */
|
---|
1230 | /** @def RT_NOTHROW_DEF
|
---|
1231 | * Function does not throw any C++ exceptions, definition edition.
|
---|
1232 | *
|
---|
1233 | * The counter part to RT_NOTHROW_PROTO that is added to the function
|
---|
1234 | * definition.
|
---|
1235 | */
|
---|
1236 | #ifdef RT_EXCEPTIONS_ENABLED
|
---|
1237 | # if RT_MSC_PREREQ_EX(RT_MSC_VER_VS2015, 0) \
|
---|
1238 | || RT_CLANG_HAS_FEATURE(cxx_noexcept) \
|
---|
1239 | || (RT_GNUC_PREREQ(7, 0) && __cplusplus >= 201100)
|
---|
1240 | # define RT_NOTHROW_PROTO noexcept
|
---|
1241 | # define RT_NOTHROW_DEF noexcept
|
---|
1242 | # elif defined(__GNUC__)
|
---|
1243 | # if RT_GNUC_PREREQ(3, 3)
|
---|
1244 | # define RT_NOTHROW_PROTO __attribute__((__nothrow__))
|
---|
1245 | # else
|
---|
1246 | # define RT_NOTHROW_PROTO
|
---|
1247 | # endif
|
---|
1248 | # define RT_NOTHROW_DEF /* Would need a DECL_NO_THROW like __declspec(nothrow), which we wont do at this point. */
|
---|
1249 | # else
|
---|
1250 | # define RT_NOTHROW_PROTO throw()
|
---|
1251 | # define RT_NOTHROW_DEF throw()
|
---|
1252 | # endif
|
---|
1253 | #else
|
---|
1254 | # define RT_NOTHROW_PROTO
|
---|
1255 | # define RT_NOTHROW_DEF
|
---|
1256 | #endif
|
---|
1257 | /** @def RT_NOTHROW_PROTO
|
---|
1258 | * @deprecated Use RT_NOTHROW_PROTO. */
|
---|
1259 | #define RT_NO_THROW_PROTO RT_NOTHROW_PROTO
|
---|
1260 | /** @def RT_NOTHROW_DEF
|
---|
1261 | * @deprecated Use RT_NOTHROW_DEF. */
|
---|
1262 | #define RT_NO_THROW_DEF RT_NOTHROW_DEF
|
---|
1263 |
|
---|
1264 | /** @def RT_THROW
|
---|
1265 | * How to express that a method or function throws a type of exceptions. Some
|
---|
1266 | * compilers does not want this kind of information and will warning about it.
|
---|
1267 | *
|
---|
1268 | * @param a_Type The type exception.
|
---|
1269 | *
|
---|
1270 | * @remarks If the actual throwing is done from the header, enclose it by
|
---|
1271 | * \#ifdef RT_EXCEPTIONS_ENABLED ... \#else ... \#endif so the header
|
---|
1272 | * compiles cleanly without exceptions enabled.
|
---|
1273 | *
|
---|
1274 | * Do NOT use this for the actual throwing of exceptions!
|
---|
1275 | */
|
---|
1276 | #ifdef RT_EXCEPTIONS_ENABLED
|
---|
1277 | # if (__cplusplus + 0) >= 201700
|
---|
1278 | # define RT_THROW(a_Type) noexcept(false)
|
---|
1279 | # elif RT_MSC_PREREQ_EX(RT_MSC_VER_VC71, 0)
|
---|
1280 | # define RT_THROW(a_Type)
|
---|
1281 | # elif RT_GNUC_PREREQ(7, 0)
|
---|
1282 | # define RT_THROW(a_Type)
|
---|
1283 | # else
|
---|
1284 | # define RT_THROW(a_Type) throw(a_Type)
|
---|
1285 | # endif
|
---|
1286 | #else
|
---|
1287 | # define RT_THROW(a_Type)
|
---|
1288 | #endif
|
---|
1289 |
|
---|
1290 |
|
---|
1291 | /** @def RT_OVERRIDE
|
---|
1292 | * Wrapper for the C++11 override keyword.
|
---|
1293 | *
|
---|
1294 | * @remarks Recognized by g++ starting 4.7, however causes pedantic warnings
|
---|
1295 | * when used without officially enabling the C++11 features.
|
---|
1296 | */
|
---|
1297 | #ifdef __cplusplus
|
---|
1298 | # if RT_MSC_PREREQ_EX(RT_MSC_VER_VS2012, 0)
|
---|
1299 | # define RT_OVERRIDE override
|
---|
1300 | # elif RT_GNUC_PREREQ(4, 7)
|
---|
1301 | # if __cplusplus >= 201100
|
---|
1302 | # define RT_OVERRIDE override
|
---|
1303 | # else
|
---|
1304 | # define RT_OVERRIDE
|
---|
1305 | # endif
|
---|
1306 | # else
|
---|
1307 | # define RT_OVERRIDE
|
---|
1308 | # endif
|
---|
1309 | #else
|
---|
1310 | # define RT_OVERRIDE
|
---|
1311 | #endif
|
---|
1312 |
|
---|
1313 | /** @def RT_NOEXCEPT
|
---|
1314 | * Wrapper for the C++11 noexcept keyword (only true form).
|
---|
1315 | * @note use RT_NOTHROW instead.
|
---|
1316 | */
|
---|
1317 | /** @def RT_NOEXCEPT_EX
|
---|
1318 | * Wrapper for the C++11 noexcept keyword with expression.
|
---|
1319 | * @param a_Expr The expression.
|
---|
1320 | */
|
---|
1321 | #ifdef __cplusplus
|
---|
1322 | # if (RT_MSC_PREREQ_EX(RT_MSC_VER_VS2015, 0) && defined(RT_EXCEPTIONS_ENABLED)) \
|
---|
1323 | || RT_CLANG_HAS_FEATURE(cxx_noexcept) \
|
---|
1324 | || (RT_GNUC_PREREQ(7, 0) && __cplusplus >= 201100)
|
---|
1325 | # define RT_NOEXCEPT noexcept
|
---|
1326 | # define RT_NOEXCEPT_EX(a_Expr) noexcept(a_Expr)
|
---|
1327 | # else
|
---|
1328 | # define RT_NOEXCEPT
|
---|
1329 | # define RT_NOEXCEPT_EX(a_Expr)
|
---|
1330 | # endif
|
---|
1331 | #else
|
---|
1332 | # define RT_NOEXCEPT
|
---|
1333 | # define RT_NOEXCEPT_EX(a_Expr)
|
---|
1334 | #endif
|
---|
1335 |
|
---|
1336 | /** @def RT_ALIGNAS_VAR
|
---|
1337 | * Wrapper for the C++ alignas keyword when used on variables.
|
---|
1338 | *
|
---|
1339 | * This must be put before the storage class and type.
|
---|
1340 | *
|
---|
1341 | * @param a_cbAlign The alignment. Must be power of two.
|
---|
1342 | * @note If C++11 is not enabled/detectable, alternatives will be used where
|
---|
1343 | * available. */
|
---|
1344 | /** @def RT_ALIGNAS_TYPE
|
---|
1345 | * Wrapper for the C++ alignas keyword when used on types.
|
---|
1346 | *
|
---|
1347 | * When using struct, this must follow the struct keyword.
|
---|
1348 | *
|
---|
1349 | * @param a_cbAlign The alignment. Must be power of two.
|
---|
1350 | * @note If C++11 is not enabled/detectable, alternatives will be used where
|
---|
1351 | * available. */
|
---|
1352 | /** @def RT_ALIGNAS_MEMB
|
---|
1353 | * Wrapper for the C++ alignas keyword when used on structure members.
|
---|
1354 | *
|
---|
1355 | * This must be put before the variable type.
|
---|
1356 | *
|
---|
1357 | * @param a_cbAlign The alignment. Must be power of two.
|
---|
1358 | * @note If C++11 is not enabled/detectable, alternatives will be used where
|
---|
1359 | * available. */
|
---|
1360 | #ifdef __cplusplus
|
---|
1361 | # if __cplusplus >= 201100 || defined(DOXYGEN_RUNNING)
|
---|
1362 | # define RT_ALIGNAS_VAR(a_cbAlign) alignas(a_cbAlign)
|
---|
1363 | # define RT_ALIGNAS_TYPE(a_cbAlign) alignas(a_cbAlign)
|
---|
1364 | # define RT_ALIGNAS_MEMB(a_cbAlign) alignas(a_cbAlign)
|
---|
1365 | # endif
|
---|
1366 | #endif
|
---|
1367 | #ifndef RT_ALIGNAS_VAR
|
---|
1368 | # ifdef _MSC_VER
|
---|
1369 | # define RT_ALIGNAS_VAR(a_cbAlign) __declspec(align(a_cbAlign))
|
---|
1370 | # define RT_ALIGNAS_TYPE(a_cbAlign) __declspec(align(a_cbAlign))
|
---|
1371 | # define RT_ALIGNAS_MEMB(a_cbAlign) __declspec(align(a_cbAlign))
|
---|
1372 | # elif defined(__GNUC__)
|
---|
1373 | # define RT_ALIGNAS_VAR(a_cbAlign) __attribute__((__aligned__(a_cbAlign)))
|
---|
1374 | # define RT_ALIGNAS_TYPE(a_cbAlign) __attribute__((__aligned__(a_cbAlign)))
|
---|
1375 | # define RT_ALIGNAS_MEMB(a_cbAlign) __attribute__((__aligned__(a_cbAlign)))
|
---|
1376 | # else
|
---|
1377 | # define RT_ALIGNAS_VAR(a_cbAlign)
|
---|
1378 | # define RT_ALIGNAS_TYPE(a_cbAlign)
|
---|
1379 | # define RT_ALIGNAS_MEMB(a_cbAlign)
|
---|
1380 | # endif
|
---|
1381 | #endif
|
---|
1382 |
|
---|
1383 | /** @def RT_CACHELINE_SIZE
|
---|
1384 | * The typical cache line size for the target architecture.
|
---|
1385 | * @see RT_ALIGNAS_VAR, RT_ALIGNAS_TYPE, RT_ALIGNAS_MEMB
|
---|
1386 | */
|
---|
1387 | #if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64) \
|
---|
1388 | || defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64) \
|
---|
1389 | || defined(RT_ARCH_SPARC32) || defined(RT_ARCH_SPARC64) \
|
---|
1390 | || defined(DOXYGEN_RUNNING)
|
---|
1391 | # define RT_CACHELINE_SIZE 64
|
---|
1392 | #else
|
---|
1393 | # define RT_CACHELINE_SIZE 128 /* better overdo it */
|
---|
1394 | #endif
|
---|
1395 |
|
---|
1396 | /** @def RT_FALL_THROUGH
|
---|
1397 | * Tell the compiler that we're falling through to the next case in a switch.
|
---|
1398 | * @sa RT_FALL_THRU */
|
---|
1399 | #if RT_CLANG_PREREQ(4, 0) && RT_CPLUSPLUS_PREREQ(201100)
|
---|
1400 | # define RT_FALL_THROUGH() [[clang::fallthrough]]
|
---|
1401 | #elif RT_CLANG_PREREQ(12, 0) || RT_GNUC_PREREQ(7, 0)
|
---|
1402 | # define RT_FALL_THROUGH() __attribute__((__fallthrough__))
|
---|
1403 | #else
|
---|
1404 | # define RT_FALL_THROUGH() (void)0
|
---|
1405 | #endif
|
---|
1406 | /** @def RT_FALL_THRU
|
---|
1407 | * Tell the compiler that we're falling thru to the next case in a switch.
|
---|
1408 | * @sa RT_FALL_THROUGH */
|
---|
1409 | #define RT_FALL_THRU() RT_FALL_THROUGH()
|
---|
1410 |
|
---|
1411 |
|
---|
1412 | /** @def RT_IPRT_FORMAT_ATTR
|
---|
1413 | * Identifies a function taking an IPRT format string.
|
---|
1414 | * @param a_iFmt The index (1-based) of the format string argument.
|
---|
1415 | * @param a_iArgs The index (1-based) of the first format argument, use 0 for
|
---|
1416 | * va_list.
|
---|
1417 | */
|
---|
1418 | #if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
|
---|
1419 | # define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs) __attribute__((__iprt_format__(a_iFmt, a_iArgs)))
|
---|
1420 | #else
|
---|
1421 | # define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs)
|
---|
1422 | #endif
|
---|
1423 |
|
---|
1424 | /** @def RT_IPRT_FORMAT_ATTR_MAYBE_NULL
|
---|
1425 | * Identifies a function taking an IPRT format string, NULL is allowed.
|
---|
1426 | * @param a_iFmt The index (1-based) of the format string argument.
|
---|
1427 | * @param a_iArgs The index (1-based) of the first format argument, use 0 for
|
---|
1428 | * va_list.
|
---|
1429 | */
|
---|
1430 | #if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
|
---|
1431 | # define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs) __attribute__((__iprt_format_maybe_null__(a_iFmt, a_iArgs)))
|
---|
1432 | #else
|
---|
1433 | # define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs)
|
---|
1434 | #endif
|
---|
1435 |
|
---|
1436 |
|
---|
1437 | /** @def RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
|
---|
1438 | * Indicates that the "hidden" visibility attribute can be used (GCC) */
|
---|
1439 | #if defined(__GNUC__)
|
---|
1440 | # if __GNUC__ >= 4 && !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
|
---|
1441 | # define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
|
---|
1442 | # endif
|
---|
1443 | #endif
|
---|
1444 |
|
---|
1445 | /** @def RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
1446 | * If the defined, the compiler supports the variadic macro feature (..., __VA_ARGS__). */
|
---|
1447 | #if defined(_MSC_VER)
|
---|
1448 | # if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
|
---|
1449 | # define RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
1450 | # endif
|
---|
1451 | #elif defined(__GNUC__)
|
---|
1452 | # if __GNUC__ >= 3 /* not entirely sure when this was added */
|
---|
1453 | # define RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
1454 | # endif
|
---|
1455 | #elif defined(__WATCOMC__)
|
---|
1456 | # define RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
1457 | #endif
|
---|
1458 |
|
---|
1459 | /** @def RT_CB_LOG_CAST
|
---|
1460 | * Helper for logging function pointers to function may throw stuff.
|
---|
1461 | *
|
---|
1462 | * Not needed for function pointer types declared using our DECLCALLBACK
|
---|
1463 | * macros, only external types. */
|
---|
1464 | #if defined(_MSC_VER) && defined(RT_EXCEPTIONS_ENABLED)
|
---|
1465 | # define RT_CB_LOG_CAST(a_pfnCallback) ((uintptr_t)(a_pfnCallback) + 1 - 1)
|
---|
1466 | #else
|
---|
1467 | # define RT_CB_LOG_CAST(a_pfnCallback) (a_pfnCallback)
|
---|
1468 | #endif
|
---|
1469 |
|
---|
1470 |
|
---|
1471 |
|
---|
1472 | /** @def RTCALL
|
---|
1473 | * The standard calling convention for the Runtime interfaces.
|
---|
1474 | *
|
---|
1475 | * @remarks The regparm(0) in the X86/GNUC variant deals with -mregparm=x use in
|
---|
1476 | * the linux kernel and potentially elsewhere (3rd party).
|
---|
1477 | */
|
---|
1478 | #if defined(_MSC_VER) || defined(__WATCOMC__)
|
---|
1479 | # define RTCALL __cdecl
|
---|
1480 | #elif defined(RT_OS_OS2)
|
---|
1481 | # define RTCALL __cdecl
|
---|
1482 | #elif defined(__GNUC__) && defined(RT_ARCH_X86)
|
---|
1483 | # define RTCALL __attribute__((__cdecl__,__regparm__(0)))
|
---|
1484 | #else
|
---|
1485 | # define RTCALL
|
---|
1486 | #endif
|
---|
1487 |
|
---|
1488 | /** @def DECLEXPORT
|
---|
1489 | * How to declare an exported function.
|
---|
1490 | * @param a_RetType The return type of the function declaration.
|
---|
1491 | */
|
---|
1492 | #if defined(_MSC_VER) || defined(RT_OS_OS2)
|
---|
1493 | # define DECLEXPORT(a_RetType) __declspec(dllexport) a_RetType
|
---|
1494 | #elif defined(RT_USE_VISIBILITY_DEFAULT)
|
---|
1495 | # define DECLEXPORT(a_RetType) __attribute__((visibility("default"))) a_RetType
|
---|
1496 | #else
|
---|
1497 | # define DECLEXPORT(a_RetType) a_RetType
|
---|
1498 | #endif
|
---|
1499 |
|
---|
1500 | /** @def DECL_EXPORT_NOTHROW
|
---|
1501 | * How to declare an exported function that does not throw C++ exceptions.
|
---|
1502 | * @param a_RetType The return type of the function declaration.
|
---|
1503 | */
|
---|
1504 | #define DECL_EXPORT_NOTHROW(a_RetType) DECL_NOTHROW(DECLEXPORT(a_RetType))
|
---|
1505 |
|
---|
1506 | /** @def DECLIMPORT
|
---|
1507 | * How to declare an imported function.
|
---|
1508 | * @param a_RetType The return type of the function declaration.
|
---|
1509 | */
|
---|
1510 | #if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
|
---|
1511 | # define DECLIMPORT(a_RetType) __declspec(dllimport) a_RetType
|
---|
1512 | #else
|
---|
1513 | # define DECLIMPORT(a_RetType) a_RetType
|
---|
1514 | #endif
|
---|
1515 |
|
---|
1516 | /** @def DECL_IMPORT_NOTHROW
|
---|
1517 | * How to declare an imported function that does not throw C++ exceptions.
|
---|
1518 | * @param a_RetType The return type of the function declaration.
|
---|
1519 | */
|
---|
1520 | #define DECL_IMPORT_NOTHROW(a_RetType) DECL_NOTHROW(DECLIMPORT(a_RetType))
|
---|
1521 |
|
---|
1522 | /** @def DECL_HIDDEN_ONLY
|
---|
1523 | * How to declare a non-exported function or variable.
|
---|
1524 | * @param a_Type The return type of the function or the data type of the variable.
|
---|
1525 | * @sa DECL_HIDDEN, DECL_HIDDEN_DATA, DECL_HIDDEN_CONST
|
---|
1526 | * @internal Considered more or less internal.
|
---|
1527 | */
|
---|
1528 | #if !defined(RT_GCC_SUPPORTS_VISIBILITY_HIDDEN) || defined(RT_NO_VISIBILITY_HIDDEN)
|
---|
1529 | # define DECL_HIDDEN_ONLY(a_Type) a_Type
|
---|
1530 | #else
|
---|
1531 | # define DECL_HIDDEN_ONLY(a_Type) __attribute__((visibility("hidden"))) a_Type
|
---|
1532 | #endif
|
---|
1533 |
|
---|
1534 | /** @def DECLHIDDEN
|
---|
1535 | * How to declare a non-exported function or variable.
|
---|
1536 | * @param a_Type The return type of the function or the data type of the variable.
|
---|
1537 | * @sa DECL_HIDDEN_THROW, DECL_HIDDEN_DATA, DECL_HIDDEN_CONST
|
---|
1538 | * @todo split up into data and non-data.
|
---|
1539 | */
|
---|
1540 | #define DECLHIDDEN(a_Type) DECL_NOTHROW(DECL_HIDDEN_ONLY(a_Type))
|
---|
1541 |
|
---|
1542 | /** @def DECL_HIDDEN_NOTHROW
|
---|
1543 | * How to declare a non-exported function that does not throw C++ exceptions.
|
---|
1544 | * @param a_RetType The return type of the function.
|
---|
1545 | * @note Same as DECLHIDDEN but provided to go along with DECL_IMPORT_NOTHROW
|
---|
1546 | * and DECL_EXPORT_NOTHROW.
|
---|
1547 | */
|
---|
1548 | #define DECL_HIDDEN_NOTHROW(a_RetType) DECL_NOTHROW(DECL_HIDDEN_ONLY(a_RetType))
|
---|
1549 |
|
---|
1550 | /** @def DECL_HIDDEN_THROW
|
---|
1551 | * How to declare a non-exported function that may throw C++ exceptions.
|
---|
1552 | * @param a_RetType The return type of the function.
|
---|
1553 | */
|
---|
1554 | #define DECL_HIDDEN_THROW(a_RetType) DECL_HIDDEN_ONLY(a_Type)
|
---|
1555 |
|
---|
1556 | /** @def DECL_HIDDEN_DATA
|
---|
1557 | * How to declare a non-exported variable.
|
---|
1558 | * @param a_Type The data type of the variable.
|
---|
1559 | * @sa DECL_HIDDEN_CONST
|
---|
1560 | */
|
---|
1561 | #if !defined(RT_GCC_SUPPORTS_VISIBILITY_HIDDEN) || defined(RT_NO_VISIBILITY_HIDDEN)
|
---|
1562 | # define DECL_HIDDEN_DATA(a_Type) a_Type
|
---|
1563 | #else
|
---|
1564 | # define DECL_HIDDEN_DATA(a_Type) __attribute__((visibility("hidden"))) a_Type
|
---|
1565 | #endif
|
---|
1566 |
|
---|
1567 | /** @def DECL_HIDDEN_CONST
|
---|
1568 | * Workaround for g++ warnings when applying the hidden attribute to a const
|
---|
1569 | * definition. Use DECL_HIDDEN_DATA for the declaration.
|
---|
1570 | * @param a_Type The data type of the variable.
|
---|
1571 | * @sa DECL_HIDDEN_DATA
|
---|
1572 | */
|
---|
1573 | #if defined(__cplusplus) && defined(__GNUC__)
|
---|
1574 | # define DECL_HIDDEN_CONST(a_Type) a_Type
|
---|
1575 | #else
|
---|
1576 | # define DECL_HIDDEN_CONST(a_Type) DECL_HIDDEN_DATA(a_Type)
|
---|
1577 | #endif
|
---|
1578 |
|
---|
1579 | /** @def DECL_INVALID
|
---|
1580 | * How to declare a function not available for linking in the current context.
|
---|
1581 | * The purpose is to create compile or like time errors when used. This isn't
|
---|
1582 | * possible on all platforms.
|
---|
1583 | * @param a_RetType The return type of the function.
|
---|
1584 | */
|
---|
1585 | #if defined(_MSC_VER)
|
---|
1586 | # define DECL_INVALID(a_RetType) __declspec(dllimport) a_RetType __stdcall
|
---|
1587 | #elif defined(__GNUC__) && defined(__cplusplus)
|
---|
1588 | # define DECL_INVALID(a_RetType) extern "C++" a_RetType
|
---|
1589 | #else
|
---|
1590 | # define DECL_INVALID(a_RetType) a_RetType
|
---|
1591 | #endif
|
---|
1592 |
|
---|
1593 | /** @def DECLASM
|
---|
1594 | * How to declare an internal assembly function.
|
---|
1595 | * @param a_RetType The return type of the function declaration.
|
---|
1596 | * @note DECL_NOTHROW is implied.
|
---|
1597 | */
|
---|
1598 | #ifdef __cplusplus
|
---|
1599 | # define DECLASM(a_RetType) extern "C" DECL_NOTHROW(a_RetType RTCALL)
|
---|
1600 | #else
|
---|
1601 | # define DECLASM(a_RetType) DECL_NOTHROW(a_RetType RTCALL)
|
---|
1602 | #endif
|
---|
1603 |
|
---|
1604 | /** @def RT_ASM_DECL_PRAGMA_WATCOM
|
---|
1605 | * How to declare a assembly method prototype with watcom \#pragma aux definition. */
|
---|
1606 | /** @def RT_ASM_DECL_PRAGMA_WATCOM_386
|
---|
1607 | * Same as RT_ASM_DECL_PRAGMA_WATCOM, but there is no 16-bit version when
|
---|
1608 | * 8086, 80186 or 80286 is selected as the target CPU. */
|
---|
1609 | #if defined(__WATCOMC__) && ARCH_BITS == 16 && defined(RT_ARCH_X86)
|
---|
1610 | # define RT_ASM_DECL_PRAGMA_WATCOM(a_RetType) a_RetType
|
---|
1611 | # if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
|
---|
1612 | # define RT_ASM_DECL_PRAGMA_WATCOM_386(a_RetType) DECLASM(a_RetType)
|
---|
1613 | # else
|
---|
1614 | # define RT_ASM_DECL_PRAGMA_WATCOM_386(a_RetType) a_RetType
|
---|
1615 | # endif
|
---|
1616 | #elif defined(__WATCOMC__) && ARCH_BITS == 32 && defined(RT_ARCH_X86)
|
---|
1617 | # define RT_ASM_DECL_PRAGMA_WATCOM(a_RetType) a_RetType
|
---|
1618 | # define RT_ASM_DECL_PRAGMA_WATCOM_386(a_RetType) a_RetType
|
---|
1619 | #else
|
---|
1620 | # define RT_ASM_DECL_PRAGMA_WATCOM(a_RetType) DECLASM(a_RetType)
|
---|
1621 | # define RT_ASM_DECL_PRAGMA_WATCOM_386(a_RetType) DECLASM(a_RetType)
|
---|
1622 | #endif
|
---|
1623 |
|
---|
1624 | /** @def DECL_NO_RETURN
|
---|
1625 | * How to declare a function which does not return.
|
---|
1626 | * @note This macro can be combined with other macros, for example
|
---|
1627 | * @code
|
---|
1628 | * RTR3DECL(DECL_NO_RETURN(void)) foo(void);
|
---|
1629 | * @endcode
|
---|
1630 | */
|
---|
1631 | #ifdef _MSC_VER
|
---|
1632 | # define DECL_NO_RETURN(a_RetType) __declspec(noreturn) a_RetType
|
---|
1633 | #elif defined(__GNUC__)
|
---|
1634 | # define DECL_NO_RETURN(a_RetType) __attribute__((noreturn)) a_RetType
|
---|
1635 | #else
|
---|
1636 | # define DECL_NO_RETURN(a_RetType) a_RetType
|
---|
1637 | #endif
|
---|
1638 |
|
---|
1639 | /** @def DECL_RETURNS_TWICE
|
---|
1640 | * How to declare a function which may return more than once.
|
---|
1641 | * @note This macro can be combined with other macros, for example
|
---|
1642 | * @code
|
---|
1643 | * RTR3DECL(DECL_RETURNS_TWICE(void)) MySetJmp(void);
|
---|
1644 | * @endcode
|
---|
1645 | */
|
---|
1646 | #if RT_GNUC_PREREQ(4, 1)
|
---|
1647 | # define DECL_RETURNS_TWICE(a_RetType) __attribute__((returns_twice)) a_RetType
|
---|
1648 | #else
|
---|
1649 | # define DECL_RETURNS_TWICE(a_RetType) a_RetType
|
---|
1650 | #endif
|
---|
1651 |
|
---|
1652 | /** @def DECL_CHECK_RETURN
|
---|
1653 | * Require a return value to be checked.
|
---|
1654 | * @note This macro can be combined with other macros, for example
|
---|
1655 | * @code
|
---|
1656 | * RTR3DECL(DECL_CHECK_RETURN(int)) MayReturnInfoStatus(void);
|
---|
1657 | * @endcode
|
---|
1658 | */
|
---|
1659 | #if RT_GNUC_PREREQ(3, 4)
|
---|
1660 | # define DECL_CHECK_RETURN(a_RetType) __attribute__((warn_unused_result)) a_RetType
|
---|
1661 | #elif defined(_MSC_VER)
|
---|
1662 | # define DECL_CHECK_RETURN(a_RetType) __declspec("SAL_checkReturn") a_RetType
|
---|
1663 | #else
|
---|
1664 | # define DECL_CHECK_RETURN(a_RetType) a_RetType
|
---|
1665 | #endif
|
---|
1666 |
|
---|
1667 | /** @def DECL_CHECK_RETURN_NOT_R3
|
---|
1668 | * Variation of DECL_CHECK_RETURN that only applies the required to non-ring-3
|
---|
1669 | * code.
|
---|
1670 | */
|
---|
1671 | #ifndef IN_RING3
|
---|
1672 | # define DECL_CHECK_RETURN_NOT_R3(a_RetType) DECL_CHECK_RETURN(a_RetType)
|
---|
1673 | #else
|
---|
1674 | # define DECL_CHECK_RETURN_NOT_R3(a_RetType) a_RetType
|
---|
1675 | #endif
|
---|
1676 |
|
---|
1677 | /** @def DECLWEAK
|
---|
1678 | * How to declare a variable which is not necessarily resolved at
|
---|
1679 | * runtime.
|
---|
1680 | * @note This macro can be combined with other macros, for example
|
---|
1681 | * @code
|
---|
1682 | * RTR3DECL(DECLWEAK(int)) foo;
|
---|
1683 | * @endcode
|
---|
1684 | */
|
---|
1685 | #if defined(__GNUC__)
|
---|
1686 | # define DECLWEAK(a_Type) a_Type __attribute__((weak))
|
---|
1687 | #else
|
---|
1688 | # define DECLWEAK(a_Type) a_Type
|
---|
1689 | #endif
|
---|
1690 |
|
---|
1691 | /** @def DECLCALLBACK
|
---|
1692 | * How to declare an call back function.
|
---|
1693 | * @param a_RetType The return type of the function declaration.
|
---|
1694 | * @note DECL_NOTHROW is implied.
|
---|
1695 | * @note Use DECLCALLBACKTYPE for typedefs.
|
---|
1696 | */
|
---|
1697 | #define DECLCALLBACK(a_RetType) DECL_NOTHROW(a_RetType RT_FAR_CODE RTCALL)
|
---|
1698 |
|
---|
1699 | /** @def DECL_HIDDEN_CALLBACK
|
---|
1700 | * How to declare an call back function with hidden visibility.
|
---|
1701 | * @param a_RetType The return type of the function declaration.
|
---|
1702 | * @note DECL_NOTHROW is implied.
|
---|
1703 | * @note Use DECLCALLBACKTYPE for typedefs.
|
---|
1704 | */
|
---|
1705 | #define DECL_HIDDEN_CALLBACK(a_RetType) DECL_HIDDEN_ONLY(DECLCALLBACK(a_RetType))
|
---|
1706 |
|
---|
1707 | /** @def DECLCALLBACKTYPE_EX
|
---|
1708 | * How to declare an call back function type.
|
---|
1709 | * @param a_RetType The return type of the function declaration.
|
---|
1710 | * @param a_CallConv Calling convention.
|
---|
1711 | * @param a_Name The name of the typedef
|
---|
1712 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1713 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1714 | */
|
---|
1715 | #if RT_CLANG_PREREQ(6,0) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1716 | # define DECLCALLBACKTYPE_EX(a_RetType, a_CallConv, a_Name, a_Args) __attribute__((__nothrow__)) a_RetType a_CallConv a_Name a_Args
|
---|
1717 | #elif RT_MSC_PREREQ(RT_MSC_VER_VS2015) /*?*/ && defined(__cplusplus) && defined(_MSC_EXTENSIONS) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1718 | # define DECLCALLBACKTYPE_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType a_CallConv a_Name a_Args throw()
|
---|
1719 | #else
|
---|
1720 | # define DECLCALLBACKTYPE_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType a_CallConv a_Name a_Args
|
---|
1721 | #endif
|
---|
1722 | /** @def DECLCALLBACKTYPE
|
---|
1723 | * How to declare an call back function type.
|
---|
1724 | * @param a_RetType The return type of the function declaration.
|
---|
1725 | * @param a_Name The name of the typedef
|
---|
1726 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1727 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1728 | */
|
---|
1729 | #define DECLCALLBACKTYPE(a_RetType, a_Name, a_Args) DECLCALLBACKTYPE_EX(a_RetType, RT_FAR_CODE RTCALL, a_Name, a_Args)
|
---|
1730 |
|
---|
1731 | /** @def DECLCALLBACKPTR_EX
|
---|
1732 | * How to declare an call back function pointer.
|
---|
1733 | * @param a_RetType The return type of the function declaration.
|
---|
1734 | * @param a_CallConv Calling convention.
|
---|
1735 | * @param a_Name The name of the variable member.
|
---|
1736 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1737 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1738 | */
|
---|
1739 | #if defined(__IBMC__) || defined(__IBMCPP__)
|
---|
1740 | # define DECLCALLBACKPTR_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (* a_CallConv a_Name) a_Args
|
---|
1741 | #elif RT_CLANG_PREREQ(6,0) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1742 | # define DECLCALLBACKPTR_EX(a_RetType, a_CallConv, a_Name, a_Args) __attribute__((__nothrow__)) a_RetType (a_CallConv * a_Name) a_Args
|
---|
1743 | #elif RT_MSC_PREREQ(RT_MSC_VER_VS2015) /*?*/ && defined(__cplusplus) && defined(_MSC_EXTENSIONS) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1744 | # define DECLCALLBACKPTR_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (a_CallConv * a_Name) a_Args throw()
|
---|
1745 | #else
|
---|
1746 | # define DECLCALLBACKPTR_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (a_CallConv * a_Name) a_Args
|
---|
1747 | #endif
|
---|
1748 | /** @def DECLCALLBACKPTR
|
---|
1749 | * How to declare an call back function pointer.
|
---|
1750 | * @param a_RetType The return type of the function declaration.
|
---|
1751 | * @param a_Name The name of the variable member.
|
---|
1752 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1753 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1754 | */
|
---|
1755 | #define DECLCALLBACKPTR(a_RetType, a_Name, a_Args) DECLCALLBACKPTR_EX(a_RetType, RT_FAR_CODE RTCALL, a_Name, a_Args)
|
---|
1756 |
|
---|
1757 | /** @def DECLCALLBACKMEMBER_EX
|
---|
1758 | * How to declare an call back function pointer member.
|
---|
1759 | * @param a_RetType The return type of the function declaration.
|
---|
1760 | * @param a_CallConv Calling convention.
|
---|
1761 | * @param a_Name The name of the struct/union/class member.
|
---|
1762 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1763 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1764 | */
|
---|
1765 | #if defined(__IBMC__) || defined(__IBMCPP__)
|
---|
1766 | # define DECLCALLBACKMEMBER_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (* a_CallConv a_Name) a_Args
|
---|
1767 | #elif RT_CLANG_PREREQ(6,0) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1768 | # define DECLCALLBACKMEMBER_EX(a_RetType, a_CallConv, a_Name, a_Args) __attribute__((__nothrow__)) a_RetType (a_CallConv *a_Name) a_Args
|
---|
1769 | #elif RT_MSC_PREREQ(RT_MSC_VER_VS2015) /*?*/ && defined(__cplusplus) && defined(_MSC_EXTENSIONS) && !defined(RT_RELAXED_CALLBACKS_TYPES)
|
---|
1770 | # define DECLCALLBACKMEMBER_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (a_CallConv *a_Name) a_Args throw()
|
---|
1771 | #else
|
---|
1772 | # define DECLCALLBACKMEMBER_EX(a_RetType, a_CallConv, a_Name, a_Args) a_RetType (a_CallConv *a_Name) a_Args
|
---|
1773 | #endif
|
---|
1774 | /** @def DECLCALLBACKMEMBER
|
---|
1775 | * How to declare an call back function pointer member.
|
---|
1776 | * @param a_RetType The return type of the function declaration.
|
---|
1777 | * @param a_Name The name of the struct/union/class member.
|
---|
1778 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1779 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1780 | */
|
---|
1781 | #define DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args) DECLCALLBACKMEMBER_EX(a_RetType, RT_FAR_CODE RTCALL, a_Name, a_Args)
|
---|
1782 |
|
---|
1783 | /** @def DECLR3CALLBACKMEMBER
|
---|
1784 | * How to declare an call back function pointer member - R3 Ptr.
|
---|
1785 | * @param a_RetType The return type of the function declaration.
|
---|
1786 | * @param a_Name The name of the struct/union/class member.
|
---|
1787 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1788 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1789 | */
|
---|
1790 | #if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
|
---|
1791 | # define DECLR3CALLBACKMEMBER(a_RetType, a_Name, a_Args) DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args)
|
---|
1792 | #else
|
---|
1793 | # define DECLR3CALLBACKMEMBER(a_RetType, a_Name, a_Args) RTR3PTR a_Name
|
---|
1794 | #endif
|
---|
1795 |
|
---|
1796 | /** @def DECLRCCALLBACKMEMBER
|
---|
1797 | * How to declare an call back function pointer member - RC Ptr.
|
---|
1798 | * @param a_RetType The return type of the function declaration.
|
---|
1799 | * @param a_Name The name of the struct/union/class member.
|
---|
1800 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1801 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1802 | */
|
---|
1803 | #if defined(IN_RC) || defined(DOXYGEN_RUNNING)
|
---|
1804 | # define DECLRCCALLBACKMEMBER(a_RetType, a_Name, a_Args) DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args)
|
---|
1805 | #else
|
---|
1806 | # define DECLRCCALLBACKMEMBER(a_RetType, a_Name, a_Args) RTRCPTR a_Name
|
---|
1807 | #endif
|
---|
1808 | #if defined(IN_RC) || defined(DOXYGEN_RUNNING)
|
---|
1809 | # define DECLRGCALLBACKMEMBER(a_RetType, a_Name, a_Args) DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args)
|
---|
1810 | #else
|
---|
1811 | # define DECLRGCALLBACKMEMBER(a_RetType, a_Name, a_Args) RTRGPTR a_Name
|
---|
1812 | #endif
|
---|
1813 |
|
---|
1814 | /** @def DECLR0CALLBACKMEMBER
|
---|
1815 | * How to declare an call back function pointer member - R0 Ptr.
|
---|
1816 | * @param a_RetType The return type of the function declaration.
|
---|
1817 | * @param a_Name The name of the struct/union/class member.
|
---|
1818 | * @param a_Args The argument list enclosed in parentheses.
|
---|
1819 | * @note DECL_NOTHROW is implied, but not supported by all compilers yet.
|
---|
1820 | */
|
---|
1821 | #if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
|
---|
1822 | # define DECLR0CALLBACKMEMBER(a_RetType, a_Name, a_Args) DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args)
|
---|
1823 | #else
|
---|
1824 | # define DECLR0CALLBACKMEMBER(a_RetType, a_Name, a_Args) RTR0PTR a_Name
|
---|
1825 | #endif
|
---|
1826 |
|
---|
1827 | /** @def DECLINLINE
|
---|
1828 | * How to declare a function as inline that does not throw any C++ exceptions.
|
---|
1829 | * @param a_RetType The return type of the function declaration.
|
---|
1830 | * @remarks Don't use this macro on C++ methods.
|
---|
1831 | * @sa DECL_INLINE_THROW
|
---|
1832 | */
|
---|
1833 | #if defined(__GNUC__) && !defined(DOXYGEN_RUNNING)
|
---|
1834 | # define DECLINLINE(a_RetType) DECL_NOTHROW(static __inline__ a_RetType)
|
---|
1835 | #elif defined(__cplusplus) || defined(DOXYGEN_RUNNING)
|
---|
1836 | # define DECLINLINE(a_RetType) DECL_NOTHROW(static inline a_RetType)
|
---|
1837 | #elif defined(_MSC_VER)
|
---|
1838 | # define DECLINLINE(a_RetType) DECL_NOTHROW(static _inline a_RetType)
|
---|
1839 | #elif defined(__IBMC__)
|
---|
1840 | # define DECLINLINE(a_RetType) DECL_NOTHROW(_Inline a_RetType)
|
---|
1841 | #else
|
---|
1842 | # define DECLINLINE(a_RetType) DECL_NOTHROW(inline a_RetType)
|
---|
1843 | #endif
|
---|
1844 |
|
---|
1845 | /** @def DECL_INLINE_THROW
|
---|
1846 | * How to declare a function as inline that throws C++ exceptions.
|
---|
1847 | * @param a_RetType The return type of the function declaration.
|
---|
1848 | * @remarks Don't use this macro on C++ methods.
|
---|
1849 | */
|
---|
1850 | #if defined(__GNUC__) && !defined(DOXYGEN_RUNNING)
|
---|
1851 | # define DECL_INLINE_THROW(a_RetType) static __inline__ a_RetType
|
---|
1852 | #elif defined(__cplusplus) || defined(DOXYGEN_RUNNING)
|
---|
1853 | # define DECL_INLINE_THROW(a_RetType) static inline a_RetType
|
---|
1854 | #elif defined(_MSC_VER)
|
---|
1855 | # define DECL_INLINE_THROW(a_RetType) static _inline a_RetType
|
---|
1856 | #elif defined(__IBMC__)
|
---|
1857 | # define DECL_INLINE_THROW(a_RetType) _Inline a_RetType
|
---|
1858 | #else
|
---|
1859 | # define DECL_INLINE_THROW(a_RetType) inline a_RetType
|
---|
1860 | #endif
|
---|
1861 |
|
---|
1862 | /** @def DECL_FORCE_INLINE
|
---|
1863 | * How to declare a function that does not throw any C++ exceptions as inline
|
---|
1864 | * and try convince the compiler to always inline it regardless of optimization
|
---|
1865 | * switches.
|
---|
1866 | * @param a_RetType The return type of the function declaration.
|
---|
1867 | * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
|
---|
1868 | * @sa DECL_FORCE_INLINE_THROW
|
---|
1869 | */
|
---|
1870 | #ifdef __GNUC__
|
---|
1871 | # define DECL_FORCE_INLINE(a_RetType) __attribute__((__always_inline__)) DECLINLINE(a_RetType)
|
---|
1872 | #elif defined(_MSC_VER)
|
---|
1873 | # define DECL_FORCE_INLINE(a_RetType) DECL_NOTHROW(__forceinline a_RetType)
|
---|
1874 | #else
|
---|
1875 | # define DECL_FORCE_INLINE(a_RetType) DECLINLINE(a_RetType)
|
---|
1876 | #endif
|
---|
1877 |
|
---|
1878 | /** @def DECL_FORCE_INLINE_THROW
|
---|
1879 | * How to declare a function throwing C++ exceptions as inline and try convince
|
---|
1880 | * the compiler to always inline it regardless of optimization switches.
|
---|
1881 | * @param a_RetType The return type of the function declaration.
|
---|
1882 | * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
|
---|
1883 | */
|
---|
1884 | #ifdef __GNUC__
|
---|
1885 | # define DECL_FORCE_INLINE_THROW(a_RetType) __attribute__((__always_inline__)) DECL_INLINE_THROW(a_RetType)
|
---|
1886 | #elif defined(_MSC_VER)
|
---|
1887 | # define DECL_FORCE_INLINE_THROW(a_RetType) __forceinline a_RetType
|
---|
1888 | #else
|
---|
1889 | # define DECL_FORCE_INLINE_THROW(a_RetType) DECL_INLINE_THROW(a_RetType)
|
---|
1890 | #endif
|
---|
1891 |
|
---|
1892 |
|
---|
1893 | /** @def DECL_NO_INLINE
|
---|
1894 | * How to declare a function telling the compiler not to inline it.
|
---|
1895 | * @param scope The function scope, static or RT_NOTHING.
|
---|
1896 | * @param a_RetType The return type of the function declaration.
|
---|
1897 | * @remarks Don't use this macro on C++ methods.
|
---|
1898 | */
|
---|
1899 | #ifdef __GNUC__
|
---|
1900 | # define DECL_NO_INLINE(scope, a_RetType) __attribute__((__noinline__)) scope a_RetType
|
---|
1901 | #elif defined(_MSC_VER)
|
---|
1902 | # define DECL_NO_INLINE(scope, a_RetType) __declspec(noinline) scope a_RetType
|
---|
1903 | #else
|
---|
1904 | # define DECL_NO_INLINE(scope,a_RetType) scope a_RetType
|
---|
1905 | #endif
|
---|
1906 |
|
---|
1907 |
|
---|
1908 | /** @def IN_RT_STATIC
|
---|
1909 | * Used to indicate whether we're linking against a static IPRT
|
---|
1910 | * or not.
|
---|
1911 | *
|
---|
1912 | * The IPRT symbols will be declared as hidden (if supported). Note that this
|
---|
1913 | * define has no effect without also setting one of the IN_RT_R0, IN_RT_R3 or
|
---|
1914 | * IN_RT_RC indicators.
|
---|
1915 | */
|
---|
1916 |
|
---|
1917 | /** @def IN_RT_R0
|
---|
1918 | * Used to indicate whether we're inside the same link module as the host
|
---|
1919 | * context ring-0 Runtime Library.
|
---|
1920 | */
|
---|
1921 | /** @def RTR0DECL(a_RetType)
|
---|
1922 | * Runtime Library host context ring-0 export or import declaration.
|
---|
1923 | * @param a_RetType The return a_RetType of the function declaration.
|
---|
1924 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
1925 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
1926 | * @note DECL_NOTHROW is implied.
|
---|
1927 | */
|
---|
1928 | #ifdef IN_RT_R0
|
---|
1929 | # ifdef IN_RT_STATIC
|
---|
1930 | # define RTR0DECL(a_RetType) DECL_HIDDEN_NOTHROW(a_RetType) RTCALL
|
---|
1931 | # else
|
---|
1932 | # define RTR0DECL(a_RetType) DECL_EXPORT_NOTHROW(a_RetType) RTCALL
|
---|
1933 | # endif
|
---|
1934 | #else
|
---|
1935 | # define RTR0DECL(a_RetType) DECL_IMPORT_NOTHROW(a_RetType) RTCALL
|
---|
1936 | #endif
|
---|
1937 |
|
---|
1938 | /** @def IN_RT_R3
|
---|
1939 | * Used to indicate whether we're inside the same link module as the host
|
---|
1940 | * context ring-3 Runtime Library.
|
---|
1941 | */
|
---|
1942 | /** @def RTR3DECL(a_RetType)
|
---|
1943 | * Runtime Library host context ring-3 export or import declaration.
|
---|
1944 | * @param a_RetType The return type of the function declaration.
|
---|
1945 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
1946 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
1947 | * @note DECL_NOTHROW is implied.
|
---|
1948 | */
|
---|
1949 | #ifdef IN_RT_R3
|
---|
1950 | # ifdef IN_RT_STATIC
|
---|
1951 | # define RTR3DECL(a_RetType) DECL_HIDDEN_NOTHROW(a_RetType) RTCALL
|
---|
1952 | # else
|
---|
1953 | # define RTR3DECL(a_RetType) DECL_EXPORT_NOTHROW(a_RetType) RTCALL
|
---|
1954 | # endif
|
---|
1955 | #else
|
---|
1956 | # define RTR3DECL(a_RetType) DECL_IMPORT_NOTHROW(a_RetType) RTCALL
|
---|
1957 | #endif
|
---|
1958 |
|
---|
1959 | /** @def IN_RT_RC
|
---|
1960 | * Used to indicate whether we're inside the same link module as the raw-mode
|
---|
1961 | * context (RC) runtime library.
|
---|
1962 | */
|
---|
1963 | /** @def RTRCDECL(a_RetType)
|
---|
1964 | * Runtime Library raw-mode context export or import declaration.
|
---|
1965 | * @param a_RetType The return type of the function declaration.
|
---|
1966 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
1967 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
1968 | * @note DECL_NOTHROW is implied.
|
---|
1969 | */
|
---|
1970 | #ifdef IN_RT_RC
|
---|
1971 | # ifdef IN_RT_STATIC
|
---|
1972 | # define RTRCDECL(a_RetType) DECL_HIDDEN_NOTHROW(a_RetType) RTCALL
|
---|
1973 | # else
|
---|
1974 | # define RTRCDECL(a_RetType) DECL_EXPORT_NOTHROW(a_RetType) RTCALL
|
---|
1975 | # endif
|
---|
1976 | #else
|
---|
1977 | # define RTRCDECL(a_RetType) DECL_IMPORT_NOTHROW(a_RetType) RTCALL
|
---|
1978 | #endif
|
---|
1979 |
|
---|
1980 | /** @def RTDECL(a_RetType)
|
---|
1981 | * Runtime Library export or import declaration.
|
---|
1982 | * Functions declared using this macro exists in all contexts.
|
---|
1983 | * @param a_RetType The return type of the function declaration.
|
---|
1984 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
1985 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
1986 | * @note DECL_NOTHROW is implied.
|
---|
1987 | */
|
---|
1988 | #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
|
---|
1989 | # ifdef IN_RT_STATIC
|
---|
1990 | # define RTDECL(a_RetType) DECL_HIDDEN_NOTHROW(a_RetType) RTCALL
|
---|
1991 | # else
|
---|
1992 | # define RTDECL(a_RetType) DECL_EXPORT_NOTHROW(a_RetType) RTCALL
|
---|
1993 | # endif
|
---|
1994 | #else
|
---|
1995 | # define RTDECL(a_RetType) DECL_IMPORT_NOTHROW(a_RetType) RTCALL
|
---|
1996 | #endif
|
---|
1997 |
|
---|
1998 | /** @def RTDATADECL(a_Type)
|
---|
1999 | * Runtime Library export or import declaration.
|
---|
2000 | * Data declared using this macro exists in all contexts.
|
---|
2001 | * @param a_Type The data type.
|
---|
2002 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
2003 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
2004 | */
|
---|
2005 | /** @def RT_DECL_DATA_CONST(a_Type)
|
---|
2006 | * Definition of a const variable. See DECL_HIDDEN_CONST.
|
---|
2007 | * @param a_Type The const data type.
|
---|
2008 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
2009 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
2010 | */
|
---|
2011 | #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
|
---|
2012 | # ifdef IN_RT_STATIC
|
---|
2013 | # define RTDATADECL(a_Type) DECL_HIDDEN_DATA(a_Type)
|
---|
2014 | # define RT_DECL_DATA_CONST(a_Type) DECL_HIDDEN_CONST(a_Type)
|
---|
2015 | # else
|
---|
2016 | # define RTDATADECL(a_Type) DECLEXPORT(a_Type)
|
---|
2017 | # if defined(__cplusplus) && defined(__GNUC__)
|
---|
2018 | # define RT_DECL_DATA_CONST(a_Type) a_Type
|
---|
2019 | # else
|
---|
2020 | # define RT_DECL_DATA_CONST(a_Type) DECLEXPORT(a_Type)
|
---|
2021 | # endif
|
---|
2022 | # endif
|
---|
2023 | #else
|
---|
2024 | # define RTDATADECL(a_Type) DECLIMPORT(a_Type)
|
---|
2025 | # define RT_DECL_DATA_CONST(a_Type) DECLIMPORT(a_Type)
|
---|
2026 | #endif
|
---|
2027 |
|
---|
2028 | /** @def RT_DECL_CLASS
|
---|
2029 | * Declares an class living in the runtime.
|
---|
2030 | * @remarks This is only used inside IPRT. Other APIs need to define their own
|
---|
2031 | * XXXX_DECL macros for dealing with import/export/static visibility.
|
---|
2032 | */
|
---|
2033 | #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
|
---|
2034 | # ifdef IN_RT_STATIC
|
---|
2035 | # define RT_DECL_CLASS
|
---|
2036 | # else
|
---|
2037 | # define RT_DECL_CLASS DECLEXPORT_CLASS
|
---|
2038 | # endif
|
---|
2039 | #else
|
---|
2040 | # define RT_DECL_CLASS DECLIMPORT_CLASS
|
---|
2041 | #endif
|
---|
2042 |
|
---|
2043 |
|
---|
2044 | /** @def RT_NOCRT
|
---|
2045 | * Symbol name wrapper for the No-CRT bits.
|
---|
2046 | *
|
---|
2047 | * In order to coexist in the same process as other CRTs, we need to
|
---|
2048 | * decorate the symbols such that they don't conflict the ones in the
|
---|
2049 | * other CRTs. The result of such conflicts / duplicate symbols can
|
---|
2050 | * confuse the dynamic loader on Unix like systems.
|
---|
2051 | *
|
---|
2052 | * Define RT_WITHOUT_NOCRT_WRAPPERS to drop the wrapping.
|
---|
2053 | * Define RT_WITHOUT_NOCRT_WRAPPER_ALIASES to drop the aliases to the
|
---|
2054 | * wrapped names.
|
---|
2055 | */
|
---|
2056 | /** @def RT_NOCRT_STR
|
---|
2057 | * Same as RT_NOCRT only it'll return a double quoted string of the result.
|
---|
2058 | */
|
---|
2059 | #if !defined(RT_WITHOUT_NOCRT_WRAPPERS) || defined(RT_FORCE_NOCRT_WRAPPERS)
|
---|
2060 | # define RT_NOCRT(name) nocrt_ ## name
|
---|
2061 | # define RT_NOCRT_STR(name) "nocrt_" # name
|
---|
2062 | #else
|
---|
2063 | # define RT_NOCRT(name) name
|
---|
2064 | # define RT_NOCRT_STR(name) #name
|
---|
2065 | #endif
|
---|
2066 |
|
---|
2067 |
|
---|
2068 | /** @name Untrusted data classifications.
|
---|
2069 | * @{ */
|
---|
2070 | /** @def RT_UNTRUSTED_USER
|
---|
2071 | * For marking non-volatile (race free) data from user mode as untrusted.
|
---|
2072 | * This is just for visible documentation. */
|
---|
2073 | #define RT_UNTRUSTED_USER
|
---|
2074 | /** @def RT_UNTRUSTED_VOLATILE_USER
|
---|
2075 | * For marking volatile data shared with user mode as untrusted.
|
---|
2076 | * This is more than just documentation as it specifies the 'volatile' keyword,
|
---|
2077 | * because the guest could modify the data at any time. */
|
---|
2078 | #define RT_UNTRUSTED_VOLATILE_USER volatile
|
---|
2079 |
|
---|
2080 | /** @def RT_UNTRUSTED_GUEST
|
---|
2081 | * For marking non-volatile (race free) data from the guest as untrusted.
|
---|
2082 | * This is just for visible documentation. */
|
---|
2083 | #define RT_UNTRUSTED_GUEST
|
---|
2084 | /** @def RT_UNTRUSTED_VOLATILE_GUEST
|
---|
2085 | * For marking volatile data shared with the guest as untrusted.
|
---|
2086 | * This is more than just documentation as it specifies the 'volatile' keyword,
|
---|
2087 | * because the guest could modify the data at any time. */
|
---|
2088 | #define RT_UNTRUSTED_VOLATILE_GUEST volatile
|
---|
2089 |
|
---|
2090 | /** @def RT_UNTRUSTED_HOST
|
---|
2091 | * For marking non-volatile (race free) data from the host as untrusted.
|
---|
2092 | * This is just for visible documentation. */
|
---|
2093 | #define RT_UNTRUSTED_HOST
|
---|
2094 | /** @def RT_UNTRUSTED_VOLATILE_HOST
|
---|
2095 | * For marking volatile data shared with the host as untrusted.
|
---|
2096 | * This is more than just documentation as it specifies the 'volatile' keyword,
|
---|
2097 | * because the host could modify the data at any time. */
|
---|
2098 | #define RT_UNTRUSTED_VOLATILE_HOST volatile
|
---|
2099 |
|
---|
2100 | /** @def RT_UNTRUSTED_HSTGST
|
---|
2101 | * For marking non-volatile (race free) data from the host/gust as untrusted.
|
---|
2102 | * This is just for visible documentation. */
|
---|
2103 | #define RT_UNTRUSTED_HSTGST
|
---|
2104 | /** @def RT_UNTRUSTED_VOLATILE_HSTGST
|
---|
2105 | * For marking volatile data shared with the host/guest as untrusted.
|
---|
2106 | * This is more than just documentation as it specifies the 'volatile' keyword,
|
---|
2107 | * because the host could modify the data at any time. */
|
---|
2108 | #define RT_UNTRUSTED_VOLATILE_HSTGST volatile
|
---|
2109 | /** @} */
|
---|
2110 |
|
---|
2111 | /** @name Fences for use when handling untrusted data.
|
---|
2112 | * @{ */
|
---|
2113 | /** For use after copying untruated volatile data to a non-volatile location.
|
---|
2114 | * This translates to a compiler memory barrier and will help ensure that the
|
---|
2115 | * compiler uses the non-volatile copy of the data. */
|
---|
2116 | #define RT_UNTRUSTED_NONVOLATILE_COPY_FENCE() ASMCompilerBarrier()
|
---|
2117 | /** For use after finished validating guest input.
|
---|
2118 | * What this translates to is architecture dependent. On intel it will
|
---|
2119 | * translate to a CPU load+store fence as well as a compiler memory barrier. */
|
---|
2120 | #if defined(RT_ARCH_AMD64) || (defined(RT_ARCH_X86) && !defined(RT_WITH_OLD_CPU_SUPPORT))
|
---|
2121 | # define RT_UNTRUSTED_VALIDATED_FENCE() do { ASMCompilerBarrier(); ASMReadFence(); } while (0)
|
---|
2122 | #elif defined(RT_ARCH_X86)
|
---|
2123 | # define RT_UNTRUSTED_VALIDATED_FENCE() do { ASMCompilerBarrier(); ASMMemoryFence(); } while (0)
|
---|
2124 | #else
|
---|
2125 | # define RT_UNTRUSTED_VALIDATED_FENCE() do { ASMCompilerBarrier(); } while (0)
|
---|
2126 | #endif
|
---|
2127 | /** @} */
|
---|
2128 |
|
---|
2129 |
|
---|
2130 | /** @def RT_LIKELY
|
---|
2131 | * Give the compiler a hint that an expression is very likely to hold true.
|
---|
2132 | *
|
---|
2133 | * Some compilers support explicit branch prediction so that the CPU backend
|
---|
2134 | * can hint the processor and also so that code blocks can be reordered such
|
---|
2135 | * that the predicted path sees a more linear flow, thus improving cache
|
---|
2136 | * behaviour, etc.
|
---|
2137 | *
|
---|
2138 | * IPRT provides the macros RT_LIKELY() and RT_UNLIKELY() as a way to utilize
|
---|
2139 | * this compiler feature when present.
|
---|
2140 | *
|
---|
2141 | * A few notes about the usage:
|
---|
2142 | *
|
---|
2143 | * - Generally, order your code use RT_LIKELY() instead of RT_UNLIKELY().
|
---|
2144 | *
|
---|
2145 | * - Generally, use RT_UNLIKELY() with error condition checks (unless you
|
---|
2146 | * have some _strong_ reason to do otherwise, in which case document it),
|
---|
2147 | * and/or RT_LIKELY() with success condition checks, assuming you want
|
---|
2148 | * to optimize for the success path.
|
---|
2149 | *
|
---|
2150 | * - Other than that, if you don't know the likelihood of a test succeeding
|
---|
2151 | * from empirical or other 'hard' evidence, don't make predictions unless
|
---|
2152 | * you happen to be a Dirk Gently character.
|
---|
2153 | *
|
---|
2154 | * - These macros are meant to be used in places that get executed a lot. It
|
---|
2155 | * is wasteful to make predictions in code that is executed rarely (e.g.
|
---|
2156 | * at subsystem initialization time) as the basic block reordering that this
|
---|
2157 | * affects can often generate larger code.
|
---|
2158 | *
|
---|
2159 | * - Note that RT_SUCCESS() and RT_FAILURE() already makes use of RT_LIKELY()
|
---|
2160 | * and RT_UNLIKELY(). Should you wish for prediction free status checks,
|
---|
2161 | * use the RT_SUCCESS_NP() and RT_FAILURE_NP() macros instead.
|
---|
2162 | *
|
---|
2163 | *
|
---|
2164 | * @returns the boolean result of the expression.
|
---|
2165 | * @param expr The expression that's very likely to be true.
|
---|
2166 | * @see RT_UNLIKELY
|
---|
2167 | */
|
---|
2168 | /** @def RT_UNLIKELY
|
---|
2169 | * Give the compiler a hint that an expression is highly unlikely to hold true.
|
---|
2170 | *
|
---|
2171 | * See the usage instructions give in the RT_LIKELY() docs.
|
---|
2172 | *
|
---|
2173 | * @returns the boolean result of the expression.
|
---|
2174 | * @param expr The expression that's very unlikely to be true.
|
---|
2175 | * @see RT_LIKELY
|
---|
2176 | *
|
---|
2177 | * @deprecated Please use RT_LIKELY() instead wherever possible! That gives us
|
---|
2178 | * a better chance of the windows compilers to generate favorable code
|
---|
2179 | * too. The belief is that the compiler will by default assume the
|
---|
2180 | * if-case is more likely than the else-case.
|
---|
2181 | */
|
---|
2182 | #if defined(__GNUC__)
|
---|
2183 | # if __GNUC__ >= 3 && !defined(FORTIFY_RUNNING)
|
---|
2184 | # define RT_LIKELY(expr) __builtin_expect(!!(expr), 1)
|
---|
2185 | # define RT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
|
---|
2186 | # else
|
---|
2187 | # define RT_LIKELY(expr) (expr)
|
---|
2188 | # define RT_UNLIKELY(expr) (expr)
|
---|
2189 | # endif
|
---|
2190 | #else
|
---|
2191 | # define RT_LIKELY(expr) (expr)
|
---|
2192 | # define RT_UNLIKELY(expr) (expr)
|
---|
2193 | #endif
|
---|
2194 |
|
---|
2195 | /** @def RT_EXPAND_2
|
---|
2196 | * Helper for RT_EXPAND. */
|
---|
2197 | #define RT_EXPAND_2(a_Expr) a_Expr
|
---|
2198 | /** @def RT_EXPAND
|
---|
2199 | * Returns the expanded expression.
|
---|
2200 | * @param a_Expr The expression to expand. */
|
---|
2201 | #define RT_EXPAND(a_Expr) RT_EXPAND_2(a_Expr)
|
---|
2202 |
|
---|
2203 | /** @def RT_STR
|
---|
2204 | * Returns the argument as a string constant.
|
---|
2205 | * @param str Argument to stringify. */
|
---|
2206 | #define RT_STR(str) #str
|
---|
2207 | /** @def RT_XSTR
|
---|
2208 | * Returns the expanded argument as a string.
|
---|
2209 | * @param str Argument to expand and stringify. */
|
---|
2210 | #define RT_XSTR(str) RT_STR(str)
|
---|
2211 |
|
---|
2212 | /** @def RT_LSTR_2
|
---|
2213 | * Helper for RT_WSTR that gets the expanded @a str.
|
---|
2214 | * @param str String litteral to prefix with 'L'. */
|
---|
2215 | #define RT_LSTR_2(str) L##str
|
---|
2216 | /** @def RT_LSTR
|
---|
2217 | * Returns the expanded argument with a L string prefix.
|
---|
2218 | *
|
---|
2219 | * Intended for converting ASCII string \#defines into wide char string
|
---|
2220 | * litterals on Windows.
|
---|
2221 | *
|
---|
2222 | * @param str String litteral to . */
|
---|
2223 | #define RT_LSTR(str) RT_LSTR_2(str)
|
---|
2224 |
|
---|
2225 | /** @def RT_UNPACK_CALL
|
---|
2226 | * Unpacks the an argument list inside an extra set of parenthesis and turns it
|
---|
2227 | * into a call to @a a_Fn.
|
---|
2228 | *
|
---|
2229 | * @param a_Fn Function/macro to call.
|
---|
2230 | * @param a_Args Parameter list in parenthesis.
|
---|
2231 | */
|
---|
2232 | #define RT_UNPACK_CALL(a_Fn, a_Args) a_Fn a_Args
|
---|
2233 |
|
---|
2234 | #if defined(RT_COMPILER_SUPPORTS_VA_ARGS) || defined(DOXYGEN_RUNNING)
|
---|
2235 |
|
---|
2236 | /** @def RT_UNPACK_ARGS
|
---|
2237 | * Returns the arguments without parenthesis.
|
---|
2238 | *
|
---|
2239 | * @param ... Parameter list in parenthesis.
|
---|
2240 | * @remarks Requires RT_COMPILER_SUPPORTS_VA_ARGS.
|
---|
2241 | */
|
---|
2242 | # define RT_UNPACK_ARGS(...) __VA_ARGS__
|
---|
2243 |
|
---|
2244 | /** @def RT_COUNT_VA_ARGS_HLP
|
---|
2245 | * Helper for RT_COUNT_VA_ARGS that picks out the argument count from
|
---|
2246 | * RT_COUNT_VA_ARGS_REV_SEQ. */
|
---|
2247 | # define RT_COUNT_VA_ARGS_HLP( \
|
---|
2248 | c69, c68, c67, c66, c65, c64, c63, c62, c61, c60, \
|
---|
2249 | c59, c58, c57, c56, c55, c54, c53, c52, c51, c50, \
|
---|
2250 | c49, c48, c47, c46, c45, c44, c43, c42, c41, c40, \
|
---|
2251 | c39, c38, c37, c36, c35, c34, c33, c32, c31, c30, \
|
---|
2252 | c29, c28, c27, c26, c25, c24, c23, c22, c21, c20, \
|
---|
2253 | c19, c18, c17, c16, c15, c14, c13, c12, c11, c10, \
|
---|
2254 | c9, c8, c7, c6, c5, c4, c3, c2, c1, cArgs, ...) cArgs
|
---|
2255 | /** Argument count sequence. */
|
---|
2256 | # define RT_COUNT_VA_ARGS_REV_SEQ \
|
---|
2257 | 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, \
|
---|
2258 | 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
|
---|
2259 | 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
|
---|
2260 | 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
|
---|
2261 | 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
|
---|
2262 | 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
|
---|
2263 | 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
---|
2264 | /** This is for zero arguments. At least Visual C++ requires it. */
|
---|
2265 | # define RT_COUNT_VA_ARGS_PREFIX_RT_NOTHING RT_COUNT_VA_ARGS_REV_SEQ
|
---|
2266 | /**
|
---|
2267 | * Counts the number of arguments given to the variadic macro.
|
---|
2268 | *
|
---|
2269 | * Max is 69.
|
---|
2270 | *
|
---|
2271 | * @returns Number of arguments in the ellipsis
|
---|
2272 | * @param ... Arguments to count.
|
---|
2273 | * @remarks Requires RT_COMPILER_SUPPORTS_VA_ARGS.
|
---|
2274 | */
|
---|
2275 | # define RT_COUNT_VA_ARGS(...) \
|
---|
2276 | RT_UNPACK_CALL(RT_COUNT_VA_ARGS_HLP, (RT_COUNT_VA_ARGS_PREFIX_ ## __VA_ARGS__ ## RT_NOTHING, \
|
---|
2277 | RT_COUNT_VA_ARGS_REV_SEQ))
|
---|
2278 |
|
---|
2279 | #endif /* RT_COMPILER_SUPPORTS_VA_ARGS */
|
---|
2280 |
|
---|
2281 |
|
---|
2282 | /** @def RT_CONCAT
|
---|
2283 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2284 | *
|
---|
2285 | * @param a The first part.
|
---|
2286 | * @param b The second part.
|
---|
2287 | */
|
---|
2288 | #define RT_CONCAT(a,b) RT_CONCAT_HLP(a,b)
|
---|
2289 | /** RT_CONCAT helper, don't use. */
|
---|
2290 | #define RT_CONCAT_HLP(a,b) a##b
|
---|
2291 |
|
---|
2292 | /** @def RT_CONCAT3
|
---|
2293 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2294 | *
|
---|
2295 | * @param a The 1st part.
|
---|
2296 | * @param b The 2nd part.
|
---|
2297 | * @param c The 3rd part.
|
---|
2298 | */
|
---|
2299 | #define RT_CONCAT3(a,b,c) RT_CONCAT3_HLP(a,b,c)
|
---|
2300 | /** RT_CONCAT3 helper, don't use. */
|
---|
2301 | #define RT_CONCAT3_HLP(a,b,c) a##b##c
|
---|
2302 |
|
---|
2303 | /** @def RT_CONCAT4
|
---|
2304 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2305 | *
|
---|
2306 | * @param a The 1st part.
|
---|
2307 | * @param b The 2nd part.
|
---|
2308 | * @param c The 3rd part.
|
---|
2309 | * @param d The 4th part.
|
---|
2310 | */
|
---|
2311 | #define RT_CONCAT4(a,b,c,d) RT_CONCAT4_HLP(a,b,c,d)
|
---|
2312 | /** RT_CONCAT4 helper, don't use. */
|
---|
2313 | #define RT_CONCAT4_HLP(a,b,c,d) a##b##c##d
|
---|
2314 |
|
---|
2315 | /** @def RT_CONCAT5
|
---|
2316 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2317 | *
|
---|
2318 | * @param a The 1st part.
|
---|
2319 | * @param b The 2nd part.
|
---|
2320 | * @param c The 3rd part.
|
---|
2321 | * @param d The 4th part.
|
---|
2322 | * @param e The 5th part.
|
---|
2323 | */
|
---|
2324 | #define RT_CONCAT5(a,b,c,d,e) RT_CONCAT5_HLP(a,b,c,d,e)
|
---|
2325 | /** RT_CONCAT5 helper, don't use. */
|
---|
2326 | #define RT_CONCAT5_HLP(a,b,c,d,e) a##b##c##d##e
|
---|
2327 |
|
---|
2328 | /** @def RT_CONCAT6
|
---|
2329 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2330 | *
|
---|
2331 | * @param a The 1st part.
|
---|
2332 | * @param b The 2nd part.
|
---|
2333 | * @param c The 3rd part.
|
---|
2334 | * @param d The 4th part.
|
---|
2335 | * @param e The 5th part.
|
---|
2336 | * @param f The 6th part.
|
---|
2337 | */
|
---|
2338 | #define RT_CONCAT6(a,b,c,d,e,f) RT_CONCAT6_HLP(a,b,c,d,e,f)
|
---|
2339 | /** RT_CONCAT6 helper, don't use. */
|
---|
2340 | #define RT_CONCAT6_HLP(a,b,c,d,e,f) a##b##c##d##e##f
|
---|
2341 |
|
---|
2342 | /** @def RT_CONCAT7
|
---|
2343 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2344 | *
|
---|
2345 | * @param a The 1st part.
|
---|
2346 | * @param b The 2nd part.
|
---|
2347 | * @param c The 3rd part.
|
---|
2348 | * @param d The 4th part.
|
---|
2349 | * @param e The 5th part.
|
---|
2350 | * @param f The 6th part.
|
---|
2351 | * @param g The 7th part.
|
---|
2352 | */
|
---|
2353 | #define RT_CONCAT7(a,b,c,d,e,f,g) RT_CONCAT7_HLP(a,b,c,d,e,f,g)
|
---|
2354 | /** RT_CONCAT7 helper, don't use. */
|
---|
2355 | #define RT_CONCAT7_HLP(a,b,c,d,e,f,g) a##b##c##d##e##f##g
|
---|
2356 |
|
---|
2357 | /** @def RT_CONCAT8
|
---|
2358 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2359 | *
|
---|
2360 | * @param a The 1st part.
|
---|
2361 | * @param b The 2nd part.
|
---|
2362 | * @param c The 3rd part.
|
---|
2363 | * @param d The 4th part.
|
---|
2364 | * @param e The 5th part.
|
---|
2365 | * @param f The 6th part.
|
---|
2366 | * @param g The 7th part.
|
---|
2367 | * @param h The 8th part.
|
---|
2368 | */
|
---|
2369 | #define RT_CONCAT8(a,b,c,d,e,f,g,h) RT_CONCAT8_HLP(a,b,c,d,e,f,g,h)
|
---|
2370 | /** RT_CONCAT8 helper, don't use. */
|
---|
2371 | #define RT_CONCAT8_HLP(a,b,c,d,e,f,g,h) a##b##c##d##e##f##g##h
|
---|
2372 |
|
---|
2373 | /** @def RT_CONCAT9
|
---|
2374 | * Concatenate the expanded arguments without any extra spaces in between.
|
---|
2375 | *
|
---|
2376 | * @param a The 1st part.
|
---|
2377 | * @param b The 2nd part.
|
---|
2378 | * @param c The 3rd part.
|
---|
2379 | * @param d The 4th part.
|
---|
2380 | * @param e The 5th part.
|
---|
2381 | * @param f The 6th part.
|
---|
2382 | * @param g The 7th part.
|
---|
2383 | * @param h The 8th part.
|
---|
2384 | * @param i The 9th part.
|
---|
2385 | */
|
---|
2386 | #define RT_CONCAT9(a,b,c,d,e,f,g,h,i) RT_CONCAT9_HLP(a,b,c,d,e,f,g,h,i)
|
---|
2387 | /** RT_CONCAT9 helper, don't use. */
|
---|
2388 | #define RT_CONCAT9_HLP(a,b,c,d,e,f,g,h,i) a##b##c##d##e##f##g##h##i
|
---|
2389 |
|
---|
2390 | /**
|
---|
2391 | * String constant tuple - string constant, strlen(string constant).
|
---|
2392 | *
|
---|
2393 | * @param a_szConst String constant.
|
---|
2394 | * @sa RTSTRTUPLE
|
---|
2395 | */
|
---|
2396 | #define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
|
---|
2397 |
|
---|
2398 |
|
---|
2399 | /**
|
---|
2400 | * Macro for using in switch statements that turns constants into strings.
|
---|
2401 | *
|
---|
2402 | * @param a_Const The constant (not string).
|
---|
2403 | */
|
---|
2404 | #define RT_CASE_RET_STR(a_Const) case a_Const: return #a_Const
|
---|
2405 |
|
---|
2406 |
|
---|
2407 | /** @def RT_BIT
|
---|
2408 | * Convert a bit number into an integer bitmask (unsigned).
|
---|
2409 | * @param bit The bit number.
|
---|
2410 | */
|
---|
2411 | #define RT_BIT(bit) ( 1U << (bit) )
|
---|
2412 |
|
---|
2413 | /** @def RT_BIT_32
|
---|
2414 | * Convert a bit number into a 32-bit bitmask (unsigned).
|
---|
2415 | * @param bit The bit number.
|
---|
2416 | */
|
---|
2417 | #define RT_BIT_32(bit) ( UINT32_C(1) << (bit) )
|
---|
2418 |
|
---|
2419 | /** @def RT_BIT_64
|
---|
2420 | * Convert a bit number into a 64-bit bitmask (unsigned).
|
---|
2421 | * @param bit The bit number.
|
---|
2422 | */
|
---|
2423 | #define RT_BIT_64(bit) ( UINT64_C(1) << (bit) )
|
---|
2424 |
|
---|
2425 | /** @def RT_BIT_Z
|
---|
2426 | * Convert a bit number into a size_t bitmask (for avoid MSC warnings).
|
---|
2427 | * @param a_iBit The bit number.
|
---|
2428 | */
|
---|
2429 | #define RT_BIT_Z(a_iBit) ( (size_t)(1) << (a_iBit) )
|
---|
2430 |
|
---|
2431 |
|
---|
2432 | /** @def RT_BF_GET
|
---|
2433 | * Gets the value of a bit field in an integer value.
|
---|
2434 | *
|
---|
2435 | * This requires a couple of macros to be defined for the field:
|
---|
2436 | * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
|
---|
2437 | * - \<a_FieldNm\>_MASK: The field mask.
|
---|
2438 | *
|
---|
2439 | * @returns The bit field value.
|
---|
2440 | * @param a_uValue The integer value containing the field.
|
---|
2441 | * @param a_FieldNm The field name prefix for getting at the _SHIFT and
|
---|
2442 | * _MASK macros.
|
---|
2443 | * @sa #RT_BF_CLEAR, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
|
---|
2444 | */
|
---|
2445 | #define RT_BF_GET(a_uValue, a_FieldNm) ( ((a_uValue) >> RT_CONCAT(a_FieldNm,_SHIFT)) & RT_BF_ZMASK(a_FieldNm) )
|
---|
2446 |
|
---|
2447 | /** @def RT_BF_SET
|
---|
2448 | * Sets the given bit field in the integer value.
|
---|
2449 | *
|
---|
2450 | * This requires a couple of macros to be defined for the field:
|
---|
2451 | * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
|
---|
2452 | * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
|
---|
2453 | * integer value!!
|
---|
2454 | *
|
---|
2455 | * @returns Integer value with bit field set to @a a_uFieldValue.
|
---|
2456 | * @param a_uValue The integer value containing the field.
|
---|
2457 | * @param a_FieldNm The field name prefix for getting at the _SHIFT and
|
---|
2458 | * _MASK macros.
|
---|
2459 | * @param a_uFieldValue The new field value.
|
---|
2460 | * @sa #RT_BF_GET, #RT_BF_CLEAR, #RT_BF_MAKE, #RT_BF_ZMASK
|
---|
2461 | */
|
---|
2462 | #define RT_BF_SET(a_uValue, a_FieldNm, a_uFieldValue) ( RT_BF_CLEAR(a_uValue, a_FieldNm) | RT_BF_MAKE(a_FieldNm, a_uFieldValue) )
|
---|
2463 |
|
---|
2464 | /** @def RT_BF_CLEAR
|
---|
2465 | * Clears the given bit field in the integer value.
|
---|
2466 | *
|
---|
2467 | * This requires a couple of macros to be defined for the field:
|
---|
2468 | * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
|
---|
2469 | * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
|
---|
2470 | * integer value!!
|
---|
2471 | *
|
---|
2472 | * @returns Integer value with bit field set to zero.
|
---|
2473 | * @param a_uValue The integer value containing the field.
|
---|
2474 | * @param a_FieldNm The field name prefix for getting at the _SHIFT and
|
---|
2475 | * _MASK macros.
|
---|
2476 | * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
|
---|
2477 | */
|
---|
2478 | #define RT_BF_CLEAR(a_uValue, a_FieldNm) ( (a_uValue) & ~RT_CONCAT(a_FieldNm,_MASK) )
|
---|
2479 |
|
---|
2480 | /** @def RT_BF_MAKE
|
---|
2481 | * Shifts and masks a bit field value into position in the integer value.
|
---|
2482 | *
|
---|
2483 | * This requires a couple of macros to be defined for the field:
|
---|
2484 | * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
|
---|
2485 | * - \<a_FieldNm\>_MASK: The field mask.
|
---|
2486 | *
|
---|
2487 | * @param a_FieldNm The field name prefix for getting at the _SHIFT and
|
---|
2488 | * _MASK macros.
|
---|
2489 | * @param a_uFieldValue The field value that should be masked and shifted
|
---|
2490 | * into position.
|
---|
2491 | * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_ZMASK
|
---|
2492 | */
|
---|
2493 | #define RT_BF_MAKE(a_FieldNm, a_uFieldValue) ( ((a_uFieldValue) & RT_BF_ZMASK(a_FieldNm) ) << RT_CONCAT(a_FieldNm,_SHIFT) )
|
---|
2494 |
|
---|
2495 | /** @def RT_BF_ZMASK
|
---|
2496 | * Helper for getting the field mask shifted to bit position zero.
|
---|
2497 | *
|
---|
2498 | * @param a_FieldNm The field name prefix for getting at the _SHIFT and
|
---|
2499 | * _MASK macros.
|
---|
2500 | * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_MAKE
|
---|
2501 | */
|
---|
2502 | #define RT_BF_ZMASK(a_FieldNm) ( RT_CONCAT(a_FieldNm,_MASK) >> RT_CONCAT(a_FieldNm,_SHIFT) )
|
---|
2503 |
|
---|
2504 | /** Bit field compile time check helper
|
---|
2505 | * @internal */
|
---|
2506 | #define RT_BF_CHECK_DO_XOR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) ^ RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
|
---|
2507 | /** Bit field compile time check helper
|
---|
2508 | * @internal */
|
---|
2509 | #define RT_BF_CHECK_DO_OR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) | RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
|
---|
2510 | /** Bit field compile time check helper
|
---|
2511 | * @internal */
|
---|
2512 | #define RT_BF_CHECK_DO_1ST_MASK_BIT(a_uLeft, a_RightPrefix, a_FieldNm) \
|
---|
2513 | ((a_uLeft) && ( (RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U ) )
|
---|
2514 | /** Used to check that a bit field mask does not start too early.
|
---|
2515 | * @internal */
|
---|
2516 | #define RT_BF_CHECK_DO_MASK_START(a_uLeft, a_RightPrefix, a_FieldNm) \
|
---|
2517 | ( (a_uLeft) \
|
---|
2518 | && ( RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT) == 0 \
|
---|
2519 | || ( ( ( ((RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U) \
|
---|
2520 | << RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) /* => single bit mask, correct type */ \
|
---|
2521 | - 1U) /* => mask of all bits below the field */ \
|
---|
2522 | & RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK)) == 0 ) )
|
---|
2523 | /** @name Bit field compile time check recursion workers.
|
---|
2524 | * @internal
|
---|
2525 | * @{ */
|
---|
2526 | #define RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix, f1) \
|
---|
2527 | a_DoThis(a_uLeft, a_RightPrefix, f1)
|
---|
2528 | #define RT_BF_CHECK_DO_2(a_DoThis, a_uLeft, a_RightPrefix, f1, f2) \
|
---|
2529 | RT_BF_CHECK_DO_1(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2)
|
---|
2530 | #define RT_BF_CHECK_DO_3(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3) \
|
---|
2531 | RT_BF_CHECK_DO_2(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3)
|
---|
2532 | #define RT_BF_CHECK_DO_4(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4) \
|
---|
2533 | RT_BF_CHECK_DO_3(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4)
|
---|
2534 | #define RT_BF_CHECK_DO_5(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5) \
|
---|
2535 | RT_BF_CHECK_DO_4(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5)
|
---|
2536 | #define RT_BF_CHECK_DO_6(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6) \
|
---|
2537 | RT_BF_CHECK_DO_5(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6)
|
---|
2538 | #define RT_BF_CHECK_DO_7(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7) \
|
---|
2539 | RT_BF_CHECK_DO_6(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7)
|
---|
2540 | #define RT_BF_CHECK_DO_8(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8) \
|
---|
2541 | RT_BF_CHECK_DO_7(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8)
|
---|
2542 | #define RT_BF_CHECK_DO_9(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9) \
|
---|
2543 | RT_BF_CHECK_DO_8(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9)
|
---|
2544 | #define RT_BF_CHECK_DO_10(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10) \
|
---|
2545 | RT_BF_CHECK_DO_9(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10)
|
---|
2546 | #define RT_BF_CHECK_DO_11(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) \
|
---|
2547 | RT_BF_CHECK_DO_10(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11)
|
---|
2548 | #define RT_BF_CHECK_DO_12(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) \
|
---|
2549 | RT_BF_CHECK_DO_11(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12)
|
---|
2550 | #define RT_BF_CHECK_DO_13(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13) \
|
---|
2551 | RT_BF_CHECK_DO_12(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13)
|
---|
2552 | #define RT_BF_CHECK_DO_14(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14) \
|
---|
2553 | RT_BF_CHECK_DO_13(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14)
|
---|
2554 | #define RT_BF_CHECK_DO_15(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15) \
|
---|
2555 | RT_BF_CHECK_DO_14(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15)
|
---|
2556 | #define RT_BF_CHECK_DO_16(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) \
|
---|
2557 | RT_BF_CHECK_DO_15(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16)
|
---|
2558 | #define RT_BF_CHECK_DO_17(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17) \
|
---|
2559 | RT_BF_CHECK_DO_16(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)
|
---|
2560 | #define RT_BF_CHECK_DO_18(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18) \
|
---|
2561 | RT_BF_CHECK_DO_17(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18)
|
---|
2562 | #define RT_BF_CHECK_DO_19(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19) \
|
---|
2563 | RT_BF_CHECK_DO_18(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19)
|
---|
2564 | #define RT_BF_CHECK_DO_20(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20) \
|
---|
2565 | RT_BF_CHECK_DO_19(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20)
|
---|
2566 | #define RT_BF_CHECK_DO_21(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21) \
|
---|
2567 | RT_BF_CHECK_DO_20(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21)
|
---|
2568 | #define RT_BF_CHECK_DO_22(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22) \
|
---|
2569 | RT_BF_CHECK_DO_21(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22)
|
---|
2570 | #define RT_BF_CHECK_DO_23(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23) \
|
---|
2571 | RT_BF_CHECK_DO_22(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23)
|
---|
2572 | #define RT_BF_CHECK_DO_24(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24) \
|
---|
2573 | RT_BF_CHECK_DO_23(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24)
|
---|
2574 | #define RT_BF_CHECK_DO_25(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25) \
|
---|
2575 | RT_BF_CHECK_DO_24(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25)
|
---|
2576 | #define RT_BF_CHECK_DO_26(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26) \
|
---|
2577 | RT_BF_CHECK_DO_25(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26)
|
---|
2578 | #define RT_BF_CHECK_DO_27(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27) \
|
---|
2579 | RT_BF_CHECK_DO_26(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27)
|
---|
2580 | #define RT_BF_CHECK_DO_28(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28) \
|
---|
2581 | RT_BF_CHECK_DO_27(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28)
|
---|
2582 | #define RT_BF_CHECK_DO_29(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29) \
|
---|
2583 | RT_BF_CHECK_DO_28(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29)
|
---|
2584 | #define RT_BF_CHECK_DO_30(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30) \
|
---|
2585 | RT_BF_CHECK_DO_29(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30)
|
---|
2586 | #define RT_BF_CHECK_DO_31(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31) \
|
---|
2587 | RT_BF_CHECK_DO_30(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31)
|
---|
2588 | #define RT_BF_CHECK_DO_32(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32) \
|
---|
2589 | RT_BF_CHECK_DO_31(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32)
|
---|
2590 | #define RT_BF_CHECK_DO_33(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33) \
|
---|
2591 | RT_BF_CHECK_DO_32(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33)
|
---|
2592 | #define RT_BF_CHECK_DO_34(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34) \
|
---|
2593 | RT_BF_CHECK_DO_33(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34)
|
---|
2594 | #define RT_BF_CHECK_DO_35(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35) \
|
---|
2595 | RT_BF_CHECK_DO_34(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35)
|
---|
2596 | #define RT_BF_CHECK_DO_36(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36) \
|
---|
2597 | RT_BF_CHECK_DO_35(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36)
|
---|
2598 | #define RT_BF_CHECK_DO_37(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37) \
|
---|
2599 | RT_BF_CHECK_DO_36(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37)
|
---|
2600 | #define RT_BF_CHECK_DO_38(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38) \
|
---|
2601 | RT_BF_CHECK_DO_37(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38)
|
---|
2602 | #define RT_BF_CHECK_DO_39(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39) \
|
---|
2603 | RT_BF_CHECK_DO_38(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39)
|
---|
2604 | #define RT_BF_CHECK_DO_40(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40) \
|
---|
2605 | RT_BF_CHECK_DO_39(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40)
|
---|
2606 | #define RT_BF_CHECK_DO_41(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41) \
|
---|
2607 | RT_BF_CHECK_DO_40(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41)
|
---|
2608 | #define RT_BF_CHECK_DO_42(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42) \
|
---|
2609 | RT_BF_CHECK_DO_41(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42)
|
---|
2610 | #define RT_BF_CHECK_DO_43(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43) \
|
---|
2611 | RT_BF_CHECK_DO_42(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43)
|
---|
2612 | #define RT_BF_CHECK_DO_44(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44) \
|
---|
2613 | RT_BF_CHECK_DO_43(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44)
|
---|
2614 | #define RT_BF_CHECK_DO_45(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45) \
|
---|
2615 | RT_BF_CHECK_DO_44(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45)
|
---|
2616 | #define RT_BF_CHECK_DO_46(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46) \
|
---|
2617 | RT_BF_CHECK_DO_45(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46)
|
---|
2618 | #define RT_BF_CHECK_DO_47(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47) \
|
---|
2619 | RT_BF_CHECK_DO_46(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47)
|
---|
2620 | #define RT_BF_CHECK_DO_48(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48) \
|
---|
2621 | RT_BF_CHECK_DO_47(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48)
|
---|
2622 | #define RT_BF_CHECK_DO_49(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49) \
|
---|
2623 | RT_BF_CHECK_DO_48(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49)
|
---|
2624 | #define RT_BF_CHECK_DO_50(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50) \
|
---|
2625 | RT_BF_CHECK_DO_49(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50)
|
---|
2626 | #define RT_BF_CHECK_DO_51(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51) \
|
---|
2627 | RT_BF_CHECK_DO_40(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51)
|
---|
2628 | #define RT_BF_CHECK_DO_52(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52) \
|
---|
2629 | RT_BF_CHECK_DO_51(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52)
|
---|
2630 | #define RT_BF_CHECK_DO_53(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53) \
|
---|
2631 | RT_BF_CHECK_DO_52(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53)
|
---|
2632 | #define RT_BF_CHECK_DO_54(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54) \
|
---|
2633 | RT_BF_CHECK_DO_53(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54)
|
---|
2634 | #define RT_BF_CHECK_DO_55(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55) \
|
---|
2635 | RT_BF_CHECK_DO_54(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55)
|
---|
2636 | #define RT_BF_CHECK_DO_56(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56) \
|
---|
2637 | RT_BF_CHECK_DO_55(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56)
|
---|
2638 | #define RT_BF_CHECK_DO_57(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57) \
|
---|
2639 | RT_BF_CHECK_DO_56(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57)
|
---|
2640 | #define RT_BF_CHECK_DO_58(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58) \
|
---|
2641 | RT_BF_CHECK_DO_57(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58)
|
---|
2642 | #define RT_BF_CHECK_DO_59(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59) \
|
---|
2643 | RT_BF_CHECK_DO_58(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59)
|
---|
2644 | #define RT_BF_CHECK_DO_60(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60) \
|
---|
2645 | RT_BF_CHECK_DO_59(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60)
|
---|
2646 | #define RT_BF_CHECK_DO_61(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61) \
|
---|
2647 | RT_BF_CHECK_DO_60(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61)
|
---|
2648 | #define RT_BF_CHECK_DO_62(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62) \
|
---|
2649 | RT_BF_CHECK_DO_61(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62)
|
---|
2650 | #define RT_BF_CHECK_DO_63(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62, f63) \
|
---|
2651 | RT_BF_CHECK_DO_62(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62, f63)
|
---|
2652 | #define RT_BF_CHECK_DO_64(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62, f63, f64) \
|
---|
2653 | RT_BF_CHECK_DO_63(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31, f32, f33, f34, f35, f36, f37, f38, f39, f40, f41, f42, f43, f44, f45, f46, f47, f48, f49, f50, f51, f52, f53, f54, f55, f56, f57, f58, f59, f60, f61, f62, f63, f64)
|
---|
2654 | /** @} */
|
---|
2655 |
|
---|
2656 | /** @def RT_BF_ASSERT_COMPILE_CHECKS
|
---|
2657 | * Emits a series of AssertCompile statements checking that the bit-field
|
---|
2658 | * declarations doesn't overlap, has holes, and generally makes some sense.
|
---|
2659 | *
|
---|
2660 | * This requires variadic macros because its too much to type otherwise.
|
---|
2661 | */
|
---|
2662 | #if defined(RT_COMPILER_SUPPORTS_VA_ARGS) || defined(DOXYGEN_RUNNING)
|
---|
2663 | # define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) \
|
---|
2664 | AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_OR_MASK, a_uZero, a_Prefix, RT_UNPACK_ARGS a_Fields ) == a_uCovered); \
|
---|
2665 | AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_XOR_MASK, a_uCovered, a_Prefix, RT_UNPACK_ARGS a_Fields ) == 0); \
|
---|
2666 | AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_1ST_MASK_BIT, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true); \
|
---|
2667 | AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_MASK_START, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true)
|
---|
2668 | /** Bit field compile time check helper
|
---|
2669 | * @internal */
|
---|
2670 | # define RT_BF_CHECK_DO_N(a_DoThis, a_uLeft, a_RightPrefix, ...) \
|
---|
2671 | RT_UNPACK_CALL(RT_CONCAT(RT_BF_CHECK_DO_, RT_EXPAND(RT_COUNT_VA_ARGS(__VA_ARGS__))), (a_DoThis, a_uLeft, a_RightPrefix, __VA_ARGS__))
|
---|
2672 | #else
|
---|
2673 | # define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) AssertCompile(true)
|
---|
2674 | #endif
|
---|
2675 |
|
---|
2676 |
|
---|
2677 | /** @def RT_ALIGN
|
---|
2678 | * Align macro.
|
---|
2679 | * @param u Value to align.
|
---|
2680 | * @param uAlignment The alignment. Power of two!
|
---|
2681 | *
|
---|
2682 | * @remark Be extremely careful when using this macro with type which sizeof != sizeof int.
|
---|
2683 | * When possible use any of the other RT_ALIGN_* macros. And when that's not
|
---|
2684 | * possible, make 101% sure that uAlignment is specified with a right sized type.
|
---|
2685 | *
|
---|
2686 | * Specifying an unsigned 32-bit alignment constant with a 64-bit value will give
|
---|
2687 | * you a 32-bit return value!
|
---|
2688 | *
|
---|
2689 | * In short: Don't use this macro. Use RT_ALIGN_T() instead.
|
---|
2690 | */
|
---|
2691 | #define RT_ALIGN(u, uAlignment) ( ((u) + ((uAlignment) - 1)) & ~((uAlignment) - 1) )
|
---|
2692 |
|
---|
2693 | /** @def RT_ALIGN_T
|
---|
2694 | * Align macro.
|
---|
2695 | * @param u Value to align.
|
---|
2696 | * @param uAlignment The alignment. Power of two!
|
---|
2697 | * @param type Integer type to use while aligning.
|
---|
2698 | * @remark This macro is the preferred alignment macro, it doesn't have any of the pitfalls RT_ALIGN has.
|
---|
2699 | */
|
---|
2700 | #define RT_ALIGN_T(u, uAlignment, type) ( ((type)(u) + ((uAlignment) - 1)) & ~(type)((uAlignment) - 1) )
|
---|
2701 |
|
---|
2702 | /** @def RT_ALIGN_32
|
---|
2703 | * Align macro for a 32-bit value.
|
---|
2704 | * @param u32 Value to align.
|
---|
2705 | * @param uAlignment The alignment. Power of two!
|
---|
2706 | */
|
---|
2707 | #define RT_ALIGN_32(u32, uAlignment) RT_ALIGN_T(u32, uAlignment, uint32_t)
|
---|
2708 |
|
---|
2709 | /** @def RT_ALIGN_64
|
---|
2710 | * Align macro for a 64-bit value.
|
---|
2711 | * @param u64 Value to align.
|
---|
2712 | * @param uAlignment The alignment. Power of two!
|
---|
2713 | */
|
---|
2714 | #define RT_ALIGN_64(u64, uAlignment) RT_ALIGN_T(u64, uAlignment, uint64_t)
|
---|
2715 |
|
---|
2716 | /** @def RT_ALIGN_Z
|
---|
2717 | * Align macro for size_t.
|
---|
2718 | * @param cb Value to align.
|
---|
2719 | * @param uAlignment The alignment. Power of two!
|
---|
2720 | */
|
---|
2721 | #define RT_ALIGN_Z(cb, uAlignment) RT_ALIGN_T(cb, uAlignment, size_t)
|
---|
2722 |
|
---|
2723 | /** @def RT_ALIGN_P
|
---|
2724 | * Align macro for pointers.
|
---|
2725 | * @param pv Value to align.
|
---|
2726 | * @param uAlignment The alignment. Power of two!
|
---|
2727 | */
|
---|
2728 | #define RT_ALIGN_P(pv, uAlignment) RT_ALIGN_PT(pv, uAlignment, void *)
|
---|
2729 |
|
---|
2730 | /** @def RT_ALIGN_PT
|
---|
2731 | * Align macro for pointers with type cast.
|
---|
2732 | * @param u Value to align.
|
---|
2733 | * @param uAlignment The alignment. Power of two!
|
---|
2734 | * @param CastType The type to cast the result to.
|
---|
2735 | */
|
---|
2736 | #define RT_ALIGN_PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, uintptr_t) )
|
---|
2737 |
|
---|
2738 | /** @def RT_ALIGN_R3PT
|
---|
2739 | * Align macro for ring-3 pointers with type cast.
|
---|
2740 | * @param u Value to align.
|
---|
2741 | * @param uAlignment The alignment. Power of two!
|
---|
2742 | * @param CastType The type to cast the result to.
|
---|
2743 | */
|
---|
2744 | #define RT_ALIGN_R3PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR3UINTPTR) )
|
---|
2745 |
|
---|
2746 | /** @def RT_ALIGN_R0PT
|
---|
2747 | * Align macro for ring-0 pointers with type cast.
|
---|
2748 | * @param u Value to align.
|
---|
2749 | * @param uAlignment The alignment. Power of two!
|
---|
2750 | * @param CastType The type to cast the result to.
|
---|
2751 | */
|
---|
2752 | #define RT_ALIGN_R0PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR0UINTPTR) )
|
---|
2753 |
|
---|
2754 | /** @def RT_ALIGN_GCPT
|
---|
2755 | * Align macro for GC pointers with type cast.
|
---|
2756 | * @param u Value to align.
|
---|
2757 | * @param uAlignment The alignment. Power of two!
|
---|
2758 | * @param CastType The type to cast the result to.
|
---|
2759 | */
|
---|
2760 | #define RT_ALIGN_GCPT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTGCUINTPTR) )
|
---|
2761 |
|
---|
2762 |
|
---|
2763 | /** @def RT_OFFSETOF
|
---|
2764 | * Our own special offsetof() variant, returns a signed result.
|
---|
2765 | *
|
---|
2766 | * @returns offset into the structure of the specified member. signed.
|
---|
2767 | * @param type Structure type.
|
---|
2768 | * @param member Member.
|
---|
2769 | *
|
---|
2770 | * @remarks Only use this for static offset calculations. Please
|
---|
2771 | * use RT_UOFFSETOF_DYN for dynamic ones (i.e. involves
|
---|
2772 | * non-constant array indexing).
|
---|
2773 | *
|
---|
2774 | */
|
---|
2775 | #if RT_GNUC_PREREQ(4, 0)
|
---|
2776 | # define RT_OFFSETOF(type, member) ( (int)__builtin_offsetof(type, member) )
|
---|
2777 | #else
|
---|
2778 | # define RT_OFFSETOF(type, member) ( (int)(intptr_t)&( ((type *)(void *)0)->member) )
|
---|
2779 | #endif
|
---|
2780 |
|
---|
2781 | /** @def RT_UOFFSETOF
|
---|
2782 | * Our own offsetof() variant, returns an unsigned result.
|
---|
2783 | *
|
---|
2784 | * @returns offset into the structure of the specified member. unsigned.
|
---|
2785 | * @param type Structure type.
|
---|
2786 | * @param member Member.
|
---|
2787 | *
|
---|
2788 | * @remarks Only use this for static offset calculations. Please
|
---|
2789 | * use RT_UOFFSETOF_DYN for dynamic ones (i.e. involves
|
---|
2790 | * non-constant array indexing).
|
---|
2791 | */
|
---|
2792 | #if RT_GNUC_PREREQ(4, 0)
|
---|
2793 | # define RT_UOFFSETOF(type, member) ( (uintptr_t)__builtin_offsetof(type, member) )
|
---|
2794 | #else
|
---|
2795 | # define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) )
|
---|
2796 | #endif
|
---|
2797 |
|
---|
2798 | /** @def RT_OFFSETOF_ADD
|
---|
2799 | * RT_OFFSETOF with an addend.
|
---|
2800 | *
|
---|
2801 | * @returns offset into the structure of the specified member. signed.
|
---|
2802 | * @param type Structure type.
|
---|
2803 | * @param member Member.
|
---|
2804 | * @param addend The addend to add to the offset.
|
---|
2805 | *
|
---|
2806 | * @remarks Only use this for static offset calculations.
|
---|
2807 | */
|
---|
2808 | #define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) )
|
---|
2809 |
|
---|
2810 | /** @def RT_UOFFSETOF_ADD
|
---|
2811 | * RT_UOFFSETOF with an addend.
|
---|
2812 | *
|
---|
2813 | * @returns offset into the structure of the specified member. signed.
|
---|
2814 | * @param type Structure type.
|
---|
2815 | * @param member Member.
|
---|
2816 | * @param addend The addend to add to the offset.
|
---|
2817 | *
|
---|
2818 | * @remarks Only use this for static offset calculations.
|
---|
2819 | */
|
---|
2820 | #if RT_GNUC_PREREQ(4, 0)
|
---|
2821 | # define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)(__builtin_offsetof(type, member) + (addend)))
|
---|
2822 | #else
|
---|
2823 | # define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) )
|
---|
2824 | #endif
|
---|
2825 |
|
---|
2826 | /** @def RT_UOFFSETOF_DYN
|
---|
2827 | * Dynamic (runtime) structure offset calculations, involving
|
---|
2828 | * indexing of array members via variable.
|
---|
2829 | *
|
---|
2830 | * @returns offset into the structure of the specified member. signed.
|
---|
2831 | * @param type Structure type.
|
---|
2832 | * @param memberarray Member.
|
---|
2833 | */
|
---|
2834 | #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4)
|
---|
2835 | # define RT_UOFFSETOF_DYN(type, memberarray) ( (uintptr_t)&( ((type *)(void *)0x1000)->memberarray) - 0x1000 )
|
---|
2836 | #else
|
---|
2837 | # define RT_UOFFSETOF_DYN(type, memberarray) ( (uintptr_t)&( ((type *)(void *)0)->memberarray) )
|
---|
2838 | #endif
|
---|
2839 |
|
---|
2840 |
|
---|
2841 | /** @def RT_SIZEOFMEMB
|
---|
2842 | * Get the size of a structure member.
|
---|
2843 | *
|
---|
2844 | * @returns size of the structure member.
|
---|
2845 | * @param type Structure type.
|
---|
2846 | * @param member Member.
|
---|
2847 | */
|
---|
2848 | #define RT_SIZEOFMEMB(type, member) ( sizeof(((type *)(void *)0)->member) )
|
---|
2849 |
|
---|
2850 | /** @def RT_UOFFSET_AFTER
|
---|
2851 | * Returns the offset of the first byte following a structure/union member.
|
---|
2852 | *
|
---|
2853 | * @return byte offset into the struct.
|
---|
2854 | * @param a_Type Structure type.
|
---|
2855 | * @param a_Member The member name.
|
---|
2856 | */
|
---|
2857 | #define RT_UOFFSET_AFTER(a_Type, a_Member) ( RT_UOFFSETOF(a_Type, a_Member) + RT_SIZEOFMEMB(a_Type, a_Member) )
|
---|
2858 |
|
---|
2859 | /** @def RT_FROM_MEMBER
|
---|
2860 | * Convert a pointer to a structure member into a pointer to the structure.
|
---|
2861 | *
|
---|
2862 | * @returns pointer to the structure.
|
---|
2863 | * @param pMem Pointer to the member.
|
---|
2864 | * @param Type Structure type.
|
---|
2865 | * @param Member Member name.
|
---|
2866 | */
|
---|
2867 | #define RT_FROM_MEMBER(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
|
---|
2868 |
|
---|
2869 | /** @def RT_FROM_CPP_MEMBER
|
---|
2870 | * Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
|
---|
2871 | * invalid access to non-static data member of NULL object.
|
---|
2872 | *
|
---|
2873 | * @returns pointer to the structure.
|
---|
2874 | * @param pMem Pointer to the member.
|
---|
2875 | * @param Type Structure type.
|
---|
2876 | * @param Member Member name.
|
---|
2877 | *
|
---|
2878 | * @remarks Using the __builtin_offsetof does not shut up the compiler.
|
---|
2879 | */
|
---|
2880 | #if defined(__GNUC__) && defined(__cplusplus)
|
---|
2881 | # define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
|
---|
2882 | ( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
|
---|
2883 | #else
|
---|
2884 | # define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
|
---|
2885 | #endif
|
---|
2886 |
|
---|
2887 | /** @def RT_FROM_MEMBER_DYN
|
---|
2888 | * Convert a pointer to a structure member into a pointer to the structure.
|
---|
2889 | *
|
---|
2890 | * @returns pointer to the structure.
|
---|
2891 | * @param pMem Pointer to the member.
|
---|
2892 | * @param Type Structure type.
|
---|
2893 | * @param Member Member name dynamic size (some array is index by
|
---|
2894 | * non-constant value).
|
---|
2895 | */
|
---|
2896 | #define RT_FROM_MEMBER_DYN(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF_DYN(Type, Member)) )
|
---|
2897 |
|
---|
2898 | /** @def RT_ELEMENTS
|
---|
2899 | * Calculates the number of elements in a statically sized array.
|
---|
2900 | * @returns Element count.
|
---|
2901 | * @param aArray Array in question.
|
---|
2902 | */
|
---|
2903 | #define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
|
---|
2904 |
|
---|
2905 | /** @def RT_SAFE_SUBSCRIPT
|
---|
2906 | * Safe array subscript using modulo and size_t cast.
|
---|
2907 | * @param a_Array The array.
|
---|
2908 | * @param a_idx The array index, cast to size_t to ensure unsigned.
|
---|
2909 | */
|
---|
2910 | #define RT_SAFE_SUBSCRIPT(a_Array, a_idx) (a_Array)[(size_t)(a_idx) % RT_ELEMENTS(a_Array)]
|
---|
2911 |
|
---|
2912 | /** @def RT_SAFE_SUBSCRIPT32
|
---|
2913 | * Safe array subscript using modulo and uint32_t cast.
|
---|
2914 | * @param a_Array The array.
|
---|
2915 | * @param a_idx The array index, cast to size_t to ensure unsigned.
|
---|
2916 | * @note Only consider using this if array size is not power of two.
|
---|
2917 | */
|
---|
2918 | #define RT_SAFE_SUBSCRIPT32(a_Array, a_idx) (a_Array)[(uint32_t)(a_idx) % RT_ELEMENTS(a_Array)]
|
---|
2919 |
|
---|
2920 | /** @def RT_SAFE_SUBSCRIPT16
|
---|
2921 | * Safe array subscript using modulo and uint16_t cast.
|
---|
2922 | * @param a_Array The array.
|
---|
2923 | * @param a_idx The array index, cast to size_t to ensure unsigned.
|
---|
2924 | * @note Only consider using this if array size is not power of two.
|
---|
2925 | */
|
---|
2926 | #define RT_SAFE_SUBSCRIPT16(a_Array, a_idx) (a_Array)[(uint16_t)(a_idx) % RT_ELEMENTS(a_Array)]
|
---|
2927 |
|
---|
2928 | /** @def RT_SAFE_SUBSCRIPT8
|
---|
2929 | * Safe array subscript using modulo and uint8_t cast.
|
---|
2930 | * @param a_Array The array.
|
---|
2931 | * @param a_idx The array index, cast to size_t to ensure unsigned.
|
---|
2932 | * @note Only consider using this if array size is not power of two.
|
---|
2933 | */
|
---|
2934 | #define RT_SAFE_SUBSCRIPT8(a_Array, a_idx) (a_Array)[(uint8_t)(a_idx) % RT_ELEMENTS(a_Array)]
|
---|
2935 |
|
---|
2936 | /** @def RT_SAFE_SUBSCRIPT_NC
|
---|
2937 | * Safe array subscript using modulo but no cast.
|
---|
2938 | * @param a_Array The array.
|
---|
2939 | * @param a_idx The array index - assumes unsigned type.
|
---|
2940 | * @note Only consider using this if array size is not power of two.
|
---|
2941 | */
|
---|
2942 | #define RT_SAFE_SUBSCRIPT_NC(a_Array, a_idx) (a_Array)[(a_idx) % RT_ELEMENTS(a_Array)]
|
---|
2943 |
|
---|
2944 | /** @def RT_FLEXIBLE_ARRAY
|
---|
2945 | * What to up inside the square brackets when declaring a structure member
|
---|
2946 | * with a flexible size.
|
---|
2947 | *
|
---|
2948 | * @note RT_FLEXIBLE_ARRAY_EXTENSION must always preceed the type, unless
|
---|
2949 | * it's C-only code.
|
---|
2950 | *
|
---|
2951 | * @note Use RT_UOFFSETOF() to calculate the structure size.
|
---|
2952 | *
|
---|
2953 | * @note Never do a sizeof() on the structure or member!
|
---|
2954 | *
|
---|
2955 | * @note The member must be the last one.
|
---|
2956 | *
|
---|
2957 | * @note GCC does not permit using this in a union. So, for unions you must
|
---|
2958 | * use RT_FLEXIBLE_ARRAY_IN_UNION instead.
|
---|
2959 | *
|
---|
2960 | * @note GCC does not permit using this in nested structures, where as MSC
|
---|
2961 | * does. So, use RT_FLEXIBLE_ARRAY_NESTED for that.
|
---|
2962 | *
|
---|
2963 | * @sa RT_FLEXIBLE_ARRAY_NESTED, RT_FLEXIBLE_ARRAY_IN_UNION
|
---|
2964 | */
|
---|
2965 | #if RT_MSC_PREREQ(RT_MSC_VER_VS2005) /** @todo Probably much much earlier. */ \
|
---|
2966 | || (defined(__cplusplus) && RT_GNUC_PREREQ(6, 1)) /* not tested 7.x, but hope it works with __extension__ too. */ \
|
---|
2967 | || defined(__WATCOMC__) /* openwatcom 1.9 supports it, we don't care about older atm. */ \
|
---|
2968 | || RT_CLANG_PREREQ_EX(3, 4, 0) /* Only tested clang v3.4, support is probably older. */
|
---|
2969 | # define RT_FLEXIBLE_ARRAY
|
---|
2970 | # if defined(__cplusplus) && defined(_MSC_VER)
|
---|
2971 | # pragma warning(disable:4200) /* -wd4200 does not work with VS2010 */
|
---|
2972 | # pragma warning(disable:4815) /* -wd4815 does not work with VS2019 */
|
---|
2973 | # endif
|
---|
2974 | #elif defined(__STDC_VERSION__)
|
---|
2975 | # if __STDC_VERSION__ >= 1999901L
|
---|
2976 | # define RT_FLEXIBLE_ARRAY
|
---|
2977 | # else
|
---|
2978 | # define RT_FLEXIBLE_ARRAY 1
|
---|
2979 | # endif
|
---|
2980 | #else
|
---|
2981 | # define RT_FLEXIBLE_ARRAY 1
|
---|
2982 | #endif
|
---|
2983 |
|
---|
2984 | /** @def RT_FLEXIBLE_ARRAY_EXTENSION
|
---|
2985 | * A trick to make GNU C++ quietly accept flexible arrays in C++ code when
|
---|
2986 | * pedantic warnings are enabled. Put this on the line before the flexible
|
---|
2987 | * array. */
|
---|
2988 | #if (RT_GNUC_PREREQ(7, 0) && defined(__cplusplus)) || defined(DOXGYEN_RUNNING)
|
---|
2989 | # define RT_FLEXIBLE_ARRAY_EXTENSION RT_GCC_EXTENSION
|
---|
2990 | #else
|
---|
2991 | # define RT_FLEXIBLE_ARRAY_EXTENSION
|
---|
2992 | #endif
|
---|
2993 |
|
---|
2994 | /** @def RT_FLEXIBLE_ARRAY_NESTED
|
---|
2995 | * Variant of RT_FLEXIBLE_ARRAY for use in structures that are nested.
|
---|
2996 | *
|
---|
2997 | * GCC only allow the use of flexible array member in the top structure, whereas
|
---|
2998 | * MSC is less strict and let you do struct { struct { char szName[]; } s; };
|
---|
2999 | *
|
---|
3000 | * @note See notes for RT_FLEXIBLE_ARRAY.
|
---|
3001 | *
|
---|
3002 | * @note GCC does not permit using this in a union. So, for unions you must
|
---|
3003 | * use RT_FLEXIBLE_ARRAY_IN_NESTED_UNION instead.
|
---|
3004 | *
|
---|
3005 | * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
|
---|
3006 | */
|
---|
3007 | #ifdef _MSC_VER
|
---|
3008 | # define RT_FLEXIBLE_ARRAY_NESTED RT_FLEXIBLE_ARRAY
|
---|
3009 | #else
|
---|
3010 | # define RT_FLEXIBLE_ARRAY_NESTED 1
|
---|
3011 | #endif
|
---|
3012 |
|
---|
3013 | /** @def RT_FLEXIBLE_ARRAY_IN_UNION
|
---|
3014 | * The union version of RT_FLEXIBLE_ARRAY.
|
---|
3015 | *
|
---|
3016 | * @remarks GCC does not support flexible array members in unions, 6.1.x
|
---|
3017 | * actively checks for this. Visual C++ 2010 seems happy with it.
|
---|
3018 | *
|
---|
3019 | * @note See notes for RT_FLEXIBLE_ARRAY.
|
---|
3020 | *
|
---|
3021 | * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
|
---|
3022 | */
|
---|
3023 | #ifdef _MSC_VER
|
---|
3024 | # define RT_FLEXIBLE_ARRAY_IN_UNION RT_FLEXIBLE_ARRAY
|
---|
3025 | #else
|
---|
3026 | # define RT_FLEXIBLE_ARRAY_IN_UNION 1
|
---|
3027 | #endif
|
---|
3028 |
|
---|
3029 | /** @def RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
|
---|
3030 | * The union version of RT_FLEXIBLE_ARRAY_NESTED.
|
---|
3031 | *
|
---|
3032 | * @note See notes for RT_FLEXIBLE_ARRAY.
|
---|
3033 | *
|
---|
3034 | * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
|
---|
3035 | */
|
---|
3036 | #ifdef _MSC_VER
|
---|
3037 | # define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION RT_FLEXIBLE_ARRAY_NESTED
|
---|
3038 | #else
|
---|
3039 | # define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION 1
|
---|
3040 | #endif
|
---|
3041 |
|
---|
3042 | /** @def RT_UNION_NM
|
---|
3043 | * For compilers (like DTrace) that does not grok nameless unions, we have a
|
---|
3044 | * little hack to make them palatable.
|
---|
3045 | */
|
---|
3046 | /** @def RT_STRUCT_NM
|
---|
3047 | * For compilers (like DTrace) that does not grok nameless structs (it is
|
---|
3048 | * non-standard C++), we have a little hack to make them palatable.
|
---|
3049 | */
|
---|
3050 | #ifdef IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
3051 | # define RT_UNION_NM(a_Nm) a_Nm
|
---|
3052 | # define RT_STRUCT_NM(a_Nm) a_Nm
|
---|
3053 | #else
|
---|
3054 | # define RT_UNION_NM(a_Nm)
|
---|
3055 | # define RT_STRUCT_NM(a_Nm)
|
---|
3056 | #endif
|
---|
3057 |
|
---|
3058 | /**
|
---|
3059 | * Checks if the value is a power of two.
|
---|
3060 | *
|
---|
3061 | * @returns true if power of two, false if not.
|
---|
3062 | * @param uVal The value to test.
|
---|
3063 | * @remarks 0 is a power of two.
|
---|
3064 | * @see VERR_NOT_POWER_OF_TWO
|
---|
3065 | */
|
---|
3066 | #define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
|
---|
3067 |
|
---|
3068 | #ifdef RT_OS_OS2
|
---|
3069 | /* Undefine RT_MAX since there is an unfortunate clash with the max
|
---|
3070 | resource type define in os2.h. */
|
---|
3071 | # undef RT_MAX
|
---|
3072 | #endif
|
---|
3073 |
|
---|
3074 | /** @def RT_MAX
|
---|
3075 | * Finds the maximum value.
|
---|
3076 | * @returns The higher of the two.
|
---|
3077 | * @param Value1 Value 1
|
---|
3078 | * @param Value2 Value 2
|
---|
3079 | */
|
---|
3080 | #define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
|
---|
3081 |
|
---|
3082 | /** @def RT_MIN
|
---|
3083 | * Finds the minimum value.
|
---|
3084 | * @returns The lower of the two.
|
---|
3085 | * @param Value1 Value 1
|
---|
3086 | * @param Value2 Value 2
|
---|
3087 | */
|
---|
3088 | #define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
|
---|
3089 |
|
---|
3090 | /** @def RT_CLAMP
|
---|
3091 | * Clamps the value to minimum and maximum values.
|
---|
3092 | * @returns The clamped value.
|
---|
3093 | * @param Value The value to check.
|
---|
3094 | * @param Min Minimum value.
|
---|
3095 | * @param Max Maximum value.
|
---|
3096 | */
|
---|
3097 | #define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
|
---|
3098 |
|
---|
3099 | /** @def RT_ABS
|
---|
3100 | * Get the absolute (non-negative) value.
|
---|
3101 | * @returns The absolute value of Value.
|
---|
3102 | * @param Value The value.
|
---|
3103 | */
|
---|
3104 | #define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
|
---|
3105 |
|
---|
3106 | /** @def RT_BOOL
|
---|
3107 | * Turn non-zero/zero into true/false
|
---|
3108 | * @returns The resulting boolean value.
|
---|
3109 | * @param Value The value.
|
---|
3110 | */
|
---|
3111 | #define RT_BOOL(Value) ( !!(Value) )
|
---|
3112 |
|
---|
3113 | /** @def RT_LO_U8
|
---|
3114 | * Gets the low uint8_t of a uint16_t or something equivalent. */
|
---|
3115 | #ifdef __GNUC__
|
---|
3116 | # define RT_LO_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)(a); })
|
---|
3117 | #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
|
---|
3118 | # define RT_LO_U8(a) ( (uint8_t)(UINT8_MAX & (a)) )
|
---|
3119 | #else
|
---|
3120 | # define RT_LO_U8(a) ( (uint8_t)(a) )
|
---|
3121 | #endif
|
---|
3122 | /** @def RT_HI_U8
|
---|
3123 | * Gets the high uint8_t of a uint16_t or something equivalent. */
|
---|
3124 | #ifdef __GNUC__
|
---|
3125 | # define RT_HI_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)((a) >> 8); })
|
---|
3126 | #else
|
---|
3127 | # define RT_HI_U8(a) ( (uint8_t)((a) >> 8) )
|
---|
3128 | #endif
|
---|
3129 |
|
---|
3130 | /** @def RT_LO_U16
|
---|
3131 | * Gets the low uint16_t of a uint32_t or something equivalent. */
|
---|
3132 | #ifdef __GNUC__
|
---|
3133 | # define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)(a); })
|
---|
3134 | #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
|
---|
3135 | # define RT_LO_U16(a) ( (uint16_t)(UINT16_MAX & (a)) )
|
---|
3136 | #else
|
---|
3137 | # define RT_LO_U16(a) ( (uint16_t)(a) )
|
---|
3138 | #endif
|
---|
3139 | /** @def RT_HI_U16
|
---|
3140 | * Gets the high uint16_t of a uint32_t or something equivalent. */
|
---|
3141 | #ifdef __GNUC__
|
---|
3142 | # define RT_HI_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)((a) >> 16); })
|
---|
3143 | #else
|
---|
3144 | # define RT_HI_U16(a) ( (uint16_t)((a) >> 16) )
|
---|
3145 | #endif
|
---|
3146 |
|
---|
3147 | /** @def RT_LO_U32
|
---|
3148 | * Gets the low uint32_t of a uint64_t or something equivalent. */
|
---|
3149 | #ifdef __GNUC__
|
---|
3150 | # define RT_LO_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
|
---|
3151 | #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
|
---|
3152 | # define RT_LO_U32(a) ( (uint32_t)(UINT32_MAX & (a)) )
|
---|
3153 | #else
|
---|
3154 | # define RT_LO_U32(a) ( (uint32_t)(a) )
|
---|
3155 | #endif
|
---|
3156 | /** @def RT_HI_U32
|
---|
3157 | * Gets the high uint32_t of a uint64_t or something equivalent. */
|
---|
3158 | #ifdef __GNUC__
|
---|
3159 | # define RT_HI_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)((a) >> 32); })
|
---|
3160 | #else
|
---|
3161 | # define RT_HI_U32(a) ( (uint32_t)((a) >> 32) )
|
---|
3162 | #endif
|
---|
3163 |
|
---|
3164 | /** @def RT_BYTE1
|
---|
3165 | * Gets the first byte of something. */
|
---|
3166 | #define RT_BYTE1(a) ( (uint8_t)((a) & 0xff) )
|
---|
3167 | /** @def RT_BYTE2
|
---|
3168 | * Gets the second byte of something. */
|
---|
3169 | #define RT_BYTE2(a) ( (uint8_t)(((a) >> 8) & 0xff) )
|
---|
3170 | /** @def RT_BYTE3
|
---|
3171 | * Gets the second byte of something. */
|
---|
3172 | #define RT_BYTE3(a) ( (uint8_t)(((a) >> 16) & 0xff) )
|
---|
3173 | /** @def RT_BYTE4
|
---|
3174 | * Gets the fourth byte of something. */
|
---|
3175 | #define RT_BYTE4(a) ( (uint8_t)(((a) >> 24) & 0xff) )
|
---|
3176 | /** @def RT_BYTE5
|
---|
3177 | * Gets the fifth byte of something. */
|
---|
3178 | #define RT_BYTE5(a) ( (uint8_t)(((a) >> 32) & 0xff) )
|
---|
3179 | /** @def RT_BYTE6
|
---|
3180 | * Gets the sixth byte of something. */
|
---|
3181 | #define RT_BYTE6(a) ( (uint8_t)(((a) >> 40) & 0xff) )
|
---|
3182 | /** @def RT_BYTE7
|
---|
3183 | * Gets the seventh byte of something. */
|
---|
3184 | #define RT_BYTE7(a) ( (uint8_t)(((a) >> 48) & 0xff) )
|
---|
3185 | /** @def RT_BYTE8
|
---|
3186 | * Gets the eight byte of something. */
|
---|
3187 | #define RT_BYTE8(a) ( (uint8_t)(((a) >> 56) & 0xff) )
|
---|
3188 |
|
---|
3189 |
|
---|
3190 | /** @def RT_LODWORD
|
---|
3191 | * Gets the low dword (=uint32_t) of something.
|
---|
3192 | * @deprecated Use RT_LO_U32. */
|
---|
3193 | #define RT_LODWORD(a) ( (uint32_t)(a) )
|
---|
3194 | /** @def RT_HIDWORD
|
---|
3195 | * Gets the high dword (=uint32_t) of a 64-bit of something.
|
---|
3196 | * @deprecated Use RT_HI_U32. */
|
---|
3197 | #define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
|
---|
3198 |
|
---|
3199 | /** @def RT_LOWORD
|
---|
3200 | * Gets the low word (=uint16_t) of something.
|
---|
3201 | * @deprecated Use RT_LO_U16. */
|
---|
3202 | #define RT_LOWORD(a) ( (a) & 0xffff )
|
---|
3203 | /** @def RT_HIWORD
|
---|
3204 | * Gets the high word (=uint16_t) of a 32-bit something.
|
---|
3205 | * @deprecated Use RT_HI_U16. */
|
---|
3206 | #define RT_HIWORD(a) ( (a) >> 16 )
|
---|
3207 |
|
---|
3208 | /** @def RT_LOBYTE
|
---|
3209 | * Gets the low byte of something.
|
---|
3210 | * @deprecated Use RT_LO_U8. */
|
---|
3211 | #define RT_LOBYTE(a) ( (a) & 0xff )
|
---|
3212 | /** @def RT_HIBYTE
|
---|
3213 | * Gets the high byte of a 16-bit something.
|
---|
3214 | * @deprecated Use RT_HI_U8. */
|
---|
3215 | #define RT_HIBYTE(a) ( (a) >> 8 )
|
---|
3216 |
|
---|
3217 |
|
---|
3218 | /** @def RT_MAKE_U64
|
---|
3219 | * Constructs a uint64_t value from two uint32_t values.
|
---|
3220 | */
|
---|
3221 | #define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
|
---|
3222 |
|
---|
3223 | /** @def RT_MAKE_U64_FROM_U16
|
---|
3224 | * Constructs a uint64_t value from four uint16_t values.
|
---|
3225 | */
|
---|
3226 | #define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
|
---|
3227 | ((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
|
---|
3228 | | (uint64_t)((uint16_t)(w2)) << 32 \
|
---|
3229 | | (uint32_t)((uint16_t)(w1)) << 16 \
|
---|
3230 | | (uint16_t)(w0) ))
|
---|
3231 |
|
---|
3232 | /** @def RT_MAKE_U64_FROM_U8
|
---|
3233 | * Constructs a uint64_t value from eight uint8_t values.
|
---|
3234 | */
|
---|
3235 | #define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
|
---|
3236 | ((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
|
---|
3237 | | (uint64_t)((uint8_t)(b6)) << 48 \
|
---|
3238 | | (uint64_t)((uint8_t)(b5)) << 40 \
|
---|
3239 | | (uint64_t)((uint8_t)(b4)) << 32 \
|
---|
3240 | | (uint64_t)((uint8_t)(b3)) << 24 \
|
---|
3241 | | (uint64_t)((uint8_t)(b2)) << 16 \
|
---|
3242 | | (uint64_t)((uint8_t)(b1)) << 8 \
|
---|
3243 | | (uint64_t) (uint8_t)(b0) ))
|
---|
3244 |
|
---|
3245 | /** @def RT_MAKE_U32
|
---|
3246 | * Constructs a uint32_t value from two uint16_t values.
|
---|
3247 | */
|
---|
3248 | #define RT_MAKE_U32(Lo, Hi) \
|
---|
3249 | ((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
|
---|
3250 | | (uint16_t)(Lo) ))
|
---|
3251 |
|
---|
3252 | /** @def RT_MAKE_U32_FROM_U8
|
---|
3253 | * Constructs a uint32_t value from four uint8_t values.
|
---|
3254 | */
|
---|
3255 | #define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
|
---|
3256 | ((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
|
---|
3257 | | (uint32_t)((uint8_t)(b2)) << 16 \
|
---|
3258 | | (uint32_t)((uint8_t)(b1)) << 8 \
|
---|
3259 | | (uint8_t)(b0) ))
|
---|
3260 |
|
---|
3261 | /** @def RT_MAKE_U16
|
---|
3262 | * Constructs a uint16_t value from two uint8_t values.
|
---|
3263 | */
|
---|
3264 | #define RT_MAKE_U16(Lo, Hi) \
|
---|
3265 | ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
|
---|
3266 | | (uint8_t)(Lo) ))
|
---|
3267 |
|
---|
3268 |
|
---|
3269 | /** @def RT_BSWAP_U64
|
---|
3270 | * Reverses the byte order of an uint64_t value. */
|
---|
3271 | #if defined(__GNUC__)
|
---|
3272 | # define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) ? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
|
---|
3273 | #else
|
---|
3274 | # define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
|
---|
3275 | #endif
|
---|
3276 |
|
---|
3277 | /** @def RT_BSWAP_U32
|
---|
3278 | * Reverses the byte order of an uint32_t value. */
|
---|
3279 | #if defined(__GNUC__)
|
---|
3280 | # define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) ? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
|
---|
3281 | #else
|
---|
3282 | # define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
|
---|
3283 | #endif
|
---|
3284 |
|
---|
3285 | /** @def RT_BSWAP_U16
|
---|
3286 | * Reverses the byte order of an uint16_t value. */
|
---|
3287 | #if defined(__GNUC__)
|
---|
3288 | # define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) ? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
|
---|
3289 | #else
|
---|
3290 | # define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
|
---|
3291 | #endif
|
---|
3292 |
|
---|
3293 | /** @def RT_BSWAP_S64
|
---|
3294 | * Reverses the byte order of an int64_t value. */
|
---|
3295 | #define RT_BSWAP_S64(i64) ((int64_t)RT_BSWAP_U64((uint64_t)i64))
|
---|
3296 |
|
---|
3297 | /** @def RT_BSWAP_S32
|
---|
3298 | * Reverses the byte order of an int32_t value. */
|
---|
3299 | #define RT_BSWAP_S32(i32) ((int32_t)RT_BSWAP_U32((uint32_t)i32))
|
---|
3300 |
|
---|
3301 | /** @def RT_BSWAP_S16
|
---|
3302 | * Reverses the byte order of an int16_t value. */
|
---|
3303 | #define RT_BSWAP_S16(i16) ((int16_t)RT_BSWAP_U16((uint16_t)i16))
|
---|
3304 |
|
---|
3305 |
|
---|
3306 | /** @def RT_BSWAP_U64_C
|
---|
3307 | * Reverses the byte order of an uint64_t constant. */
|
---|
3308 | #define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
|
---|
3309 |
|
---|
3310 | /** @def RT_BSWAP_U32_C
|
---|
3311 | * Reverses the byte order of an uint32_t constant. */
|
---|
3312 | #define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
|
---|
3313 |
|
---|
3314 | /** @def RT_BSWAP_U16_C
|
---|
3315 | * Reverses the byte order of an uint16_t constant. */
|
---|
3316 | #define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
|
---|
3317 |
|
---|
3318 | /** @def RT_BSWAP_S64_C
|
---|
3319 | * Reverses the byte order of an int64_t constant. */
|
---|
3320 | #define RT_BSWAP_S64_C(i64) ((int64_t)RT_MAKE_U64(RT_BSWAP_U32_C((uint64_t)(i64) >> 32), RT_BSWAP_U32_C((uint32_t)(i64))))
|
---|
3321 |
|
---|
3322 | /** @def RT_BSWAP_S32_C
|
---|
3323 | * Reverses the byte order of an int32_t constant. */
|
---|
3324 | #define RT_BSWAP_S32_C(i32) ((int32_t)RT_MAKE_U32_FROM_U8(RT_BYTE4(i32), RT_BYTE3(i32), RT_BYTE2(i32), RT_BYTE1(i)))
|
---|
3325 |
|
---|
3326 | /** @def RT_BSWAP_S16_C
|
---|
3327 | * Reverses the byte order of an uint16_t constant. */
|
---|
3328 | #define RT_BSWAP_S16_C(i16) ((int16_t)RT_MAKE_U16(RT_HIBYTE(i16), RT_LOBYTE(i16)))
|
---|
3329 |
|
---|
3330 |
|
---|
3331 |
|
---|
3332 | /** @name Host to/from little endian.
|
---|
3333 | * @note Typically requires iprt/asm.h to be included.
|
---|
3334 | * @{ */
|
---|
3335 |
|
---|
3336 | /** @def RT_H2LE_U64
|
---|
3337 | * Converts an uint64_t value from host to little endian byte order. */
|
---|
3338 | #ifdef RT_BIG_ENDIAN
|
---|
3339 | # define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
|
---|
3340 | #else
|
---|
3341 | # define RT_H2LE_U64(u64) (u64)
|
---|
3342 | #endif
|
---|
3343 |
|
---|
3344 | /** @def RT_H2LE_U64_C
|
---|
3345 | * Converts an uint64_t constant from host to little endian byte order. */
|
---|
3346 | #ifdef RT_BIG_ENDIAN
|
---|
3347 | # define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
|
---|
3348 | #else
|
---|
3349 | # define RT_H2LE_U64_C(u64) (u64)
|
---|
3350 | #endif
|
---|
3351 |
|
---|
3352 | /** @def RT_H2LE_U32
|
---|
3353 | * Converts an uint32_t value from host to little endian byte order. */
|
---|
3354 | #ifdef RT_BIG_ENDIAN
|
---|
3355 | # define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
|
---|
3356 | #else
|
---|
3357 | # define RT_H2LE_U32(u32) (u32)
|
---|
3358 | #endif
|
---|
3359 |
|
---|
3360 | /** @def RT_H2LE_U32_C
|
---|
3361 | * Converts an uint32_t constant from host to little endian byte order. */
|
---|
3362 | #ifdef RT_BIG_ENDIAN
|
---|
3363 | # define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
|
---|
3364 | #else
|
---|
3365 | # define RT_H2LE_U32_C(u32) (u32)
|
---|
3366 | #endif
|
---|
3367 |
|
---|
3368 | /** @def RT_H2LE_U16
|
---|
3369 | * Converts an uint16_t value from host to little endian byte order. */
|
---|
3370 | #ifdef RT_BIG_ENDIAN
|
---|
3371 | # define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
|
---|
3372 | #else
|
---|
3373 | # define RT_H2LE_U16(u16) (u16)
|
---|
3374 | #endif
|
---|
3375 |
|
---|
3376 | /** @def RT_H2LE_U16_C
|
---|
3377 | * Converts an uint16_t constant from host to little endian byte order. */
|
---|
3378 | #ifdef RT_BIG_ENDIAN
|
---|
3379 | # define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
|
---|
3380 | #else
|
---|
3381 | # define RT_H2LE_U16_C(u16) (u16)
|
---|
3382 | #endif
|
---|
3383 |
|
---|
3384 |
|
---|
3385 | /** @def RT_LE2H_U64
|
---|
3386 | * Converts an uint64_t value from little endian to host byte order. */
|
---|
3387 | #ifdef RT_BIG_ENDIAN
|
---|
3388 | # define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
|
---|
3389 | #else
|
---|
3390 | # define RT_LE2H_U64(u64) (u64)
|
---|
3391 | #endif
|
---|
3392 |
|
---|
3393 | /** @def RT_LE2H_U64_C
|
---|
3394 | * Converts an uint64_t constant from little endian to host byte order. */
|
---|
3395 | #ifdef RT_BIG_ENDIAN
|
---|
3396 | # define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
|
---|
3397 | #else
|
---|
3398 | # define RT_LE2H_U64_C(u64) (u64)
|
---|
3399 | #endif
|
---|
3400 |
|
---|
3401 | /** @def RT_LE2H_U32
|
---|
3402 | * Converts an uint32_t value from little endian to host byte order. */
|
---|
3403 | #ifdef RT_BIG_ENDIAN
|
---|
3404 | # define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
|
---|
3405 | #else
|
---|
3406 | # define RT_LE2H_U32(u32) (u32)
|
---|
3407 | #endif
|
---|
3408 |
|
---|
3409 | /** @def RT_LE2H_U32_C
|
---|
3410 | * Converts an uint32_t constant from little endian to host byte order. */
|
---|
3411 | #ifdef RT_BIG_ENDIAN
|
---|
3412 | # define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
|
---|
3413 | #else
|
---|
3414 | # define RT_LE2H_U32_C(u32) (u32)
|
---|
3415 | #endif
|
---|
3416 |
|
---|
3417 | /** @def RT_LE2H_U16
|
---|
3418 | * Converts an uint16_t value from little endian to host byte order. */
|
---|
3419 | #ifdef RT_BIG_ENDIAN
|
---|
3420 | # define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
|
---|
3421 | #else
|
---|
3422 | # define RT_LE2H_U16(u16) (u16)
|
---|
3423 | #endif
|
---|
3424 |
|
---|
3425 | /** @def RT_LE2H_U16_C
|
---|
3426 | * Converts an uint16_t constant from little endian to host byte order. */
|
---|
3427 | #ifdef RT_BIG_ENDIAN
|
---|
3428 | # define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
|
---|
3429 | #else
|
---|
3430 | # define RT_LE2H_U16_C(u16) (u16)
|
---|
3431 | #endif
|
---|
3432 |
|
---|
3433 | /** @def RT_H2LE_S64
|
---|
3434 | * Converts an int64_t value from host to little endian byte order. */
|
---|
3435 | #ifdef RT_BIG_ENDIAN
|
---|
3436 | # define RT_H2LE_S64(i64) RT_BSWAP_S64(i64)
|
---|
3437 | #else
|
---|
3438 | # define RT_H2LE_S64(i64) (i64)
|
---|
3439 | #endif
|
---|
3440 |
|
---|
3441 | /** @def RT_H2LE_S64_C
|
---|
3442 | * Converts an int64_t constant from host to little endian byte order. */
|
---|
3443 | #ifdef RT_BIG_ENDIAN
|
---|
3444 | # define RT_H2LE_S64_C(i64) RT_BSWAP_S64_C(i64)
|
---|
3445 | #else
|
---|
3446 | # define RT_H2LE_S64_C(i64) (i64)
|
---|
3447 | #endif
|
---|
3448 |
|
---|
3449 | /** @def RT_H2LE_S32
|
---|
3450 | * Converts an int32_t value from host to little endian byte order. */
|
---|
3451 | #ifdef RT_BIG_ENDIAN
|
---|
3452 | # define RT_H2LE_S32(i32) RT_BSWAP_S32(i32)
|
---|
3453 | #else
|
---|
3454 | # define RT_H2LE_S32(i32) (i32)
|
---|
3455 | #endif
|
---|
3456 |
|
---|
3457 | /** @def RT_H2LE_S32_C
|
---|
3458 | * Converts an int32_t constant from host to little endian byte order. */
|
---|
3459 | #ifdef RT_BIG_ENDIAN
|
---|
3460 | # define RT_H2LE_S32_C(i32) RT_BSWAP_S32_C(i32)
|
---|
3461 | #else
|
---|
3462 | # define RT_H2LE_S32_C(i32) (i32)
|
---|
3463 | #endif
|
---|
3464 |
|
---|
3465 | /** @def RT_H2LE_S16
|
---|
3466 | * Converts an int16_t value from host to little endian byte order. */
|
---|
3467 | #ifdef RT_BIG_ENDIAN
|
---|
3468 | # define RT_H2LE_S16(i16) RT_BSWAP_S16(i16)
|
---|
3469 | #else
|
---|
3470 | # define RT_H2LE_S16(i16) (i16)
|
---|
3471 | #endif
|
---|
3472 |
|
---|
3473 | /** @def RT_H2LE_S16_C
|
---|
3474 | * Converts an int16_t constant from host to little endian byte order. */
|
---|
3475 | #ifdef RT_BIG_ENDIAN
|
---|
3476 | # define RT_H2LE_S16_C(i16) RT_BSWAP_S16_C(i16)
|
---|
3477 | #else
|
---|
3478 | # define RT_H2LE_S16_C(i16) (i16)
|
---|
3479 | #endif
|
---|
3480 |
|
---|
3481 | /** @def RT_LE2H_S64
|
---|
3482 | * Converts an int64_t value from little endian to host byte order. */
|
---|
3483 | #ifdef RT_BIG_ENDIAN
|
---|
3484 | # define RT_LE2H_S64(i64) RT_BSWAP_S64(i64)
|
---|
3485 | #else
|
---|
3486 | # define RT_LE2H_S64(i64) (i64)
|
---|
3487 | #endif
|
---|
3488 |
|
---|
3489 | /** @def RT_LE2H_S64_C
|
---|
3490 | * Converts an int64_t constant from little endian to host byte order. */
|
---|
3491 | #ifdef RT_BIG_ENDIAN
|
---|
3492 | # define RT_LE2H_S64_C(i64) RT_BSWAP_S64_C(i64)
|
---|
3493 | #else
|
---|
3494 | # define RT_LE2H_S64_C(i64) (i64)
|
---|
3495 | #endif
|
---|
3496 |
|
---|
3497 | /** @def RT_LE2H_S32
|
---|
3498 | * Converts an int32_t value from little endian to host byte order. */
|
---|
3499 | #ifdef RT_BIG_ENDIAN
|
---|
3500 | # define RT_LE2H_S32(i32) RT_BSWAP_S32(i32)
|
---|
3501 | #else
|
---|
3502 | # define RT_LE2H_S32(i32) (i32)
|
---|
3503 | #endif
|
---|
3504 |
|
---|
3505 | /** @def RT_LE2H_S32_C
|
---|
3506 | * Converts an int32_t constant from little endian to host byte order. */
|
---|
3507 | #ifdef RT_BIG_ENDIAN
|
---|
3508 | # define RT_LE2H_S32_C(i32) RT_BSWAP_S32_C(i32)
|
---|
3509 | #else
|
---|
3510 | # define RT_LE2H_S32_C(i32) (i32)
|
---|
3511 | #endif
|
---|
3512 |
|
---|
3513 | /** @def RT_LE2H_S16
|
---|
3514 | * Converts an int16_t value from little endian to host byte order. */
|
---|
3515 | #ifdef RT_BIG_ENDIAN
|
---|
3516 | # define RT_LE2H_S16(i16) RT_BSWAP_S16(i16)
|
---|
3517 | #else
|
---|
3518 | # define RT_LE2H_S16(i16) (i16)
|
---|
3519 | #endif
|
---|
3520 |
|
---|
3521 | /** @def RT_LE2H_S16_C
|
---|
3522 | * Converts an int16_t constant from little endian to host byte order. */
|
---|
3523 | #ifdef RT_BIG_ENDIAN
|
---|
3524 | # define RT_LE2H_S16_C(i16) RT_BSWAP_S16_C(i16)
|
---|
3525 | #else
|
---|
3526 | # define RT_LE2H_S16_C(i16) (i16)
|
---|
3527 | #endif
|
---|
3528 |
|
---|
3529 | /** @} */
|
---|
3530 |
|
---|
3531 | /** @name Host to/from big endian.
|
---|
3532 | * @note Typically requires iprt/asm.h to be included.
|
---|
3533 | * @{ */
|
---|
3534 |
|
---|
3535 | /** @def RT_H2BE_U64
|
---|
3536 | * Converts an uint64_t value from host to big endian byte order. */
|
---|
3537 | #ifdef RT_BIG_ENDIAN
|
---|
3538 | # define RT_H2BE_U64(u64) (u64)
|
---|
3539 | #else
|
---|
3540 | # define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
|
---|
3541 | #endif
|
---|
3542 |
|
---|
3543 | /** @def RT_H2BE_U64_C
|
---|
3544 | * Converts an uint64_t constant from host to big endian byte order. */
|
---|
3545 | #ifdef RT_BIG_ENDIAN
|
---|
3546 | # define RT_H2BE_U64_C(u64) (u64)
|
---|
3547 | #else
|
---|
3548 | # define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
|
---|
3549 | #endif
|
---|
3550 |
|
---|
3551 | /** @def RT_H2BE_U32
|
---|
3552 | * Converts an uint32_t value from host to big endian byte order. */
|
---|
3553 | #ifdef RT_BIG_ENDIAN
|
---|
3554 | # define RT_H2BE_U32(u32) (u32)
|
---|
3555 | #else
|
---|
3556 | # define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
|
---|
3557 | #endif
|
---|
3558 |
|
---|
3559 | /** @def RT_H2BE_U32_C
|
---|
3560 | * Converts an uint32_t constant from host to big endian byte order. */
|
---|
3561 | #ifdef RT_BIG_ENDIAN
|
---|
3562 | # define RT_H2BE_U32_C(u32) (u32)
|
---|
3563 | #else
|
---|
3564 | # define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
|
---|
3565 | #endif
|
---|
3566 |
|
---|
3567 | /** @def RT_H2BE_U16
|
---|
3568 | * Converts an uint16_t value from host to big endian byte order. */
|
---|
3569 | #ifdef RT_BIG_ENDIAN
|
---|
3570 | # define RT_H2BE_U16(u16) (u16)
|
---|
3571 | #else
|
---|
3572 | # define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
|
---|
3573 | #endif
|
---|
3574 |
|
---|
3575 | /** @def RT_H2BE_U16_C
|
---|
3576 | * Converts an uint16_t constant from host to big endian byte order. */
|
---|
3577 | #ifdef RT_BIG_ENDIAN
|
---|
3578 | # define RT_H2BE_U16_C(u16) (u16)
|
---|
3579 | #else
|
---|
3580 | # define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
|
---|
3581 | #endif
|
---|
3582 |
|
---|
3583 | /** @def RT_BE2H_U64
|
---|
3584 | * Converts an uint64_t value from big endian to host byte order. */
|
---|
3585 | #ifdef RT_BIG_ENDIAN
|
---|
3586 | # define RT_BE2H_U64(u64) (u64)
|
---|
3587 | #else
|
---|
3588 | # define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
|
---|
3589 | #endif
|
---|
3590 |
|
---|
3591 | /** @def RT_BE2H_U64
|
---|
3592 | * Converts an uint64_t constant from big endian to host byte order. */
|
---|
3593 | #ifdef RT_BIG_ENDIAN
|
---|
3594 | # define RT_BE2H_U64_C(u64) (u64)
|
---|
3595 | #else
|
---|
3596 | # define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
|
---|
3597 | #endif
|
---|
3598 |
|
---|
3599 | /** @def RT_BE2H_U32
|
---|
3600 | * Converts an uint32_t value from big endian to host byte order. */
|
---|
3601 | #ifdef RT_BIG_ENDIAN
|
---|
3602 | # define RT_BE2H_U32(u32) (u32)
|
---|
3603 | #else
|
---|
3604 | # define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
|
---|
3605 | #endif
|
---|
3606 |
|
---|
3607 | /** @def RT_BE2H_U32_C
|
---|
3608 | * Converts an uint32_t value from big endian to host byte order. */
|
---|
3609 | #ifdef RT_BIG_ENDIAN
|
---|
3610 | # define RT_BE2H_U32_C(u32) (u32)
|
---|
3611 | #else
|
---|
3612 | # define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
|
---|
3613 | #endif
|
---|
3614 |
|
---|
3615 | /** @def RT_BE2H_U16
|
---|
3616 | * Converts an uint16_t value from big endian to host byte order. */
|
---|
3617 | #ifdef RT_BIG_ENDIAN
|
---|
3618 | # define RT_BE2H_U16(u16) (u16)
|
---|
3619 | #else
|
---|
3620 | # define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
|
---|
3621 | #endif
|
---|
3622 |
|
---|
3623 | /** @def RT_BE2H_U16_C
|
---|
3624 | * Converts an uint16_t constant from big endian to host byte order. */
|
---|
3625 | #ifdef RT_BIG_ENDIAN
|
---|
3626 | # define RT_BE2H_U16_C(u16) (u16)
|
---|
3627 | #else
|
---|
3628 | # define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
|
---|
3629 | #endif
|
---|
3630 |
|
---|
3631 | /** @def RT_H2BE_S64
|
---|
3632 | * Converts an int64_t value from host to big endian byte order. */
|
---|
3633 | #ifdef RT_BIG_ENDIAN
|
---|
3634 | # define RT_H2BE_S64(i64) (i64)
|
---|
3635 | #else
|
---|
3636 | # define RT_H2BE_S64(i64) RT_BSWAP_S64(i64)
|
---|
3637 | #endif
|
---|
3638 |
|
---|
3639 | /** @def RT_H2BE_S64_C
|
---|
3640 | * Converts an int64_t constant from host to big endian byte order. */
|
---|
3641 | #ifdef RT_BIG_ENDIAN
|
---|
3642 | # define RT_H2BE_S64_C(i64) (i64)
|
---|
3643 | #else
|
---|
3644 | # define RT_H2BE_S64_C(i64) RT_BSWAP_S64_C(i64)
|
---|
3645 | #endif
|
---|
3646 |
|
---|
3647 | /** @def RT_H2BE_S32
|
---|
3648 | * Converts an int32_t value from host to big endian byte order. */
|
---|
3649 | #ifdef RT_BIG_ENDIAN
|
---|
3650 | # define RT_H2BE_S32(i32) (i32)
|
---|
3651 | #else
|
---|
3652 | # define RT_H2BE_S32(i32) RT_BSWAP_S32(i32)
|
---|
3653 | #endif
|
---|
3654 |
|
---|
3655 | /** @def RT_H2BE_S32_C
|
---|
3656 | * Converts an int32_t constant from host to big endian byte order. */
|
---|
3657 | #ifdef RT_BIG_ENDIAN
|
---|
3658 | # define RT_H2BE_S32_C(i32) (i32)
|
---|
3659 | #else
|
---|
3660 | # define RT_H2BE_S32_C(i32) RT_BSWAP_S32_C(i32)
|
---|
3661 | #endif
|
---|
3662 |
|
---|
3663 | /** @def RT_H2BE_S16
|
---|
3664 | * Converts an int16_t value from host to big endian byte order. */
|
---|
3665 | #ifdef RT_BIG_ENDIAN
|
---|
3666 | # define RT_H2BE_S16(i16) (i16)
|
---|
3667 | #else
|
---|
3668 | # define RT_H2BE_S16(i16) RT_BSWAP_S16(i16)
|
---|
3669 | #endif
|
---|
3670 |
|
---|
3671 | /** @def RT_H2BE_S16_C
|
---|
3672 | * Converts an int16_t constant from host to big endian byte order. */
|
---|
3673 | #ifdef RT_BIG_ENDIAN
|
---|
3674 | # define RT_H2BE_S16_C(i16) (i16)
|
---|
3675 | #else
|
---|
3676 | # define RT_H2BE_S16_C(i16) RT_BSWAP_S16_C(i16)
|
---|
3677 | #endif
|
---|
3678 |
|
---|
3679 | /** @def RT_BE2H_S64
|
---|
3680 | * Converts an int64_t value from big endian to host byte order. */
|
---|
3681 | #ifdef RT_BIG_ENDIAN
|
---|
3682 | # define RT_BE2H_S64(i64) (i64)
|
---|
3683 | #else
|
---|
3684 | # define RT_BE2H_S64(i64) RT_BSWAP_S64(i64)
|
---|
3685 | #endif
|
---|
3686 |
|
---|
3687 | /** @def RT_BE2H_S64
|
---|
3688 | * Converts an int64_t constant from big endian to host byte order. */
|
---|
3689 | #ifdef RT_BIG_ENDIAN
|
---|
3690 | # define RT_BE2H_S64_C(i64) (i64)
|
---|
3691 | #else
|
---|
3692 | # define RT_BE2H_S64_C(i64) RT_BSWAP_S64_C(i64)
|
---|
3693 | #endif
|
---|
3694 |
|
---|
3695 | /** @def RT_BE2H_S32
|
---|
3696 | * Converts an int32_t value from big endian to host byte order. */
|
---|
3697 | #ifdef RT_BIG_ENDIAN
|
---|
3698 | # define RT_BE2H_S32(i32) (i32)
|
---|
3699 | #else
|
---|
3700 | # define RT_BE2H_S32(i32) RT_BSWAP_S32(i32)
|
---|
3701 | #endif
|
---|
3702 |
|
---|
3703 | /** @def RT_BE2H_S32_C
|
---|
3704 | * Converts an int32_t value from big endian to host byte order. */
|
---|
3705 | #ifdef RT_BIG_ENDIAN
|
---|
3706 | # define RT_BE2H_S32_C(i32) (i32)
|
---|
3707 | #else
|
---|
3708 | # define RT_BE2H_S32_C(i32) RT_BSWAP_S32_C(i32)
|
---|
3709 | #endif
|
---|
3710 |
|
---|
3711 | /** @def RT_BE2H_S16
|
---|
3712 | * Converts an int16_t value from big endian to host byte order. */
|
---|
3713 | #ifdef RT_BIG_ENDIAN
|
---|
3714 | # define RT_BE2H_S16(i16) (i16)
|
---|
3715 | #else
|
---|
3716 | # define RT_BE2H_S16(i16) RT_BSWAP_S16(i16)
|
---|
3717 | #endif
|
---|
3718 |
|
---|
3719 | /** @def RT_BE2H_S16_C
|
---|
3720 | * Converts an int16_t constant from big endian to host byte order. */
|
---|
3721 | #ifdef RT_BIG_ENDIAN
|
---|
3722 | # define RT_BE2H_S16_C(i16) (i16)
|
---|
3723 | #else
|
---|
3724 | # define RT_BE2H_S16_C(i16) RT_BSWAP_S16_C(i16)
|
---|
3725 | #endif
|
---|
3726 | /** @} */
|
---|
3727 |
|
---|
3728 | /** @name Host to/from network byte order.
|
---|
3729 | * @note Typically requires iprt/asm.h to be included.
|
---|
3730 | * @{ */
|
---|
3731 |
|
---|
3732 | /** @def RT_H2N_U64
|
---|
3733 | * Converts an uint64_t value from host to network byte order. */
|
---|
3734 | #define RT_H2N_U64(u64) RT_H2BE_U64(u64)
|
---|
3735 |
|
---|
3736 | /** @def RT_H2N_U64_C
|
---|
3737 | * Converts an uint64_t constant from host to network byte order. */
|
---|
3738 | #define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
|
---|
3739 |
|
---|
3740 | /** @def RT_H2N_U32
|
---|
3741 | * Converts an uint32_t value from host to network byte order. */
|
---|
3742 | #define RT_H2N_U32(u32) RT_H2BE_U32(u32)
|
---|
3743 |
|
---|
3744 | /** @def RT_H2N_U32_C
|
---|
3745 | * Converts an uint32_t constant from host to network byte order. */
|
---|
3746 | #define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
|
---|
3747 |
|
---|
3748 | /** @def RT_H2N_U16
|
---|
3749 | * Converts an uint16_t value from host to network byte order. */
|
---|
3750 | #define RT_H2N_U16(u16) RT_H2BE_U16(u16)
|
---|
3751 |
|
---|
3752 | /** @def RT_H2N_U16_C
|
---|
3753 | * Converts an uint16_t constant from host to network byte order. */
|
---|
3754 | #define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
|
---|
3755 |
|
---|
3756 | /** @def RT_N2H_U64
|
---|
3757 | * Converts an uint64_t value from network to host byte order. */
|
---|
3758 | #define RT_N2H_U64(u64) RT_BE2H_U64(u64)
|
---|
3759 |
|
---|
3760 | /** @def RT_N2H_U64_C
|
---|
3761 | * Converts an uint64_t constant from network to host byte order. */
|
---|
3762 | #define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
|
---|
3763 |
|
---|
3764 | /** @def RT_N2H_U32
|
---|
3765 | * Converts an uint32_t value from network to host byte order. */
|
---|
3766 | #define RT_N2H_U32(u32) RT_BE2H_U32(u32)
|
---|
3767 |
|
---|
3768 | /** @def RT_N2H_U32_C
|
---|
3769 | * Converts an uint32_t constant from network to host byte order. */
|
---|
3770 | #define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
|
---|
3771 |
|
---|
3772 | /** @def RT_N2H_U16
|
---|
3773 | * Converts an uint16_t value from network to host byte order. */
|
---|
3774 | #define RT_N2H_U16(u16) RT_BE2H_U16(u16)
|
---|
3775 |
|
---|
3776 | /** @def RT_N2H_U16_C
|
---|
3777 | * Converts an uint16_t value from network to host byte order. */
|
---|
3778 | #define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
|
---|
3779 |
|
---|
3780 | /** @def RT_H2N_S64
|
---|
3781 | * Converts an int64_t value from host to network byte order. */
|
---|
3782 | #define RT_H2N_S64(i64) RT_H2BE_S64(i64)
|
---|
3783 |
|
---|
3784 | /** @def RT_H2N_S64_C
|
---|
3785 | * Converts an int64_t constant from host to network byte order. */
|
---|
3786 | #define RT_H2N_S64_C(i64) RT_H2BE_S64_C(i64)
|
---|
3787 |
|
---|
3788 | /** @def RT_H2N_S32
|
---|
3789 | * Converts an int32_t value from host to network byte order. */
|
---|
3790 | #define RT_H2N_S32(i32) RT_H2BE_S32(i32)
|
---|
3791 |
|
---|
3792 | /** @def RT_H2N_S32_C
|
---|
3793 | * Converts an int32_t constant from host to network byte order. */
|
---|
3794 | #define RT_H2N_S32_C(i32) RT_H2BE_S32_C(i32)
|
---|
3795 |
|
---|
3796 | /** @def RT_H2N_S16
|
---|
3797 | * Converts an int16_t value from host to network byte order. */
|
---|
3798 | #define RT_H2N_S16(i16) RT_H2BE_S16(i16)
|
---|
3799 |
|
---|
3800 | /** @def RT_H2N_S16_C
|
---|
3801 | * Converts an int16_t constant from host to network byte order. */
|
---|
3802 | #define RT_H2N_S16_C(i16) RT_H2BE_S16_C(i16)
|
---|
3803 |
|
---|
3804 | /** @def RT_N2H_S64
|
---|
3805 | * Converts an int64_t value from network to host byte order. */
|
---|
3806 | #define RT_N2H_S64(i64) RT_BE2H_S64(i64)
|
---|
3807 |
|
---|
3808 | /** @def RT_N2H_S64_C
|
---|
3809 | * Converts an int64_t constant from network to host byte order. */
|
---|
3810 | #define RT_N2H_S64_C(i64) RT_BE2H_S64_C(i64)
|
---|
3811 |
|
---|
3812 | /** @def RT_N2H_S32
|
---|
3813 | * Converts an int32_t value from network to host byte order. */
|
---|
3814 | #define RT_N2H_S32(i32) RT_BE2H_S32(i32)
|
---|
3815 |
|
---|
3816 | /** @def RT_N2H_S32_C
|
---|
3817 | * Converts an int32_t constant from network to host byte order. */
|
---|
3818 | #define RT_N2H_S32_C(i32) RT_BE2H_S32_C(i32)
|
---|
3819 |
|
---|
3820 | /** @def RT_N2H_S16
|
---|
3821 | * Converts an int16_t value from network to host byte order. */
|
---|
3822 | #define RT_N2H_S16(i16) RT_BE2H_S16(i16)
|
---|
3823 |
|
---|
3824 | /** @def RT_N2H_S16_C
|
---|
3825 | * Converts an int16_t value from network to host byte order. */
|
---|
3826 | #define RT_N2H_S16_C(i16) RT_BE2H_S16_C(i16)
|
---|
3827 |
|
---|
3828 | /** @} */
|
---|
3829 |
|
---|
3830 |
|
---|
3831 | /*
|
---|
3832 | * The BSD sys/param.h + machine/param.h file is a major source of
|
---|
3833 | * namespace pollution. Kill off some of the worse ones unless we're
|
---|
3834 | * compiling kernel code.
|
---|
3835 | */
|
---|
3836 | #if defined(RT_OS_DARWIN) \
|
---|
3837 | && !defined(KERNEL) \
|
---|
3838 | && !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
|
---|
3839 | && ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
|
---|
3840 | /* sys/param.h: */
|
---|
3841 | # undef PSWP
|
---|
3842 | # undef PVM
|
---|
3843 | # undef PINOD
|
---|
3844 | # undef PRIBO
|
---|
3845 | # undef PVFS
|
---|
3846 | # undef PZERO
|
---|
3847 | # undef PSOCK
|
---|
3848 | # undef PWAIT
|
---|
3849 | # undef PLOCK
|
---|
3850 | # undef PPAUSE
|
---|
3851 | # undef PUSER
|
---|
3852 | # undef PRIMASK
|
---|
3853 | # undef MINBUCKET
|
---|
3854 | # undef MAXALLOCSAVE
|
---|
3855 | # undef FSHIFT
|
---|
3856 | # undef FSCALE
|
---|
3857 |
|
---|
3858 | /* i386/machine.h: */
|
---|
3859 | # undef ALIGN
|
---|
3860 | # undef ALIGNBYTES
|
---|
3861 | # undef DELAY
|
---|
3862 | # undef STATUS_WORD
|
---|
3863 | # undef USERMODE
|
---|
3864 | # undef BASEPRI
|
---|
3865 | # undef MSIZE
|
---|
3866 | # undef CLSIZE
|
---|
3867 | # undef CLSIZELOG2
|
---|
3868 | #endif
|
---|
3869 |
|
---|
3870 | /** @def NIL_OFFSET
|
---|
3871 | * NIL offset.
|
---|
3872 | * Whenever we use offsets instead of pointers to save space and relocation effort
|
---|
3873 | * NIL_OFFSET shall be used as the equivalent to NULL.
|
---|
3874 | */
|
---|
3875 | #define NIL_OFFSET (~0U)
|
---|
3876 |
|
---|
3877 |
|
---|
3878 | /** @def NOREF
|
---|
3879 | * Keeps the compiler from bitching about an unused parameter, local variable,
|
---|
3880 | * or other stuff, will never use _Pragma are is thus more flexible.
|
---|
3881 | */
|
---|
3882 | #define NOREF(var) (void)(var)
|
---|
3883 |
|
---|
3884 | /** @def RT_NOREF_PV
|
---|
3885 | * Keeps the compiler from bitching about an unused parameter or local variable.
|
---|
3886 | * This one cannot be used with structure members and such, like for instance
|
---|
3887 | * AssertRC may end up doing due to its generic nature.
|
---|
3888 | */
|
---|
3889 | #if defined(__cplusplus) && RT_CLANG_PREREQ(6, 0)
|
---|
3890 | # define RT_NOREF_PV(var) _Pragma(RT_STR(unused(var)))
|
---|
3891 | #else
|
---|
3892 | # define RT_NOREF_PV(var) (void)(var)
|
---|
3893 | #endif
|
---|
3894 |
|
---|
3895 | /** @def RT_NOREF1
|
---|
3896 | * RT_NOREF_PV shorthand taking on parameter. */
|
---|
3897 | #define RT_NOREF1(var1) RT_NOREF_PV(var1)
|
---|
3898 | /** @def RT_NOREF2
|
---|
3899 | * RT_NOREF_PV shorthand taking two parameters. */
|
---|
3900 | #define RT_NOREF2(var1, var2) RT_NOREF_PV(var1); RT_NOREF1(var2)
|
---|
3901 | /** @def RT_NOREF3
|
---|
3902 | * RT_NOREF_PV shorthand taking three parameters. */
|
---|
3903 | #define RT_NOREF3(var1, var2, var3) RT_NOREF_PV(var1); RT_NOREF2(var2, var3)
|
---|
3904 | /** @def RT_NOREF4
|
---|
3905 | * RT_NOREF_PV shorthand taking four parameters. */
|
---|
3906 | #define RT_NOREF4(var1, var2, var3, var4) RT_NOREF_PV(var1); RT_NOREF3(var2, var3, var4)
|
---|
3907 | /** @def RT_NOREF5
|
---|
3908 | * RT_NOREF_PV shorthand taking five parameters. */
|
---|
3909 | #define RT_NOREF5(var1, var2, var3, var4, var5) RT_NOREF_PV(var1); RT_NOREF4(var2, var3, var4, var5)
|
---|
3910 | /** @def RT_NOREF6
|
---|
3911 | * RT_NOREF_PV shorthand taking six parameters. */
|
---|
3912 | #define RT_NOREF6(var1, var2, var3, var4, var5, var6) RT_NOREF_PV(var1); RT_NOREF5(var2, var3, var4, var5, var6)
|
---|
3913 | /** @def RT_NOREF7
|
---|
3914 | * RT_NOREF_PV shorthand taking seven parameters. */
|
---|
3915 | #define RT_NOREF7(var1, var2, var3, var4, var5, var6, var7) \
|
---|
3916 | RT_NOREF_PV(var1); RT_NOREF6(var2, var3, var4, var5, var6, var7)
|
---|
3917 | /** @def RT_NOREF8
|
---|
3918 | * RT_NOREF_PV shorthand taking eight parameters. */
|
---|
3919 | #define RT_NOREF8(var1, var2, var3, var4, var5, var6, var7, var8) \
|
---|
3920 | RT_NOREF_PV(var1); RT_NOREF7(var2, var3, var4, var5, var6, var7, var8)
|
---|
3921 | /** @def RT_NOREF9
|
---|
3922 | * RT_NOREF_PV shorthand taking nine parameters. */
|
---|
3923 | #define RT_NOREF9(var1, var2, var3, var4, var5, var6, var7, var8, var9) \
|
---|
3924 | RT_NOREF_PV(var1); RT_NOREF8(var2, var3, var4, var5, var6, var7, var8, var9)
|
---|
3925 | /** @def RT_NOREF10
|
---|
3926 | * RT_NOREF_PV shorthand taking ten parameters. */
|
---|
3927 | #define RT_NOREF10(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10) \
|
---|
3928 | RT_NOREF_PV(var1); RT_NOREF_PV(var2); RT_NOREF_PV(var3); RT_NOREF_PV(var4); RT_NOREF_PV(var5); RT_NOREF_PV(var6); \
|
---|
3929 | RT_NOREF_PV(var7); RT_NOREF_PV(var8); RT_NOREF_PV(var9); RT_NOREF_PV(var10)
|
---|
3930 | /** @def RT_NOREF11
|
---|
3931 | * RT_NOREF_PV shorthand taking eleven parameters. */
|
---|
3932 | #define RT_NOREF11(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11) \
|
---|
3933 | RT_NOREF_PV(var1); RT_NOREF10(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11)
|
---|
3934 | /** @def RT_NOREF12
|
---|
3935 | * RT_NOREF_PV shorthand taking twelve parameters. */
|
---|
3936 | #define RT_NOREF12(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12) \
|
---|
3937 | RT_NOREF_PV(var1); RT_NOREF11(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12)
|
---|
3938 | /** @def RT_NOREF13
|
---|
3939 | * RT_NOREF_PV shorthand taking thirteen parameters. */
|
---|
3940 | #define RT_NOREF13(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13) \
|
---|
3941 | RT_NOREF_PV(var1); RT_NOREF12(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13)
|
---|
3942 | /** @def RT_NOREF14
|
---|
3943 | * RT_NOREF_PV shorthand taking fourteen parameters. */
|
---|
3944 | #define RT_NOREF14(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14) \
|
---|
3945 | RT_NOREF_PV(var1); RT_NOREF13(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14)
|
---|
3946 | /** @def RT_NOREF15
|
---|
3947 | * RT_NOREF_PV shorthand taking fifteen parameters. */
|
---|
3948 | #define RT_NOREF15(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15) \
|
---|
3949 | RT_NOREF_PV(var1); RT_NOREF14(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15)
|
---|
3950 | /** @def RT_NOREF16
|
---|
3951 | * RT_NOREF_PV shorthand taking fifteen parameters. */
|
---|
3952 | #define RT_NOREF16(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16) \
|
---|
3953 | RT_NOREF_PV(var1); RT_NOREF15(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16)
|
---|
3954 | /** @def RT_NOREF17
|
---|
3955 | * RT_NOREF_PV shorthand taking seventeen parameters. */
|
---|
3956 | #define RT_NOREF17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \
|
---|
3957 | RT_NOREF_PV(v1); RT_NOREF16(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
|
---|
3958 | /** @def RT_NOREF18
|
---|
3959 | * RT_NOREF_PV shorthand taking eighteen parameters. */
|
---|
3960 | #define RT_NOREF18(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \
|
---|
3961 | RT_NOREF_PV(v1); RT_NOREF17(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
|
---|
3962 | /** @def RT_NOREF19
|
---|
3963 | * RT_NOREF_PV shorthand taking nineteen parameters. */
|
---|
3964 | #define RT_NOREF19(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \
|
---|
3965 | RT_NOREF_PV(v1); RT_NOREF18(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
|
---|
3966 | /** @def RT_NOREF20
|
---|
3967 | * RT_NOREF_PV shorthand taking twenty parameters. */
|
---|
3968 | #define RT_NOREF20(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \
|
---|
3969 | RT_NOREF_PV(v1); RT_NOREF19(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
|
---|
3970 | /** @def RT_NOREF21
|
---|
3971 | * RT_NOREF_PV shorthand taking twentyone parameters. */
|
---|
3972 | #define RT_NOREF21(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \
|
---|
3973 | RT_NOREF_PV(v1); RT_NOREF20(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
|
---|
3974 | /** @def RT_NOREF22
|
---|
3975 | * RT_NOREF_PV shorthand taking twentytwo parameters. */
|
---|
3976 | #define RT_NOREF22(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) \
|
---|
3977 | RT_NOREF_PV(v1); RT_NOREF21(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
|
---|
3978 |
|
---|
3979 | /** @def RT_NOREF
|
---|
3980 | * RT_NOREF_PV variant using the variadic macro feature of C99.
|
---|
3981 | * @remarks Only use this in sources */
|
---|
3982 | #ifdef RT_COMPILER_SUPPORTS_VA_ARGS
|
---|
3983 | # define RT_NOREF(...) \
|
---|
3984 | RT_UNPACK_CALL(RT_CONCAT(RT_NOREF, RT_EXPAND(RT_COUNT_VA_ARGS(__VA_ARGS__))),(__VA_ARGS__))
|
---|
3985 | #endif
|
---|
3986 |
|
---|
3987 |
|
---|
3988 | /** @def RT_BREAKPOINT
|
---|
3989 | * Emit a debug breakpoint instruction.
|
---|
3990 | *
|
---|
3991 | * @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
|
---|
3992 | * to force gdb to remain at the int3 source line.
|
---|
3993 | * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
|
---|
3994 | * x86/amd64.
|
---|
3995 | */
|
---|
3996 | #ifdef __GNUC__
|
---|
3997 | # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
3998 | # if !defined(__L4ENV__)
|
---|
3999 | # define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
|
---|
4000 | # else
|
---|
4001 | # define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
|
---|
4002 | # endif
|
---|
4003 | # elif defined(RT_ARCH_SPARC64)
|
---|
4004 | # define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
|
---|
4005 | # elif defined(RT_ARCH_SPARC)
|
---|
4006 | # define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
|
---|
4007 | # elif defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64)
|
---|
4008 | # define RT_BREAKPOINT() __asm__ __volatile__("brk #0x1\n\t")
|
---|
4009 | # endif
|
---|
4010 | #endif
|
---|
4011 | #ifdef _MSC_VER
|
---|
4012 | # define RT_BREAKPOINT() __debugbreak()
|
---|
4013 | #endif
|
---|
4014 | #if defined(__IBMC__) || defined(__IBMCPP__)
|
---|
4015 | # define RT_BREAKPOINT() __interrupt(3)
|
---|
4016 | #endif
|
---|
4017 | #if defined(__WATCOMC__)
|
---|
4018 | # define RT_BREAKPOINT() _asm { int 3 }
|
---|
4019 | #endif
|
---|
4020 | #ifndef RT_BREAKPOINT
|
---|
4021 | # error "This compiler/arch is not supported!"
|
---|
4022 | #endif
|
---|
4023 |
|
---|
4024 |
|
---|
4025 | /** @defgroup grp_rt_cdefs_size Size Constants
|
---|
4026 | * (Of course, these are binary computer terms, not SI.)
|
---|
4027 | * @{
|
---|
4028 | */
|
---|
4029 | /** 1 K (Kilo) (1 024). */
|
---|
4030 | #define _1K 0x00000400
|
---|
4031 | /** 2 K (Kilo) (2 048). */
|
---|
4032 | #define _2K 0x00000800
|
---|
4033 | /** 4 K (Kilo) (4 096). */
|
---|
4034 | #define _4K 0x00001000
|
---|
4035 | /** 8 K (Kilo) (8 192). */
|
---|
4036 | #define _8K 0x00002000
|
---|
4037 | /** 16 K (Kilo) (16 384). */
|
---|
4038 | #define _16K 0x00004000
|
---|
4039 | /** 32 K (Kilo) (32 768). */
|
---|
4040 | #define _32K 0x00008000
|
---|
4041 | /** 64 K (Kilo) (65 536). */
|
---|
4042 | #if ARCH_BITS != 16
|
---|
4043 | # define _64K 0x00010000
|
---|
4044 | #else
|
---|
4045 | # define _64K UINT32_C(0x00010000)
|
---|
4046 | #endif
|
---|
4047 | /** 128 K (Kilo) (131 072). */
|
---|
4048 | #if ARCH_BITS != 16
|
---|
4049 | # define _128K 0x00020000
|
---|
4050 | #else
|
---|
4051 | # define _128K UINT32_C(0x00020000)
|
---|
4052 | #endif
|
---|
4053 | /** 256 K (Kilo) (262 144). */
|
---|
4054 | #if ARCH_BITS != 16
|
---|
4055 | # define _256K 0x00040000
|
---|
4056 | #else
|
---|
4057 | # define _256K UINT32_C(0x00040000)
|
---|
4058 | #endif
|
---|
4059 | /** 512 K (Kilo) (524 288). */
|
---|
4060 | #if ARCH_BITS != 16
|
---|
4061 | # define _512K 0x00080000
|
---|
4062 | #else
|
---|
4063 | # define _512K UINT32_C(0x00080000)
|
---|
4064 | #endif
|
---|
4065 | /** 1 M (Mega) (1 048 576). */
|
---|
4066 | #if ARCH_BITS != 16
|
---|
4067 | # define _1M 0x00100000
|
---|
4068 | #else
|
---|
4069 | # define _1M UINT32_C(0x00100000)
|
---|
4070 | #endif
|
---|
4071 | /** 2 M (Mega) (2 097 152). */
|
---|
4072 | #if ARCH_BITS != 16
|
---|
4073 | # define _2M 0x00200000
|
---|
4074 | #else
|
---|
4075 | # define _2M UINT32_C(0x00200000)
|
---|
4076 | #endif
|
---|
4077 | /** 4 M (Mega) (4 194 304). */
|
---|
4078 | #if ARCH_BITS != 16
|
---|
4079 | # define _4M 0x00400000
|
---|
4080 | #else
|
---|
4081 | # define _4M UINT32_C(0x00400000)
|
---|
4082 | #endif
|
---|
4083 | /** 8 M (Mega) (8 388 608). */
|
---|
4084 | #define _8M UINT32_C(0x00800000)
|
---|
4085 | /** 16 M (Mega) (16 777 216). */
|
---|
4086 | #define _16M UINT32_C(0x01000000)
|
---|
4087 | /** 32 M (Mega) (33 554 432). */
|
---|
4088 | #define _32M UINT32_C(0x02000000)
|
---|
4089 | /** 64 M (Mega) (67 108 864). */
|
---|
4090 | #define _64M UINT32_C(0x04000000)
|
---|
4091 | /** 128 M (Mega) (134 217 728). */
|
---|
4092 | #define _128M UINT32_C(0x08000000)
|
---|
4093 | /** 256 M (Mega) (268 435 456). */
|
---|
4094 | #define _256M UINT32_C(0x10000000)
|
---|
4095 | /** 512 M (Mega) (536 870 912). */
|
---|
4096 | #define _512M UINT32_C(0x20000000)
|
---|
4097 | /** 1 G (Giga) (1 073 741 824). (32-bit) */
|
---|
4098 | #if ARCH_BITS != 16
|
---|
4099 | # define _1G 0x40000000
|
---|
4100 | #else
|
---|
4101 | # define _1G UINT32_C(0x40000000)
|
---|
4102 | #endif
|
---|
4103 | /** 1 G (Giga) (1 073 741 824). (64-bit) */
|
---|
4104 | #if ARCH_BITS != 16
|
---|
4105 | # define _1G64 0x40000000LL
|
---|
4106 | #else
|
---|
4107 | # define _1G64 UINT64_C(0x40000000)
|
---|
4108 | #endif
|
---|
4109 | /** 2 G (Giga) (2 147 483 648). (32-bit) */
|
---|
4110 | #define _2G32 UINT32_C(0x80000000)
|
---|
4111 | /** 2 G (Giga) (2 147 483 648). (64-bit) */
|
---|
4112 | #if ARCH_BITS != 16
|
---|
4113 | # define _2G 0x0000000080000000LL
|
---|
4114 | #else
|
---|
4115 | # define _2G UINT64_C(0x0000000080000000)
|
---|
4116 | #endif
|
---|
4117 | /** 4 G (Giga) (4 294 967 296). */
|
---|
4118 | #if ARCH_BITS != 16
|
---|
4119 | # define _4G 0x0000000100000000LL
|
---|
4120 | #else
|
---|
4121 | # define _4G UINT64_C(0x0000000100000000)
|
---|
4122 | #endif
|
---|
4123 | /** 1 T (Tera) (1 099 511 627 776). */
|
---|
4124 | #if ARCH_BITS != 16
|
---|
4125 | # define _1T 0x0000010000000000LL
|
---|
4126 | #else
|
---|
4127 | # define _1T UINT64_C(0x0000010000000000)
|
---|
4128 | #endif
|
---|
4129 | /** 1 P (Peta) (1 125 899 906 842 624). */
|
---|
4130 | #if ARCH_BITS != 16
|
---|
4131 | # define _1P 0x0004000000000000LL
|
---|
4132 | #else
|
---|
4133 | # define _1P UINT64_C(0x0004000000000000)
|
---|
4134 | #endif
|
---|
4135 | /** 1 E (Exa) (1 152 921 504 606 846 976). */
|
---|
4136 | #if ARCH_BITS != 16
|
---|
4137 | # define _1E 0x1000000000000000LL
|
---|
4138 | #else
|
---|
4139 | # define _1E UINT64_C(0x1000000000000000)
|
---|
4140 | #endif
|
---|
4141 | /** 2 E (Exa) (2 305 843 009 213 693 952). */
|
---|
4142 | #if ARCH_BITS != 16
|
---|
4143 | # define _2E 0x2000000000000000ULL
|
---|
4144 | #else
|
---|
4145 | # define _2E UINT64_C(0x2000000000000000)
|
---|
4146 | #endif
|
---|
4147 | /** @} */
|
---|
4148 |
|
---|
4149 | /** @defgroup grp_rt_cdefs_decimal_grouping Decimal Constant Grouping Macros
|
---|
4150 | * @{ */
|
---|
4151 | #define RT_D1(g1) g1
|
---|
4152 | #define RT_D2(g1, g2) g1#g2
|
---|
4153 | #define RT_D3(g1, g2, g3) g1#g2#g3
|
---|
4154 | #define RT_D4(g1, g2, g3, g4) g1#g2#g3#g4
|
---|
4155 | #define RT_D5(g1, g2, g3, g4, g5) g1#g2#g3#g4#g5
|
---|
4156 | #define RT_D6(g1, g2, g3, g4, g5, g6) g1#g2#g3#g4#g5#g6
|
---|
4157 | #define RT_D7(g1, g2, g3, g4, g5, g6, g7) g1#g2#g3#g4#g5#g6#g7
|
---|
4158 |
|
---|
4159 | #define RT_D1_U(g1) UINT32_C(g1)
|
---|
4160 | #define RT_D2_U(g1, g2) UINT32_C(g1#g2)
|
---|
4161 | #define RT_D3_U(g1, g2, g3) UINT32_C(g1#g2#g3)
|
---|
4162 | #define RT_D4_U(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
|
---|
4163 | #define RT_D5_U(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
|
---|
4164 | #define RT_D6_U(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
|
---|
4165 | #define RT_D7_U(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
|
---|
4166 |
|
---|
4167 | #define RT_D1_S(g1) INT32_C(g1)
|
---|
4168 | #define RT_D2_S(g1, g2) INT32_C(g1#g2)
|
---|
4169 | #define RT_D3_S(g1, g2, g3) INT32_C(g1#g2#g3)
|
---|
4170 | #define RT_D4_S(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
|
---|
4171 | #define RT_D5_S(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
|
---|
4172 | #define RT_D6_S(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
|
---|
4173 | #define RT_D7_S(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
|
---|
4174 |
|
---|
4175 | #define RT_D1_U32(g1) UINT32_C(g1)
|
---|
4176 | #define RT_D2_U32(g1, g2) UINT32_C(g1#g2)
|
---|
4177 | #define RT_D3_U32(g1, g2, g3) UINT32_C(g1#g2#g3)
|
---|
4178 | #define RT_D4_U32(g1, g2, g3, g4) UINT32_C(g1#g2#g3#g4)
|
---|
4179 |
|
---|
4180 | #define RT_D1_S32(g1) INT32_C(g1)
|
---|
4181 | #define RT_D2_S32(g1, g2) INT32_C(g1#g2)
|
---|
4182 | #define RT_D3_S32(g1, g2, g3) INT32_C(g1#g2#g3)
|
---|
4183 | #define RT_D4_S32(g1, g2, g3, g4) INT32_C(g1#g2#g3#g4)
|
---|
4184 |
|
---|
4185 | #define RT_D1_U64(g1) UINT64_C(g1)
|
---|
4186 | #define RT_D2_U64(g1, g2) UINT64_C(g1#g2)
|
---|
4187 | #define RT_D3_U64(g1, g2, g3) UINT64_C(g1#g2#g3)
|
---|
4188 | #define RT_D4_U64(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
|
---|
4189 | #define RT_D5_U64(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
|
---|
4190 | #define RT_D6_U64(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
|
---|
4191 | #define RT_D7_U64(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
|
---|
4192 |
|
---|
4193 | #define RT_D1_S64(g1) INT64_C(g1)
|
---|
4194 | #define RT_D2_S64(g1, g2) INT64_C(g1#g2)
|
---|
4195 | #define RT_D3_S64(g1, g2, g3) INT64_C(g1#g2#g3)
|
---|
4196 | #define RT_D4_S64(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
|
---|
4197 | #define RT_D5_S64(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
|
---|
4198 | #define RT_D6_S64(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
|
---|
4199 | #define RT_D7_S64(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
|
---|
4200 | /** @} */
|
---|
4201 |
|
---|
4202 |
|
---|
4203 | /** @defgroup grp_rt_cdefs_time Time Constants
|
---|
4204 | * @{
|
---|
4205 | */
|
---|
4206 | /** 1 hour expressed in nanoseconds (64-bit). */
|
---|
4207 | #define RT_NS_1HOUR UINT64_C(3600000000000)
|
---|
4208 | /** 30 minutes expressed in nanoseconds (64-bit). */
|
---|
4209 | #define RT_NS_30MIN UINT64_C(1800000000000)
|
---|
4210 | /** 5 minutes expressed in nanoseconds (64-bit). */
|
---|
4211 | #define RT_NS_5MIN UINT64_C(300000000000)
|
---|
4212 | /** 1 minute expressed in nanoseconds (64-bit). */
|
---|
4213 | #define RT_NS_1MIN UINT64_C(60000000000)
|
---|
4214 | /** 45 seconds expressed in nanoseconds (64-bit). */
|
---|
4215 | #define RT_NS_45SEC UINT64_C(45000000000)
|
---|
4216 | /** 30 seconds expressed in nanoseconds (64-bit). */
|
---|
4217 | #define RT_NS_30SEC UINT64_C(30000000000)
|
---|
4218 | /** 20 seconds expressed in nanoseconds (64-bit). */
|
---|
4219 | #define RT_NS_20SEC UINT64_C(20000000000)
|
---|
4220 | /** 15 seconds expressed in nanoseconds (64-bit). */
|
---|
4221 | #define RT_NS_15SEC UINT64_C(15000000000)
|
---|
4222 | /** 10 seconds expressed in nanoseconds (64-bit). */
|
---|
4223 | #define RT_NS_10SEC UINT64_C(10000000000)
|
---|
4224 | /** 1 second expressed in nanoseconds. */
|
---|
4225 | #define RT_NS_1SEC UINT32_C(1000000000)
|
---|
4226 | /** 100 millsecond expressed in nanoseconds. */
|
---|
4227 | #define RT_NS_100MS UINT32_C(100000000)
|
---|
4228 | /** 10 millsecond expressed in nanoseconds. */
|
---|
4229 | #define RT_NS_10MS UINT32_C(10000000)
|
---|
4230 | /** 8 millsecond expressed in nanoseconds. */
|
---|
4231 | #define RT_NS_8MS UINT32_C(8000000)
|
---|
4232 | /** 2 millsecond expressed in nanoseconds. */
|
---|
4233 | #define RT_NS_2MS UINT32_C(2000000)
|
---|
4234 | /** 1 millsecond expressed in nanoseconds. */
|
---|
4235 | #define RT_NS_1MS UINT32_C(1000000)
|
---|
4236 | /** 100 microseconds expressed in nanoseconds. */
|
---|
4237 | #define RT_NS_100US UINT32_C(100000)
|
---|
4238 | /** 10 microseconds expressed in nanoseconds. */
|
---|
4239 | #define RT_NS_10US UINT32_C(10000)
|
---|
4240 | /** 1 microsecond expressed in nanoseconds. */
|
---|
4241 | #define RT_NS_1US UINT32_C(1000)
|
---|
4242 |
|
---|
4243 | /** 1 second expressed in nanoseconds - 64-bit type. */
|
---|
4244 | #define RT_NS_1SEC_64 UINT64_C(1000000000)
|
---|
4245 | /** 100 millsecond expressed in nanoseconds - 64-bit type. */
|
---|
4246 | #define RT_NS_100MS_64 UINT64_C(100000000)
|
---|
4247 | /** 10 millsecond expressed in nanoseconds - 64-bit type. */
|
---|
4248 | #define RT_NS_10MS_64 UINT64_C(10000000)
|
---|
4249 | /** 1 millsecond expressed in nanoseconds - 64-bit type. */
|
---|
4250 | #define RT_NS_1MS_64 UINT64_C(1000000)
|
---|
4251 | /** 100 microseconds expressed in nanoseconds - 64-bit type. */
|
---|
4252 | #define RT_NS_100US_64 UINT64_C(100000)
|
---|
4253 | /** 10 microseconds expressed in nanoseconds - 64-bit type. */
|
---|
4254 | #define RT_NS_10US_64 UINT64_C(10000)
|
---|
4255 | /** 1 microsecond expressed in nanoseconds - 64-bit type. */
|
---|
4256 | #define RT_NS_1US_64 UINT64_C(1000)
|
---|
4257 |
|
---|
4258 | /** 1 hour expressed in microseconds. */
|
---|
4259 | #define RT_US_1HOUR UINT32_C(3600000000)
|
---|
4260 | /** 30 minutes expressed in microseconds. */
|
---|
4261 | #define RT_US_30MIN UINT32_C(1800000000)
|
---|
4262 | /** 5 minutes expressed in microseconds. */
|
---|
4263 | #define RT_US_5MIN UINT32_C(300000000)
|
---|
4264 | /** 1 minute expressed in microseconds. */
|
---|
4265 | #define RT_US_1MIN UINT32_C(60000000)
|
---|
4266 | /** 45 seconds expressed in microseconds. */
|
---|
4267 | #define RT_US_45SEC UINT32_C(45000000)
|
---|
4268 | /** 30 seconds expressed in microseconds. */
|
---|
4269 | #define RT_US_30SEC UINT32_C(30000000)
|
---|
4270 | /** 20 seconds expressed in microseconds. */
|
---|
4271 | #define RT_US_20SEC UINT32_C(20000000)
|
---|
4272 | /** 15 seconds expressed in microseconds. */
|
---|
4273 | #define RT_US_15SEC UINT32_C(15000000)
|
---|
4274 | /** 10 seconds expressed in microseconds. */
|
---|
4275 | #define RT_US_10SEC UINT32_C(10000000)
|
---|
4276 | /** 5 seconds expressed in microseconds. */
|
---|
4277 | #define RT_US_5SEC UINT32_C(5000000)
|
---|
4278 | /** 1 second expressed in microseconds. */
|
---|
4279 | #define RT_US_1SEC UINT32_C(1000000)
|
---|
4280 | /** 100 millsecond expressed in microseconds. */
|
---|
4281 | #define RT_US_100MS UINT32_C(100000)
|
---|
4282 | /** 10 millsecond expressed in microseconds. */
|
---|
4283 | #define RT_US_10MS UINT32_C(10000)
|
---|
4284 | /** 1 millsecond expressed in microseconds. */
|
---|
4285 | #define RT_US_1MS UINT32_C(1000)
|
---|
4286 |
|
---|
4287 | /** 1 hour expressed in microseconds - 64-bit type. */
|
---|
4288 | #define RT_US_1HOUR_64 UINT64_C(3600000000)
|
---|
4289 | /** 30 minutes expressed in microseconds - 64-bit type. */
|
---|
4290 | #define RT_US_30MIN_64 UINT64_C(1800000000)
|
---|
4291 | /** 5 minutes expressed in microseconds - 64-bit type. */
|
---|
4292 | #define RT_US_5MIN_64 UINT64_C(300000000)
|
---|
4293 | /** 1 minute expressed in microseconds - 64-bit type. */
|
---|
4294 | #define RT_US_1MIN_64 UINT64_C(60000000)
|
---|
4295 | /** 45 seconds expressed in microseconds - 64-bit type. */
|
---|
4296 | #define RT_US_45SEC_64 UINT64_C(45000000)
|
---|
4297 | /** 30 seconds expressed in microseconds - 64-bit type. */
|
---|
4298 | #define RT_US_30SEC_64 UINT64_C(30000000)
|
---|
4299 | /** 20 seconds expressed in microseconds - 64-bit type. */
|
---|
4300 | #define RT_US_20SEC_64 UINT64_C(20000000)
|
---|
4301 | /** 15 seconds expressed in microseconds - 64-bit type. */
|
---|
4302 | #define RT_US_15SEC_64 UINT64_C(15000000)
|
---|
4303 | /** 10 seconds expressed in microseconds - 64-bit type. */
|
---|
4304 | #define RT_US_10SEC_64 UINT64_C(10000000)
|
---|
4305 | /** 5 seconds expressed in microseconds - 64-bit type. */
|
---|
4306 | #define RT_US_5SEC_64 UINT64_C(5000000)
|
---|
4307 | /** 1 second expressed in microseconds - 64-bit type. */
|
---|
4308 | #define RT_US_1SEC_64 UINT64_C(1000000)
|
---|
4309 | /** 100 millsecond expressed in microseconds - 64-bit type. */
|
---|
4310 | #define RT_US_100MS_64 UINT64_C(100000)
|
---|
4311 | /** 10 millsecond expressed in microseconds - 64-bit type. */
|
---|
4312 | #define RT_US_10MS_64 UINT64_C(10000)
|
---|
4313 | /** 1 millsecond expressed in microseconds - 64-bit type. */
|
---|
4314 | #define RT_US_1MS_64 UINT64_C(1000)
|
---|
4315 |
|
---|
4316 | /** 1 hour expressed in milliseconds. */
|
---|
4317 | #define RT_MS_1HOUR UINT32_C(3600000)
|
---|
4318 | /** 30 minutes expressed in milliseconds. */
|
---|
4319 | #define RT_MS_30MIN UINT32_C(1800000)
|
---|
4320 | /** 5 minutes expressed in milliseconds. */
|
---|
4321 | #define RT_MS_5MIN UINT32_C(300000)
|
---|
4322 | /** 1 minute expressed in milliseconds. */
|
---|
4323 | #define RT_MS_1MIN UINT32_C(60000)
|
---|
4324 | /** 45 seconds expressed in milliseconds. */
|
---|
4325 | #define RT_MS_45SEC UINT32_C(45000)
|
---|
4326 | /** 30 seconds expressed in milliseconds. */
|
---|
4327 | #define RT_MS_30SEC UINT32_C(30000)
|
---|
4328 | /** 20 seconds expressed in milliseconds. */
|
---|
4329 | #define RT_MS_20SEC UINT32_C(20000)
|
---|
4330 | /** 15 seconds expressed in milliseconds. */
|
---|
4331 | #define RT_MS_15SEC UINT32_C(15000)
|
---|
4332 | /** 10 seconds expressed in milliseconds. */
|
---|
4333 | #define RT_MS_10SEC UINT32_C(10000)
|
---|
4334 | /** 5 seconds expressed in milliseconds. */
|
---|
4335 | #define RT_MS_5SEC UINT32_C(5000)
|
---|
4336 | /** 1 second expressed in milliseconds. */
|
---|
4337 | #define RT_MS_1SEC UINT32_C(1000)
|
---|
4338 |
|
---|
4339 | /** 1 hour expressed in milliseconds - 64-bit type. */
|
---|
4340 | #define RT_MS_1HOUR_64 UINT64_C(3600000)
|
---|
4341 | /** 30 minutes expressed in milliseconds - 64-bit type. */
|
---|
4342 | #define RT_MS_30MIN_64 UINT64_C(1800000)
|
---|
4343 | /** 5 minutes expressed in milliseconds - 64-bit type. */
|
---|
4344 | #define RT_MS_5MIN_64 UINT64_C(300000)
|
---|
4345 | /** 1 minute expressed in milliseconds - 64-bit type. */
|
---|
4346 | #define RT_MS_1MIN_64 UINT64_C(60000)
|
---|
4347 | /** 45 seconds expressed in milliseconds - 64-bit type. */
|
---|
4348 | #define RT_MS_45SEC_64 UINT64_C(45000)
|
---|
4349 | /** 30 seconds expressed in milliseconds - 64-bit type. */
|
---|
4350 | #define RT_MS_30SEC_64 UINT64_C(30000)
|
---|
4351 | /** 20 seconds expressed in milliseconds - 64-bit type. */
|
---|
4352 | #define RT_MS_20SEC_64 UINT64_C(20000)
|
---|
4353 | /** 15 seconds expressed in milliseconds - 64-bit type. */
|
---|
4354 | #define RT_MS_15SEC_64 UINT64_C(15000)
|
---|
4355 | /** 10 seconds expressed in milliseconds - 64-bit type. */
|
---|
4356 | #define RT_MS_10SEC_64 UINT64_C(10000)
|
---|
4357 | /** 5 seconds expressed in milliseconds - 64-bit type. */
|
---|
4358 | #define RT_MS_5SEC_64 UINT64_C(5000)
|
---|
4359 | /** 1 second expressed in milliseconds - 64-bit type. */
|
---|
4360 | #define RT_MS_1SEC_64 UINT64_C(1000)
|
---|
4361 |
|
---|
4362 | /** The number of seconds per week. */
|
---|
4363 | #define RT_SEC_1WEEK UINT32_C(604800)
|
---|
4364 | /** The number of seconds per day. */
|
---|
4365 | #define RT_SEC_1DAY UINT32_C(86400)
|
---|
4366 | /** The number of seconds per hour. */
|
---|
4367 | #define RT_SEC_1HOUR UINT32_C(3600)
|
---|
4368 |
|
---|
4369 | /** The number of seconds per week - 64-bit type. */
|
---|
4370 | #define RT_SEC_1WEEK_64 UINT64_C(604800)
|
---|
4371 | /** The number of seconds per day - 64-bit type. */
|
---|
4372 | #define RT_SEC_1DAY_64 UINT64_C(86400)
|
---|
4373 | /** The number of seconds per hour - 64-bit type. */
|
---|
4374 | #define RT_SEC_1HOUR_64 UINT64_C(3600)
|
---|
4375 | /** @} */
|
---|
4376 |
|
---|
4377 |
|
---|
4378 | /** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
|
---|
4379 | * @{ */
|
---|
4380 | /** Other format. */
|
---|
4381 | #define RT_DBGTYPE_OTHER RT_BIT_32(0)
|
---|
4382 | /** Stabs. */
|
---|
4383 | #define RT_DBGTYPE_STABS RT_BIT_32(1)
|
---|
4384 | /** Debug With Arbitrary Record Format (DWARF). */
|
---|
4385 | #define RT_DBGTYPE_DWARF RT_BIT_32(2)
|
---|
4386 | /** Microsoft Codeview debug info. */
|
---|
4387 | #define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
|
---|
4388 | /** Watcom debug info. */
|
---|
4389 | #define RT_DBGTYPE_WATCOM RT_BIT_32(4)
|
---|
4390 | /** IBM High Level Language debug info. */
|
---|
4391 | #define RT_DBGTYPE_HLL RT_BIT_32(5)
|
---|
4392 | /** Old OS/2 and Windows symbol file. */
|
---|
4393 | #define RT_DBGTYPE_SYM RT_BIT_32(6)
|
---|
4394 | /** Map file. */
|
---|
4395 | #define RT_DBGTYPE_MAP RT_BIT_32(7)
|
---|
4396 | /** @} */
|
---|
4397 |
|
---|
4398 |
|
---|
4399 | /** @defgroup grp_rt_cdefs_exetype Executable Image Types
|
---|
4400 | * @{ */
|
---|
4401 | /** Some other format. */
|
---|
4402 | #define RT_EXETYPE_OTHER RT_BIT_32(0)
|
---|
4403 | /** Portable Executable. */
|
---|
4404 | #define RT_EXETYPE_PE RT_BIT_32(1)
|
---|
4405 | /** Linear eXecutable. */
|
---|
4406 | #define RT_EXETYPE_LX RT_BIT_32(2)
|
---|
4407 | /** Linear Executable. */
|
---|
4408 | #define RT_EXETYPE_LE RT_BIT_32(3)
|
---|
4409 | /** New Executable. */
|
---|
4410 | #define RT_EXETYPE_NE RT_BIT_32(4)
|
---|
4411 | /** DOS Executable (Mark Zbikowski). */
|
---|
4412 | #define RT_EXETYPE_MZ RT_BIT_32(5)
|
---|
4413 | /** COM Executable. */
|
---|
4414 | #define RT_EXETYPE_COM RT_BIT_32(6)
|
---|
4415 | /** a.out Executable. */
|
---|
4416 | #define RT_EXETYPE_AOUT RT_BIT_32(7)
|
---|
4417 | /** Executable and Linkable Format. */
|
---|
4418 | #define RT_EXETYPE_ELF RT_BIT_32(8)
|
---|
4419 | /** Mach-O Executable (including FAT ones). */
|
---|
4420 | #define RT_EXETYPE_MACHO RT_BIT_32(9)
|
---|
4421 | /** TE from UEFI. */
|
---|
4422 | #define RT_EXETYPE_TE RT_BIT_32(9)
|
---|
4423 | /** @} */
|
---|
4424 |
|
---|
4425 |
|
---|
4426 | /** @def RT_VALID_PTR
|
---|
4427 | * Pointer validation macro.
|
---|
4428 | * @param ptr The pointer.
|
---|
4429 | */
|
---|
4430 | #if defined(RT_ARCH_AMD64)
|
---|
4431 | # ifdef IN_RING3
|
---|
4432 | # if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
|
---|
4433 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
|
---|
4434 | && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
|
---|
4435 | # elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
|
---|
4436 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
|
---|
4437 | && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
|
---|
4438 | || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
|
---|
4439 | # elif defined(RT_OS_LINUX) /* May use 5-level paging (see Documentation/x86/x86_64/mm.rst). */
|
---|
4440 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x1000U /* one invalid page at the bottom */ \
|
---|
4441 | && !((uintptr_t)(ptr) & 0xff00000000000000ULL) )
|
---|
4442 | # else
|
---|
4443 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x1000U \
|
---|
4444 | && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
|
---|
4445 | # endif
|
---|
4446 | # else /* !IN_RING3 */
|
---|
4447 | # if defined(RT_OS_LINUX) /* May use 5-level paging (see Documentation/x86/x86_64/mm.rst). */
|
---|
4448 | # if 1 /* User address are no longer considered valid in kernel mode (SMAP, etc). */
|
---|
4449 | # define RT_VALID_PTR(ptr) ((uintptr_t)(ptr) - 0xff00000000000000ULL < 0x00ffffffffe00000ULL) /* 2MB invalid space at the top */
|
---|
4450 | # else
|
---|
4451 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x200000 >= 0x201000U /* one invalid page at the bottom and 2MB at the top */ \
|
---|
4452 | && ( ((uintptr_t)(ptr) & 0xff00000000000000ULL) == 0xff00000000000000ULL \
|
---|
4453 | || ((uintptr_t)(ptr) & 0xff00000000000000ULL) == 0) )
|
---|
4454 | # endif
|
---|
4455 | # else
|
---|
4456 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
|
---|
4457 | && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
|
---|
4458 | || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
|
---|
4459 | # endif
|
---|
4460 | # endif /* !IN_RING3 */
|
---|
4461 |
|
---|
4462 | #elif defined(RT_ARCH_X86)
|
---|
4463 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
|
---|
4464 |
|
---|
4465 | #elif defined(RT_ARCH_SPARC64)
|
---|
4466 | # ifdef IN_RING3
|
---|
4467 | # if defined(RT_OS_SOLARIS)
|
---|
4468 | /** Sparc64 user mode: According to Figure 9.4 in solaris internals */
|
---|
4469 | /** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
|
---|
4470 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
|
---|
4471 | # else
|
---|
4472 | # error "Port me"
|
---|
4473 | # endif
|
---|
4474 | # else /* !IN_RING3 */
|
---|
4475 | # if defined(RT_OS_SOLARIS)
|
---|
4476 | /** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
|
---|
4477 | * internals. Verify in sources. */
|
---|
4478 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
|
---|
4479 | # else
|
---|
4480 | # error "Port me"
|
---|
4481 | # endif
|
---|
4482 | # endif /* !IN_RING3 */
|
---|
4483 |
|
---|
4484 | #elif defined(RT_ARCH_SPARC)
|
---|
4485 | # ifdef IN_RING3
|
---|
4486 | # ifdef RT_OS_SOLARIS
|
---|
4487 | /** Sparc user mode: According to
|
---|
4488 | * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
|
---|
4489 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
|
---|
4490 |
|
---|
4491 | # else
|
---|
4492 | # error "Port me"
|
---|
4493 | # endif
|
---|
4494 | # else /* !IN_RING3 */
|
---|
4495 | # ifdef RT_OS_SOLARIS
|
---|
4496 | /** @todo Sparc kernel mode: Check the sources! */
|
---|
4497 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
|
---|
4498 | # else
|
---|
4499 | # error "Port me"
|
---|
4500 | # endif
|
---|
4501 | # endif /* !IN_RING3 */
|
---|
4502 |
|
---|
4503 | #elif defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64)
|
---|
4504 | /* ASSUMES that at least the last and first 4K are out of bounds. */
|
---|
4505 | # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
|
---|
4506 |
|
---|
4507 | #else
|
---|
4508 | # error "Architecture identifier missing / not implemented."
|
---|
4509 | #endif
|
---|
4510 |
|
---|
4511 | /** @def RT_VALID_ALIGNED_PTR
|
---|
4512 | * Pointer validation macro that also checks the alignment.
|
---|
4513 | * @param ptr The pointer.
|
---|
4514 | * @param align The alignment, must be a power of two.
|
---|
4515 | */
|
---|
4516 | #define RT_VALID_ALIGNED_PTR(ptr, align) \
|
---|
4517 | ( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
|
---|
4518 | && RT_VALID_PTR(ptr) )
|
---|
4519 |
|
---|
4520 |
|
---|
4521 | /** @def VALID_PHYS32
|
---|
4522 | * 32 bits physical address validation macro.
|
---|
4523 | * @param Phys The RTGCPHYS address.
|
---|
4524 | */
|
---|
4525 | #define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
|
---|
4526 |
|
---|
4527 | /** @def N_
|
---|
4528 | * The \#define N_ is used to mark a string for translation. This is usable in
|
---|
4529 | * any part of the code, as it is only used by the tools that create message
|
---|
4530 | * catalogs. This macro is a no-op as far as the compiler and code generation
|
---|
4531 | * is concerned.
|
---|
4532 | *
|
---|
4533 | * If you want to both mark a string for translation and translate it, use _().
|
---|
4534 | */
|
---|
4535 | #define N_(s) (s)
|
---|
4536 |
|
---|
4537 | /** @def _
|
---|
4538 | * The \#define _ is used to mark a string for translation and to translate it
|
---|
4539 | * in one step.
|
---|
4540 | *
|
---|
4541 | * If you want to only mark a string for translation, use N_().
|
---|
4542 | */
|
---|
4543 | #define _(s) gettext(s)
|
---|
4544 |
|
---|
4545 |
|
---|
4546 | #if (!defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)) || defined(DOXYGEN_RUNNING)
|
---|
4547 | # if defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
|
---|
4548 | /** With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
|
---|
4549 | * for the other compilers. */
|
---|
4550 | # define __PRETTY_FUNCTION__ __FUNCSIG__
|
---|
4551 | # else
|
---|
4552 | # define __PRETTY_FUNCTION__ __FUNCTION__
|
---|
4553 | # endif
|
---|
4554 | #endif
|
---|
4555 |
|
---|
4556 |
|
---|
4557 | /** @def RT_STRICT
|
---|
4558 | * The \#define RT_STRICT controls whether or not assertions and other runtime
|
---|
4559 | * checks should be compiled in or not. This is defined when DEBUG is defined.
|
---|
4560 | * If RT_NO_STRICT is defined, it will unconditionally be undefined.
|
---|
4561 | *
|
---|
4562 | * If you want assertions which are not subject to compile time options use
|
---|
4563 | * the AssertRelease*() flavors.
|
---|
4564 | */
|
---|
4565 | #if !defined(RT_STRICT) && defined(DEBUG)
|
---|
4566 | # define RT_STRICT
|
---|
4567 | #endif
|
---|
4568 | #ifdef RT_NO_STRICT
|
---|
4569 | # undef RT_STRICT
|
---|
4570 | #endif
|
---|
4571 |
|
---|
4572 | /** @todo remove this: */
|
---|
4573 | #if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
|
---|
4574 | # define RT_LOCK_NO_STRICT
|
---|
4575 | #endif
|
---|
4576 | #if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
|
---|
4577 | # define RT_LOCK_NO_STRICT_ORDER
|
---|
4578 | #endif
|
---|
4579 |
|
---|
4580 | /** @def RT_LOCK_STRICT
|
---|
4581 | * The \#define RT_LOCK_STRICT controls whether deadlock detection and related
|
---|
4582 | * checks are done in the lock and semaphore code. It is by default enabled in
|
---|
4583 | * RT_STRICT builds, but this behavior can be overridden by defining
|
---|
4584 | * RT_LOCK_NO_STRICT. */
|
---|
4585 | #if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
|
---|
4586 | # define RT_LOCK_STRICT
|
---|
4587 | #endif
|
---|
4588 | /** @def RT_LOCK_NO_STRICT
|
---|
4589 | * The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
|
---|
4590 | #if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
|
---|
4591 | # undef RT_LOCK_STRICT
|
---|
4592 | #endif
|
---|
4593 |
|
---|
4594 | /** @def RT_LOCK_STRICT_ORDER
|
---|
4595 | * The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
|
---|
4596 | * by the lock and semaphore code. It is by default enabled in RT_STRICT
|
---|
4597 | * builds, but this behavior can be overridden by defining
|
---|
4598 | * RT_LOCK_NO_STRICT_ORDER. */
|
---|
4599 | #if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
|
---|
4600 | # define RT_LOCK_STRICT_ORDER
|
---|
4601 | #endif
|
---|
4602 | /** @def RT_LOCK_NO_STRICT_ORDER
|
---|
4603 | * The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
|
---|
4604 | #if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
|
---|
4605 | # undef RT_LOCK_STRICT_ORDER
|
---|
4606 | #endif
|
---|
4607 |
|
---|
4608 |
|
---|
4609 | /** Source position. */
|
---|
4610 | #define RT_SRC_POS __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
|
---|
4611 |
|
---|
4612 | /** Source position declaration. */
|
---|
4613 | #define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
|
---|
4614 |
|
---|
4615 | /** Source position arguments. */
|
---|
4616 | #define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
|
---|
4617 |
|
---|
4618 | /** Applies NOREF() to the source position arguments. */
|
---|
4619 | #define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
|
---|
4620 |
|
---|
4621 |
|
---|
4622 | /** @def RT_INLINE_ASM_EXTERNAL
|
---|
4623 | * Defined as 1 if the compiler does not support inline assembly.
|
---|
4624 | * The ASM* functions will then be implemented in external .asm files.
|
---|
4625 | */
|
---|
4626 | #if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
|
---|
4627 | || (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86) && !defined(RT_ARCH_ARM64) && !defined(RT_ARCH_ARM32)) \
|
---|
4628 | || defined(__WATCOMC__)
|
---|
4629 | # define RT_INLINE_ASM_EXTERNAL 1
|
---|
4630 | #else
|
---|
4631 | # define RT_INLINE_ASM_EXTERNAL 0
|
---|
4632 | #endif
|
---|
4633 |
|
---|
4634 | /** @def RT_INLINE_ASM_GNU_STYLE
|
---|
4635 | * Defined as 1 if the compiler understands GNU style inline assembly.
|
---|
4636 | */
|
---|
4637 | #if defined(_MSC_VER) || defined(__WATCOMC__)
|
---|
4638 | # define RT_INLINE_ASM_GNU_STYLE 0
|
---|
4639 | #else
|
---|
4640 | # define RT_INLINE_ASM_GNU_STYLE 1
|
---|
4641 | #endif
|
---|
4642 |
|
---|
4643 | /** @def RT_INLINE_ASM_USES_INTRIN
|
---|
4644 | * Defined as one of the RT_MSC_VER_XXX MSC version values if the compiler have
|
---|
4645 | * and uses intrin.h. Otherwise it is 0. */
|
---|
4646 | #ifdef _MSC_VER
|
---|
4647 | # if _MSC_VER >= RT_MSC_VER_VS2019 /* Visual C++ v14.2 */
|
---|
4648 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2019
|
---|
4649 | # elif _MSC_VER >= RT_MSC_VER_VS2017 /* Visual C++ v14.1 */
|
---|
4650 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2017
|
---|
4651 | # elif _MSC_VER >= RT_MSC_VER_VS2015 /* Visual C++ v14.0 */
|
---|
4652 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2015
|
---|
4653 | # elif _MSC_VER >= RT_MSC_VER_VS2013 /* Visual C++ v12.0 */
|
---|
4654 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2013
|
---|
4655 | # elif _MSC_VER >= RT_MSC_VER_VS2012 /* Visual C++ v11.0 */
|
---|
4656 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2012
|
---|
4657 | # elif _MSC_VER >= RT_MSC_VER_VS2010 /* Visual C++ v10.0 */
|
---|
4658 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2010
|
---|
4659 | # elif _MSC_VER >= RT_MSC_VER_VS2008 /* Visual C++ v9.0 */
|
---|
4660 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2008
|
---|
4661 | # elif _MSC_VER >= RT_MSC_VER_VS2005 /* Visual C++ v8.0 */
|
---|
4662 | # define RT_INLINE_ASM_USES_INTRIN RT_MSC_VER_VS2005
|
---|
4663 | # endif
|
---|
4664 | #endif
|
---|
4665 | #ifndef RT_INLINE_ASM_USES_INTRIN
|
---|
4666 | # define RT_INLINE_ASM_USES_INTRIN 0
|
---|
4667 | #endif
|
---|
4668 |
|
---|
4669 | #define RT_MSC_VER_VS2012 (1700) /**< Visual Studio 2012. */
|
---|
4670 | #define RT_MSC_VER_VC110 RT_MSC_VER_VS2012 /**< Visual C++ 11.0, aka Visual Studio 2012. */
|
---|
4671 | #define RT_MSC_VER_VS2013 (1800) /**< Visual Studio 2013. */
|
---|
4672 | #define RT_MSC_VER_VC120 RT_MSC_VER_VS2013 /**< Visual C++ 12.0, aka Visual Studio 2013. */
|
---|
4673 | #define RT_MSC_VER_VS2015 (1900) /**< Visual Studio 2015. */
|
---|
4674 | #define RT_MSC_VER_VC140 RT_MSC_VER_VS2015 /**< Visual C++ 14.0, aka Visual Studio 2015. */
|
---|
4675 | #define RT_MSC_VER_VS2017 (1910) /**< Visual Studio 2017. */
|
---|
4676 | #define RT_MSC_VER_VC141 RT_MSC_VER_VS2017 /**< Visual C++ 14.1, aka Visual Studio 2017. */
|
---|
4677 | #define RT_MSC_VER_VS2019 (1920) /**< Visual Studio 2017. */
|
---|
4678 | #define RT_MSC_VER_VC142 RT_MSC_VER_VS2019 /**< Visual C++ 14.2, aka Visual Studio 2019. */
|
---|
4679 |
|
---|
4680 | /** @def RT_COMPILER_SUPPORTS_LAMBDA
|
---|
4681 | * If the defined, the compiler supports lambda expressions. These expressions
|
---|
4682 | * are useful for embedding assertions and type checks into macros. */
|
---|
4683 | #if defined(_MSC_VER) && defined(__cplusplus)
|
---|
4684 | # if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
|
---|
4685 | # define RT_COMPILER_SUPPORTS_LAMBDA
|
---|
4686 | # endif
|
---|
4687 | #elif defined(__GNUC__) && defined(__cplusplus)
|
---|
4688 | /* 4.5 or later, I think, if in ++11 mode... */
|
---|
4689 | #endif
|
---|
4690 |
|
---|
4691 | /** @def RT_DATA_IS_FAR
|
---|
4692 | * Set to 1 if we're in 16-bit mode and use far pointers.
|
---|
4693 | */
|
---|
4694 | #if ARCH_BITS == 16 && defined(__WATCOMC__) \
|
---|
4695 | && (defined(__COMPACT__) || defined(__LARGE__))
|
---|
4696 | # define RT_DATA_IS_FAR 1
|
---|
4697 | #else
|
---|
4698 | # define RT_DATA_IS_FAR 0
|
---|
4699 | #endif
|
---|
4700 |
|
---|
4701 | /** @def RT_FAR
|
---|
4702 | * For indicating far pointers in 16-bit code.
|
---|
4703 | * Does nothing in 32-bit and 64-bit code. */
|
---|
4704 | /** @def RT_NEAR
|
---|
4705 | * For indicating near pointers in 16-bit code.
|
---|
4706 | * Does nothing in 32-bit and 64-bit code. */
|
---|
4707 | /** @def RT_FAR_CODE
|
---|
4708 | * For indicating far 16-bit functions.
|
---|
4709 | * Does nothing in 32-bit and 64-bit code. */
|
---|
4710 | /** @def RT_NEAR_CODE
|
---|
4711 | * For indicating near 16-bit functions.
|
---|
4712 | * Does nothing in 32-bit and 64-bit code. */
|
---|
4713 | /** @def RT_FAR_DATA
|
---|
4714 | * For indicating far 16-bit external data, i.e. in a segment other than DATA16.
|
---|
4715 | * Does nothing in 32-bit and 64-bit code. */
|
---|
4716 | #if ARCH_BITS == 16
|
---|
4717 | # define RT_FAR __far
|
---|
4718 | # define RT_NEAR __near
|
---|
4719 | # define RT_FAR_CODE __far
|
---|
4720 | # define RT_NEAR_CODE __near
|
---|
4721 | # define RT_FAR_DATA __far
|
---|
4722 | #else
|
---|
4723 | # define RT_FAR
|
---|
4724 | # define RT_NEAR
|
---|
4725 | # define RT_FAR_CODE
|
---|
4726 | # define RT_NEAR_CODE
|
---|
4727 | # define RT_FAR_DATA
|
---|
4728 | #endif
|
---|
4729 |
|
---|
4730 |
|
---|
4731 | /** @} */
|
---|
4732 |
|
---|
4733 |
|
---|
4734 | /** @defgroup grp_rt_cdefs_cpp Special Macros for C++
|
---|
4735 | * @ingroup grp_rt_cdefs
|
---|
4736 | * @{
|
---|
4737 | */
|
---|
4738 |
|
---|
4739 | #ifdef __cplusplus
|
---|
4740 |
|
---|
4741 | /** @def DECLEXPORT_CLASS
|
---|
4742 | * How to declare an exported class. Place this macro after the 'class'
|
---|
4743 | * keyword in the declaration of every class you want to export.
|
---|
4744 | *
|
---|
4745 | * @note It is necessary to use this macro even for inner classes declared
|
---|
4746 | * inside the already exported classes. This is a GCC specific requirement,
|
---|
4747 | * but it seems not to harm other compilers.
|
---|
4748 | */
|
---|
4749 | #if defined(_MSC_VER) || defined(RT_OS_OS2)
|
---|
4750 | # define DECLEXPORT_CLASS __declspec(dllexport)
|
---|
4751 | #elif defined(RT_USE_VISIBILITY_DEFAULT)
|
---|
4752 | # define DECLEXPORT_CLASS __attribute__((visibility("default")))
|
---|
4753 | #else
|
---|
4754 | # define DECLEXPORT_CLASS
|
---|
4755 | #endif
|
---|
4756 |
|
---|
4757 | /** @def DECLIMPORT_CLASS
|
---|
4758 | * How to declare an imported class Place this macro after the 'class'
|
---|
4759 | * keyword in the declaration of every class you want to export.
|
---|
4760 | *
|
---|
4761 | * @note It is necessary to use this macro even for inner classes declared
|
---|
4762 | * inside the already exported classes. This is a GCC specific requirement,
|
---|
4763 | * but it seems not to harm other compilers.
|
---|
4764 | */
|
---|
4765 | #if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
|
---|
4766 | # define DECLIMPORT_CLASS __declspec(dllimport)
|
---|
4767 | #elif defined(RT_USE_VISIBILITY_DEFAULT)
|
---|
4768 | # define DECLIMPORT_CLASS __attribute__((visibility("default")))
|
---|
4769 | #else
|
---|
4770 | # define DECLIMPORT_CLASS
|
---|
4771 | #endif
|
---|
4772 |
|
---|
4773 | /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP
|
---|
4774 | * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity
|
---|
4775 | * resolver. The following snippet clearly demonstrates the code causing this
|
---|
4776 | * error:
|
---|
4777 | * @code
|
---|
4778 | * class A
|
---|
4779 | * {
|
---|
4780 | * public:
|
---|
4781 | * operator bool() const { return false; }
|
---|
4782 | * operator int*() const { return NULL; }
|
---|
4783 | * };
|
---|
4784 | * int main()
|
---|
4785 | * {
|
---|
4786 | * A a;
|
---|
4787 | * if (!a);
|
---|
4788 | * if (a && 0);
|
---|
4789 | * return 0;
|
---|
4790 | * }
|
---|
4791 | * @endcode
|
---|
4792 | * The code itself seems pretty valid to me and GCC thinks the same.
|
---|
4793 | *
|
---|
4794 | * This macro fixes the compiler error by explicitly overloading implicit
|
---|
4795 | * global operators !, && and || that take the given class instance as one of
|
---|
4796 | * their arguments.
|
---|
4797 | *
|
---|
4798 | * The best is to use this macro right after the class declaration.
|
---|
4799 | *
|
---|
4800 | * @note The macro expands to nothing for compilers other than MSVC.
|
---|
4801 | *
|
---|
4802 | * @param Cls Class to apply the workaround to
|
---|
4803 | */
|
---|
4804 | #if defined(_MSC_VER)
|
---|
4805 | # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
|
---|
4806 | inline bool operator! (const Cls &that) { return !bool (that); } \
|
---|
4807 | inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
|
---|
4808 | inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
|
---|
4809 | inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
|
---|
4810 | inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
|
---|
4811 | #else
|
---|
4812 | # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
|
---|
4813 | #endif
|
---|
4814 |
|
---|
4815 | /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL
|
---|
4816 | * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes.
|
---|
4817 | *
|
---|
4818 | * @param Tpl Name of the template class to apply the workaround to
|
---|
4819 | * @param ArgsDecl arguments of the template, as declared in |<>| after the
|
---|
4820 | * |template| keyword, including |<>|
|
---|
4821 | * @param Args arguments of the template, as specified in |<>| after the
|
---|
4822 | * template class name when using the, including |<>|
|
---|
4823 | *
|
---|
4824 | * Example:
|
---|
4825 | * @code
|
---|
4826 | * // template class declaration
|
---|
4827 | * template <class C>
|
---|
4828 | * class Foo { ... };
|
---|
4829 | * // applied workaround
|
---|
4830 | * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
|
---|
4831 | * @endcode
|
---|
4832 | */
|
---|
4833 | #if defined(_MSC_VER)
|
---|
4834 | # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
|
---|
4835 | template ArgsDecl \
|
---|
4836 | inline bool operator! (const Tpl Args &that) { return !bool (that); } \
|
---|
4837 | template ArgsDecl \
|
---|
4838 | inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
|
---|
4839 | template ArgsDecl \
|
---|
4840 | inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
|
---|
4841 | template ArgsDecl \
|
---|
4842 | inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
|
---|
4843 | template ArgsDecl \
|
---|
4844 | inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
|
---|
4845 | #else
|
---|
4846 | # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
|
---|
4847 | #endif
|
---|
4848 |
|
---|
4849 |
|
---|
4850 | /** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP
|
---|
4851 | * Declares the copy constructor and the assignment operation as inlined no-ops
|
---|
4852 | * (non-existent functions) for the given class. Use this macro inside the
|
---|
4853 | * private section if you want to effectively disable these operations for your
|
---|
4854 | * class.
|
---|
4855 | *
|
---|
4856 | * @param Cls class name to declare for
|
---|
4857 | */
|
---|
4858 | #define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
|
---|
4859 | inline Cls(const Cls &); \
|
---|
4860 | inline Cls &operator= (const Cls &)
|
---|
4861 |
|
---|
4862 |
|
---|
4863 | /** @def DECLARE_CLS_NEW_DELETE_NOOP
|
---|
4864 | * Declares the new and delete operations as no-ops (non-existent functions)
|
---|
4865 | * for the given class. Use this macro inside the private section if you want
|
---|
4866 | * to effectively limit creating class instances on the stack only.
|
---|
4867 | *
|
---|
4868 | * @note The destructor of the given class must not be virtual, otherwise a
|
---|
4869 | * compile time error will occur. Note that this is not a drawback: having
|
---|
4870 | * the virtual destructor for a stack-based class is absolutely useless
|
---|
4871 | * (the real class of the stack-based instance is always known to the compiler
|
---|
4872 | * at compile time, so it will always call the correct destructor).
|
---|
4873 | *
|
---|
4874 | * @param Cls class name to declare for
|
---|
4875 | */
|
---|
4876 | #define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
|
---|
4877 | inline static void *operator new (size_t); \
|
---|
4878 | inline static void operator delete (void *)
|
---|
4879 |
|
---|
4880 | #endif /* __cplusplus */
|
---|
4881 |
|
---|
4882 | /** @} */
|
---|
4883 |
|
---|
4884 | #endif /* !IPRT_INCLUDED_cdefs_h */
|
---|
4885 |
|
---|