VirtualBox

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

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

iprt/cdefs.h: Hope the extension trick works for gcc 7x. too. Unable to install g++-7 to test here. bugref:9746

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