VirtualBox

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

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

iprt/cdefs.h: Added a CTX_EXPR(a_R3Expr, a_R0Expr, a_RCExpr) macro for avoiding #ifdefs. bugref:9218

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