VirtualBox

source: vbox/trunk/include/iprt/cdefs.h@ 80531

Last change on this file since 80531 was 80531, checked in by vboxsync, 5 years ago

VMM,Devices: Some PDM device model refactoring. bugref:9218

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette