VirtualBox

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

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

iprt/cdefs.h: Added RT_BIT_Z the returns size_t to help deal with annoying VC++ 14.1 warning (existed in earlier versions but is not more persistent). bugref:8489

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 173.4 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 Use RT_UOFFSETOF() to calculate the structure size.
2547 *
2548 * @note Never to a sizeof() on the structure or member!
2549 *
2550 * @note The member must be the last one.
2551 *
2552 * @note GCC does not permit using this in a union. So, for unions you must
2553 * use RT_FLEXIBLE_ARRAY_IN_UNION instead.
2554 *
2555 * @note GCC does not permit using this in nested structures, where as MSC
2556 * does. So, use RT_FLEXIBLE_ARRAY_NESTED for that.
2557 *
2558 * @sa RT_FLEXIBLE_ARRAY_NESTED, RT_FLEXIBLE_ARRAY_IN_UNION
2559 */
2560#if RT_MSC_PREREQ(RT_MSC_VER_VS2005) /** @todo Probably much much earlier. */ \
2561 || (defined(__cplusplus) && RT_GNUC_PREREQ(6, 1) && !RT_GNUC_PREREQ(7, 0)) /* gcc-7 warns again */\
2562 || defined(__WATCOMC__) /* openwatcom 1.9 supports it, we don't care about older atm. */ \
2563 || RT_CLANG_PREREQ_EX(3, 4, 0) /* Only tested clang v3.4, support is probably older. */
2564# define RT_FLEXIBLE_ARRAY
2565# if defined(__cplusplus) && defined(_MSC_VER)
2566# pragma warning(disable:4200) /* -wd4200 does not work with VS2010 */
2567# endif
2568#elif defined(__STDC_VERSION__)
2569# if __STDC_VERSION__ >= 1999901L
2570# define RT_FLEXIBLE_ARRAY
2571# else
2572# define RT_FLEXIBLE_ARRAY 1
2573# endif
2574#else
2575# define RT_FLEXIBLE_ARRAY 1
2576#endif
2577
2578/** @def RT_FLEXIBLE_ARRAY_NESTED
2579 * Variant of RT_FLEXIBLE_ARRAY for use in structures that are nested.
2580 *
2581 * GCC only allow the use of flexible array member in the top structure, whereas
2582 * MSC is less strict and let you do struct { struct { char szName[]; } s; };
2583 *
2584 * @note See notes for RT_FLEXIBLE_ARRAY.
2585 *
2586 * @note GCC does not permit using this in a union. So, for unions you must
2587 * use RT_FLEXIBLE_ARRAY_IN_NESTED_UNION instead.
2588 *
2589 * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2590 */
2591#ifdef _MSC_VER
2592# define RT_FLEXIBLE_ARRAY_NESTED RT_FLEXIBLE_ARRAY
2593#else
2594# define RT_FLEXIBLE_ARRAY_NESTED 1
2595#endif
2596
2597/** @def RT_FLEXIBLE_ARRAY_IN_UNION
2598 * The union version of RT_FLEXIBLE_ARRAY.
2599 *
2600 * @remarks GCC does not support flexible array members in unions, 6.1.x
2601 * actively checks for this. Visual C++ 2010 seems happy with it.
2602 *
2603 * @note See notes for RT_FLEXIBLE_ARRAY.
2604 *
2605 * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2606 */
2607#ifdef _MSC_VER
2608# define RT_FLEXIBLE_ARRAY_IN_UNION RT_FLEXIBLE_ARRAY
2609#else
2610# define RT_FLEXIBLE_ARRAY_IN_UNION 1
2611#endif
2612
2613/** @def RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2614 * The union version of RT_FLEXIBLE_ARRAY_NESTED.
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_NESTED_UNION RT_FLEXIBLE_ARRAY_NESTED
2622#else
2623# define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION 1
2624#endif
2625
2626/** @def RT_UNION_NM
2627 * For compilers (like DTrace) that does not grok nameless unions, we have a
2628 * little hack to make them palatable.
2629 */
2630/** @def RT_STRUCT_NM
2631 * For compilers (like DTrace) that does not grok nameless structs (it is
2632 * non-standard C++), we have a little hack to make them palatable.
2633 */
2634#ifdef IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
2635# define RT_UNION_NM(a_Nm) a_Nm
2636# define RT_STRUCT_NM(a_Nm) a_Nm
2637#else
2638# define RT_UNION_NM(a_Nm)
2639# define RT_STRUCT_NM(a_Nm)
2640#endif
2641
2642/**
2643 * Checks if the value is a power of two.
2644 *
2645 * @returns true if power of two, false if not.
2646 * @param uVal The value to test.
2647 * @remarks 0 is a power of two.
2648 * @see VERR_NOT_POWER_OF_TWO
2649 */
2650#define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
2651
2652#ifdef RT_OS_OS2
2653/* Undefine RT_MAX since there is an unfortunate clash with the max
2654 resource type define in os2.h. */
2655# undef RT_MAX
2656#endif
2657
2658/** @def RT_MAX
2659 * Finds the maximum value.
2660 * @returns The higher of the two.
2661 * @param Value1 Value 1
2662 * @param Value2 Value 2
2663 */
2664#define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
2665
2666/** @def RT_MIN
2667 * Finds the minimum value.
2668 * @returns The lower of the two.
2669 * @param Value1 Value 1
2670 * @param Value2 Value 2
2671 */
2672#define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
2673
2674/** @def RT_CLAMP
2675 * Clamps the value to minimum and maximum values.
2676 * @returns The clamped value.
2677 * @param Value The value to check.
2678 * @param Min Minimum value.
2679 * @param Max Maximum value.
2680 */
2681#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
2682
2683/** @def RT_ABS
2684 * Get the absolute (non-negative) value.
2685 * @returns The absolute value of Value.
2686 * @param Value The value.
2687 */
2688#define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
2689
2690/** @def RT_BOOL
2691 * Turn non-zero/zero into true/false
2692 * @returns The resulting boolean value.
2693 * @param Value The value.
2694 */
2695#define RT_BOOL(Value) ( !!(Value) )
2696
2697/** @def RT_LO_U8
2698 * Gets the low uint8_t of a uint16_t or something equivalent. */
2699#ifdef __GNUC__
2700# define RT_LO_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)(a); })
2701#elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2702# define RT_LO_U8(a) ( (uint8_t)(UINT8_MAX & (a)) )
2703#else
2704# define RT_LO_U8(a) ( (uint8_t)(a) )
2705#endif
2706/** @def RT_HI_U8
2707 * Gets the high uint8_t of a uint16_t or something equivalent. */
2708#ifdef __GNUC__
2709# define RT_HI_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)((a) >> 8); })
2710#else
2711# define RT_HI_U8(a) ( (uint8_t)((a) >> 8) )
2712#endif
2713
2714/** @def RT_LO_U16
2715 * Gets the low uint16_t of a uint32_t or something equivalent. */
2716#ifdef __GNUC__
2717# define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)(a); })
2718#elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2719# define RT_LO_U16(a) ( (uint16_t)(UINT16_MAX & (a)) )
2720#else
2721# define RT_LO_U16(a) ( (uint16_t)(a) )
2722#endif
2723/** @def RT_HI_U16
2724 * Gets the high uint16_t of a uint32_t or something equivalent. */
2725#ifdef __GNUC__
2726# define RT_HI_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)((a) >> 16); })
2727#else
2728# define RT_HI_U16(a) ( (uint16_t)((a) >> 16) )
2729#endif
2730
2731/** @def RT_LO_U32
2732 * Gets the low uint32_t of a uint64_t or something equivalent. */
2733#ifdef __GNUC__
2734# define RT_LO_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
2735#elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2736# define RT_LO_U32(a) ( (uint32_t)(UINT32_MAX & (a)) )
2737#else
2738# define RT_LO_U32(a) ( (uint32_t)(a) )
2739#endif
2740/** @def RT_HI_U32
2741 * Gets the high uint32_t of a uint64_t or something equivalent. */
2742#ifdef __GNUC__
2743# define RT_HI_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)((a) >> 32); })
2744#else
2745# define RT_HI_U32(a) ( (uint32_t)((a) >> 32) )
2746#endif
2747
2748/** @def RT_BYTE1
2749 * Gets the first byte of something. */
2750#define RT_BYTE1(a) ( (uint8_t)((a) & 0xff) )
2751/** @def RT_BYTE2
2752 * Gets the second byte of something. */
2753#define RT_BYTE2(a) ( (uint8_t)(((a) >> 8) & 0xff) )
2754/** @def RT_BYTE3
2755 * Gets the second byte of something. */
2756#define RT_BYTE3(a) ( (uint8_t)(((a) >> 16) & 0xff) )
2757/** @def RT_BYTE4
2758 * Gets the fourth byte of something. */
2759#define RT_BYTE4(a) ( (uint8_t)(((a) >> 24) & 0xff) )
2760/** @def RT_BYTE5
2761 * Gets the fifth byte of something. */
2762#define RT_BYTE5(a) ( (uint8_t)(((a) >> 32) & 0xff) )
2763/** @def RT_BYTE6
2764 * Gets the sixth byte of something. */
2765#define RT_BYTE6(a) ( (uint8_t)(((a) >> 40) & 0xff) )
2766/** @def RT_BYTE7
2767 * Gets the seventh byte of something. */
2768#define RT_BYTE7(a) ( (uint8_t)(((a) >> 48) & 0xff) )
2769/** @def RT_BYTE8
2770 * Gets the eight byte of something. */
2771#define RT_BYTE8(a) ( (uint8_t)(((a) >> 56) & 0xff) )
2772
2773
2774/** @def RT_LODWORD
2775 * Gets the low dword (=uint32_t) of something.
2776 * @deprecated Use RT_LO_U32. */
2777#define RT_LODWORD(a) ( (uint32_t)(a) )
2778/** @def RT_HIDWORD
2779 * Gets the high dword (=uint32_t) of a 64-bit of something.
2780 * @deprecated Use RT_HI_U32. */
2781#define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
2782
2783/** @def RT_LOWORD
2784 * Gets the low word (=uint16_t) of something.
2785 * @deprecated Use RT_LO_U16. */
2786#define RT_LOWORD(a) ( (a) & 0xffff )
2787/** @def RT_HIWORD
2788 * Gets the high word (=uint16_t) of a 32-bit something.
2789 * @deprecated Use RT_HI_U16. */
2790#define RT_HIWORD(a) ( (a) >> 16 )
2791
2792/** @def RT_LOBYTE
2793 * Gets the low byte of something.
2794 * @deprecated Use RT_LO_U8. */
2795#define RT_LOBYTE(a) ( (a) & 0xff )
2796/** @def RT_HIBYTE
2797 * Gets the high byte of a 16-bit something.
2798 * @deprecated Use RT_HI_U8. */
2799#define RT_HIBYTE(a) ( (a) >> 8 )
2800
2801
2802/** @def RT_MAKE_U64
2803 * Constructs a uint64_t value from two uint32_t values.
2804 */
2805#define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
2806
2807/** @def RT_MAKE_U64_FROM_U16
2808 * Constructs a uint64_t value from four uint16_t values.
2809 */
2810#define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
2811 ((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
2812 | (uint64_t)((uint16_t)(w2)) << 32 \
2813 | (uint32_t)((uint16_t)(w1)) << 16 \
2814 | (uint16_t)(w0) ))
2815
2816/** @def RT_MAKE_U64_FROM_U8
2817 * Constructs a uint64_t value from eight uint8_t values.
2818 */
2819#define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
2820 ((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
2821 | (uint64_t)((uint8_t)(b6)) << 48 \
2822 | (uint64_t)((uint8_t)(b5)) << 40 \
2823 | (uint64_t)((uint8_t)(b4)) << 32 \
2824 | (uint32_t)((uint8_t)(b3)) << 24 \
2825 | (uint32_t)((uint8_t)(b2)) << 16 \
2826 | (uint16_t)((uint8_t)(b1)) << 8 \
2827 | (uint8_t)(b0) ))
2828
2829/** @def RT_MAKE_U32
2830 * Constructs a uint32_t value from two uint16_t values.
2831 */
2832#define RT_MAKE_U32(Lo, Hi) \
2833 ((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
2834 | (uint16_t)(Lo) ))
2835
2836/** @def RT_MAKE_U32_FROM_U8
2837 * Constructs a uint32_t value from four uint8_t values.
2838 */
2839#define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
2840 ((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
2841 | (uint32_t)((uint8_t)(b2)) << 16 \
2842 | (uint16_t)((uint8_t)(b1)) << 8 \
2843 | (uint8_t)(b0) ))
2844
2845/** @def RT_MAKE_U16
2846 * Constructs a uint16_t value from two uint8_t values.
2847 */
2848#define RT_MAKE_U16(Lo, Hi) \
2849 ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
2850 | (uint8_t)(Lo) ))
2851
2852
2853/** @def RT_BSWAP_U64
2854 * Reverses the byte order of an uint64_t value. */
2855#if 0
2856# define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64)
2857#elif defined(__GNUC__)
2858# define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) \
2859 ? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
2860#else
2861# define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
2862#endif
2863
2864/** @def RT_BSWAP_U32
2865 * Reverses the byte order of an uint32_t value. */
2866#if 0
2867# define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32)
2868#elif defined(__GNUC__)
2869# define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) \
2870 ? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
2871#else
2872# define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
2873#endif
2874
2875/** @def RT_BSWAP_U16
2876 * Reverses the byte order of an uint16_t value. */
2877#if 0
2878# define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16)
2879#elif defined(__GNUC__)
2880# define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) \
2881 ? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
2882#else
2883# define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
2884#endif
2885
2886
2887/** @def RT_BSWAP_U64_C
2888 * Reverses the byte order of an uint64_t constant. */
2889#define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
2890
2891/** @def RT_BSWAP_U32_C
2892 * Reverses the byte order of an uint32_t constant. */
2893#define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
2894
2895/** @def RT_BSWAP_U16_C
2896 * Reverses the byte order of an uint16_t constant. */
2897#define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
2898
2899
2900/** @def RT_H2LE_U64
2901 * Converts an uint64_t value from host to little endian byte order. */
2902#ifdef RT_BIG_ENDIAN
2903# define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
2904#else
2905# define RT_H2LE_U64(u64) (u64)
2906#endif
2907
2908/** @def RT_H2LE_U64_C
2909 * Converts an uint64_t constant from host to little endian byte order. */
2910#ifdef RT_BIG_ENDIAN
2911# define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
2912#else
2913# define RT_H2LE_U64_C(u64) (u64)
2914#endif
2915
2916/** @def RT_H2LE_U32
2917 * Converts an uint32_t value from host to little endian byte order. */
2918#ifdef RT_BIG_ENDIAN
2919# define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
2920#else
2921# define RT_H2LE_U32(u32) (u32)
2922#endif
2923
2924/** @def RT_H2LE_U32_C
2925 * Converts an uint32_t constant from host to little endian byte order. */
2926#ifdef RT_BIG_ENDIAN
2927# define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
2928#else
2929# define RT_H2LE_U32_C(u32) (u32)
2930#endif
2931
2932/** @def RT_H2LE_U16
2933 * Converts an uint16_t value from host to little endian byte order. */
2934#ifdef RT_BIG_ENDIAN
2935# define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
2936#else
2937# define RT_H2LE_U16(u16) (u16)
2938#endif
2939
2940/** @def RT_H2LE_U16_C
2941 * Converts an uint16_t constant from host to little endian byte order. */
2942#ifdef RT_BIG_ENDIAN
2943# define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
2944#else
2945# define RT_H2LE_U16_C(u16) (u16)
2946#endif
2947
2948
2949/** @def RT_LE2H_U64
2950 * Converts an uint64_t value from little endian to host byte order. */
2951#ifdef RT_BIG_ENDIAN
2952# define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
2953#else
2954# define RT_LE2H_U64(u64) (u64)
2955#endif
2956
2957/** @def RT_LE2H_U64_C
2958 * Converts an uint64_t constant from little endian to host byte order. */
2959#ifdef RT_BIG_ENDIAN
2960# define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
2961#else
2962# define RT_LE2H_U64_C(u64) (u64)
2963#endif
2964
2965/** @def RT_LE2H_U32
2966 * Converts an uint32_t value from little endian to host byte order. */
2967#ifdef RT_BIG_ENDIAN
2968# define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
2969#else
2970# define RT_LE2H_U32(u32) (u32)
2971#endif
2972
2973/** @def RT_LE2H_U32_C
2974 * Converts an uint32_t constant from little endian to host byte order. */
2975#ifdef RT_BIG_ENDIAN
2976# define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
2977#else
2978# define RT_LE2H_U32_C(u32) (u32)
2979#endif
2980
2981/** @def RT_LE2H_U16
2982 * Converts an uint16_t value from little endian to host byte order. */
2983#ifdef RT_BIG_ENDIAN
2984# define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
2985#else
2986# define RT_LE2H_U16(u16) (u16)
2987#endif
2988
2989/** @def RT_LE2H_U16_C
2990 * Converts an uint16_t constant from little endian to host byte order. */
2991#ifdef RT_BIG_ENDIAN
2992# define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
2993#else
2994# define RT_LE2H_U16_C(u16) (u16)
2995#endif
2996
2997
2998/** @def RT_H2BE_U64
2999 * Converts an uint64_t value from host to big endian byte order. */
3000#ifdef RT_BIG_ENDIAN
3001# define RT_H2BE_U64(u64) (u64)
3002#else
3003# define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
3004#endif
3005
3006/** @def RT_H2BE_U64_C
3007 * Converts an uint64_t constant from host to big endian byte order. */
3008#ifdef RT_BIG_ENDIAN
3009# define RT_H2BE_U64_C(u64) (u64)
3010#else
3011# define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
3012#endif
3013
3014/** @def RT_H2BE_U32
3015 * Converts an uint32_t value from host to big endian byte order. */
3016#ifdef RT_BIG_ENDIAN
3017# define RT_H2BE_U32(u32) (u32)
3018#else
3019# define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
3020#endif
3021
3022/** @def RT_H2BE_U32_C
3023 * Converts an uint32_t constant from host to big endian byte order. */
3024#ifdef RT_BIG_ENDIAN
3025# define RT_H2BE_U32_C(u32) (u32)
3026#else
3027# define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
3028#endif
3029
3030/** @def RT_H2BE_U16
3031 * Converts an uint16_t value from host to big endian byte order. */
3032#ifdef RT_BIG_ENDIAN
3033# define RT_H2BE_U16(u16) (u16)
3034#else
3035# define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
3036#endif
3037
3038/** @def RT_H2BE_U16_C
3039 * Converts an uint16_t constant from host to big endian byte order. */
3040#ifdef RT_BIG_ENDIAN
3041# define RT_H2BE_U16_C(u16) (u16)
3042#else
3043# define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
3044#endif
3045
3046/** @def RT_BE2H_U64
3047 * Converts an uint64_t value from big endian to host byte order. */
3048#ifdef RT_BIG_ENDIAN
3049# define RT_BE2H_U64(u64) (u64)
3050#else
3051# define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
3052#endif
3053
3054/** @def RT_BE2H_U64
3055 * Converts an uint64_t constant from big endian to host byte order. */
3056#ifdef RT_BIG_ENDIAN
3057# define RT_BE2H_U64_C(u64) (u64)
3058#else
3059# define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
3060#endif
3061
3062/** @def RT_BE2H_U32
3063 * Converts an uint32_t value from big endian to host byte order. */
3064#ifdef RT_BIG_ENDIAN
3065# define RT_BE2H_U32(u32) (u32)
3066#else
3067# define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
3068#endif
3069
3070/** @def RT_BE2H_U32_C
3071 * Converts an uint32_t value from big endian to host byte order. */
3072#ifdef RT_BIG_ENDIAN
3073# define RT_BE2H_U32_C(u32) (u32)
3074#else
3075# define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
3076#endif
3077
3078/** @def RT_BE2H_U16
3079 * Converts an uint16_t value from big endian to host byte order. */
3080#ifdef RT_BIG_ENDIAN
3081# define RT_BE2H_U16(u16) (u16)
3082#else
3083# define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
3084#endif
3085
3086/** @def RT_BE2H_U16_C
3087 * Converts an uint16_t constant from big endian to host byte order. */
3088#ifdef RT_BIG_ENDIAN
3089# define RT_BE2H_U16_C(u16) (u16)
3090#else
3091# define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
3092#endif
3093
3094
3095/** @def RT_H2N_U64
3096 * Converts an uint64_t value from host to network byte order. */
3097#define RT_H2N_U64(u64) RT_H2BE_U64(u64)
3098
3099/** @def RT_H2N_U64_C
3100 * Converts an uint64_t constant from host to network byte order. */
3101#define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
3102
3103/** @def RT_H2N_U32
3104 * Converts an uint32_t value from host to network byte order. */
3105#define RT_H2N_U32(u32) RT_H2BE_U32(u32)
3106
3107/** @def RT_H2N_U32_C
3108 * Converts an uint32_t constant from host to network byte order. */
3109#define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
3110
3111/** @def RT_H2N_U16
3112 * Converts an uint16_t value from host to network byte order. */
3113#define RT_H2N_U16(u16) RT_H2BE_U16(u16)
3114
3115/** @def RT_H2N_U16_C
3116 * Converts an uint16_t constant from host to network byte order. */
3117#define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
3118
3119/** @def RT_N2H_U64
3120 * Converts an uint64_t value from network to host byte order. */
3121#define RT_N2H_U64(u64) RT_BE2H_U64(u64)
3122
3123/** @def RT_N2H_U64_C
3124 * Converts an uint64_t constant from network to host byte order. */
3125#define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
3126
3127/** @def RT_N2H_U32
3128 * Converts an uint32_t value from network to host byte order. */
3129#define RT_N2H_U32(u32) RT_BE2H_U32(u32)
3130
3131/** @def RT_N2H_U32_C
3132 * Converts an uint32_t constant from network to host byte order. */
3133#define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
3134
3135/** @def RT_N2H_U16
3136 * Converts an uint16_t value from network to host byte order. */
3137#define RT_N2H_U16(u16) RT_BE2H_U16(u16)
3138
3139/** @def RT_N2H_U16_C
3140 * Converts an uint16_t value from network to host byte order. */
3141#define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
3142
3143
3144/*
3145 * The BSD sys/param.h + machine/param.h file is a major source of
3146 * namespace pollution. Kill off some of the worse ones unless we're
3147 * compiling kernel code.
3148 */
3149#if defined(RT_OS_DARWIN) \
3150 && !defined(KERNEL) \
3151 && !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
3152 && ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
3153/* sys/param.h: */
3154# undef PSWP
3155# undef PVM
3156# undef PINOD
3157# undef PRIBO
3158# undef PVFS
3159# undef PZERO
3160# undef PSOCK
3161# undef PWAIT
3162# undef PLOCK
3163# undef PPAUSE
3164# undef PUSER
3165# undef PRIMASK
3166# undef MINBUCKET
3167# undef MAXALLOCSAVE
3168# undef FSHIFT
3169# undef FSCALE
3170
3171/* i386/machine.h: */
3172# undef ALIGN
3173# undef ALIGNBYTES
3174# undef DELAY
3175# undef STATUS_WORD
3176# undef USERMODE
3177# undef BASEPRI
3178# undef MSIZE
3179# undef CLSIZE
3180# undef CLSIZELOG2
3181#endif
3182
3183/** @def NIL_OFFSET
3184 * NIL offset.
3185 * Whenever we use offsets instead of pointers to save space and relocation effort
3186 * NIL_OFFSET shall be used as the equivalent to NULL.
3187 */
3188#define NIL_OFFSET (~0U)
3189
3190
3191/** @def NOREF
3192 * Keeps the compiler from bitching about an unused parameter, local variable,
3193 * or other stuff, will never use _Pragma are is thus more flexible.
3194 */
3195#define NOREF(var) (void)(var)
3196
3197/** @def RT_NOREF_PV
3198 * Keeps the compiler from bitching about an unused parameter or local variable.
3199 * This one cannot be used with structure members and such, like for instance
3200 * AssertRC may end up doing due to its generic nature.
3201 */
3202#if defined(__cplusplus) && RT_CLANG_PREREQ(6, 0)
3203# define RT_NOREF_PV(var) _Pragma(RT_STR(unused(var)))
3204#else
3205# define RT_NOREF_PV(var) (void)(var)
3206#endif
3207
3208/** @def RT_NOREF1
3209 * RT_NOREF_PV shorthand taking on parameter. */
3210#define RT_NOREF1(var1) RT_NOREF_PV(var1)
3211/** @def RT_NOREF2
3212 * RT_NOREF_PV shorthand taking two parameters. */
3213#define RT_NOREF2(var1, var2) RT_NOREF_PV(var1); RT_NOREF1(var2)
3214/** @def RT_NOREF3
3215 * RT_NOREF_PV shorthand taking three parameters. */
3216#define RT_NOREF3(var1, var2, var3) RT_NOREF_PV(var1); RT_NOREF2(var2, var3)
3217/** @def RT_NOREF4
3218 * RT_NOREF_PV shorthand taking four parameters. */
3219#define RT_NOREF4(var1, var2, var3, var4) RT_NOREF_PV(var1); RT_NOREF3(var2, var3, var4)
3220/** @def RT_NOREF5
3221 * RT_NOREF_PV shorthand taking five parameters. */
3222#define RT_NOREF5(var1, var2, var3, var4, var5) RT_NOREF_PV(var1); RT_NOREF4(var2, var3, var4, var5)
3223/** @def RT_NOREF6
3224 * RT_NOREF_PV shorthand taking six parameters. */
3225#define RT_NOREF6(var1, var2, var3, var4, var5, var6) RT_NOREF_PV(var1); RT_NOREF5(var2, var3, var4, var5, var6)
3226/** @def RT_NOREF7
3227 * RT_NOREF_PV shorthand taking seven parameters. */
3228#define RT_NOREF7(var1, var2, var3, var4, var5, var6, var7) \
3229 RT_NOREF_PV(var1); RT_NOREF6(var2, var3, var4, var5, var6, var7)
3230/** @def RT_NOREF8
3231 * RT_NOREF_PV shorthand taking eight parameters. */
3232#define RT_NOREF8(var1, var2, var3, var4, var5, var6, var7, var8) \
3233 RT_NOREF_PV(var1); RT_NOREF7(var2, var3, var4, var5, var6, var7, var8)
3234/** @def RT_NOREF9
3235 * RT_NOREF_PV shorthand taking nine parameters. */
3236#define RT_NOREF9(var1, var2, var3, var4, var5, var6, var7, var8, var9) \
3237 RT_NOREF_PV(var1); RT_NOREF8(var2, var3, var4, var5, var6, var7, var8, var9)
3238/** @def RT_NOREF10
3239 * RT_NOREF_PV shorthand taking ten parameters. */
3240#define RT_NOREF10(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10) \
3241 RT_NOREF_PV(var1); RT_NOREF_PV(var2); RT_NOREF_PV(var3); RT_NOREF_PV(var4); RT_NOREF_PV(var5); RT_NOREF_PV(var6); \
3242 RT_NOREF_PV(var7); RT_NOREF_PV(var8); RT_NOREF_PV(var9); RT_NOREF_PV(var10)
3243/** @def RT_NOREF11
3244 * RT_NOREF_PV shorthand taking eleven parameters. */
3245#define RT_NOREF11(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11) \
3246 RT_NOREF_PV(var1); RT_NOREF10(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11)
3247/** @def RT_NOREF12
3248 * RT_NOREF_PV shorthand taking twelve parameters. */
3249#define RT_NOREF12(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12) \
3250 RT_NOREF_PV(var1); RT_NOREF11(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12)
3251/** @def RT_NOREF13
3252 * RT_NOREF_PV shorthand taking thirteen parameters. */
3253#define RT_NOREF13(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13) \
3254 RT_NOREF_PV(var1); RT_NOREF12(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13)
3255/** @def RT_NOREF14
3256 * RT_NOREF_PV shorthand taking fourteen parameters. */
3257#define RT_NOREF14(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14) \
3258 RT_NOREF_PV(var1); RT_NOREF13(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14)
3259/** @def RT_NOREF15
3260 * RT_NOREF_PV shorthand taking fifteen parameters. */
3261#define RT_NOREF15(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15) \
3262 RT_NOREF_PV(var1); RT_NOREF14(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15)
3263/** @def RT_NOREF16
3264 * RT_NOREF_PV shorthand taking fifteen parameters. */
3265#define RT_NOREF16(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16) \
3266 RT_NOREF_PV(var1); RT_NOREF15(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16)
3267/** @def RT_NOREF17
3268 * RT_NOREF_PV shorthand taking seventeen parameters. */
3269#define RT_NOREF17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \
3270 RT_NOREF_PV(v1); RT_NOREF16(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
3271/** @def RT_NOREF18
3272 * RT_NOREF_PV shorthand taking eighteen parameters. */
3273#define RT_NOREF18(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \
3274 RT_NOREF_PV(v1); RT_NOREF17(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
3275/** @def RT_NOREF19
3276 * RT_NOREF_PV shorthand taking nineteen parameters. */
3277#define RT_NOREF19(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \
3278 RT_NOREF_PV(v1); RT_NOREF18(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
3279/** @def RT_NOREF20
3280 * RT_NOREF_PV shorthand taking twenty parameters. */
3281#define RT_NOREF20(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \
3282 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)
3283/** @def RT_NOREF21
3284 * RT_NOREF_PV shorthand taking twentyone parameters. */
3285#define RT_NOREF21(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \
3286 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)
3287/** @def RT_NOREF22
3288 * RT_NOREF_PV shorthand taking twentytwo parameters. */
3289#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) \
3290 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)
3291
3292/** @def RT_NOREF
3293 * RT_NOREF_PV variant using the variadic macro feature of C99.
3294 * @remarks Only use this in sources */
3295#ifdef RT_COMPILER_SUPPORTS_VA_ARGS
3296# define RT_NOREF(...) \
3297 RT_UNPACK_CALL(RT_CONCAT(RT_NOREF, RT_EXPAND(RT_COUNT_VA_ARGS(__VA_ARGS__))),(__VA_ARGS__))
3298#endif
3299
3300
3301/** @def RT_BREAKPOINT
3302 * Emit a debug breakpoint instruction.
3303 *
3304 * @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
3305 * to force gdb to remain at the int3 source line.
3306 * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
3307 * x86/amd64.
3308 */
3309#ifdef __GNUC__
3310# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
3311# if !defined(__L4ENV__)
3312# define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
3313# else
3314# define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
3315# endif
3316# elif defined(RT_ARCH_SPARC64)
3317# define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
3318# elif defined(RT_ARCH_SPARC)
3319# define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
3320# endif
3321#endif
3322#ifdef _MSC_VER
3323# define RT_BREAKPOINT() __debugbreak()
3324#endif
3325#if defined(__IBMC__) || defined(__IBMCPP__)
3326# define RT_BREAKPOINT() __interrupt(3)
3327#endif
3328#if defined(__WATCOMC__)
3329# define RT_BREAKPOINT() _asm { int 3 }
3330#endif
3331#ifndef RT_BREAKPOINT
3332# error "This compiler/arch is not supported!"
3333#endif
3334
3335
3336/** @defgroup grp_rt_cdefs_size Size Constants
3337 * (Of course, these are binary computer terms, not SI.)
3338 * @{
3339 */
3340/** 1 K (Kilo) (1 024). */
3341#define _1K 0x00000400
3342/** 2 K (Kilo) (2 048). */
3343#define _2K 0x00000800
3344/** 4 K (Kilo) (4 096). */
3345#define _4K 0x00001000
3346/** 8 K (Kilo) (8 192). */
3347#define _8K 0x00002000
3348/** 16 K (Kilo) (16 384). */
3349#define _16K 0x00004000
3350/** 32 K (Kilo) (32 768). */
3351#define _32K 0x00008000
3352/** 64 K (Kilo) (65 536). */
3353#if ARCH_BITS != 16
3354# define _64K 0x00010000
3355#else
3356# define _64K UINT32_C(0x00010000)
3357#endif
3358/** 128 K (Kilo) (131 072). */
3359#if ARCH_BITS != 16
3360# define _128K 0x00020000
3361#else
3362# define _128K UINT32_C(0x00020000)
3363#endif
3364/** 256 K (Kilo) (262 144). */
3365#if ARCH_BITS != 16
3366# define _256K 0x00040000
3367#else
3368# define _256K UINT32_C(0x00040000)
3369#endif
3370/** 512 K (Kilo) (524 288). */
3371#if ARCH_BITS != 16
3372# define _512K 0x00080000
3373#else
3374# define _512K UINT32_C(0x00080000)
3375#endif
3376/** 1 M (Mega) (1 048 576). */
3377#if ARCH_BITS != 16
3378# define _1M 0x00100000
3379#else
3380# define _1M UINT32_C(0x00100000)
3381#endif
3382/** 2 M (Mega) (2 097 152). */
3383#if ARCH_BITS != 16
3384# define _2M 0x00200000
3385#else
3386# define _2M UINT32_C(0x00200000)
3387#endif
3388/** 4 M (Mega) (4 194 304). */
3389#if ARCH_BITS != 16
3390# define _4M 0x00400000
3391#else
3392# define _4M UINT32_C(0x00400000)
3393#endif
3394/** 8 M (Mega) (8 388 608). */
3395#define _8M UINT32_C(0x00800000)
3396/** 16 M (Mega) (16 777 216). */
3397#define _16M UINT32_C(0x01000000)
3398/** 32 M (Mega) (33 554 432). */
3399#define _32M UINT32_C(0x02000000)
3400/** 64 M (Mega) (67 108 864). */
3401#define _64M UINT32_C(0x04000000)
3402/** 128 M (Mega) (134 217 728). */
3403#define _128M UINT32_C(0x08000000)
3404/** 256 M (Mega) (268 435 456). */
3405#define _256M UINT32_C(0x10000000)
3406/** 512 M (Mega) (536 870 912). */
3407#define _512M UINT32_C(0x20000000)
3408/** 1 G (Giga) (1 073 741 824). (32-bit) */
3409#if ARCH_BITS != 16
3410# define _1G 0x40000000
3411#else
3412# define _1G UINT32_C(0x40000000)
3413#endif
3414/** 1 G (Giga) (1 073 741 824). (64-bit) */
3415#if ARCH_BITS != 16
3416# define _1G64 0x40000000LL
3417#else
3418# define _1G64 UINT64_C(0x40000000)
3419#endif
3420/** 2 G (Giga) (2 147 483 648). (32-bit) */
3421#define _2G32 UINT32_C(0x80000000)
3422/** 2 G (Giga) (2 147 483 648). (64-bit) */
3423#if ARCH_BITS != 16
3424# define _2G 0x0000000080000000LL
3425#else
3426# define _2G UINT64_C(0x0000000080000000)
3427#endif
3428/** 4 G (Giga) (4 294 967 296). */
3429#if ARCH_BITS != 16
3430# define _4G 0x0000000100000000LL
3431#else
3432# define _4G UINT64_C(0x0000000100000000)
3433#endif
3434/** 1 T (Tera) (1 099 511 627 776). */
3435#if ARCH_BITS != 16
3436# define _1T 0x0000010000000000LL
3437#else
3438# define _1T UINT64_C(0x0000010000000000)
3439#endif
3440/** 1 P (Peta) (1 125 899 906 842 624). */
3441#if ARCH_BITS != 16
3442# define _1P 0x0004000000000000LL
3443#else
3444# define _1P UINT64_C(0x0004000000000000)
3445#endif
3446/** 1 E (Exa) (1 152 921 504 606 846 976). */
3447#if ARCH_BITS != 16
3448# define _1E 0x1000000000000000LL
3449#else
3450# define _1E UINT64_C(0x1000000000000000)
3451#endif
3452/** 2 E (Exa) (2 305 843 009 213 693 952). */
3453#if ARCH_BITS != 16
3454# define _2E 0x2000000000000000ULL
3455#else
3456# define _2E UINT64_C(0x2000000000000000)
3457#endif
3458/** @} */
3459
3460/** @defgroup grp_rt_cdefs_decimal_grouping Decimal Constant Grouping Macros
3461 * @{ */
3462#define RT_D1(g1) g1
3463#define RT_D2(g1, g2) g1#g2
3464#define RT_D3(g1, g2, g3) g1#g2#g3
3465#define RT_D4(g1, g2, g3, g4) g1#g2#g3#g4
3466#define RT_D5(g1, g2, g3, g4, g5) g1#g2#g3#g4#g5
3467#define RT_D6(g1, g2, g3, g4, g5, g6) g1#g2#g3#g4#g5#g6
3468#define RT_D7(g1, g2, g3, g4, g5, g6, g7) g1#g2#g3#g4#g5#g6#g7
3469
3470#define RT_D1_U(g1) UINT32_C(g1)
3471#define RT_D2_U(g1, g2) UINT32_C(g1#g2)
3472#define RT_D3_U(g1, g2, g3) UINT32_C(g1#g2#g3)
3473#define RT_D4_U(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
3474#define RT_D5_U(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
3475#define RT_D6_U(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
3476#define RT_D7_U(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
3477
3478#define RT_D1_S(g1) INT32_C(g1)
3479#define RT_D2_S(g1, g2) INT32_C(g1#g2)
3480#define RT_D3_S(g1, g2, g3) INT32_C(g1#g2#g3)
3481#define RT_D4_S(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
3482#define RT_D5_S(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
3483#define RT_D6_S(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
3484#define RT_D7_S(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
3485
3486#define RT_D1_U32(g1) UINT32_C(g1)
3487#define RT_D2_U32(g1, g2) UINT32_C(g1#g2)
3488#define RT_D3_U32(g1, g2, g3) UINT32_C(g1#g2#g3)
3489#define RT_D4_U32(g1, g2, g3, g4) UINT32_C(g1#g2#g3#g4)
3490
3491#define RT_D1_S32(g1) INT32_C(g1)
3492#define RT_D2_S32(g1, g2) INT32_C(g1#g2)
3493#define RT_D3_S32(g1, g2, g3) INT32_C(g1#g2#g3)
3494#define RT_D4_S32(g1, g2, g3, g4) INT32_C(g1#g2#g3#g4)
3495
3496#define RT_D1_U64(g1) UINT64_C(g1)
3497#define RT_D2_U64(g1, g2) UINT64_C(g1#g2)
3498#define RT_D3_U64(g1, g2, g3) UINT64_C(g1#g2#g3)
3499#define RT_D4_U64(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
3500#define RT_D5_U64(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
3501#define RT_D6_U64(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
3502#define RT_D7_U64(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
3503
3504#define RT_D1_S64(g1) INT64_C(g1)
3505#define RT_D2_S64(g1, g2) INT64_C(g1#g2)
3506#define RT_D3_S64(g1, g2, g3) INT64_C(g1#g2#g3)
3507#define RT_D4_S64(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
3508#define RT_D5_S64(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
3509#define RT_D6_S64(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
3510#define RT_D7_S64(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
3511/** @} */
3512
3513
3514/** @defgroup grp_rt_cdefs_time Time Constants
3515 * @{
3516 */
3517/** 1 hour expressed in nanoseconds (64-bit). */
3518#define RT_NS_1HOUR UINT64_C(3600000000000)
3519/** 30 minutes expressed in nanoseconds (64-bit). */
3520#define RT_NS_30MIN UINT64_C(1800000000000)
3521/** 5 minutes expressed in nanoseconds (64-bit). */
3522#define RT_NS_5MIN UINT64_C(300000000000)
3523/** 1 minute expressed in nanoseconds (64-bit). */
3524#define RT_NS_1MIN UINT64_C(60000000000)
3525/** 45 seconds expressed in nanoseconds (64-bit). */
3526#define RT_NS_45SEC UINT64_C(45000000000)
3527/** 30 seconds expressed in nanoseconds (64-bit). */
3528#define RT_NS_30SEC UINT64_C(30000000000)
3529/** 20 seconds expressed in nanoseconds (64-bit). */
3530#define RT_NS_20SEC UINT64_C(20000000000)
3531/** 15 seconds expressed in nanoseconds (64-bit). */
3532#define RT_NS_15SEC UINT64_C(15000000000)
3533/** 10 seconds expressed in nanoseconds (64-bit). */
3534#define RT_NS_10SEC UINT64_C(10000000000)
3535/** 1 second expressed in nanoseconds. */
3536#define RT_NS_1SEC UINT32_C(1000000000)
3537/** 100 millsecond expressed in nanoseconds. */
3538#define RT_NS_100MS UINT32_C(100000000)
3539/** 10 millsecond expressed in nanoseconds. */
3540#define RT_NS_10MS UINT32_C(10000000)
3541/** 8 millsecond expressed in nanoseconds. */
3542#define RT_NS_8MS UINT32_C(8000000)
3543/** 2 millsecond expressed in nanoseconds. */
3544#define RT_NS_2MS UINT32_C(2000000)
3545/** 1 millsecond expressed in nanoseconds. */
3546#define RT_NS_1MS UINT32_C(1000000)
3547/** 100 microseconds expressed in nanoseconds. */
3548#define RT_NS_100US UINT32_C(100000)
3549/** 10 microseconds expressed in nanoseconds. */
3550#define RT_NS_10US UINT32_C(10000)
3551/** 1 microsecond expressed in nanoseconds. */
3552#define RT_NS_1US UINT32_C(1000)
3553
3554/** 1 second expressed in nanoseconds - 64-bit type. */
3555#define RT_NS_1SEC_64 UINT64_C(1000000000)
3556/** 100 millsecond expressed in nanoseconds - 64-bit type. */
3557#define RT_NS_100MS_64 UINT64_C(100000000)
3558/** 10 millsecond expressed in nanoseconds - 64-bit type. */
3559#define RT_NS_10MS_64 UINT64_C(10000000)
3560/** 1 millsecond expressed in nanoseconds - 64-bit type. */
3561#define RT_NS_1MS_64 UINT64_C(1000000)
3562/** 100 microseconds expressed in nanoseconds - 64-bit type. */
3563#define RT_NS_100US_64 UINT64_C(100000)
3564/** 10 microseconds expressed in nanoseconds - 64-bit type. */
3565#define RT_NS_10US_64 UINT64_C(10000)
3566/** 1 microsecond expressed in nanoseconds - 64-bit type. */
3567#define RT_NS_1US_64 UINT64_C(1000)
3568
3569/** 1 hour expressed in microseconds. */
3570#define RT_US_1HOUR UINT32_C(3600000000)
3571/** 30 minutes expressed in microseconds. */
3572#define RT_US_30MIN UINT32_C(1800000000)
3573/** 5 minutes expressed in microseconds. */
3574#define RT_US_5MIN UINT32_C(300000000)
3575/** 1 minute expressed in microseconds. */
3576#define RT_US_1MIN UINT32_C(60000000)
3577/** 45 seconds expressed in microseconds. */
3578#define RT_US_45SEC UINT32_C(45000000)
3579/** 30 seconds expressed in microseconds. */
3580#define RT_US_30SEC UINT32_C(30000000)
3581/** 20 seconds expressed in microseconds. */
3582#define RT_US_20SEC UINT32_C(20000000)
3583/** 15 seconds expressed in microseconds. */
3584#define RT_US_15SEC UINT32_C(15000000)
3585/** 10 seconds expressed in microseconds. */
3586#define RT_US_10SEC UINT32_C(10000000)
3587/** 5 seconds expressed in microseconds. */
3588#define RT_US_5SEC UINT32_C(5000000)
3589/** 1 second expressed in microseconds. */
3590#define RT_US_1SEC UINT32_C(1000000)
3591/** 100 millsecond expressed in microseconds. */
3592#define RT_US_100MS UINT32_C(100000)
3593/** 10 millsecond expressed in microseconds. */
3594#define RT_US_10MS UINT32_C(10000)
3595/** 1 millsecond expressed in microseconds. */
3596#define RT_US_1MS UINT32_C(1000)
3597
3598/** 1 hour expressed in microseconds - 64-bit type. */
3599#define RT_US_1HOUR_64 UINT64_C(3600000000)
3600/** 30 minutes expressed in microseconds - 64-bit type. */
3601#define RT_US_30MIN_64 UINT64_C(1800000000)
3602/** 5 minutes expressed in microseconds - 64-bit type. */
3603#define RT_US_5MIN_64 UINT64_C(300000000)
3604/** 1 minute expressed in microseconds - 64-bit type. */
3605#define RT_US_1MIN_64 UINT64_C(60000000)
3606/** 45 seconds expressed in microseconds - 64-bit type. */
3607#define RT_US_45SEC_64 UINT64_C(45000000)
3608/** 30 seconds expressed in microseconds - 64-bit type. */
3609#define RT_US_30SEC_64 UINT64_C(30000000)
3610/** 20 seconds expressed in microseconds - 64-bit type. */
3611#define RT_US_20SEC_64 UINT64_C(20000000)
3612/** 15 seconds expressed in microseconds - 64-bit type. */
3613#define RT_US_15SEC_64 UINT64_C(15000000)
3614/** 10 seconds expressed in microseconds - 64-bit type. */
3615#define RT_US_10SEC_64 UINT64_C(10000000)
3616/** 5 seconds expressed in microseconds - 64-bit type. */
3617#define RT_US_5SEC_64 UINT64_C(5000000)
3618/** 1 second expressed in microseconds - 64-bit type. */
3619#define RT_US_1SEC_64 UINT64_C(1000000)
3620/** 100 millsecond expressed in microseconds - 64-bit type. */
3621#define RT_US_100MS_64 UINT64_C(100000)
3622/** 10 millsecond expressed in microseconds - 64-bit type. */
3623#define RT_US_10MS_64 UINT64_C(10000)
3624/** 1 millsecond expressed in microseconds - 64-bit type. */
3625#define RT_US_1MS_64 UINT64_C(1000)
3626
3627/** 1 hour expressed in milliseconds. */
3628#define RT_MS_1HOUR UINT32_C(3600000)
3629/** 30 minutes expressed in milliseconds. */
3630#define RT_MS_30MIN UINT32_C(1800000)
3631/** 5 minutes expressed in milliseconds. */
3632#define RT_MS_5MIN UINT32_C(300000)
3633/** 1 minute expressed in milliseconds. */
3634#define RT_MS_1MIN UINT32_C(60000)
3635/** 45 seconds expressed in milliseconds. */
3636#define RT_MS_45SEC UINT32_C(45000)
3637/** 30 seconds expressed in milliseconds. */
3638#define RT_MS_30SEC UINT32_C(30000)
3639/** 20 seconds expressed in milliseconds. */
3640#define RT_MS_20SEC UINT32_C(20000)
3641/** 15 seconds expressed in milliseconds. */
3642#define RT_MS_15SEC UINT32_C(15000)
3643/** 10 seconds expressed in milliseconds. */
3644#define RT_MS_10SEC UINT32_C(10000)
3645/** 5 seconds expressed in milliseconds. */
3646#define RT_MS_5SEC UINT32_C(5000)
3647/** 1 second expressed in milliseconds. */
3648#define RT_MS_1SEC UINT32_C(1000)
3649
3650/** 1 hour expressed in milliseconds - 64-bit type. */
3651#define RT_MS_1HOUR_64 UINT64_C(3600000)
3652/** 30 minutes expressed in milliseconds - 64-bit type. */
3653#define RT_MS_30MIN_64 UINT64_C(1800000)
3654/** 5 minutes expressed in milliseconds - 64-bit type. */
3655#define RT_MS_5MIN_64 UINT64_C(300000)
3656/** 1 minute expressed in milliseconds - 64-bit type. */
3657#define RT_MS_1MIN_64 UINT64_C(60000)
3658/** 45 seconds expressed in milliseconds - 64-bit type. */
3659#define RT_MS_45SEC_64 UINT64_C(45000)
3660/** 30 seconds expressed in milliseconds - 64-bit type. */
3661#define RT_MS_30SEC_64 UINT64_C(30000)
3662/** 20 seconds expressed in milliseconds - 64-bit type. */
3663#define RT_MS_20SEC_64 UINT64_C(20000)
3664/** 15 seconds expressed in milliseconds - 64-bit type. */
3665#define RT_MS_15SEC_64 UINT64_C(15000)
3666/** 10 seconds expressed in milliseconds - 64-bit type. */
3667#define RT_MS_10SEC_64 UINT64_C(10000)
3668/** 5 seconds expressed in milliseconds - 64-bit type. */
3669#define RT_MS_5SEC_64 UINT64_C(5000)
3670/** 1 second expressed in milliseconds - 64-bit type. */
3671#define RT_MS_1SEC_64 UINT64_C(1000)
3672
3673/** The number of seconds per week. */
3674#define RT_SEC_1WEEK UINT32_C(604800)
3675/** The number of seconds per day. */
3676#define RT_SEC_1DAY UINT32_C(86400)
3677/** The number of seconds per hour. */
3678#define RT_SEC_1HOUR UINT32_C(3600)
3679
3680/** The number of seconds per week - 64-bit type. */
3681#define RT_SEC_1WEEK_64 UINT64_C(604800)
3682/** The number of seconds per day - 64-bit type. */
3683#define RT_SEC_1DAY_64 UINT64_C(86400)
3684/** The number of seconds per hour - 64-bit type. */
3685#define RT_SEC_1HOUR_64 UINT64_C(3600)
3686/** @} */
3687
3688
3689/** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
3690 * @{ */
3691/** Other format. */
3692#define RT_DBGTYPE_OTHER RT_BIT_32(0)
3693/** Stabs. */
3694#define RT_DBGTYPE_STABS RT_BIT_32(1)
3695/** Debug With Arbitrary Record Format (DWARF). */
3696#define RT_DBGTYPE_DWARF RT_BIT_32(2)
3697/** Microsoft Codeview debug info. */
3698#define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
3699/** Watcom debug info. */
3700#define RT_DBGTYPE_WATCOM RT_BIT_32(4)
3701/** IBM High Level Language debug info. */
3702#define RT_DBGTYPE_HLL RT_BIT_32(5)
3703/** Old OS/2 and Windows symbol file. */
3704#define RT_DBGTYPE_SYM RT_BIT_32(6)
3705/** Map file. */
3706#define RT_DBGTYPE_MAP RT_BIT_32(7)
3707/** @} */
3708
3709
3710/** @defgroup grp_rt_cdefs_exetype Executable Image Types
3711 * @{ */
3712/** Some other format. */
3713#define RT_EXETYPE_OTHER RT_BIT_32(0)
3714/** Portable Executable. */
3715#define RT_EXETYPE_PE RT_BIT_32(1)
3716/** Linear eXecutable. */
3717#define RT_EXETYPE_LX RT_BIT_32(2)
3718/** Linear Executable. */
3719#define RT_EXETYPE_LE RT_BIT_32(3)
3720/** New Executable. */
3721#define RT_EXETYPE_NE RT_BIT_32(4)
3722/** DOS Executable (Mark Zbikowski). */
3723#define RT_EXETYPE_MZ RT_BIT_32(5)
3724/** COM Executable. */
3725#define RT_EXETYPE_COM RT_BIT_32(6)
3726/** a.out Executable. */
3727#define RT_EXETYPE_AOUT RT_BIT_32(7)
3728/** Executable and Linkable Format. */
3729#define RT_EXETYPE_ELF RT_BIT_32(8)
3730/** Mach-O Executable (including FAT ones). */
3731#define RT_EXETYPE_MACHO RT_BIT_32(9)
3732/** TE from UEFI. */
3733#define RT_EXETYPE_TE RT_BIT_32(9)
3734/** @} */
3735
3736
3737/** @def VALID_PTR
3738 * Pointer validation macro.
3739 * @param ptr The pointer.
3740 */
3741#if defined(RT_ARCH_AMD64)
3742# ifdef IN_RING3
3743# if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
3744# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
3745 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
3746# elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
3747# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3748 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
3749 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
3750# else
3751# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3752 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
3753# endif
3754# else /* !IN_RING3 */
3755# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3756 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
3757 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
3758# endif /* !IN_RING3 */
3759
3760#elif defined(RT_ARCH_X86)
3761# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3762
3763#elif defined(RT_ARCH_SPARC64)
3764# ifdef IN_RING3
3765# if defined(RT_OS_SOLARIS)
3766/** Sparc64 user mode: According to Figure 9.4 in solaris internals */
3767/** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
3768# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
3769# else
3770# error "Port me"
3771# endif
3772# else /* !IN_RING3 */
3773# if defined(RT_OS_SOLARIS)
3774/** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
3775 * internals. Verify in sources. */
3776# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
3777# else
3778# error "Port me"
3779# endif
3780# endif /* !IN_RING3 */
3781
3782#elif defined(RT_ARCH_SPARC)
3783# ifdef IN_RING3
3784# ifdef RT_OS_SOLARIS
3785/** Sparc user mode: According to
3786 * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
3787# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
3788
3789# else
3790# error "Port me"
3791# endif
3792# else /* !IN_RING3 */
3793# ifdef RT_OS_SOLARIS
3794/** @todo Sparc kernel mode: Check the sources! */
3795# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3796# else
3797# error "Port me"
3798# endif
3799# endif /* !IN_RING3 */
3800
3801#elif defined(RT_ARCH_ARM)
3802/* ASSUMES that at least the last and first 4K are out of bounds. */
3803# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3804
3805#else
3806# error "Architecture identifier missing / not implemented."
3807#endif
3808
3809/** Old name for RT_VALID_PTR. */
3810#define VALID_PTR(ptr) RT_VALID_PTR(ptr)
3811
3812/** @def RT_VALID_ALIGNED_PTR
3813 * Pointer validation macro that also checks the alignment.
3814 * @param ptr The pointer.
3815 * @param align The alignment, must be a power of two.
3816 */
3817#define RT_VALID_ALIGNED_PTR(ptr, align) \
3818 ( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
3819 && VALID_PTR(ptr) )
3820
3821
3822/** @def VALID_PHYS32
3823 * 32 bits physical address validation macro.
3824 * @param Phys The RTGCPHYS address.
3825 */
3826#define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
3827
3828/** @def N_
3829 * The \#define N_ is used to mark a string for translation. This is usable in
3830 * any part of the code, as it is only used by the tools that create message
3831 * catalogs. This macro is a no-op as far as the compiler and code generation
3832 * is concerned.
3833 *
3834 * If you want to both mark a string for translation and translate it, use _().
3835 */
3836#define N_(s) (s)
3837
3838/** @def _
3839 * The \#define _ is used to mark a string for translation and to translate it
3840 * in one step.
3841 *
3842 * If you want to only mark a string for translation, use N_().
3843 */
3844#define _(s) gettext(s)
3845
3846
3847#if (!defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)) || defined(DOXYGEN_RUNNING)
3848# if defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
3849/** With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
3850 * for the other compilers. */
3851# define __PRETTY_FUNCTION__ __FUNCSIG__
3852# else
3853# define __PRETTY_FUNCTION__ __FUNCTION__
3854# endif
3855#endif
3856
3857
3858/** @def RT_STRICT
3859 * The \#define RT_STRICT controls whether or not assertions and other runtime
3860 * checks should be compiled in or not. This is defined when DEBUG is defined.
3861 * If RT_NO_STRICT is defined, it will unconditionally be undefined.
3862 *
3863 * If you want assertions which are not subject to compile time options use
3864 * the AssertRelease*() flavors.
3865 */
3866#if !defined(RT_STRICT) && defined(DEBUG)
3867# define RT_STRICT
3868#endif
3869#ifdef RT_NO_STRICT
3870# undef RT_STRICT
3871#endif
3872
3873/** @todo remove this: */
3874#if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
3875# define RT_LOCK_NO_STRICT
3876#endif
3877#if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
3878# define RT_LOCK_NO_STRICT_ORDER
3879#endif
3880
3881/** @def RT_LOCK_STRICT
3882 * The \#define RT_LOCK_STRICT controls whether deadlock detection and related
3883 * checks are done in the lock and semaphore code. It is by default enabled in
3884 * RT_STRICT builds, but this behavior can be overridden by defining
3885 * RT_LOCK_NO_STRICT. */
3886#if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
3887# define RT_LOCK_STRICT
3888#endif
3889/** @def RT_LOCK_NO_STRICT
3890 * The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
3891#if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
3892# undef RT_LOCK_STRICT
3893#endif
3894
3895/** @def RT_LOCK_STRICT_ORDER
3896 * The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
3897 * by the lock and semaphore code. It is by default enabled in RT_STRICT
3898 * builds, but this behavior can be overridden by defining
3899 * RT_LOCK_NO_STRICT_ORDER. */
3900#if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
3901# define RT_LOCK_STRICT_ORDER
3902#endif
3903/** @def RT_LOCK_NO_STRICT_ORDER
3904 * The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
3905#if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
3906# undef RT_LOCK_STRICT_ORDER
3907#endif
3908
3909
3910/** Source position. */
3911#define RT_SRC_POS __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
3912
3913/** Source position declaration. */
3914#define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
3915
3916/** Source position arguments. */
3917#define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
3918
3919/** Applies NOREF() to the source position arguments. */
3920#define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
3921
3922
3923/** @def RT_INLINE_ASM_EXTERNAL
3924 * Defined as 1 if the compiler does not support inline assembly.
3925 * The ASM* functions will then be implemented in external .asm files.
3926 */
3927#if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
3928 || (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86)) \
3929 || defined(__WATCOMC__)
3930# define RT_INLINE_ASM_EXTERNAL 1
3931#else
3932# define RT_INLINE_ASM_EXTERNAL 0
3933#endif
3934
3935/** @def RT_INLINE_ASM_GNU_STYLE
3936 * Defined as 1 if the compiler understands GNU style inline assembly.
3937 */
3938#if defined(_MSC_VER) || defined(__WATCOMC__)
3939# define RT_INLINE_ASM_GNU_STYLE 0
3940#else
3941# define RT_INLINE_ASM_GNU_STYLE 1
3942#endif
3943
3944/** @def RT_INLINE_ASM_USES_INTRIN
3945 * Defined as the major MSC version if the compiler have and uses intrin.h.
3946 * Otherwise it is 0. */
3947#ifdef _MSC_VER
3948# if _MSC_VER >= 1700 /* Visual C++ v11.0 / 2012 */
3949# define RT_INLINE_ASM_USES_INTRIN 17
3950# elif _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3951# define RT_INLINE_ASM_USES_INTRIN 16
3952# elif _MSC_VER >= 1500 /* Visual C++ v9.0 / 2008 */
3953# define RT_INLINE_ASM_USES_INTRIN 15
3954# elif _MSC_VER >= 1400 /* Visual C++ v8.0 / 2005 */
3955# define RT_INLINE_ASM_USES_INTRIN 14
3956# endif
3957#endif
3958#ifndef RT_INLINE_ASM_USES_INTRIN
3959# define RT_INLINE_ASM_USES_INTRIN 0
3960#endif
3961
3962/** @def RT_COMPILER_SUPPORTS_LAMBDA
3963 * If the defined, the compiler supports lambda expressions. These expressions
3964 * are useful for embedding assertions and type checks into macros. */
3965#if defined(_MSC_VER) && defined(__cplusplus)
3966# if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3967# define RT_COMPILER_SUPPORTS_LAMBDA
3968# endif
3969#elif defined(__GNUC__) && defined(__cplusplus)
3970/* 4.5 or later, I think, if in ++11 mode... */
3971#endif
3972
3973/** @def RT_DATA_IS_FAR
3974 * Set to 1 if we're in 16-bit mode and use far pointers.
3975 */
3976#if ARCH_BITS == 16 && defined(__WATCOMC__) \
3977 && (defined(__COMPACT__) || defined(__LARGE__))
3978# define RT_DATA_IS_FAR 1
3979#else
3980# define RT_DATA_IS_FAR 0
3981#endif
3982
3983/** @def RT_FAR
3984 * For indicating far pointers in 16-bit code.
3985 * Does nothing in 32-bit and 64-bit code. */
3986/** @def RT_NEAR
3987 * For indicating near pointers in 16-bit code.
3988 * Does nothing in 32-bit and 64-bit code. */
3989/** @def RT_FAR_CODE
3990 * For indicating far 16-bit functions.
3991 * Does nothing in 32-bit and 64-bit code. */
3992/** @def RT_NEAR_CODE
3993 * For indicating near 16-bit functions.
3994 * Does nothing in 32-bit and 64-bit code. */
3995/** @def RT_FAR_DATA
3996 * For indicating far 16-bit external data, i.e. in a segment other than DATA16.
3997 * Does nothing in 32-bit and 64-bit code. */
3998#if ARCH_BITS == 16
3999# define RT_FAR __far
4000# define RT_NEAR __near
4001# define RT_FAR_CODE __far
4002# define RT_NEAR_CODE __near
4003# define RT_FAR_DATA __far
4004#else
4005# define RT_FAR
4006# define RT_NEAR
4007# define RT_FAR_CODE
4008# define RT_NEAR_CODE
4009# define RT_FAR_DATA
4010#endif
4011
4012
4013/** @} */
4014
4015
4016/** @defgroup grp_rt_cdefs_cpp Special Macros for C++
4017 * @ingroup grp_rt_cdefs
4018 * @{
4019 */
4020
4021#ifdef __cplusplus
4022
4023/** @def DECLEXPORT_CLASS
4024 * How to declare an exported class. Place this macro after the 'class'
4025 * keyword in the declaration of every class you want to export.
4026 *
4027 * @note It is necessary to use this macro even for inner classes declared
4028 * inside the already exported classes. This is a GCC specific requirement,
4029 * but it seems not to harm other compilers.
4030 */
4031#if defined(_MSC_VER) || defined(RT_OS_OS2)
4032# define DECLEXPORT_CLASS __declspec(dllexport)
4033#elif defined(RT_USE_VISIBILITY_DEFAULT)
4034# define DECLEXPORT_CLASS __attribute__((visibility("default")))
4035#else
4036# define DECLEXPORT_CLASS
4037#endif
4038
4039/** @def DECLIMPORT_CLASS
4040 * How to declare an imported class Place this macro after the 'class'
4041 * keyword in the declaration of every class you want to export.
4042 *
4043 * @note It is necessary to use this macro even for inner classes declared
4044 * inside the already exported classes. This is a GCC specific requirement,
4045 * but it seems not to harm other compilers.
4046 */
4047#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
4048# define DECLIMPORT_CLASS __declspec(dllimport)
4049#elif defined(RT_USE_VISIBILITY_DEFAULT)
4050# define DECLIMPORT_CLASS __attribute__((visibility("default")))
4051#else
4052# define DECLIMPORT_CLASS
4053#endif
4054
4055/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP
4056 * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity
4057 * resolver. The following snippet clearly demonstrates the code causing this
4058 * error:
4059 * @code
4060 * class A
4061 * {
4062 * public:
4063 * operator bool() const { return false; }
4064 * operator int*() const { return NULL; }
4065 * };
4066 * int main()
4067 * {
4068 * A a;
4069 * if (!a);
4070 * if (a && 0);
4071 * return 0;
4072 * }
4073 * @endcode
4074 * The code itself seems pretty valid to me and GCC thinks the same.
4075 *
4076 * This macro fixes the compiler error by explicitly overloading implicit
4077 * global operators !, && and || that take the given class instance as one of
4078 * their arguments.
4079 *
4080 * The best is to use this macro right after the class declaration.
4081 *
4082 * @note The macro expands to nothing for compilers other than MSVC.
4083 *
4084 * @param Cls Class to apply the workaround to
4085 */
4086#if defined(_MSC_VER)
4087# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
4088 inline bool operator! (const Cls &that) { return !bool (that); } \
4089 inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
4090 inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
4091 inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
4092 inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
4093#else
4094# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
4095#endif
4096
4097/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL
4098 * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes.
4099 *
4100 * @param Tpl Name of the template class to apply the workaround to
4101 * @param ArgsDecl arguments of the template, as declared in |<>| after the
4102 * |template| keyword, including |<>|
4103 * @param Args arguments of the template, as specified in |<>| after the
4104 * template class name when using the, including |<>|
4105 *
4106 * Example:
4107 * @code
4108 * // template class declaration
4109 * template <class C>
4110 * class Foo { ... };
4111 * // applied workaround
4112 * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
4113 * @endcode
4114 */
4115#if defined(_MSC_VER)
4116# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
4117 template ArgsDecl \
4118 inline bool operator! (const Tpl Args &that) { return !bool (that); } \
4119 template ArgsDecl \
4120 inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
4121 template ArgsDecl \
4122 inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
4123 template ArgsDecl \
4124 inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
4125 template ArgsDecl \
4126 inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
4127#else
4128# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
4129#endif
4130
4131
4132/** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP
4133 * Declares the copy constructor and the assignment operation as inlined no-ops
4134 * (non-existent functions) for the given class. Use this macro inside the
4135 * private section if you want to effectively disable these operations for your
4136 * class.
4137 *
4138 * @param Cls class name to declare for
4139 */
4140#define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
4141 inline Cls(const Cls &); \
4142 inline Cls &operator= (const Cls &)
4143
4144
4145/** @def DECLARE_CLS_NEW_DELETE_NOOP
4146 * Declares the new and delete operations as no-ops (non-existent functions)
4147 * for the given class. Use this macro inside the private section if you want
4148 * to effectively limit creating class instances on the stack only.
4149 *
4150 * @note The destructor of the given class must not be virtual, otherwise a
4151 * compile time error will occur. Note that this is not a drawback: having
4152 * the virtual destructor for a stack-based class is absolutely useless
4153 * (the real class of the stack-based instance is always known to the compiler
4154 * at compile time, so it will always call the correct destructor).
4155 *
4156 * @param Cls class name to declare for
4157 */
4158#define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
4159 inline static void *operator new (size_t); \
4160 inline static void operator delete (void *)
4161
4162#endif /* __cplusplus */
4163
4164/** @} */
4165
4166#endif /* !IPRT_INCLUDED_cdefs_h */
4167
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