]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - ubuntu/vbox/vboxsf/include/iprt/cdefs.h
2 * IPRT - Common C and C++ definitions.
6 * Copyright (C) 2006-2017 Oracle Corporation
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.
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.
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.
26 #ifndef ___iprt_cdefs_h
27 #define ___iprt_cdefs_h
30 /** @defgroup grp_rt_cdefs IPRT Common Definitions and Macros
34 /** @def RT_C_DECLS_BEGIN
35 * Used to start a block of function declarations which are shared
36 * between C and C++ program.
39 /** @def RT_C_DECLS_END
40 * Used to end a block of function declarations which are shared
41 * between C and C++ program.
44 #if defined(__cplusplus)
45 # define RT_C_DECLS_BEGIN extern "C" {
46 # define RT_C_DECLS_END }
48 # define RT_C_DECLS_BEGIN
49 # define RT_C_DECLS_END
54 * Shut up DOXYGEN warnings and guide it properly thru the code.
56 #ifdef DOXYGEN_RUNNING
59 # define RT_ARCH_AMD64
61 # define RT_ARCH_SPARC
62 # define RT_ARCH_SPARC64
73 # define RT_LOCK_STRICT
74 # define RT_LOCK_NO_STRICT
75 # define RT_LOCK_STRICT_ORDER
76 # define RT_LOCK_NO_STRICT_ORDER
77 # define RT_BREAKPOINT
78 # define RT_NO_DEPRECATED_MACROS
79 # define RT_EXCEPTIONS_ENABLED
80 # define RT_BIG_ENDIAN
81 # define RT_LITTLE_ENDIAN
82 # define RT_COMPILER_GROKS_64BIT_BITFIELDS
83 # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
84 # define RT_NO_VISIBILITY_HIDDEN
85 # define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
86 # define RT_COMPILER_SUPPORTS_VA_ARGS
87 # define RT_COMPILER_SUPPORTS_LAMBDA
88 #endif /* DOXYGEN_RUNNING */
91 * Indicates that we're compiling for the X86 architecture.
94 /** @def RT_ARCH_AMD64
95 * Indicates that we're compiling for the AMD64 architecture.
98 /** @def RT_ARCH_SPARC
99 * Indicates that we're compiling for the SPARC V8 architecture (32-bit).
102 /** @def RT_ARCH_SPARC64
103 * Indicates that we're compiling for the SPARC V9 architecture (64-bit).
105 #if !defined(RT_ARCH_X86) \
106 && !defined(RT_ARCH_AMD64) \
107 && !defined(RT_ARCH_SPARC) \
108 && !defined(RT_ARCH_SPARC64) \
109 && !defined(RT_ARCH_ARM)
110 # if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || defined(__AMD64__)
111 # define RT_ARCH_AMD64
112 # elif defined(__i386__) || defined(_M_IX86) || defined(__X86__)
114 # elif defined(__sparcv9)
115 # define RT_ARCH_SPARC64
116 # elif defined(__sparc__)
117 # define RT_ARCH_SPARC
118 # elif defined(__arm__) || defined(__arm32__)
120 # else /* PORTME: append test for new archs. */
121 # error "Check what predefined macros your compiler uses to indicate architecture."
123 /* PORTME: append new archs checks. */
124 #elif defined(RT_ARCH_X86) && defined(RT_ARCH_AMD64)
125 # error "Both RT_ARCH_X86 and RT_ARCH_AMD64 cannot be defined at the same time!"
126 #elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC)
127 # error "Both RT_ARCH_X86 and RT_ARCH_SPARC cannot be defined at the same time!"
128 #elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC64)
129 # error "Both RT_ARCH_X86 and RT_ARCH_SPARC64 cannot be defined at the same time!"
130 #elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC)
131 # error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC cannot be defined at the same time!"
132 #elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC64)
133 # error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC64 cannot be defined at the same time!"
134 #elif defined(RT_ARCH_SPARC) && defined(RT_ARCH_SPARC64)
135 # error "Both RT_ARCH_SPARC and RT_ARCH_SPARC64 cannot be defined at the same time!"
136 #elif defined(RT_ARCH_ARM) && defined(RT_ARCH_AMD64)
137 # error "Both RT_ARCH_ARM and RT_ARCH_AMD64 cannot be defined at the same time!"
138 #elif defined(RT_ARCH_ARM) && defined(RT_ARCH_X86)
139 # error "Both RT_ARCH_ARM and RT_ARCH_X86 cannot be defined at the same time!"
140 #elif defined(RT_ARCH_ARM) && defined(RT_ARCH_SPARC64)
141 # error "Both RT_ARCH_ARM and RT_ARCH_SPARC64 cannot be defined at the same time!"
142 #elif defined(RT_ARCH_ARM) && defined(RT_ARCH_SPARC)
143 # error "Both RT_ARCH_ARM and RT_ARCH_SPARC cannot be defined at the same time!"
146 /* Final check (PORTME). */
147 #if (defined(RT_ARCH_X86) != 0) \
148 + (defined(RT_ARCH_AMD64) != 0) \
149 + (defined(RT_ARCH_SPARC) != 0) \
150 + (defined(RT_ARCH_SPARC64) != 0) \
151 + (defined(RT_ARCH_ARM) != 0) \
153 # error "Exactly one RT_ARCH_XXX macro shall be defined"
156 /** @def RT_GNUC_PREREQ
157 * Shorter than fiddling with __GNUC__ and __GNUC_MINOR__.
159 * @param a_MinMajor Minimum major version
160 * @param a_MinMinor The minor version number part.
162 #define RT_GNUC_PREREQ(a_MinMajor, a_MinMinor) RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
163 /** @def RT_GNUC_PREREQ_EX
164 * Simplified way of checking __GNUC__ and __GNUC_MINOR__ regardless of actual
165 * compiler used, returns @a a_OtherRet for other compilers.
167 * @param a_MinMajor Minimum major version
168 * @param a_MinMinor The minor version number part.
169 * @param a_OtherRet What to return for non-GCC compilers.
171 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
172 # define RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) \
173 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((a_MinMajor) << 16) + (a_MinMinor))
175 # define RT_GNUC_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
178 /** @def RT_MSC_PREREQ
179 * Convenient way of checking _MSC_VER regardless of actual compiler used
180 * (returns false if not MSC).
182 * @param a_MinVer Preferably a RT_MSC_VER_XXX value.
184 #define RT_MSC_PREREQ(a_MinVer) RT_MSC_PREREQ_EX(a_MinVer, 0)
185 /** @def RT_MSC_PREREQ_EX
186 * Convenient way of checking _MSC_VER regardless of actual compiler used,
187 * returns @a a_OtherRet for other compilers.
189 * @param a_MinVer Preferably a RT_MSC_VER_XXX value.
190 * @param a_OtherRet What to return for non-MSC compilers.
192 #if defined(_MSC_VER)
193 # define RT_MSC_PREREQ_EX(a_MinVer, a_OtherRet) ( (_MSC_VER) >= (a_MinVer) )
195 # define RT_MSC_PREREQ_EX(a_MinVer, a_OtherRet) (a_OtherRet)
197 /** @name RT_MSC_VER_XXX - _MSC_VER values to use with RT_MSC_PREREQ.
198 * @remarks The VCxxx values are derived from the CRT DLLs shipping with the
201 #define RT_MSC_VER_VC50 (1100) /**< Visual C++ 5.0. */
202 #define RT_MSC_VER_VC60 (1200) /**< Visual C++ 6.0. */
203 #define RT_MSC_VER_VC70 (1300) /**< Visual C++ 7.0. */
204 #define RT_MSC_VER_VC70 (1300) /**< Visual C++ 7.0. */
205 #define RT_MSC_VER_VS2003 (1310) /**< Visual Studio 2003, aka Visual C++ 7.1. */
206 #define RT_MSC_VER_VC71 RT_MSC_VER_VS2003 /**< Visual C++ 7.1, aka Visual Studio 2003. */
207 #define RT_MSC_VER_VS2005 (1400) /**< Visual Studio 2005. */
208 #define RT_MSC_VER_VC80 RT_MSC_VER_VS2005 /**< Visual C++ 8.0, aka Visual Studio 2008. */
209 #define RT_MSC_VER_VS2008 (1500) /**< Visual Studio 2008. */
210 #define RT_MSC_VER_VC90 RT_MSC_VER_VS2008 /**< Visual C++ 9.0, aka Visual Studio 2008. */
211 #define RT_MSC_VER_VS2010 (1600) /**< Visual Studio 2010. */
212 #define RT_MSC_VER_VC100 RT_MSC_VER_VS2010 /**< Visual C++ 10.0, aka Visual Studio 2010. */
213 #define RT_MSC_VER_VS2012 (1700) /**< Visual Studio 2012. */
214 #define RT_MSC_VER_VC110 RT_MSC_VER_VS2012 /**< Visual C++ 11.0, aka Visual Studio 2012. */
215 #define RT_MSC_VER_VS2013 (1800) /**< Visual Studio 2013. */
216 #define RT_MSC_VER_VC120 RT_MSC_VER_VS2013 /**< Visual C++ 12.0, aka Visual Studio 2013. */
217 #define RT_MSC_VER_VS2015 (1900) /**< Visual Studio 2015. */
218 #define RT_MSC_VER_VC140 RT_MSC_VER_VS2015 /**< Visual C++ 14.0, aka Visual Studio 2015. */
221 /** @def RT_CLANG_PREREQ
222 * Shorter than fiddling with __clang_major__ and __clang_minor__.
224 * @param a_MinMajor Minimum major version
225 * @param a_MinMinor The minor version number part.
227 #define RT_CLANG_PREREQ(a_MinMajor, a_MinMinor) RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
228 /** @def RT_CLANG_PREREQ_EX
229 * Simplified way of checking __clang_major__ and __clang_minor__ regardless of
230 * actual compiler used, returns @a a_OtherRet for other compilers.
232 * @param a_MinMajor Minimum major version
233 * @param a_MinMinor The minor version number part.
234 * @param a_OtherRet What to return for non-GCC compilers.
236 #if defined(__clang_major__) && defined(__clang_minor__)
237 # define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) \
238 ((__clang_major__ << 16) + __clang_minor__ >= ((a_MinMajor) << 16) + (a_MinMinor))
240 # define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
245 * Indicates that we're compiling for the X86 architecture.
250 * Indicates that we're compiling for the AMD64 architecture.
253 #if !defined(__X86__) && !defined(__AMD64__) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
254 # if defined(RT_ARCH_AMD64)
256 # elif defined(RT_ARCH_X86)
259 # error "Check what predefined macros your compiler uses to indicate architecture."
261 #elif defined(__X86__) && defined(__AMD64__)
262 # error "Both __X86__ and __AMD64__ cannot be defined at the same time!"
263 #elif defined(__X86__) && !defined(RT_ARCH_X86)
264 # error "__X86__ without RT_ARCH_X86!"
265 #elif defined(__AMD64__) && !defined(RT_ARCH_AMD64)
266 # error "__AMD64__ without RT_ARCH_AMD64!"
269 /** @def RT_BIG_ENDIAN
270 * Defined if the architecture is big endian. */
271 /** @def RT_LITTLE_ENDIAN
272 * Defined if the architecture is little endian. */
273 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_ARM)
274 # define RT_LITTLE_ENDIAN
275 #elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
276 # define RT_BIG_ENDIAN
278 # error "PORTME: architecture endianess"
280 #if defined(RT_BIG_ENDIAN) && defined(RT_LITTLE_ENDIAN)
281 # error "Both RT_BIG_ENDIAN and RT_LITTLE_ENDIAN are defined"
286 * Used to indicate that we're compiling code which is running
287 * in Ring-0 Host Context.
291 * Used to indicate that we're compiling code which is running
292 * in Ring-3 Host Context.
296 * Used to indicate that we're compiling code which is running
297 * in the Raw-mode Context (implies R0).
299 #if !defined(IN_RING3) && !defined(IN_RING0) && !defined(IN_RC) && !defined(IN_RC)
300 # error "You must define which context the compiled code should run in; IN_RING3, IN_RING0 or IN_RC"
302 #if (defined(IN_RING3) && (defined(IN_RING0) || defined(IN_RC)) ) \
303 || (defined(IN_RING0) && (defined(IN_RING3) || defined(IN_RC)) ) \
304 || (defined(IN_RC) && (defined(IN_RING3) || defined(IN_RING0)) )
305 # error "Only one of the IN_RING3, IN_RING0, IN_RC defines should be defined."
310 * Defines the bit count of the current context.
312 #if !defined(ARCH_BITS) || defined(DOXYGEN_RUNNING)
313 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64)
314 # define ARCH_BITS 64
315 # elif !defined(__I86__) || !defined(__WATCOMC__)
316 # define ARCH_BITS 32
318 # define ARCH_BITS 16
322 /* ARCH_BITS validation (PORTME). */
324 #if defined(RT_ARCH_X86) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_ARM)
325 # error "ARCH_BITS=64 but non-64-bit RT_ARCH_XXX defined."
327 #if !defined(RT_ARCH_AMD64) && !defined(RT_ARCH_SPARC64)
328 # error "ARCH_BITS=64 but no 64-bit RT_ARCH_XXX defined."
331 #elif ARCH_BITS == 32
332 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64)
333 # error "ARCH_BITS=32 but non-32-bit RT_ARCH_XXX defined."
335 #if !defined(RT_ARCH_X86) && !defined(RT_ARCH_SPARC) && !defined(RT_ARCH_ARM)
336 # error "ARCH_BITS=32 but no 32-bit RT_ARCH_XXX defined."
339 #elif ARCH_BITS == 16
340 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64) || defined(RT_ARCH_ARM)
341 # error "ARCH_BITS=16 but non-16-bit RT_ARCH_XX defined."
343 #if !defined(RT_ARCH_X86)
344 # error "ARCH_BITS=16 but RT_ARCH_X86 isn't defined."
348 # error "Unsupported ARCH_BITS value!"
351 /** @def HC_ARCH_BITS
352 * Defines the host architecture bit count.
354 #if !defined(HC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
356 # define HC_ARCH_BITS ARCH_BITS
358 # define HC_ARCH_BITS 32
362 /** @def GC_ARCH_BITS
363 * Defines the guest architecture bit count.
365 #if !defined(GC_ARCH_BITS) && !defined(DOXYGEN_RUNNING)
366 # ifdef VBOX_WITH_64_BITS_GUESTS
367 # define GC_ARCH_BITS 64
369 # define GC_ARCH_BITS 32
373 /** @def R3_ARCH_BITS
374 * Defines the host ring-3 architecture bit count.
376 #if !defined(R3_ARCH_BITS) || defined(DOXYGEN_RUNNING)
378 # define R3_ARCH_BITS ARCH_BITS
380 # define R3_ARCH_BITS HC_ARCH_BITS
384 /** @def R0_ARCH_BITS
385 * Defines the host ring-0 architecture bit count.
387 #if !defined(R0_ARCH_BITS) || defined(DOXYGEN_RUNNING)
389 # define R0_ARCH_BITS ARCH_BITS
391 # define R0_ARCH_BITS HC_ARCH_BITS
395 /** @def GC_ARCH_BITS
396 * Defines the guest architecture bit count.
398 #if !defined(GC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
400 # define GC_ARCH_BITS ARCH_BITS
402 # define GC_ARCH_BITS 32
408 /** @name RT_OPSYS_XXX - Operative System Identifiers.
409 * These are the value that the RT_OPSYS \#define can take. @{
412 #define RT_OPSYS_UNKNOWN 0
414 #define RT_OPSYS_AGNOSTIC 1
415 /** Darwin - aka Mac OS X. */
416 #define RT_OPSYS_DARWIN 2
417 /** DragonFly BSD. */
418 #define RT_OPSYS_DRAGONFLY 3
420 #define RT_OPSYS_DOS 4
422 #define RT_OPSYS_FREEBSD 5
424 #define RT_OPSYS_HAIKU 6
426 #define RT_OPSYS_LINUX 7
428 #define RT_OPSYS_L4 8
430 #define RT_OPSYS_MINIX 9
432 #define RT_OPSYS_NETBSD 11
434 #define RT_OPSYS_NETWARE 12
436 #define RT_OPSYS_NT 13
438 #define RT_OPSYS_OPENBSD 14
440 #define RT_OPSYS_OS2 15
442 #define RT_OPSYS_PLAN9 16
444 #define RT_OPSYS_QNX 17
446 #define RT_OPSYS_SOLARIS 18
448 #define RT_OPSYS_UEFI 19
450 #define RT_OPSYS_WINDOWS 20
451 /** The max RT_OPSYS_XXX value (exclusive). */
452 #define RT_OPSYS_MAX 21
456 * Indicates which OS we're targeting. It's a \#define with is
457 * assigned one of the RT_OPSYS_XXX defines above.
459 * So to test if we're on FreeBSD do the following:
461 * #if RT_OPSYS == RT_OPSYS_FREEBSD
462 * some_funky_freebsd_specific_stuff();
468 * Set RT_OPSYS_XXX according to RT_OS_XXX.
470 * Search: #define RT_OPSYS_([A-Z0-9]+) .*
471 * Replace: # elif defined(RT_OS_\1)\n# define RT_OPSYS RT_OPSYS_\1
474 # if defined(RT_OS_UNKNOWN) || defined(DOXYGEN_RUNNING)
475 # define RT_OPSYS RT_OPSYS_UNKNOWN
476 # elif defined(RT_OS_AGNOSTIC)
477 # define RT_OPSYS RT_OPSYS_AGNOSTIC
478 # elif defined(RT_OS_DARWIN)
479 # define RT_OPSYS RT_OPSYS_DARWIN
480 # elif defined(RT_OS_DRAGONFLY)
481 # define RT_OPSYS RT_OPSYS_DRAGONFLY
482 # elif defined(RT_OS_DOS)
483 # define RT_OPSYS RT_OPSYS_DOS
484 # elif defined(RT_OS_FREEBSD)
485 # define RT_OPSYS RT_OPSYS_FREEBSD
486 # elif defined(RT_OS_HAIKU)
487 # define RT_OPSYS RT_OPSYS_HAIKU
488 # elif defined(RT_OS_LINUX)
489 # define RT_OPSYS RT_OPSYS_LINUX
490 # elif defined(RT_OS_L4)
491 # define RT_OPSYS RT_OPSYS_L4
492 # elif defined(RT_OS_MINIX)
493 # define RT_OPSYS RT_OPSYS_MINIX
494 # elif defined(RT_OS_NETBSD)
495 # define RT_OPSYS RT_OPSYS_NETBSD
496 # elif defined(RT_OS_NETWARE)
497 # define RT_OPSYS RT_OPSYS_NETWARE
498 # elif defined(RT_OS_NT)
499 # define RT_OPSYS RT_OPSYS_NT
500 # elif defined(RT_OS_OPENBSD)
501 # define RT_OPSYS RT_OPSYS_OPENBSD
502 # elif defined(RT_OS_OS2)
503 # define RT_OPSYS RT_OPSYS_OS2
504 # elif defined(RT_OS_PLAN9)
505 # define RT_OPSYS RT_OPSYS_PLAN9
506 # elif defined(RT_OS_QNX)
507 # define RT_OPSYS RT_OPSYS_QNX
508 # elif defined(RT_OS_SOLARIS)
509 # define RT_OPSYS RT_OPSYS_SOLARIS
510 # elif defined(RT_OS_UEFI)
511 # define RT_OPSYS RT_OPSYS_UEFI
512 # elif defined(RT_OS_WINDOWS)
513 # define RT_OPSYS RT_OPSYS_WINDOWS
518 * Guess RT_OPSYS based on compiler predefined macros.
521 # if defined(__APPLE__)
522 # define RT_OPSYS RT_OPSYS_DARWIN
523 # elif defined(__DragonFly__)
524 # define RT_OPSYS RT_OPSYS_DRAGONFLY
525 # elif defined(__FreeBSD__) /*??*/
526 # define RT_OPSYS RT_OPSYS_FREEBSD
527 # elif defined(__gnu_linux__)
528 # define RT_OPSYS RT_OPSYS_LINUX
529 # elif defined(__NetBSD__) /*??*/
530 # define RT_OPSYS RT_OPSYS_NETBSD
531 # elif defined(__OpenBSD__) /*??*/
532 # define RT_OPSYS RT_OPSYS_OPENBSD
533 # elif defined(__OS2__)
534 # define RT_OPSYS RT_OPSYS_OS2
535 # elif defined(__sun__) || defined(__SunOS__) || defined(__sun) || defined(__SunOS)
536 # define RT_OPSYS RT_OPSYS_SOLARIS
537 # elif defined(_WIN32) || defined(_WIN64)
538 # define RT_OPSYS RT_OPSYS_WINDOWS
539 # elif defined(MSDOS) || defined(_MSDOS) || defined(DOS16RM) /* OW+MSC || MSC || DMC */
540 # define RT_OPSYS RT_OPSYS_DOS
546 #if RT_OPSYS < RT_OPSYS_UNKNOWN || RT_OPSYS >= RT_OPSYS_MAX
547 # error "Invalid RT_OPSYS value."
551 * Do some consistency checks.
553 * Search: #define RT_OPSYS_([A-Z0-9]+) .*
554 * Replace: #if defined(RT_OS_\1) && RT_OPSYS != RT_OPSYS_\1\n# error RT_OPSYS vs RT_OS_\1\n#endif
556 #if defined(RT_OS_UNKNOWN) && RT_OPSYS != RT_OPSYS_UNKNOWN
557 # error RT_OPSYS vs RT_OS_UNKNOWN
559 #if defined(RT_OS_AGNOSTIC) && RT_OPSYS != RT_OPSYS_AGNOSTIC
560 # error RT_OPSYS vs RT_OS_AGNOSTIC
562 #if defined(RT_OS_DARWIN) && RT_OPSYS != RT_OPSYS_DARWIN
563 # error RT_OPSYS vs RT_OS_DARWIN
565 #if defined(RT_OS_DRAGONFLY) && RT_OPSYS != RT_OPSYS_DRAGONFLY
566 # error RT_OPSYS vs RT_OS_DRAGONFLY
568 #if defined(RT_OS_DOS) && RT_OPSYS != RT_OPSYS_DOS
569 # error RT_OPSYS vs RT_OS_DOS
571 #if defined(RT_OS_FREEBSD) && RT_OPSYS != RT_OPSYS_FREEBSD
572 # error RT_OPSYS vs RT_OS_FREEBSD
574 #if defined(RT_OS_HAIKU) && RT_OPSYS != RT_OPSYS_HAIKU
575 # error RT_OPSYS vs RT_OS_HAIKU
577 #if defined(RT_OS_LINUX) && RT_OPSYS != RT_OPSYS_LINUX
578 # error RT_OPSYS vs RT_OS_LINUX
580 #if defined(RT_OS_L4) && RT_OPSYS != RT_OPSYS_L4
581 # error RT_OPSYS vs RT_OS_L4
583 #if defined(RT_OS_MINIX) && RT_OPSYS != RT_OPSYS_MINIX
584 # error RT_OPSYS vs RT_OS_MINIX
586 #if defined(RT_OS_NETBSD) && RT_OPSYS != RT_OPSYS_NETBSD
587 # error RT_OPSYS vs RT_OS_NETBSD
589 #if defined(RT_OS_NETWARE) && RT_OPSYS != RT_OPSYS_NETWARE
590 # error RT_OPSYS vs RT_OS_NETWARE
592 #if defined(RT_OS_NT) && RT_OPSYS != RT_OPSYS_NT
593 # error RT_OPSYS vs RT_OS_NT
595 #if defined(RT_OS_OPENBSD) && RT_OPSYS != RT_OPSYS_OPENBSD
596 # error RT_OPSYS vs RT_OS_OPENBSD
598 #if defined(RT_OS_OS2) && RT_OPSYS != RT_OPSYS_OS2
599 # error RT_OPSYS vs RT_OS_OS2
601 #if defined(RT_OS_PLAN9) && RT_OPSYS != RT_OPSYS_PLAN9
602 # error RT_OPSYS vs RT_OS_PLAN9
604 #if defined(RT_OS_QNX) && RT_OPSYS != RT_OPSYS_QNX
605 # error RT_OPSYS vs RT_OS_QNX
607 #if defined(RT_OS_SOLARIS) && RT_OPSYS != RT_OPSYS_SOLARIS
608 # error RT_OPSYS vs RT_OS_SOLARIS
610 #if defined(RT_OS_UEFI) && RT_OPSYS != RT_OPSYS_UEFI
611 # error RT_OPSYS vs RT_OS_UEFI
613 #if defined(RT_OS_WINDOWS) && RT_OPSYS != RT_OPSYS_WINDOWS
614 # error RT_OPSYS vs RT_OS_WINDOWS
618 * Make sure the RT_OS_XXX macro is defined.
620 * Search: #define RT_OPSYS_([A-Z0-9]+) .*
621 * Replace: #elif RT_OPSYS == RT_OPSYS_\1\n# ifndef RT_OS_\1\n# define RT_OS_\1\n# endif
623 #if RT_OPSYS == RT_OPSYS_UNKNOWN
624 # ifndef RT_OS_UNKNOWN
625 # define RT_OS_UNKNOWN
627 #elif RT_OPSYS == RT_OPSYS_AGNOSTIC
628 # ifndef RT_OS_AGNOSTIC
629 # define RT_OS_AGNOSTIC
631 #elif RT_OPSYS == RT_OPSYS_DARWIN
632 # ifndef RT_OS_DARWIN
633 # define RT_OS_DARWIN
635 #elif RT_OPSYS == RT_OPSYS_DRAGONFLY
636 # ifndef RT_OS_DRAGONFLY
637 # define RT_OS_DRAGONFLY
639 #elif RT_OPSYS == RT_OPSYS_DOS
643 #elif RT_OPSYS == RT_OPSYS_FREEBSD
644 # ifndef RT_OS_FREEBSD
645 # define RT_OS_FREEBSD
647 #elif RT_OPSYS == RT_OPSYS_HAIKU
651 #elif RT_OPSYS == RT_OPSYS_LINUX
655 #elif RT_OPSYS == RT_OPSYS_L4
659 #elif RT_OPSYS == RT_OPSYS_MINIX
663 #elif RT_OPSYS == RT_OPSYS_NETBSD
664 # ifndef RT_OS_NETBSD
665 # define RT_OS_NETBSD
667 #elif RT_OPSYS == RT_OPSYS_NETWARE
668 # ifndef RT_OS_NETWARE
669 # define RT_OS_NETWARE
671 #elif RT_OPSYS == RT_OPSYS_NT
675 #elif RT_OPSYS == RT_OPSYS_OPENBSD
676 # ifndef RT_OS_OPENBSD
677 # define RT_OS_OPENBSD
679 #elif RT_OPSYS == RT_OPSYS_OS2
683 #elif RT_OPSYS == RT_OPSYS_PLAN9
687 #elif RT_OPSYS == RT_OPSYS_QNX
691 #elif RT_OPSYS == RT_OPSYS_SOLARIS
692 # ifndef RT_OS_SOLARIS
693 # define RT_OS_SOLARIS
695 #elif RT_OPSYS == RT_OPSYS_UEFI
699 #elif RT_OPSYS == RT_OPSYS_WINDOWS
700 # ifndef RT_OS_WINDOWS
701 # define RT_OS_WINDOWS
704 # error "Bad RT_OPSYS value."
709 * Checks whether the given OpSys uses DOS-style paths or not.
711 * By DOS-style paths we include drive lettering and UNC paths.
713 * @returns true / false
714 * @param a_OpSys The RT_OPSYS_XXX value to check, will be reference
717 #define RT_OPSYS_USES_DOS_PATHS(a_OpSys) \
718 ( (a_OpSys) == RT_OPSYS_WINDOWS \
719 || (a_OpSys) == RT_OPSYS_OS2 \
720 || (a_OpSys) == RT_OPSYS_DOS )
725 * Declare a type differently in GC, R3 and R0.
727 * @param GCType The GC type.
728 * @param R3Type The R3 type.
729 * @param R0Type The R0 type.
730 * @remark For pointers used only in one context use RCPTRTYPE(), R3R0PTRTYPE(), R3PTRTYPE() or R0PTRTYPE().
733 # define CTXTYPE(GCType, R3Type, R0Type) GCType
734 #elif defined(IN_RING3)
735 # define CTXTYPE(GCType, R3Type, R0Type) R3Type
737 # define CTXTYPE(GCType, R3Type, R0Type) R0Type
741 * Declare a pointer which is used in the raw mode context but appears in structure(s) used by
742 * both HC and RC. The main purpose is to make sure structures have the same
743 * size when built for different architectures.
745 * @param RCType The RC type.
747 #define RCPTRTYPE(RCType) CTXTYPE(RCType, RTRCPTR, RTRCPTR)
750 * Declare a pointer which is used in HC, is explicitly valid in ring 3 and 0,
751 * but appears in structure(s) used by both HC and GC. The main purpose is to
752 * make sure structures have the same size when built for different architectures.
754 * @param R3R0Type The R3R0 type.
755 * @remarks This used to be called HCPTRTYPE.
757 #define R3R0PTRTYPE(R3R0Type) CTXTYPE(RTHCPTR, R3R0Type, R3R0Type)
760 * Declare a pointer which is used in R3 but appears in structure(s) used by
761 * both HC and GC. The main purpose is to make sure structures have the same
762 * size when built for different architectures.
764 * @param R3Type The R3 type.
766 #define R3PTRTYPE(R3Type) CTXTYPE(RTHCUINTPTR, R3Type, RTHCUINTPTR)
769 * Declare a pointer which is used in R0 but appears in structure(s) used by
770 * both HC and GC. The main purpose is to make sure structures have the same
771 * size when built for different architectures.
773 * @param R0Type The R0 type.
775 #define R0PTRTYPE(R0Type) CTXTYPE(RTHCUINTPTR, RTHCUINTPTR, R0Type)
778 * Adds the suffix of the current context to the passed in
779 * identifier name. The suffix is HC or GC.
781 * This is macro should only be used in shared code to avoid a forest of ifdefs.
782 * @param var Identifier name.
783 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
785 /** @def OTHERCTXSUFF
786 * Adds the suffix of the other context to the passed in
787 * identifier name. The suffix is HC or GC.
789 * This is macro should only be used in shared code to avoid a forest of ifdefs.
790 * @param var Identifier name.
791 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
794 # define CTXSUFF(var) var##GC
795 # define OTHERCTXSUFF(var) var##HC
797 # define CTXSUFF(var) var##HC
798 # define OTHERCTXSUFF(var) var##GC
802 * Adds the suffix of the current context to the passed in
803 * identifier name. The suffix is R3, R0 or GC.
805 * This is macro should only be used in shared code to avoid a forest of ifdefs.
806 * @param var Identifier name.
807 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
810 # define CTXALLSUFF(var) var##GC
811 #elif defined(IN_RING0)
812 # define CTXALLSUFF(var) var##R0
814 # define CTXALLSUFF(var) var##R3
818 * Adds the suffix of the current context to the passed in
819 * identifier name. The suffix is R3, R0 or RC.
821 * This is macro should only be used in shared code to avoid a forest of ifdefs.
822 * @param var Identifier name.
824 * @remark This will replace CTXALLSUFF and CTXSUFF before long.
827 # define CTX_SUFF(var) var##RC
828 #elif defined(IN_RING0)
829 # define CTX_SUFF(var) var##R0
831 # define CTX_SUFF(var) var##R3
835 * Adds the suffix of the current context to the passed in
836 * identifier name, combining RC and R0 into RZ.
837 * The suffix thus is R3 or RZ.
839 * This is macro should only be used in shared code to avoid a forest of ifdefs.
840 * @param var Identifier name.
842 * @remark This will replace CTXALLSUFF and CTXSUFF before long.
845 # define CTX_SUFF_Z(var) var##R3
847 # define CTX_SUFF_Z(var) var##RZ
852 * Adds the current context as a middle name of an identifier name
853 * The middle name is HC or GC.
855 * This is macro should only be used in shared code to avoid a forest of ifdefs.
856 * @param first First name.
857 * @param last Surname.
860 * Adds the other context as a middle name of an identifier name
861 * The middle name is HC or GC.
863 * This is macro should only be used in shared code to avoid a forest of ifdefs.
864 * @param first First name.
865 * @param last Surname.
866 * @deprecated use CTX_MID or CTX_MID_Z
869 # define CTXMID(first, last) first##GC##last
870 # define OTHERCTXMID(first, last) first##HC##last
872 # define CTXMID(first, last) first##HC##last
873 # define OTHERCTXMID(first, last) first##GC##last
877 * Adds the current context as a middle name of an identifier name.
878 * The middle name is R3, R0 or GC.
880 * This is macro should only be used in shared code to avoid a forest of ifdefs.
881 * @param first First name.
882 * @param last Surname.
883 * @deprecated use CTX_MID or CTX_MID_Z
886 # define CTXALLMID(first, last) first##GC##last
887 #elif defined(IN_RING0)
888 # define CTXALLMID(first, last) first##R0##last
890 # define CTXALLMID(first, last) first##R3##last
894 * Adds the current context as a middle name of an identifier name.
895 * The middle name is R3, R0 or RC.
897 * This is macro should only be used in shared code to avoid a forest of ifdefs.
898 * @param first First name.
899 * @param last Surname.
902 # define CTX_MID(first, last) first##RC##last
903 #elif defined(IN_RING0)
904 # define CTX_MID(first, last) first##R0##last
906 # define CTX_MID(first, last) first##R3##last
910 * Adds the current context as a middle name of an identifier name, combining RC
912 * The middle name thus is either R3 or RZ.
914 * This is macro should only be used in shared code to avoid a forest of ifdefs.
915 * @param first First name.
916 * @param last Surname.
919 # define CTX_MID_Z(first, last) first##R3##last
921 # define CTX_MID_Z(first, last) first##RZ##last
926 * A macro which in GC and R0 will return a dummy string while in R3 it will return
929 * This is typically used to wrap description strings in structures shared
930 * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING3 mess.
932 * @param pR3String The R3 string. Only referenced in R3.
933 * @see R0STRING and GCSTRING
936 # define R3STRING(pR3String) (pR3String)
938 # define R3STRING(pR3String) ("<R3_STRING>")
942 * A macro which in GC and R3 will return a dummy string while in R0 it will return
945 * This is typically used to wrap description strings in structures shared
946 * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING0 mess.
948 * @param pR0String The R0 string. Only referenced in R0.
949 * @see R3STRING and GCSTRING
952 # define R0STRING(pR0String) (pR0String)
954 # define R0STRING(pR0String) ("<R0_STRING>")
958 * A macro which in R3 and R0 will return a dummy string while in RC it will return
961 * This is typically used to wrap description strings in structures shared
962 * between R3, R0 and/or RC. The intention is to avoid the \#ifdef IN_RC mess.
964 * @param pRCString The RC string. Only referenced in RC.
965 * @see R3STRING, R0STRING
968 # define RCSTRING(pRCString) (pRCString)
970 # define RCSTRING(pRCString) ("<RC_STRING>")
975 * A macro that expands to nothing.
976 * This is primarily intended as a dummy argument for macros to avoid the
977 * undefined behavior passing empty arguments to an macro (ISO C90 and C++98,
978 * gcc v4.4 warns about it).
982 /** @def RT_GCC_EXTENSION
983 * Macro for shutting up GCC warnings about using language extensions. */
985 # define RT_GCC_EXTENSION __extension__
987 # define RT_GCC_EXTENSION
990 /** @def RT_GCC_NO_WARN_DEPRECATED_BEGIN
991 * Used to start a block of code where GCC should not warn about deprecated
993 #if RT_GNUC_PREREQ(4, 6)
994 # define RT_GCC_NO_WARN_DEPRECATED_BEGIN \
995 _Pragma("GCC diagnostic push") \
996 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
997 /** @def RT_GCC_NO_WARN_DEPRECATED_END
998 * Used to end a block of code where GCC should not warn about deprecated
1000 # define RT_GCC_NO_WARN_DEPRECATED_END \
1001 _Pragma("GCC diagnostic pop")
1003 # define RT_GCC_NO_WARN_DEPRECATED_BEGIN
1004 # define RT_GCC_NO_WARN_DEPRECATED_END
1007 /** @def RT_GCC_NO_WARN_CONVERSION_BEGIN
1008 * Used to start a block of code where GCC should not warn about implicit
1009 * conversions that may alter a value. */
1010 #if RT_GNUC_PREREQ(4, 6)
1011 # define RT_GCC_NO_WARN_CONVERSION_BEGIN \
1012 _Pragma("GCC diagnostic push") \
1013 _Pragma("GCC diagnostic ignored \"-Wconversion\"")
1014 /** @def RT_GCC_NO_WARN_CONVERSION_END
1015 * Used to end a block of code where GCC should not warn about implicit
1016 * conversions that may alter a value. */
1017 # define RT_GCC_NO_WARN_CONVERSION_END \
1018 _Pragma("GCC diagnostic pop")
1020 # define RT_GCC_NO_WARN_CONVERSION_BEGIN
1021 # define RT_GCC_NO_WARN_CONVERSION_END
1024 /** @def RT_COMPILER_GROKS_64BIT_BITFIELDS
1025 * Macro that is defined if the compiler understands 64-bit bitfields. */
1026 #if !defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__))
1027 # if !defined(__WATCOMC__) /* watcom compiler doesn't grok it either. */
1028 # define RT_COMPILER_GROKS_64BIT_BITFIELDS
1032 /** @def RT_COMPILER_WITH_80BIT_LONG_DOUBLE
1033 * Macro that is defined if the compiler implements long double as the
1034 * IEEE extended precision floating. */
1035 #if (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) && !defined(RT_OS_WINDOWS)
1036 # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
1040 /** @def RT_EXCEPTIONS_ENABLED
1041 * Defined when C++ exceptions are enabled.
1043 #if !defined(RT_EXCEPTIONS_ENABLED) \
1044 && defined(__cplusplus) \
1045 && ( (defined(_MSC_VER) && defined(_CPPUNWIND)) \
1046 || (defined(__GNUC__) && defined(__EXCEPTIONS)))
1047 # define RT_EXCEPTIONS_ENABLED
1050 /** @def RT_NO_THROW_PROTO
1051 * How to express that a function doesn't throw C++ exceptions
1052 * and the compiler can thus save itself the bother of trying
1053 * to catch any of them. Put this between the closing parenthesis
1054 * and the semicolon in function prototypes (and implementation if C++).
1056 * @remarks May not work on C++ methods, mainly intented for C-style APIs.
1058 * @remarks The use of the nothrow attribute with GCC is because old compilers
1059 * (4.1.1, 32-bit) leaking the nothrow into global space or something
1060 * when used with RTDECL or similar. Using this forces use to have two
1061 * macros, as the nothrow attribute is not for the function definition.
1063 #ifdef RT_EXCEPTIONS_ENABLED
1065 # if RT_GNUC_PREREQ(3, 3)
1066 # define RT_NO_THROW_PROTO __attribute__((__nothrow__))
1068 # define RT_NO_THROW_PROTO
1071 # define RT_NO_THROW_PROTO throw()
1074 # define RT_NO_THROW_PROTO
1077 /** @def RT_NO_THROW_DEF
1078 * The counter part to RT_NO_THROW_PROTO that is added to the function
1081 #if defined(RT_EXCEPTIONS_ENABLED) && !defined(__GNUC__)
1082 # define RT_NO_THROW_DEF RT_NO_THROW_PROTO
1084 # define RT_NO_THROW_DEF
1088 * How to express that a method or function throws a type of exceptions. Some
1089 * compilers does not want this kind of information and will warning about it.
1091 * @param type The type exception.
1093 * @remarks If the actual throwing is done from the header, enclose it by
1094 * \#ifdef RT_EXCEPTIONS_ENABLED ... \#else ... \#endif so the header
1095 * compiles cleanly without exceptions enabled.
1097 * Do NOT use this for the actual throwing of exceptions!
1099 #ifdef RT_EXCEPTIONS_ENABLED
1100 # if RT_MSC_PREREQ_EX(RT_MSC_VER_VC71, 0)
1101 # define RT_THROW(type)
1102 # elif RT_GNUC_PREREQ(7, 0)
1103 # define RT_THROW(type)
1105 # define RT_THROW(type) throw(type)
1108 # define RT_THROW(type)
1112 /** @def RT_FALL_THROUGH
1113 * Tell the compiler that we're falling through to the next case in a switch.
1114 * @sa RT_FALL_THRU */
1115 #if RT_GNUC_PREREQ(7, 0)
1116 # define RT_FALL_THROUGH() __attribute__((fallthrough))
1118 # define RT_FALL_THROUGH() (void)0
1120 /** @def RT_FALL_THRU
1121 * Tell the compiler that we're falling thru to the next case in a switch.
1122 * @sa RT_FALL_THROUGH */
1123 #define RT_FALL_THRU() RT_FALL_THROUGH()
1126 /** @def RT_IPRT_FORMAT_ATTR
1127 * Identifies a function taking an IPRT format string.
1128 * @param a_iFmt The index (1-based) of the format string argument.
1129 * @param a_iArgs The index (1-based) of the first format argument, use 0 for
1132 #if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
1133 # define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs) __attribute__((__iprt_format__(a_iFmt, a_iArgs)))
1135 # define RT_IPRT_FORMAT_ATTR(a_iFmt, a_iArgs)
1138 /** @def RT_IPRT_FORMAT_ATTR_MAYBE_NULL
1139 * Identifies a function taking an IPRT format string, NULL is allowed.
1140 * @param a_iFmt The index (1-based) of the format string argument.
1141 * @param a_iArgs The index (1-based) of the first format argument, use 0 for
1144 #if defined(__GNUC__) && defined(WITH_IPRT_FORMAT_ATTRIBUTE)
1145 # define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs) __attribute__((__iprt_format_maybe_null__(a_iFmt, a_iArgs)))
1147 # define RT_IPRT_FORMAT_ATTR_MAYBE_NULL(a_iFmt, a_iArgs)
1151 /** @def RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
1152 * Indicates that the "hidden" visibility attribute can be used (GCC) */
1153 #if defined(__GNUC__)
1154 # if __GNUC__ >= 4 && !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
1155 # define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
1159 /** @def RT_COMPILER_SUPPORTS_VA_ARGS
1160 * If the defined, the compiler supports the variadic macro feature (..., __VA_ARGS__). */
1161 #if defined(_MSC_VER)
1162 # if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
1163 # define RT_COMPILER_SUPPORTS_VA_ARGS
1165 #elif defined(__GNUC__)
1166 # if __GNUC__ >= 3 /* not entirely sure when this was added */
1167 # define RT_COMPILER_SUPPORTS_VA_ARGS
1174 * The standard calling convention for the Runtime interfaces.
1176 * @remarks The regparm(0) in the X86/GNUC variant deals with -mregparm=x use in
1177 * the linux kernel and potentially elsewhere (3rd party).
1179 #if defined(_MSC_VER) || defined(__WATCOMC__)
1180 # define RTCALL __cdecl
1181 #elif defined(RT_OS_OS2)
1182 # define RTCALL __cdecl
1183 #elif defined(__GNUC__) && defined(RT_ARCH_X86)
1184 # define RTCALL __attribute__((__cdecl__,__regparm__(0)))
1190 * How to declare an exported function.
1191 * @param type The return type of the function declaration.
1193 #if defined(_MSC_VER) || defined(RT_OS_OS2)
1194 # define DECLEXPORT(type) __declspec(dllexport) type
1195 #elif defined(RT_USE_VISIBILITY_DEFAULT)
1196 # define DECLEXPORT(type) __attribute__((visibility("default"))) type
1198 # define DECLEXPORT(type) type
1202 * How to declare an imported function.
1203 * @param type The return type of the function declaration.
1205 #if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
1206 # define DECLIMPORT(type) __declspec(dllimport) type
1208 # define DECLIMPORT(type) type
1212 * How to declare a non-exported function or variable.
1213 * @param type The return type of the function or the data type of the variable.
1215 #if !defined(RT_GCC_SUPPORTS_VISIBILITY_HIDDEN) || defined(RT_NO_VISIBILITY_HIDDEN)
1216 # define DECLHIDDEN(type) type
1218 # define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
1221 /** @def DECL_HIDDEN_CONST
1222 * Workaround for g++ warnings when applying the hidden attribute to a const
1223 * definition. Use DECLHIDDEN for the declaration.
1224 * @param a_Type The return type of the function or the data type of
1227 #if defined(__cplusplus) && defined(__GNUC__)
1228 # define DECL_HIDDEN_CONST(a_Type) a_Type
1230 # define DECL_HIDDEN_CONST(a_Type) DECLHIDDEN(a_Type)
1233 /** @def DECL_INVALID
1234 * How to declare a function not available for linking in the current context.
1235 * The purpose is to create compile or like time errors when used. This isn't
1236 * possible on all platforms.
1237 * @param type The return type of the function.
1239 #if defined(_MSC_VER)
1240 # define DECL_INVALID(type) __declspec(dllimport) type __stdcall
1241 #elif defined(__GNUC__) && defined(__cplusplus)
1242 # define DECL_INVALID(type) extern "C++" type
1244 # define DECL_INVALID(type) type
1248 * How to declare an internal assembly function.
1249 * @param type The return type of the function declaration.
1252 # define DECLASM(type) extern "C" type RTCALL
1254 # define DECLASM(type) type RTCALL
1257 /** @def DECLASMTYPE
1258 * How to declare an internal assembly function type.
1259 * @param type The return type of the function.
1261 #define DECLASMTYPE(type) type RTCALL
1263 /** @def DECL_NO_RETURN
1264 * How to declare a function which does not return.
1265 * @note This macro can be combined with other macros, for example
1267 * EMR3DECL(DECL_NO_RETURN(void)) foo(void);
1271 # define DECL_NO_RETURN(type) __declspec(noreturn) type
1272 #elif defined(__GNUC__)
1273 # define DECL_NO_RETURN(type) __attribute__((noreturn)) type
1275 # define DECL_NO_RETURN(type) type
1277 /** @deprecated Use DECL_NO_RETURN instead. */
1278 #define DECLNORETURN(type) DECL_NO_RETURN(type)
1280 /** @def DECL_RETURNS_TWICE
1281 * How to declare a function which may return more than once.
1282 * @note This macro can be combined with other macros, for example
1284 * EMR3DECL(DECL_RETURNS_TWICE(void)) MySetJmp(void);
1287 #if RT_GNUC_PREREQ(4, 1)
1288 # define DECL_RETURNS_TWICE(type) __attribute__((returns_twice)) type
1290 # define DECL_RETURNS_TWICE(type) type
1294 * How to declare a variable which is not necessarily resolved at
1296 * @note This macro can be combined with other macros, for example
1298 * EMR3DECL(DECLWEAK(int)) foo;
1301 #if defined(__GNUC__)
1302 # define DECLWEAK(type) type __attribute__((weak))
1304 # define DECLWEAK(type) type
1307 /** @def DECLCALLBACK
1308 * How to declare an call back function type.
1309 * @param type The return type of the function declaration.
1311 #define DECLCALLBACK(type) type RT_FAR_CODE RTCALL
1313 /** @def DECLCALLBACKPTR
1314 * How to declare an call back function pointer.
1315 * @param type The return type of the function declaration.
1316 * @param name The name of the variable member.
1318 #if defined(__IBMC__) || defined(__IBMCPP__)
1319 # define DECLCALLBACKPTR(type, name) type (* RTCALL name)
1321 # define DECLCALLBACKPTR(type, name) type (RT_FAR_CODE RTCALL * name)
1324 /** @def DECLCALLBACKMEMBER
1325 * How to declare an call back function pointer member.
1326 * @param type The return type of the function declaration.
1327 * @param name The name of the struct/union/class member.
1329 #if defined(__IBMC__) || defined(__IBMCPP__)
1330 # define DECLCALLBACKMEMBER(type, name) type (* RTCALL name)
1332 # define DECLCALLBACKMEMBER(type, name) type (RT_FAR_CODE RTCALL * name)
1335 /** @def DECLR3CALLBACKMEMBER
1336 * How to declare an call back function pointer member - R3 Ptr.
1337 * @param type The return type of the function declaration.
1338 * @param name The name of the struct/union/class member.
1339 * @param args The argument list enclosed in parentheses.
1342 # define DECLR3CALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
1344 # define DECLR3CALLBACKMEMBER(type, name, args) RTR3PTR name
1347 /** @def DECLRCCALLBACKMEMBER
1348 * How to declare an call back function pointer member - RC Ptr.
1349 * @param type The return type of the function declaration.
1350 * @param name The name of the struct/union/class member.
1351 * @param args The argument list enclosed in parentheses.
1354 # define DECLRCCALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
1356 # define DECLRCCALLBACKMEMBER(type, name, args) RTRCPTR name
1359 /** @def DECLR0CALLBACKMEMBER
1360 * How to declare an call back function pointer member - R0 Ptr.
1361 * @param type The return type of the function declaration.
1362 * @param name The name of the struct/union/class member.
1363 * @param args The argument list enclosed in parentheses.
1366 # define DECLR0CALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
1368 # define DECLR0CALLBACKMEMBER(type, name, args) RTR0PTR name
1372 * How to declare a function as inline.
1373 * @param type The return type of the function declaration.
1374 * @remarks Don't use this macro on C++ methods.
1377 # define DECLINLINE(type) static __inline__ type
1378 #elif defined(__cplusplus)
1379 # define DECLINLINE(type) static inline type
1380 #elif defined(_MSC_VER)
1381 # define DECLINLINE(type) static _inline type
1382 #elif defined(__IBMC__)
1383 # define DECLINLINE(type) _Inline type
1385 # define DECLINLINE(type) inline type
1389 /** @def DECL_FORCE_INLINE
1390 * How to declare a function as inline and try convince the compiler to always
1391 * inline it regardless of optimization switches.
1392 * @param type The return type of the function declaration.
1393 * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
1396 # define DECL_FORCE_INLINE(type) __attribute__((__always_inline__)) DECLINLINE(type)
1397 #elif defined(_MSC_VER)
1398 # define DECL_FORCE_INLINE(type) __forceinline type
1400 # define DECL_FORCE_INLINE(type) DECLINLINE(type)
1404 /** @def DECL_NO_INLINE
1405 * How to declare a function telling the compiler not to inline it.
1406 * @param scope The function scope, static or RT_NOTHING.
1407 * @param type The return type of the function declaration.
1408 * @remarks Don't use this macro on C++ methods.
1411 # define DECL_NO_INLINE(scope,type) __attribute__((__noinline__)) scope type
1412 #elif defined(_MSC_VER)
1413 # define DECL_NO_INLINE(scope,type) __declspec(noinline) scope type
1415 # define DECL_NO_INLINE(scope,type) scope type
1419 /** @def IN_RT_STATIC
1420 * Used to indicate whether we're linking against a static IPRT
1423 * The IPRT symbols will be declared as hidden (if supported). Note that this
1424 * define has no effect without also setting one of the IN_RT_R0, IN_RT_R3 or
1425 * IN_RT_RC indicators.
1429 * Used to indicate whether we're inside the same link module as the host
1430 * context ring-0 Runtime Library.
1432 /** @def RTR0DECL(type)
1433 * Runtime Library host context ring-0 export or import declaration.
1434 * @param type The return type of the function declaration.
1435 * @remarks This is only used inside IPRT. Other APIs need to define their own
1436 * XXXX_DECL macros for dealing with import/export/static visibility.
1439 # ifdef IN_RT_STATIC
1440 # define RTR0DECL(type) DECLHIDDEN(type) RTCALL
1442 # define RTR0DECL(type) DECLEXPORT(type) RTCALL
1445 # define RTR0DECL(type) DECLIMPORT(type) RTCALL
1449 * Used to indicate whether we're inside the same link module as the host
1450 * context ring-3 Runtime Library.
1452 /** @def RTR3DECL(type)
1453 * Runtime Library host context ring-3 export or import declaration.
1454 * @param type The return type of the function declaration.
1455 * @remarks This is only used inside IPRT. Other APIs need to define their own
1456 * XXXX_DECL macros for dealing with import/export/static visibility.
1459 # ifdef IN_RT_STATIC
1460 # define RTR3DECL(type) DECLHIDDEN(type) RTCALL
1462 # define RTR3DECL(type) DECLEXPORT(type) RTCALL
1465 # define RTR3DECL(type) DECLIMPORT(type) RTCALL
1469 * Used to indicate whether we're inside the same link module as the raw-mode
1470 * context (RC) runtime library.
1472 /** @def RTRCDECL(type)
1473 * Runtime Library raw-mode context export or import declaration.
1474 * @param type The return type of the function declaration.
1475 * @remarks This is only used inside IPRT. Other APIs need to define their own
1476 * XXXX_DECL macros for dealing with import/export/static visibility.
1479 # ifdef IN_RT_STATIC
1480 # define RTRCDECL(type) DECLHIDDEN(type) RTCALL
1482 # define RTRCDECL(type) DECLEXPORT(type) RTCALL
1485 # define RTRCDECL(type) DECLIMPORT(type) RTCALL
1488 /** @def RTDECL(type)
1489 * Runtime Library export or import declaration.
1490 * Functions declared using this macro exists in all contexts.
1491 * @param type The return type of the function declaration.
1492 * @remarks This is only used inside IPRT. Other APIs need to define their own
1493 * XXXX_DECL macros for dealing with import/export/static visibility.
1495 #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
1496 # ifdef IN_RT_STATIC
1497 # define RTDECL(type) DECLHIDDEN(type) RTCALL
1499 # define RTDECL(type) DECLEXPORT(type) RTCALL
1502 # define RTDECL(type) DECLIMPORT(type) RTCALL
1505 /** @def RTDATADECL(type)
1506 * Runtime Library export or import declaration.
1507 * Data declared using this macro exists in all contexts.
1508 * @param type The data type.
1509 * @remarks This is only used inside IPRT. Other APIs need to define their own
1510 * XXXX_DECL macros for dealing with import/export/static visibility.
1512 /** @def RT_DECL_DATA_CONST(type)
1513 * Definition of a const variable. See DECL_HIDDEN_CONST.
1514 * @param type The const data type.
1515 * @remarks This is only used inside IPRT. Other APIs need to define their own
1516 * XXXX_DECL macros for dealing with import/export/static visibility.
1518 #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
1519 # ifdef IN_RT_STATIC
1520 # define RTDATADECL(type) DECLHIDDEN(type)
1521 # define RT_DECL_DATA_CONST(type) DECL_HIDDEN_CONST(type)
1523 # define RTDATADECL(type) DECLEXPORT(type)
1524 # if defined(__cplusplus) && defined(__GNUC__)
1525 # define RT_DECL_DATA_CONST(type) type
1527 # define RT_DECL_DATA_CONST(type) DECLEXPORT(type)
1531 # define RTDATADECL(type) DECLIMPORT(type)
1532 # define RT_DECL_DATA_CONST(type) DECLIMPORT(type)
1535 /** @def RT_DECL_CLASS
1536 * Declares an class living in the runtime.
1537 * @remarks This is only used inside IPRT. Other APIs need to define their own
1538 * XXXX_DECL macros for dealing with import/export/static visibility.
1540 #if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
1541 # ifdef IN_RT_STATIC
1542 # define RT_DECL_CLASS
1544 # define RT_DECL_CLASS DECLEXPORT_CLASS
1547 # define RT_DECL_CLASS DECLIMPORT_CLASS
1552 * Symbol name wrapper for the No-CRT bits.
1554 * In order to coexist in the same process as other CRTs, we need to
1555 * decorate the symbols such that they don't conflict the ones in the
1556 * other CRTs. The result of such conflicts / duplicate symbols can
1557 * confuse the dynamic loader on Unix like systems.
1559 * Define RT_WITHOUT_NOCRT_WRAPPERS to drop the wrapping.
1560 * Define RT_WITHOUT_NOCRT_WRAPPER_ALIASES to drop the aliases to the
1563 /** @def RT_NOCRT_STR
1564 * Same as RT_NOCRT only it'll return a double quoted string of the result.
1566 #ifndef RT_WITHOUT_NOCRT_WRAPPERS
1567 # define RT_NOCRT(name) nocrt_ ## name
1568 # define RT_NOCRT_STR(name) "nocrt_" # name
1570 # define RT_NOCRT(name) name
1571 # define RT_NOCRT_STR(name) #name
1577 * Give the compiler a hint that an expression is very likely to hold true.
1579 * Some compilers support explicit branch prediction so that the CPU backend
1580 * can hint the processor and also so that code blocks can be reordered such
1581 * that the predicted path sees a more linear flow, thus improving cache
1584 * IPRT provides the macros RT_LIKELY() and RT_UNLIKELY() as a way to utilize
1585 * this compiler feature when present.
1587 * A few notes about the usage:
1589 * - Generally, order your code use RT_LIKELY() instead of RT_UNLIKELY().
1591 * - Generally, use RT_UNLIKELY() with error condition checks (unless you
1592 * have some _strong_ reason to do otherwise, in which case document it),
1593 * and/or RT_LIKELY() with success condition checks, assuming you want
1594 * to optimize for the success path.
1596 * - Other than that, if you don't know the likelihood of a test succeeding
1597 * from empirical or other 'hard' evidence, don't make predictions unless
1598 * you happen to be a Dirk Gently character.
1600 * - These macros are meant to be used in places that get executed a lot. It
1601 * is wasteful to make predictions in code that is executed rarely (e.g.
1602 * at subsystem initialization time) as the basic block reordering that this
1603 * affects can often generate larger code.
1605 * - Note that RT_SUCCESS() and RT_FAILURE() already makes use of RT_LIKELY()
1606 * and RT_UNLIKELY(). Should you wish for prediction free status checks,
1607 * use the RT_SUCCESS_NP() and RT_FAILURE_NP() macros instead.
1610 * @returns the boolean result of the expression.
1611 * @param expr The expression that's very likely to be true.
1614 /** @def RT_UNLIKELY
1615 * Give the compiler a hint that an expression is highly unlikely to hold true.
1617 * See the usage instructions give in the RT_LIKELY() docs.
1619 * @returns the boolean result of the expression.
1620 * @param expr The expression that's very unlikely to be true.
1623 * @deprecated Please use RT_LIKELY() instead wherever possible! That gives us
1624 * a better chance of the windows compilers to generate favorable code
1625 * too. The belief is that the compiler will by default assume the
1626 * if-case is more likely than the else-case.
1628 #if defined(__GNUC__)
1629 # if __GNUC__ >= 3 && !defined(FORTIFY_RUNNING)
1630 # define RT_LIKELY(expr) __builtin_expect(!!(expr), 1)
1631 # define RT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1633 # define RT_LIKELY(expr) (expr)
1634 # define RT_UNLIKELY(expr) (expr)
1637 # define RT_LIKELY(expr) (expr)
1638 # define RT_UNLIKELY(expr) (expr)
1641 /** @def RT_EXPAND_2
1642 * Helper for RT_EXPAND. */
1643 #define RT_EXPAND_2(a_Expr) a_Expr
1645 * Returns the expanded expression.
1646 * @param a_Expr The expression to expand. */
1647 #define RT_EXPAND(a_Expr) RT_EXPAND_2(a_Expr)
1650 * Returns the argument as a string constant.
1651 * @param str Argument to stringify. */
1652 #define RT_STR(str) #str
1654 * Returns the expanded argument as a string.
1655 * @param str Argument to expand and stringify. */
1656 #define RT_XSTR(str) RT_STR(str)
1659 * Helper for RT_WSTR that gets the expanded @a str.
1660 * @param str String litteral to prefix with 'L'. */
1661 #define RT_LSTR_2(str) L##str
1663 * Returns the expanded argument with a L string prefix.
1665 * Intended for converting ASCII string \#defines into wide char string
1666 * litterals on Windows.
1668 * @param str String litteral to . */
1669 #define RT_LSTR(str) RT_LSTR_2(str)
1671 /** @def RT_UNPACK_CALL
1672 * Unpacks the an argument list inside an extra set of parenthesis and turns it
1673 * into a call to @a a_Fn.
1675 * @param a_Fn Function/macro to call.
1676 * @param a_Args Parameter list in parenthesis.
1678 #define RT_UNPACK_CALL(a_Fn, a_Args) a_Fn a_Args
1680 #if defined(RT_COMPILER_SUPPORTS_VA_ARGS) || defined(DOXYGEN_RUNNING)
1682 /** @def RT_UNPACK_ARGS
1683 * Returns the arguments without parenthesis.
1685 * @param ... Parameter list in parenthesis.
1686 * @remarks Requires RT_COMPILER_SUPPORTS_VA_ARGS.
1688 # define RT_UNPACK_ARGS(...) __VA_ARGS__
1690 /** @def RT_COUNT_VA_ARGS_HLP
1691 * Helper for RT_COUNT_VA_ARGS that picks out the argument count from
1692 * RT_COUNT_VA_ARGS_REV_SEQ. */
1693 # define RT_COUNT_VA_ARGS_HLP( \
1694 c69, c68, c67, c66, c65, c64, c63, c62, c61, c60, \
1695 c59, c58, c57, c56, c55, c54, c53, c52, c51, c50, \
1696 c49, c48, c47, c46, c45, c44, c43, c42, c41, c40, \
1697 c39, c38, c37, c36, c35, c34, c33, c32, c31, c30, \
1698 c29, c28, c27, c26, c25, c24, c23, c22, c21, c20, \
1699 c19, c18, c17, c16, c15, c14, c13, c12, c11, c10, \
1700 c9, c8, c7, c6, c5, c4, c3, c2, c1, cArgs, ...) cArgs
1701 /** Argument count sequence. */
1702 # define RT_COUNT_VA_ARGS_REV_SEQ \
1703 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, \
1704 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
1705 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
1706 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
1707 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
1708 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
1709 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
1710 /** This is for zero arguments. At least Visual C++ requires it. */
1711 # define RT_COUNT_VA_ARGS_PREFIX_RT_NOTHING RT_COUNT_VA_ARGS_REV_SEQ
1713 * Counts the number of arguments given to the variadic macro.
1717 * @returns Number of arguments in the ellipsis
1718 * @param ... Arguments to count.
1719 * @remarks Requires RT_COMPILER_SUPPORTS_VA_ARGS.
1721 # define RT_COUNT_VA_ARGS(...) \
1722 RT_UNPACK_CALL(RT_COUNT_VA_ARGS_HLP, (RT_COUNT_VA_ARGS_PREFIX_ ## __VA_ARGS__ ## RT_NOTHING, \
1723 RT_COUNT_VA_ARGS_REV_SEQ))
1725 #endif /* RT_COMPILER_SUPPORTS_VA_ARGS */
1729 * Concatenate the expanded arguments without any extra spaces in between.
1731 * @param a The first part.
1732 * @param b The second part.
1734 #define RT_CONCAT(a,b) RT_CONCAT_HLP(a,b)
1735 /** RT_CONCAT helper, don't use. */
1736 #define RT_CONCAT_HLP(a,b) a##b
1739 * Concatenate the expanded arguments without any extra spaces in between.
1741 * @param a The 1st part.
1742 * @param b The 2nd part.
1743 * @param c The 3rd part.
1745 #define RT_CONCAT3(a,b,c) RT_CONCAT3_HLP(a,b,c)
1746 /** RT_CONCAT3 helper, don't use. */
1747 #define RT_CONCAT3_HLP(a,b,c) a##b##c
1750 * Concatenate the expanded arguments without any extra spaces in between.
1752 * @param a The 1st part.
1753 * @param b The 2nd part.
1754 * @param c The 3rd part.
1755 * @param d The 4th part.
1757 #define RT_CONCAT4(a,b,c,d) RT_CONCAT4_HLP(a,b,c,d)
1758 /** RT_CONCAT4 helper, don't use. */
1759 #define RT_CONCAT4_HLP(a,b,c,d) a##b##c##d
1762 * Concatenate the expanded arguments without any extra spaces in between.
1764 * @param a The 1st part.
1765 * @param b The 2nd part.
1766 * @param c The 3rd part.
1767 * @param d The 4th part.
1768 * @param e The 5th part.
1770 #define RT_CONCAT5(a,b,c,d,e) RT_CONCAT5_HLP(a,b,c,d,e)
1771 /** RT_CONCAT5 helper, don't use. */
1772 #define RT_CONCAT5_HLP(a,b,c,d,e) a##b##c##d##e
1775 * Concatenate the expanded arguments without any extra spaces in between.
1777 * @param a The 1st part.
1778 * @param b The 2nd part.
1779 * @param c The 3rd part.
1780 * @param d The 4th part.
1781 * @param e The 5th part.
1782 * @param f The 6th part.
1784 #define RT_CONCAT6(a,b,c,d,e,f) RT_CONCAT6_HLP(a,b,c,d,e,f)
1785 /** RT_CONCAT6 helper, don't use. */
1786 #define RT_CONCAT6_HLP(a,b,c,d,e,f) a##b##c##d##e##f
1789 * Concatenate the expanded arguments without any extra spaces in between.
1791 * @param a The 1st part.
1792 * @param b The 2nd part.
1793 * @param c The 3rd part.
1794 * @param d The 4th part.
1795 * @param e The 5th part.
1796 * @param f The 6th part.
1797 * @param g The 7th part.
1799 #define RT_CONCAT7(a,b,c,d,e,f,g) RT_CONCAT7_HLP(a,b,c,d,e,f,g)
1800 /** RT_CONCAT7 helper, don't use. */
1801 #define RT_CONCAT7_HLP(a,b,c,d,e,f,g) a##b##c##d##e##f##g
1804 * Concatenate the expanded arguments without any extra spaces in between.
1806 * @param a The 1st part.
1807 * @param b The 2nd part.
1808 * @param c The 3rd part.
1809 * @param d The 4th part.
1810 * @param e The 5th part.
1811 * @param f The 6th part.
1812 * @param g The 7th part.
1813 * @param h The 8th part.
1815 #define RT_CONCAT8(a,b,c,d,e,f,g,h) RT_CONCAT8_HLP(a,b,c,d,e,f,g,h)
1816 /** RT_CONCAT8 helper, don't use. */
1817 #define RT_CONCAT8_HLP(a,b,c,d,e,f,g,h) a##b##c##d##e##f##g##h
1820 * Concatenate the expanded arguments without any extra spaces in between.
1822 * @param a The 1st part.
1823 * @param b The 2nd part.
1824 * @param c The 3rd part.
1825 * @param d The 4th part.
1826 * @param e The 5th part.
1827 * @param f The 6th part.
1828 * @param g The 7th part.
1829 * @param h The 8th part.
1830 * @param i The 9th part.
1832 #define RT_CONCAT9(a,b,c,d,e,f,g,h,i) RT_CONCAT9_HLP(a,b,c,d,e,f,g,h,i)
1833 /** RT_CONCAT9 helper, don't use. */
1834 #define RT_CONCAT9_HLP(a,b,c,d,e,f,g,h,i) a##b##c##d##e##f##g##h##i
1837 * String constant tuple - string constant, strlen(string constant).
1839 * @param a_szConst String constant.
1842 #define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
1846 * Macro for using in switch statements that turns constants into strings.
1848 * @param a_Const The constant (not string).
1850 #define RT_CASE_RET_STR(a_Const) case a_Const: return #a_Const
1854 * Convert a bit number into an integer bitmask (unsigned).
1855 * @param bit The bit number.
1857 #define RT_BIT(bit) ( 1U << (bit) )
1860 * Convert a bit number into a 32-bit bitmask (unsigned).
1861 * @param bit The bit number.
1863 #define RT_BIT_32(bit) ( UINT32_C(1) << (bit) )
1866 * Convert a bit number into a 64-bit bitmask (unsigned).
1867 * @param bit The bit number.
1869 #define RT_BIT_64(bit) ( UINT64_C(1) << (bit) )
1873 * Gets the value of a bit field in an integer value.
1875 * This requires a couple of macros to be defined for the field:
1876 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1877 * - \<a_FieldNm\>_MASK: The field mask.
1879 * @returns The bit field value.
1880 * @param a_uValue The integer value containing the field.
1881 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1883 * @sa #RT_BF_CLEAR, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
1885 #define RT_BF_GET(a_uValue, a_FieldNm) ( ((a_uValue) >> RT_CONCAT(a_FieldNm,_SHIFT)) & RT_BF_ZMASK(a_FieldNm) )
1888 * Sets the given bit field in the integer value.
1890 * This requires a couple of macros to be defined for the field:
1891 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1892 * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
1895 * @returns Integer value with bit field set to @a a_uFieldValue.
1896 * @param a_uValue The integer value containing the field.
1897 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1899 * @param a_uFieldValue The new field value.
1900 * @sa #RT_BF_GET, #RT_BF_CLEAR, #RT_BF_MAKE, #RT_BF_ZMASK
1902 #define RT_BF_SET(a_uValue, a_FieldNm, a_uFieldValue) ( RT_BF_CLEAR(a_uValue, a_FieldNm) | RT_BF_MAKE(a_FieldNm, a_uFieldValue) )
1904 /** @def RT_BF_CLEAR
1905 * Clears the given bit field in the integer value.
1907 * This requires a couple of macros to be defined for the field:
1908 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1909 * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
1912 * @returns Integer value with bit field set to zero.
1913 * @param a_uValue The integer value containing the field.
1914 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1916 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
1918 #define RT_BF_CLEAR(a_uValue, a_FieldNm) ( (a_uValue) & ~RT_CONCAT(a_FieldNm,_MASK) )
1921 * Shifts and masks a bit field value into position in the integer value.
1923 * This requires a couple of macros to be defined for the field:
1924 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1925 * - \<a_FieldNm\>_MASK: The field mask.
1927 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1929 * @param a_uFieldValue The field value that should be masked and shifted
1931 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_ZMASK
1933 #define RT_BF_MAKE(a_FieldNm, a_uFieldValue) ( ((a_uFieldValue) & RT_BF_ZMASK(a_FieldNm) ) << RT_CONCAT(a_FieldNm,_SHIFT) )
1935 /** @def RT_BF_ZMASK
1936 * Helper for getting the field mask shifted to bit position zero.
1938 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1940 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_MAKE
1942 #define RT_BF_ZMASK(a_FieldNm) ( RT_CONCAT(a_FieldNm,_MASK) >> RT_CONCAT(a_FieldNm,_SHIFT) )
1944 /** Bit field compile time check helper
1946 #define RT_BF_CHECK_DO_XOR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) ^ RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
1947 /** Bit field compile time check helper
1949 #define RT_BF_CHECK_DO_OR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) | RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
1950 /** Bit field compile time check helper
1952 #define RT_BF_CHECK_DO_1ST_MASK_BIT(a_uLeft, a_RightPrefix, a_FieldNm) \
1953 ((a_uLeft) && ( (RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U ) )
1954 /** Used to check that a bit field mask does not start too early.
1956 #define RT_BF_CHECK_DO_MASK_START(a_uLeft, a_RightPrefix, a_FieldNm) \
1958 && ( RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT) == 0 \
1959 || ( ( ( ((RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U) \
1960 << RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) /* => single bit mask, correct type */ \
1961 - 1U) /* => mask of all bits below the field */ \
1962 & RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK)) == 0 ) )
1963 /** @name Bit field compile time check recursion workers.
1966 #define RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix, f1) \
1967 a_DoThis(a_uLeft, a_RightPrefix, f1)
1968 #define RT_BF_CHECK_DO_2(a_DoThis, a_uLeft, a_RightPrefix, f1, f2) \
1969 RT_BF_CHECK_DO_1(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2)
1970 #define RT_BF_CHECK_DO_3(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3) \
1971 RT_BF_CHECK_DO_2(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3)
1972 #define RT_BF_CHECK_DO_4(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4) \
1973 RT_BF_CHECK_DO_3(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4)
1974 #define RT_BF_CHECK_DO_5(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5) \
1975 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)
1976 #define RT_BF_CHECK_DO_6(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6) \
1977 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)
1978 #define RT_BF_CHECK_DO_7(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7) \
1979 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)
1980 #define RT_BF_CHECK_DO_8(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8) \
1981 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)
1982 #define RT_BF_CHECK_DO_9(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9) \
1983 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)
1984 #define RT_BF_CHECK_DO_10(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10) \
1985 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)
1986 #define RT_BF_CHECK_DO_11(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) \
1987 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)
1988 #define RT_BF_CHECK_DO_12(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) \
1989 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)
1990 #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) \
1991 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)
1992 #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) \
1993 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)
1994 #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) \
1995 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)
1996 #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) \
1997 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)
1998 #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) \
1999 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)
2000 #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) \
2001 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)
2002 #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) \
2003 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)
2004 #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) \
2005 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)
2006 #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) \
2007 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)
2008 #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) \
2009 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)
2010 #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) \
2011 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)
2012 #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) \
2013 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)
2014 #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) \
2015 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)
2016 #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) \
2017 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)
2018 #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) \
2019 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)
2020 #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) \
2021 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)
2022 #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) \
2023 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)
2024 #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) \
2025 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)
2026 #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) \
2027 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)
2028 #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) \
2029 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)
2030 #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) \
2031 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)
2032 #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) \
2033 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)
2034 #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) \
2035 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)
2036 #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) \
2037 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)
2038 #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) \
2039 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)
2040 #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) \
2041 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)
2042 #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) \
2043 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)
2044 #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) \
2045 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)
2046 #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) \
2047 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)
2048 #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) \
2049 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)
2050 #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) \
2051 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)
2052 #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) \
2053 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)
2054 #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) \
2055 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)
2056 #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) \
2057 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)
2058 #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) \
2059 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)
2060 #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) \
2061 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)
2062 #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) \
2063 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)
2064 #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) \
2065 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)
2066 #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) \
2067 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)
2068 #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) \
2069 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)
2070 #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) \
2071 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)
2072 #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) \
2073 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)
2074 #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) \
2075 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)
2076 #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) \
2077 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)
2078 #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) \
2079 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)
2080 #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) \
2081 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)
2082 #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) \
2083 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)
2084 #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) \
2085 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)
2086 #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) \
2087 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)
2088 #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) \
2089 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)
2090 #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) \
2091 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)
2092 #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) \
2093 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)
2096 /** @def RT_BF_ASSERT_COMPILE_CHECKS
2097 * Emits a series of AssertCompile statements checking that the bit-field
2098 * declarations doesn't overlap, has holes, and generally makes some sense.
2100 * This requires variadic macros because its too much to type otherwise.
2102 #if defined(RT_COMPILER_SUPPORTS_VA_ARGS) || defined(DOXYGEN_RUNNING)
2103 # define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) \
2104 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_OR_MASK, a_uZero, a_Prefix, RT_UNPACK_ARGS a_Fields ) == a_uCovered); \
2105 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_XOR_MASK, a_uCovered, a_Prefix, RT_UNPACK_ARGS a_Fields ) == 0); \
2106 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_1ST_MASK_BIT, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true); \
2107 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_MASK_START, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true)
2108 /** Bit field compile time check helper
2110 # define RT_BF_CHECK_DO_N(a_DoThis, a_uLeft, a_RightPrefix, ...) \
2111 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__))
2113 # define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) AssertCompile(true)
2119 * @param u Value to align.
2120 * @param uAlignment The alignment. Power of two!
2122 * @remark Be extremely careful when using this macro with type which sizeof != sizeof int.
2123 * When possible use any of the other RT_ALIGN_* macros. And when that's not
2124 * possible, make 101% sure that uAlignment is specified with a right sized type.
2126 * Specifying an unsigned 32-bit alignment constant with a 64-bit value will give
2127 * you a 32-bit return value!
2129 * In short: Don't use this macro. Use RT_ALIGN_T() instead.
2131 #define RT_ALIGN(u, uAlignment) ( ((u) + ((uAlignment) - 1)) & ~((uAlignment) - 1) )
2135 * @param u Value to align.
2136 * @param uAlignment The alignment. Power of two!
2137 * @param type Integer type to use while aligning.
2138 * @remark This macro is the preferred alignment macro, it doesn't have any of the pitfalls RT_ALIGN has.
2140 #define RT_ALIGN_T(u, uAlignment, type) ( ((type)(u) + ((uAlignment) - 1)) & ~(type)((uAlignment) - 1) )
2142 /** @def RT_ALIGN_32
2143 * Align macro for a 32-bit value.
2144 * @param u32 Value to align.
2145 * @param uAlignment The alignment. Power of two!
2147 #define RT_ALIGN_32(u32, uAlignment) RT_ALIGN_T(u32, uAlignment, uint32_t)
2149 /** @def RT_ALIGN_64
2150 * Align macro for a 64-bit value.
2151 * @param u64 Value to align.
2152 * @param uAlignment The alignment. Power of two!
2154 #define RT_ALIGN_64(u64, uAlignment) RT_ALIGN_T(u64, uAlignment, uint64_t)
2157 * Align macro for size_t.
2158 * @param cb Value to align.
2159 * @param uAlignment The alignment. Power of two!
2161 #define RT_ALIGN_Z(cb, uAlignment) RT_ALIGN_T(cb, uAlignment, size_t)
2164 * Align macro for pointers.
2165 * @param pv Value to align.
2166 * @param uAlignment The alignment. Power of two!
2168 #define RT_ALIGN_P(pv, uAlignment) RT_ALIGN_PT(pv, uAlignment, void *)
2170 /** @def RT_ALIGN_PT
2171 * Align macro for pointers with type cast.
2172 * @param u Value to align.
2173 * @param uAlignment The alignment. Power of two!
2174 * @param CastType The type to cast the result to.
2176 #define RT_ALIGN_PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, uintptr_t) )
2178 /** @def RT_ALIGN_R3PT
2179 * Align macro for ring-3 pointers with type cast.
2180 * @param u Value to align.
2181 * @param uAlignment The alignment. Power of two!
2182 * @param CastType The type to cast the result to.
2184 #define RT_ALIGN_R3PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR3UINTPTR) )
2186 /** @def RT_ALIGN_R0PT
2187 * Align macro for ring-0 pointers with type cast.
2188 * @param u Value to align.
2189 * @param uAlignment The alignment. Power of two!
2190 * @param CastType The type to cast the result to.
2192 #define RT_ALIGN_R0PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR0UINTPTR) )
2194 /** @def RT_ALIGN_GCPT
2195 * Align macro for GC pointers with type cast.
2196 * @param u Value to align.
2197 * @param uAlignment The alignment. Power of two!
2198 * @param CastType The type to cast the result to.
2200 #define RT_ALIGN_GCPT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTGCUINTPTR) )
2203 /** @def RT_OFFSETOF
2204 * Our own special offsetof() variant, returns a signed result.
2206 * This differs from the usual offsetof() in that it's not relying on builtin
2207 * compiler stuff and thus can use variables in arrays the structure may
2208 * contain. This is useful to determine the sizes of structures ending
2209 * with a variable length field. For gcc >= 4.4 see @bugref{7775}.
2211 * @returns offset into the structure of the specified member. signed.
2212 * @param type Structure type.
2213 * @param member Member.
2215 #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4)
2216 # define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 )
2218 # define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) )
2221 /** @def RT_UOFFSETOF
2222 * Our own special offsetof() variant, returns an unsigned result.
2224 * This differs from the usual offsetof() in that it's not relying on builtin
2225 * compiler stuff and thus can use variables in arrays the structure may
2226 * contain. This is useful to determine the sizes of structures ending
2227 * with a variable length field. For gcc >= 4.4 see @bugref{7775}.
2229 * @returns offset into the structure of the specified member. unsigned.
2230 * @param type Structure type.
2231 * @param member Member.
2233 #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4)
2234 # define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 )
2236 # define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) )
2239 /** @def RT_OFFSETOF_ADD
2240 * RT_OFFSETOF with an addend.
2242 * @returns offset into the structure of the specified member. signed.
2243 * @param type Structure type.
2244 * @param member Member.
2245 * @param addend The addend to add to the offset.
2247 #define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) )
2249 /** @def RT_UOFFSETOF_ADD
2250 * RT_UOFFSETOF with an addend.
2252 * @returns offset into the structure of the specified member. signed.
2253 * @param type Structure type.
2254 * @param member Member.
2255 * @param addend The addend to add to the offset.
2257 #define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) )
2259 /** @def RT_SIZEOFMEMB
2260 * Get the size of a structure member.
2262 * @returns size of the structure member.
2263 * @param type Structure type.
2264 * @param member Member.
2266 #define RT_SIZEOFMEMB(type, member) ( sizeof(((type *)(void *)0)->member) )
2268 /** @def RT_UOFFSET_AFTER
2269 * Returns the offset of the first byte following a structure/union member.
2271 * @return byte offset into the struct.
2272 * @param a_Type Structure type.
2273 * @param a_Member The member name.
2275 #define RT_UOFFSET_AFTER(a_Type, a_Member) ( RT_UOFFSETOF(a_Type, a_Member) + RT_SIZEOFMEMB(a_Type, a_Member) )
2277 /** @def RT_FROM_MEMBER
2278 * Convert a pointer to a structure member into a pointer to the structure.
2280 * @returns pointer to the structure.
2281 * @param pMem Pointer to the member.
2282 * @param Type Structure type.
2283 * @param Member Member name.
2285 #define RT_FROM_MEMBER(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
2287 /** @def RT_FROM_CPP_MEMBER
2288 * Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
2289 * invalid access to non-static data member of NULL object.
2291 * @returns pointer to the structure.
2292 * @param pMem Pointer to the member.
2293 * @param Type Structure type.
2294 * @param Member Member name.
2296 * @remarks Using the __builtin_offsetof does not shut up the compiler.
2298 #if defined(__GNUC__) && defined(__cplusplus)
2299 # define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
2300 ( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
2302 # define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
2305 /** @def RT_ELEMENTS
2306 * Calculates the number of elements in a statically sized array.
2307 * @returns Element count.
2308 * @param aArray Array in question.
2310 #define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
2312 /** @def RT_FLEXIBLE_ARRAY
2313 * What to up inside the square brackets when declaring a structure member
2314 * with a flexible size.
2316 * @note Use RT_UOFFSETOF() to calculate the structure size.
2318 * @note Never to a sizeof() on the structure or member!
2320 * @note The member must be the last one.
2322 * @note GCC does not permit using this in a union. So, for unions you must
2323 * use RT_FLEXIBLE_ARRAY_IN_UNION instead.
2325 * @note GCC does not permit using this in nested structures, where as MSC
2326 * does. So, use RT_FLEXIBLE_ARRAY_NESTED for that.
2328 * @sa RT_FLEXIBLE_ARRAY_NESTED, RT_FLEXIBLE_ARRAY_IN_UNION
2330 #if RT_MSC_PREREQ(RT_MSC_VER_VS2005) /** @todo Probably much much earlier. */ \
2331 || (defined(__cplusplus) && RT_GNUC_PREREQ(6, 1) && !RT_GNUC_PREREQ(7, 0)) /* gcc-7 warns again */\
2332 || defined(__WATCOMC__) /* openwatcom 1.9 supports it, we don't care about older atm. */ \
2333 || RT_CLANG_PREREQ_EX(3, 4, 0) /* Only tested clang v3.4, support is probably older. */
2334 # define RT_FLEXIBLE_ARRAY
2335 # if defined(__cplusplus) && defined(_MSC_VER)
2336 # pragma warning(disable:4200) /* -wd4200 does not work with VS2010 */
2338 #elif defined(__STDC_VERSION__)
2339 # if __STDC_VERSION__ >= 1999901L
2340 # define RT_FLEXIBLE_ARRAY
2342 # define RT_FLEXIBLE_ARRAY 1
2345 # define RT_FLEXIBLE_ARRAY 1
2348 /** @def RT_FLEXIBLE_ARRAY_NESTED
2349 * Variant of RT_FLEXIBLE_ARRAY for use in structures that are nested.
2351 * GCC only allow the use of flexible array member in the top structure, whereas
2352 * MSC is less strict and let you do struct { struct { char szName[]; } s; };
2354 * @note See notes for RT_FLEXIBLE_ARRAY.
2356 * @note GCC does not permit using this in a union. So, for unions you must
2357 * use RT_FLEXIBLE_ARRAY_IN_NESTED_UNION instead.
2359 * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2362 # define RT_FLEXIBLE_ARRAY_NESTED RT_FLEXIBLE_ARRAY
2364 # define RT_FLEXIBLE_ARRAY_NESTED 1
2367 /** @def RT_FLEXIBLE_ARRAY_IN_UNION
2368 * The union version of RT_FLEXIBLE_ARRAY.
2370 * @remarks GCC does not support flexible array members in unions, 6.1.x
2371 * actively checks for this. Visual C++ 2010 seems happy with it.
2373 * @note See notes for RT_FLEXIBLE_ARRAY.
2375 * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2378 # define RT_FLEXIBLE_ARRAY_IN_UNION RT_FLEXIBLE_ARRAY
2380 # define RT_FLEXIBLE_ARRAY_IN_UNION 1
2383 /** @def RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2384 * The union version of RT_FLEXIBLE_ARRAY_NESTED.
2386 * @note See notes for RT_FLEXIBLE_ARRAY.
2388 * @sa RT_FLEXIBLE_ARRAY, RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
2391 # define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION RT_FLEXIBLE_ARRAY_NESTED
2393 # define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION 1
2397 * Checks if the value is a power of two.
2399 * @returns true if power of two, false if not.
2400 * @param uVal The value to test.
2401 * @remarks 0 is a power of two.
2402 * @see VERR_NOT_POWER_OF_TWO
2404 #define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
2407 /* Undefine RT_MAX since there is an unfortunate clash with the max
2408 resource type define in os2.h. */
2413 * Finds the maximum value.
2414 * @returns The higher of the two.
2415 * @param Value1 Value 1
2416 * @param Value2 Value 2
2418 #define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
2421 * Finds the minimum value.
2422 * @returns The lower of the two.
2423 * @param Value1 Value 1
2424 * @param Value2 Value 2
2426 #define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
2429 * Clamps the value to minimum and maximum values.
2430 * @returns The clamped value.
2431 * @param Value The value to check.
2432 * @param Min Minimum value.
2433 * @param Max Maximum value.
2435 #define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
2438 * Get the absolute (non-negative) value.
2439 * @returns The absolute value of Value.
2440 * @param Value The value.
2442 #define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
2445 * Turn non-zero/zero into true/false
2446 * @returns The resulting boolean value.
2447 * @param Value The value.
2449 #define RT_BOOL(Value) ( !!(Value) )
2452 * Gets the low uint8_t of a uint16_t or something equivalent. */
2454 # define RT_LO_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)(a); })
2455 #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2456 # define RT_LO_U8(a) ( (uint8_t)(UINT8_MAX & (a)) )
2458 # define RT_LO_U8(a) ( (uint8_t)(a) )
2461 * Gets the high uint8_t of a uint16_t or something equivalent. */
2463 # define RT_HI_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)((a) >> 8); })
2465 # define RT_HI_U8(a) ( (uint8_t)((a) >> 8) )
2469 * Gets the low uint16_t of a uint32_t or something equivalent. */
2471 # define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)(a); })
2472 #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2473 # define RT_LO_U16(a) ( (uint16_t)(UINT16_MAX & (a)) )
2475 # define RT_LO_U16(a) ( (uint16_t)(a) )
2478 * Gets the high uint16_t of a uint32_t or something equivalent. */
2480 # define RT_HI_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)((a) >> 16); })
2482 # define RT_HI_U16(a) ( (uint16_t)((a) >> 16) )
2486 * Gets the low uint32_t of a uint64_t or something equivalent. */
2488 # define RT_LO_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
2489 #elif defined(_MSC_VER) /* shut up cast truncates constant value warnings */
2490 # define RT_LO_U32(a) ( (uint32_t)(UINT32_MAX & (a)) )
2492 # define RT_LO_U32(a) ( (uint32_t)(a) )
2495 * Gets the high uint32_t of a uint64_t or something equivalent. */
2497 # define RT_HI_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)((a) >> 32); })
2499 # define RT_HI_U32(a) ( (uint32_t)((a) >> 32) )
2503 * Gets the first byte of something. */
2504 #define RT_BYTE1(a) ( (a) & 0xff )
2506 * Gets the second byte of something. */
2507 #define RT_BYTE2(a) ( ((a) >> 8) & 0xff )
2509 * Gets the second byte of something. */
2510 #define RT_BYTE3(a) ( ((a) >> 16) & 0xff )
2512 * Gets the fourth byte of something. */
2513 #define RT_BYTE4(a) ( ((a) >> 24) & 0xff )
2515 * Gets the fifth byte of something. */
2516 #define RT_BYTE5(a) ( ((a) >> 32) & 0xff )
2518 * Gets the sixth byte of something. */
2519 #define RT_BYTE6(a) ( ((a) >> 40) & 0xff )
2521 * Gets the seventh byte of something. */
2522 #define RT_BYTE7(a) ( ((a) >> 48) & 0xff )
2524 * Gets the eight byte of something. */
2525 #define RT_BYTE8(a) ( ((a) >> 56) & 0xff )
2529 * Gets the low dword (=uint32_t) of something.
2530 * @deprecated Use RT_LO_U32. */
2531 #define RT_LODWORD(a) ( (uint32_t)(a) )
2533 * Gets the high dword (=uint32_t) of a 64-bit of something.
2534 * @deprecated Use RT_HI_U32. */
2535 #define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
2538 * Gets the low word (=uint16_t) of something.
2539 * @deprecated Use RT_LO_U16. */
2540 #define RT_LOWORD(a) ( (a) & 0xffff )
2542 * Gets the high word (=uint16_t) of a 32-bit something.
2543 * @deprecated Use RT_HI_U16. */
2544 #define RT_HIWORD(a) ( (a) >> 16 )
2547 * Gets the low byte of something.
2548 * @deprecated Use RT_LO_U8. */
2549 #define RT_LOBYTE(a) ( (a) & 0xff )
2551 * Gets the high byte of a 16-bit something.
2552 * @deprecated Use RT_HI_U8. */
2553 #define RT_HIBYTE(a) ( (a) >> 8 )
2556 /** @def RT_MAKE_U64
2557 * Constructs a uint64_t value from two uint32_t values.
2559 #define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
2561 /** @def RT_MAKE_U64_FROM_U16
2562 * Constructs a uint64_t value from four uint16_t values.
2564 #define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
2565 ((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
2566 | (uint64_t)((uint16_t)(w2)) << 32 \
2567 | (uint32_t)((uint16_t)(w1)) << 16 \
2570 /** @def RT_MAKE_U64_FROM_U8
2571 * Constructs a uint64_t value from eight uint8_t values.
2573 #define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
2574 ((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
2575 | (uint64_t)((uint8_t)(b6)) << 48 \
2576 | (uint64_t)((uint8_t)(b5)) << 40 \
2577 | (uint64_t)((uint8_t)(b4)) << 32 \
2578 | (uint32_t)((uint8_t)(b3)) << 24 \
2579 | (uint32_t)((uint8_t)(b2)) << 16 \
2580 | (uint16_t)((uint8_t)(b1)) << 8 \
2583 /** @def RT_MAKE_U32
2584 * Constructs a uint32_t value from two uint16_t values.
2586 #define RT_MAKE_U32(Lo, Hi) \
2587 ((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
2590 /** @def RT_MAKE_U32_FROM_U8
2591 * Constructs a uint32_t value from four uint8_t values.
2593 #define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
2594 ((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
2595 | (uint32_t)((uint8_t)(b2)) << 16 \
2596 | (uint16_t)((uint8_t)(b1)) << 8 \
2599 /** @def RT_MAKE_U16
2600 * Constructs a uint16_t value from two uint8_t values.
2602 #define RT_MAKE_U16(Lo, Hi) \
2603 ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
2607 /** @def RT_BSWAP_U64
2608 * Reverses the byte order of an uint64_t value. */
2610 # define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64)
2611 #elif defined(__GNUC__)
2612 # define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) \
2613 ? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
2615 # define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
2618 /** @def RT_BSWAP_U32
2619 * Reverses the byte order of an uint32_t value. */
2621 # define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32)
2622 #elif defined(__GNUC__)
2623 # define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) \
2624 ? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
2626 # define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
2629 /** @def RT_BSWAP_U16
2630 * Reverses the byte order of an uint16_t value. */
2632 # define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16)
2633 #elif defined(__GNUC__)
2634 # define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) \
2635 ? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
2637 # define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
2641 /** @def RT_BSWAP_U64_C
2642 * Reverses the byte order of an uint64_t constant. */
2643 #define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
2645 /** @def RT_BSWAP_U32_C
2646 * Reverses the byte order of an uint32_t constant. */
2647 #define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
2649 /** @def RT_BSWAP_U16_C
2650 * Reverses the byte order of an uint16_t constant. */
2651 #define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
2654 /** @def RT_H2LE_U64
2655 * Converts an uint64_t value from host to little endian byte order. */
2656 #ifdef RT_BIG_ENDIAN
2657 # define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
2659 # define RT_H2LE_U64(u64) (u64)
2662 /** @def RT_H2LE_U64_C
2663 * Converts an uint64_t constant from host to little endian byte order. */
2664 #ifdef RT_BIG_ENDIAN
2665 # define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
2667 # define RT_H2LE_U64_C(u64) (u64)
2670 /** @def RT_H2LE_U32
2671 * Converts an uint32_t value from host to little endian byte order. */
2672 #ifdef RT_BIG_ENDIAN
2673 # define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
2675 # define RT_H2LE_U32(u32) (u32)
2678 /** @def RT_H2LE_U32_C
2679 * Converts an uint32_t constant from host to little endian byte order. */
2680 #ifdef RT_BIG_ENDIAN
2681 # define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
2683 # define RT_H2LE_U32_C(u32) (u32)
2686 /** @def RT_H2LE_U16
2687 * Converts an uint16_t value from host to little endian byte order. */
2688 #ifdef RT_BIG_ENDIAN
2689 # define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
2691 # define RT_H2LE_U16(u16) (u16)
2694 /** @def RT_H2LE_U16_C
2695 * Converts an uint16_t constant from host to little endian byte order. */
2696 #ifdef RT_BIG_ENDIAN
2697 # define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
2699 # define RT_H2LE_U16_C(u16) (u16)
2703 /** @def RT_LE2H_U64
2704 * Converts an uint64_t value from little endian to host byte order. */
2705 #ifdef RT_BIG_ENDIAN
2706 # define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
2708 # define RT_LE2H_U64(u64) (u64)
2711 /** @def RT_LE2H_U64_C
2712 * Converts an uint64_t constant from little endian to host byte order. */
2713 #ifdef RT_BIG_ENDIAN
2714 # define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
2716 # define RT_LE2H_U64_C(u64) (u64)
2719 /** @def RT_LE2H_U32
2720 * Converts an uint32_t value from little endian to host byte order. */
2721 #ifdef RT_BIG_ENDIAN
2722 # define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
2724 # define RT_LE2H_U32(u32) (u32)
2727 /** @def RT_LE2H_U32_C
2728 * Converts an uint32_t constant from little endian to host byte order. */
2729 #ifdef RT_BIG_ENDIAN
2730 # define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
2732 # define RT_LE2H_U32_C(u32) (u32)
2735 /** @def RT_LE2H_U16
2736 * Converts an uint16_t value from little endian to host byte order. */
2737 #ifdef RT_BIG_ENDIAN
2738 # define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
2740 # define RT_LE2H_U16(u16) (u16)
2743 /** @def RT_LE2H_U16_C
2744 * Converts an uint16_t constant from little endian to host byte order. */
2745 #ifdef RT_BIG_ENDIAN
2746 # define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
2748 # define RT_LE2H_U16_C(u16) (u16)
2752 /** @def RT_H2BE_U64
2753 * Converts an uint64_t value from host to big endian byte order. */
2754 #ifdef RT_BIG_ENDIAN
2755 # define RT_H2BE_U64(u64) (u64)
2757 # define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
2760 /** @def RT_H2BE_U64_C
2761 * Converts an uint64_t constant from host to big endian byte order. */
2762 #ifdef RT_BIG_ENDIAN
2763 # define RT_H2BE_U64_C(u64) (u64)
2765 # define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
2768 /** @def RT_H2BE_U32
2769 * Converts an uint32_t value from host to big endian byte order. */
2770 #ifdef RT_BIG_ENDIAN
2771 # define RT_H2BE_U32(u32) (u32)
2773 # define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
2776 /** @def RT_H2BE_U32_C
2777 * Converts an uint32_t constant from host to big endian byte order. */
2778 #ifdef RT_BIG_ENDIAN
2779 # define RT_H2BE_U32_C(u32) (u32)
2781 # define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
2784 /** @def RT_H2BE_U16
2785 * Converts an uint16_t value from host to big endian byte order. */
2786 #ifdef RT_BIG_ENDIAN
2787 # define RT_H2BE_U16(u16) (u16)
2789 # define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
2792 /** @def RT_H2BE_U16_C
2793 * Converts an uint16_t constant from host to big endian byte order. */
2794 #ifdef RT_BIG_ENDIAN
2795 # define RT_H2BE_U16_C(u16) (u16)
2797 # define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
2800 /** @def RT_BE2H_U64
2801 * Converts an uint64_t value from big endian to host byte order. */
2802 #ifdef RT_BIG_ENDIAN
2803 # define RT_BE2H_U64(u64) (u64)
2805 # define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
2808 /** @def RT_BE2H_U64
2809 * Converts an uint64_t constant from big endian to host byte order. */
2810 #ifdef RT_BIG_ENDIAN
2811 # define RT_BE2H_U64_C(u64) (u64)
2813 # define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
2816 /** @def RT_BE2H_U32
2817 * Converts an uint32_t value from big endian to host byte order. */
2818 #ifdef RT_BIG_ENDIAN
2819 # define RT_BE2H_U32(u32) (u32)
2821 # define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
2824 /** @def RT_BE2H_U32_C
2825 * Converts an uint32_t value from big endian to host byte order. */
2826 #ifdef RT_BIG_ENDIAN
2827 # define RT_BE2H_U32_C(u32) (u32)
2829 # define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
2832 /** @def RT_BE2H_U16
2833 * Converts an uint16_t value from big endian to host byte order. */
2834 #ifdef RT_BIG_ENDIAN
2835 # define RT_BE2H_U16(u16) (u16)
2837 # define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
2840 /** @def RT_BE2H_U16_C
2841 * Converts an uint16_t constant from big endian to host byte order. */
2842 #ifdef RT_BIG_ENDIAN
2843 # define RT_BE2H_U16_C(u16) (u16)
2845 # define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
2850 * Converts an uint64_t value from host to network byte order. */
2851 #define RT_H2N_U64(u64) RT_H2BE_U64(u64)
2853 /** @def RT_H2N_U64_C
2854 * Converts an uint64_t constant from host to network byte order. */
2855 #define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
2858 * Converts an uint32_t value from host to network byte order. */
2859 #define RT_H2N_U32(u32) RT_H2BE_U32(u32)
2861 /** @def RT_H2N_U32_C
2862 * Converts an uint32_t constant from host to network byte order. */
2863 #define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
2866 * Converts an uint16_t value from host to network byte order. */
2867 #define RT_H2N_U16(u16) RT_H2BE_U16(u16)
2869 /** @def RT_H2N_U16_C
2870 * Converts an uint16_t constant from host to network byte order. */
2871 #define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
2874 * Converts an uint64_t value from network to host byte order. */
2875 #define RT_N2H_U64(u64) RT_BE2H_U64(u64)
2877 /** @def RT_N2H_U64_C
2878 * Converts an uint64_t constant from network to host byte order. */
2879 #define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
2882 * Converts an uint32_t value from network to host byte order. */
2883 #define RT_N2H_U32(u32) RT_BE2H_U32(u32)
2885 /** @def RT_N2H_U32_C
2886 * Converts an uint32_t constant from network to host byte order. */
2887 #define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
2890 * Converts an uint16_t value from network to host byte order. */
2891 #define RT_N2H_U16(u16) RT_BE2H_U16(u16)
2893 /** @def RT_N2H_U16_C
2894 * Converts an uint16_t value from network to host byte order. */
2895 #define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
2899 * The BSD sys/param.h + machine/param.h file is a major source of
2900 * namespace pollution. Kill off some of the worse ones unless we're
2901 * compiling kernel code.
2903 #if defined(RT_OS_DARWIN) \
2904 && !defined(KERNEL) \
2905 && !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
2906 && ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
2921 # undef MAXALLOCSAVE
2925 /* i386/machine.h: */
2939 * Whenever we use offsets instead of pointers to save space and relocation effort
2940 * NIL_OFFSET shall be used as the equivalent to NULL.
2942 #define NIL_OFFSET (~0U)
2946 * Keeps the compiler from bitching about an unused parameter, local variable,
2947 * or other stuff, will never use _Pragma are is thus more flexible.
2949 #define NOREF(var) (void)(var)
2951 /** @def RT_NOREF_PV
2952 * Keeps the compiler from bitching about an unused parameter or local variable.
2953 * This one cannot be used with structure members and such, like for instance
2954 * AssertRC may end up doing due to its generic nature.
2956 #if defined(__cplusplus) && RT_CLANG_PREREQ(6, 0)
2957 # define RT_NOREF_PV(var) _Pragma(RT_STR(unused(var)))
2959 # define RT_NOREF_PV(var) (void)(var)
2963 * RT_NOREF_PV shorthand taking on parameter. */
2964 #define RT_NOREF1(var1) RT_NOREF_PV(var1)
2966 * RT_NOREF_PV shorthand taking two parameters. */
2967 #define RT_NOREF2(var1, var2) RT_NOREF_PV(var1); RT_NOREF1(var2)
2969 * RT_NOREF_PV shorthand taking three parameters. */
2970 #define RT_NOREF3(var1, var2, var3) RT_NOREF_PV(var1); RT_NOREF2(var2, var3)
2972 * RT_NOREF_PV shorthand taking four parameters. */
2973 #define RT_NOREF4(var1, var2, var3, var4) RT_NOREF_PV(var1); RT_NOREF3(var2, var3, var4)
2975 * RT_NOREF_PV shorthand taking five parameters. */
2976 #define RT_NOREF5(var1, var2, var3, var4, var5) RT_NOREF_PV(var1); RT_NOREF4(var2, var3, var4, var5)
2978 * RT_NOREF_PV shorthand taking six parameters. */
2979 #define RT_NOREF6(var1, var2, var3, var4, var5, var6) RT_NOREF_PV(var1); RT_NOREF5(var2, var3, var4, var5, var6)
2981 * RT_NOREF_PV shorthand taking seven parameters. */
2982 #define RT_NOREF7(var1, var2, var3, var4, var5, var6, var7) \
2983 RT_NOREF_PV(var1); RT_NOREF6(var2, var3, var4, var5, var6, var7)
2985 * RT_NOREF_PV shorthand taking eight parameters. */
2986 #define RT_NOREF8(var1, var2, var3, var4, var5, var6, var7, var8) \
2987 RT_NOREF_PV(var1); RT_NOREF7(var2, var3, var4, var5, var6, var7, var8)
2989 * RT_NOREF_PV shorthand taking nine parameters. */
2990 #define RT_NOREF9(var1, var2, var3, var4, var5, var6, var7, var8, var9) \
2991 RT_NOREF_PV(var1); RT_NOREF8(var2, var3, var4, var5, var6, var7, var8, var9)
2993 * RT_NOREF_PV shorthand taking ten parameters. */
2994 #define RT_NOREF10(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10) \
2995 RT_NOREF_PV(var1); RT_NOREF_PV(var2); RT_NOREF_PV(var3); RT_NOREF_PV(var4); RT_NOREF_PV(var5); RT_NOREF_PV(var6); \
2996 RT_NOREF_PV(var7); RT_NOREF_PV(var8); RT_NOREF_PV(var9); RT_NOREF_PV(var10)
2998 * RT_NOREF_PV shorthand taking eleven parameters. */
2999 #define RT_NOREF11(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11) \
3000 RT_NOREF_PV(var1); RT_NOREF10(var2, var3, var4, var5, var6, var7, var8, var9, var10)
3002 * RT_NOREF_PV shorthand taking twelve parameters. */
3003 #define RT_NOREF12(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12) \
3004 RT_NOREF_PV(var1); RT_NOREF11(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12)
3006 * RT_NOREF_PV shorthand taking thirteen parameters. */
3007 #define RT_NOREF13(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13) \
3008 RT_NOREF_PV(var1); RT_NOREF12(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13)
3010 * RT_NOREF_PV shorthand taking fourteen parameters. */
3011 #define RT_NOREF14(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14) \
3012 RT_NOREF_PV(var1); RT_NOREF13(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14)
3014 * RT_NOREF_PV shorthand taking fifteen parameters. */
3015 #define RT_NOREF15(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15) \
3016 RT_NOREF_PV(var1); RT_NOREF14(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15)
3018 * RT_NOREF_PV shorthand taking fifteen parameters. */
3019 #define RT_NOREF16(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16) \
3020 RT_NOREF_PV(var1); RT_NOREF15(var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16)
3022 * RT_NOREF_PV shorthand taking seventeen parameters. */
3023 #define RT_NOREF17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \
3024 RT_NOREF_PV(v1); RT_NOREF16(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
3026 * RT_NOREF_PV shorthand taking eighteen parameters. */
3027 #define RT_NOREF18(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \
3028 RT_NOREF_PV(v1); RT_NOREF17(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
3030 * RT_NOREF_PV shorthand taking nineteen parameters. */
3031 #define RT_NOREF19(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \
3032 RT_NOREF_PV(v1); RT_NOREF18(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
3034 * RT_NOREF_PV shorthand taking twenty parameters. */
3035 #define RT_NOREF20(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \
3036 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)
3038 * RT_NOREF_PV shorthand taking twentyone parameters. */
3039 #define RT_NOREF21(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \
3040 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)
3042 * RT_NOREF_PV shorthand taking twentytwo parameters. */
3043 #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) \
3044 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)
3047 * RT_NOREF_PV variant using the variadic macro feature of C99.
3048 * @remarks Only use this in sources */
3049 #ifdef RT_COMPILER_SUPPORTS_VA_ARGS
3050 # define RT_NOREF(...) \
3051 RT_UNPACK_CALL(RT_CONCAT(RT_NOREF, RT_EXPAND(RT_COUNT_VA_ARGS(__VA_ARGS__))),(__VA_ARGS__))
3055 /** @def RT_BREAKPOINT
3056 * Emit a debug breakpoint instruction.
3058 * @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
3059 * to force gdb to remain at the int3 source line.
3060 * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
3064 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
3065 # if !defined(__L4ENV__)
3066 # define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
3068 # define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
3070 # elif defined(RT_ARCH_SPARC64)
3071 # define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
3072 # elif defined(RT_ARCH_SPARC)
3073 # define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
3077 # define RT_BREAKPOINT() __debugbreak()
3079 #if defined(__IBMC__) || defined(__IBMCPP__)
3080 # define RT_BREAKPOINT() __interrupt(3)
3082 #if defined(__WATCOMC__)
3083 # define RT_BREAKPOINT() _asm { int 3 }
3085 #ifndef RT_BREAKPOINT
3086 # error "This compiler/arch is not supported!"
3090 /** @defgroup grp_rt_cdefs_size Size Constants
3091 * (Of course, these are binary computer terms, not SI.)
3094 /** 1 K (Kilo) (1 024). */
3095 #define _1K 0x00000400
3096 /** 2 K (Kilo) (2 048). */
3097 #define _2K 0x00000800
3098 /** 4 K (Kilo) (4 096). */
3099 #define _4K 0x00001000
3100 /** 8 K (Kilo) (8 192). */
3101 #define _8K 0x00002000
3102 /** 16 K (Kilo) (16 384). */
3103 #define _16K 0x00004000
3104 /** 32 K (Kilo) (32 768). */
3105 #define _32K 0x00008000
3106 /** 64 K (Kilo) (65 536). */
3108 # define _64K 0x00010000
3110 # define _64K UINT32_C(0x00010000)
3112 /** 128 K (Kilo) (131 072). */
3114 # define _128K 0x00020000
3116 # define _128K UINT32_C(0x00020000)
3118 /** 256 K (Kilo) (262 144). */
3120 # define _256K 0x00040000
3122 # define _256K UINT32_C(0x00040000)
3124 /** 512 K (Kilo) (524 288). */
3126 # define _512K 0x00080000
3128 # define _512K UINT32_C(0x00080000)
3130 /** 1 M (Mega) (1 048 576). */
3132 # define _1M 0x00100000
3134 # define _1M UINT32_C(0x00100000)
3136 /** 2 M (Mega) (2 097 152). */
3138 # define _2M 0x00200000
3140 # define _2M UINT32_C(0x00200000)
3142 /** 4 M (Mega) (4 194 304). */
3144 # define _4M 0x00400000
3146 # define _4M UINT32_C(0x00400000)
3148 /** 8 M (Mega) (8 388 608). */
3149 #define _8M UINT32_C(0x00800000)
3150 /** 16 M (Mega) (16 777 216). */
3151 #define _16M UINT32_C(0x01000000)
3152 /** 32 M (Mega) (33 554 432). */
3153 #define _32M UINT32_C(0x02000000)
3154 /** 64 M (Mega) (67 108 864). */
3155 #define _64M UINT32_C(0x04000000)
3156 /** 128 M (Mega) (134 217 728). */
3157 #define _128M UINT32_C(0x08000000)
3158 /** 256 M (Mega) (268 435 456). */
3159 #define _256M UINT32_C(0x10000000)
3160 /** 512 M (Mega) (536 870 912). */
3161 #define _512M UINT32_C(0x20000000)
3162 /** 1 G (Giga) (1 073 741 824). (32-bit) */
3164 # define _1G 0x40000000
3166 # define _1G UINT32_C(0x40000000)
3168 /** 1 G (Giga) (1 073 741 824). (64-bit) */
3170 # define _1G64 0x40000000LL
3172 # define _1G64 UINT64_C(0x40000000)
3174 /** 2 G (Giga) (2 147 483 648). (32-bit) */
3175 #define _2G32 UINT32_C(0x80000000)
3176 /** 2 G (Giga) (2 147 483 648). (64-bit) */
3178 # define _2G 0x0000000080000000LL
3180 # define _2G UINT64_C(0x0000000080000000)
3182 /** 4 G (Giga) (4 294 967 296). */
3184 # define _4G 0x0000000100000000LL
3186 # define _4G UINT64_C(0x0000000100000000)
3188 /** 1 T (Tera) (1 099 511 627 776). */
3190 # define _1T 0x0000010000000000LL
3192 # define _1T UINT64_C(0x0000010000000000)
3194 /** 1 P (Peta) (1 125 899 906 842 624). */
3196 # define _1P 0x0004000000000000LL
3198 # define _1P UINT64_C(0x0004000000000000)
3200 /** 1 E (Exa) (1 152 921 504 606 846 976). */
3202 # define _1E 0x1000000000000000LL
3204 # define _1E UINT64_C(0x1000000000000000)
3206 /** 2 E (Exa) (2 305 843 009 213 693 952). */
3208 # define _2E 0x2000000000000000ULL
3210 # define _2E UINT64_C(0x2000000000000000)
3214 /** @defgroup grp_rt_cdefs_decimal_grouping Decimal Constant Grouping Macros
3216 #define RT_D1(g1) g1
3217 #define RT_D2(g1, g2) g1#g2
3218 #define RT_D3(g1, g2, g3) g1#g2#g3
3219 #define RT_D4(g1, g2, g3, g4) g1#g2#g3#g4
3220 #define RT_D5(g1, g2, g3, g4, g5) g1#g2#g3#g4#g5
3221 #define RT_D6(g1, g2, g3, g4, g5, g6) g1#g2#g3#g4#g5#g6
3222 #define RT_D7(g1, g2, g3, g4, g5, g6, g7) g1#g2#g3#g4#g5#g6#g7
3224 #define RT_D1_U(g1) UINT32_C(g1)
3225 #define RT_D2_U(g1, g2) UINT32_C(g1#g2)
3226 #define RT_D3_U(g1, g2, g3) UINT32_C(g1#g2#g3)
3227 #define RT_D4_U(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
3228 #define RT_D5_U(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
3229 #define RT_D6_U(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
3230 #define RT_D7_U(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
3232 #define RT_D1_S(g1) INT32_C(g1)
3233 #define RT_D2_S(g1, g2) INT32_C(g1#g2)
3234 #define RT_D3_S(g1, g2, g3) INT32_C(g1#g2#g3)
3235 #define RT_D4_S(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
3236 #define RT_D5_S(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
3237 #define RT_D6_S(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
3238 #define RT_D7_S(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
3240 #define RT_D1_U32(g1) UINT32_C(g1)
3241 #define RT_D2_U32(g1, g2) UINT32_C(g1#g2)
3242 #define RT_D3_U32(g1, g2, g3) UINT32_C(g1#g2#g3)
3243 #define RT_D4_U32(g1, g2, g3, g4) UINT32_C(g1#g2#g3#g4)
3245 #define RT_D1_S32(g1) INT32_C(g1)
3246 #define RT_D2_S32(g1, g2) INT32_C(g1#g2)
3247 #define RT_D3_S32(g1, g2, g3) INT32_C(g1#g2#g3)
3248 #define RT_D4_S32(g1, g2, g3, g4) INT32_C(g1#g2#g3#g4)
3250 #define RT_D1_U64(g1) UINT64_C(g1)
3251 #define RT_D2_U64(g1, g2) UINT64_C(g1#g2)
3252 #define RT_D3_U64(g1, g2, g3) UINT64_C(g1#g2#g3)
3253 #define RT_D4_U64(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
3254 #define RT_D5_U64(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
3255 #define RT_D6_U64(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
3256 #define RT_D7_U64(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
3258 #define RT_D1_S64(g1) INT64_C(g1)
3259 #define RT_D2_S64(g1, g2) INT64_C(g1#g2)
3260 #define RT_D3_S64(g1, g2, g3) INT64_C(g1#g2#g3)
3261 #define RT_D4_S64(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
3262 #define RT_D5_S64(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
3263 #define RT_D6_S64(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
3264 #define RT_D7_S64(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
3268 /** @defgroup grp_rt_cdefs_time Time Constants
3271 /** 1 hour expressed in nanoseconds (64-bit). */
3272 #define RT_NS_1HOUR UINT64_C(3600000000000)
3273 /** 1 minute expressed in nanoseconds (64-bit). */
3274 #define RT_NS_1MIN UINT64_C(60000000000)
3275 /** 45 second expressed in nanoseconds. */
3276 #define RT_NS_45SEC UINT64_C(45000000000)
3277 /** 30 second expressed in nanoseconds. */
3278 #define RT_NS_30SEC UINT64_C(30000000000)
3279 /** 20 second expressed in nanoseconds. */
3280 #define RT_NS_20SEC UINT64_C(20000000000)
3281 /** 15 second expressed in nanoseconds. */
3282 #define RT_NS_15SEC UINT64_C(15000000000)
3283 /** 10 second expressed in nanoseconds. */
3284 #define RT_NS_10SEC UINT64_C(10000000000)
3285 /** 1 second expressed in nanoseconds. */
3286 #define RT_NS_1SEC UINT32_C(1000000000)
3287 /** 100 millsecond expressed in nanoseconds. */
3288 #define RT_NS_100MS UINT32_C(100000000)
3289 /** 10 millsecond expressed in nanoseconds. */
3290 #define RT_NS_10MS UINT32_C(10000000)
3291 /** 1 millsecond expressed in nanoseconds. */
3292 #define RT_NS_1MS UINT32_C(1000000)
3293 /** 100 microseconds expressed in nanoseconds. */
3294 #define RT_NS_100US UINT32_C(100000)
3295 /** 10 microseconds expressed in nanoseconds. */
3296 #define RT_NS_10US UINT32_C(10000)
3297 /** 1 microsecond expressed in nanoseconds. */
3298 #define RT_NS_1US UINT32_C(1000)
3300 /** 1 second expressed in nanoseconds - 64-bit type. */
3301 #define RT_NS_1SEC_64 UINT64_C(1000000000)
3302 /** 100 millsecond expressed in nanoseconds - 64-bit type. */
3303 #define RT_NS_100MS_64 UINT64_C(100000000)
3304 /** 10 millsecond expressed in nanoseconds - 64-bit type. */
3305 #define RT_NS_10MS_64 UINT64_C(10000000)
3306 /** 1 millsecond expressed in nanoseconds - 64-bit type. */
3307 #define RT_NS_1MS_64 UINT64_C(1000000)
3308 /** 100 microseconds expressed in nanoseconds - 64-bit type. */
3309 #define RT_NS_100US_64 UINT64_C(100000)
3310 /** 10 microseconds expressed in nanoseconds - 64-bit type. */
3311 #define RT_NS_10US_64 UINT64_C(10000)
3312 /** 1 microsecond expressed in nanoseconds - 64-bit type. */
3313 #define RT_NS_1US_64 UINT64_C(1000)
3315 /** 1 hour expressed in microseconds. */
3316 #define RT_US_1HOUR UINT32_C(3600000000)
3317 /** 1 minute expressed in microseconds. */
3318 #define RT_US_1MIN UINT32_C(60000000)
3319 /** 1 second expressed in microseconds. */
3320 #define RT_US_1SEC UINT32_C(1000000)
3321 /** 100 millsecond expressed in microseconds. */
3322 #define RT_US_100MS UINT32_C(100000)
3323 /** 10 millsecond expressed in microseconds. */
3324 #define RT_US_10MS UINT32_C(10000)
3325 /** 1 millsecond expressed in microseconds. */
3326 #define RT_US_1MS UINT32_C(1000)
3328 /** 1 hour expressed in microseconds - 64-bit type. */
3329 #define RT_US_1HOUR_64 UINT64_C(3600000000)
3330 /** 1 minute expressed in microseconds - 64-bit type. */
3331 #define RT_US_1MIN_64 UINT64_C(60000000)
3332 /** 1 second expressed in microseconds - 64-bit type. */
3333 #define RT_US_1SEC_64 UINT64_C(1000000)
3334 /** 100 millsecond expressed in microseconds - 64-bit type. */
3335 #define RT_US_100MS_64 UINT64_C(100000)
3336 /** 10 millsecond expressed in microseconds - 64-bit type. */
3337 #define RT_US_10MS_64 UINT64_C(10000)
3338 /** 1 millsecond expressed in microseconds - 64-bit type. */
3339 #define RT_US_1MS_64 UINT64_C(1000)
3341 /** 1 hour expressed in milliseconds. */
3342 #define RT_MS_1HOUR UINT32_C(3600000)
3343 /** 1 minute expressed in milliseconds. */
3344 #define RT_MS_1MIN UINT32_C(60000)
3345 /** 1 second expressed in milliseconds. */
3346 #define RT_MS_1SEC UINT32_C(1000)
3348 /** 1 hour expressed in milliseconds - 64-bit type. */
3349 #define RT_MS_1HOUR_64 UINT64_C(3600000)
3350 /** 1 minute expressed in milliseconds - 64-bit type. */
3351 #define RT_MS_1MIN_64 UINT64_C(60000)
3352 /** 1 second expressed in milliseconds - 64-bit type. */
3353 #define RT_MS_1SEC_64 UINT64_C(1000)
3355 /** The number of seconds per week. */
3356 #define RT_SEC_1WEEK UINT32_C(604800)
3357 /** The number of seconds per day. */
3358 #define RT_SEC_1DAY UINT32_C(86400)
3359 /** The number of seconds per hour. */
3360 #define RT_SEC_1HOUR UINT32_C(3600)
3362 /** The number of seconds per week - 64-bit type. */
3363 #define RT_SEC_1WEEK_64 UINT64_C(604800)
3364 /** The number of seconds per day - 64-bit type. */
3365 #define RT_SEC_1DAY_64 UINT64_C(86400)
3366 /** The number of seconds per hour - 64-bit type. */
3367 #define RT_SEC_1HOUR_64 UINT64_C(3600)
3371 /** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
3373 /** Other format. */
3374 #define RT_DBGTYPE_OTHER RT_BIT_32(0)
3376 #define RT_DBGTYPE_STABS RT_BIT_32(1)
3377 /** Debug With Arbitrary Record Format (DWARF). */
3378 #define RT_DBGTYPE_DWARF RT_BIT_32(2)
3379 /** Microsoft Codeview debug info. */
3380 #define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
3381 /** Watcom debug info. */
3382 #define RT_DBGTYPE_WATCOM RT_BIT_32(4)
3383 /** IBM High Level Language debug info. */
3384 #define RT_DBGTYPE_HLL RT_BIT_32(5)
3385 /** Old OS/2 and Windows symbol file. */
3386 #define RT_DBGTYPE_SYM RT_BIT_32(6)
3388 #define RT_DBGTYPE_MAP RT_BIT_32(7)
3392 /** @defgroup grp_rt_cdefs_exetype Executable Image Types
3394 /** Some other format. */
3395 #define RT_EXETYPE_OTHER RT_BIT_32(0)
3396 /** Portable Executable. */
3397 #define RT_EXETYPE_PE RT_BIT_32(1)
3398 /** Linear eXecutable. */
3399 #define RT_EXETYPE_LX RT_BIT_32(2)
3400 /** Linear Executable. */
3401 #define RT_EXETYPE_LE RT_BIT_32(3)
3402 /** New Executable. */
3403 #define RT_EXETYPE_NE RT_BIT_32(4)
3404 /** DOS Executable (Mark Zbikowski). */
3405 #define RT_EXETYPE_MZ RT_BIT_32(5)
3406 /** COM Executable. */
3407 #define RT_EXETYPE_COM RT_BIT_32(6)
3408 /** a.out Executable. */
3409 #define RT_EXETYPE_AOUT RT_BIT_32(7)
3410 /** Executable and Linkable Format. */
3411 #define RT_EXETYPE_ELF RT_BIT_32(8)
3412 /** Mach-O Executable (including FAT ones). */
3413 #define RT_EXETYPE_MACHO RT_BIT_32(9)
3414 /** TE from UEFI. */
3415 #define RT_EXETYPE_TE RT_BIT_32(9)
3420 * Pointer validation macro.
3421 * @param ptr The pointer.
3423 #if defined(RT_ARCH_AMD64)
3425 # if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
3426 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
3427 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
3428 # elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
3429 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3430 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
3431 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
3433 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3434 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
3436 # else /* !IN_RING3 */
3437 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
3438 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
3439 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
3440 # endif /* !IN_RING3 */
3442 #elif defined(RT_ARCH_X86)
3443 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3445 #elif defined(RT_ARCH_SPARC64)
3447 # if defined(RT_OS_SOLARIS)
3448 /** Sparc64 user mode: According to Figure 9.4 in solaris internals */
3449 /** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
3450 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
3454 # else /* !IN_RING3 */
3455 # if defined(RT_OS_SOLARIS)
3456 /** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
3457 * internals. Verify in sources. */
3458 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
3462 # endif /* !IN_RING3 */
3464 #elif defined(RT_ARCH_SPARC)
3466 # ifdef RT_OS_SOLARIS
3467 /** Sparc user mode: According to
3468 * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
3469 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
3474 # else /* !IN_RING3 */
3475 # ifdef RT_OS_SOLARIS
3476 /** @todo Sparc kernel mode: Check the sources! */
3477 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3481 # endif /* !IN_RING3 */
3483 #elif defined(RT_ARCH_ARM)
3484 /* ASSUMES that at least the last and first 4K are out of bounds. */
3485 # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
3488 # error "Architecture identifier missing / not implemented."
3491 /** Old name for RT_VALID_PTR. */
3492 #define VALID_PTR(ptr) RT_VALID_PTR(ptr)
3494 /** @def RT_VALID_ALIGNED_PTR
3495 * Pointer validation macro that also checks the alignment.
3496 * @param ptr The pointer.
3497 * @param align The alignment, must be a power of two.
3499 #define RT_VALID_ALIGNED_PTR(ptr, align) \
3500 ( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
3504 /** @def VALID_PHYS32
3505 * 32 bits physical address validation macro.
3506 * @param Phys The RTGCPHYS address.
3508 #define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
3511 * The \#define N_ is used to mark a string for translation. This is usable in
3512 * any part of the code, as it is only used by the tools that create message
3513 * catalogs. This macro is a no-op as far as the compiler and code generation
3516 * If you want to both mark a string for translation and translate it, use _().
3521 * The \#define _ is used to mark a string for translation and to translate it
3524 * If you want to only mark a string for translation, use N_().
3526 #define _(s) gettext(s)
3529 /** @def __PRETTY_FUNCTION__
3530 * With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
3531 * for the other compilers.
3533 #if !defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)
3535 # define __PRETTY_FUNCTION__ __FUNCSIG__
3537 # define __PRETTY_FUNCTION__ __FUNCTION__
3543 * The \#define RT_STRICT controls whether or not assertions and other runtime
3544 * checks should be compiled in or not. This is defined when DEBUG is defined.
3545 * If RT_NO_STRICT is defined, it will unconditionally be undefined.
3547 * If you want assertions which are not subject to compile time options use
3548 * the AssertRelease*() flavors.
3550 #if !defined(RT_STRICT) && defined(DEBUG)
3557 /** @todo remove this: */
3558 #if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
3559 # define RT_LOCK_NO_STRICT
3561 #if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
3562 # define RT_LOCK_NO_STRICT_ORDER
3565 /** @def RT_LOCK_STRICT
3566 * The \#define RT_LOCK_STRICT controls whether deadlock detection and related
3567 * checks are done in the lock and semaphore code. It is by default enabled in
3568 * RT_STRICT builds, but this behavior can be overridden by defining
3569 * RT_LOCK_NO_STRICT. */
3570 #if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
3571 # define RT_LOCK_STRICT
3573 /** @def RT_LOCK_NO_STRICT
3574 * The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
3575 #if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
3576 # undef RT_LOCK_STRICT
3579 /** @def RT_LOCK_STRICT_ORDER
3580 * The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
3581 * by the lock and semaphore code. It is by default enabled in RT_STRICT
3582 * builds, but this behavior can be overridden by defining
3583 * RT_LOCK_NO_STRICT_ORDER. */
3584 #if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
3585 # define RT_LOCK_STRICT_ORDER
3587 /** @def RT_LOCK_NO_STRICT_ORDER
3588 * The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
3589 #if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
3590 # undef RT_LOCK_STRICT_ORDER
3594 /** Source position. */
3595 #define RT_SRC_POS __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
3597 /** Source position declaration. */
3598 #define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
3600 /** Source position arguments. */
3601 #define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
3603 /** Applies NOREF() to the source position arguments. */
3604 #define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
3607 /** @def RT_INLINE_ASM_EXTERNAL
3608 * Defined as 1 if the compiler does not support inline assembly.
3609 * The ASM* functions will then be implemented in external .asm files.
3611 #if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
3612 || (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86)) \
3613 || defined(__WATCOMC__)
3614 # define RT_INLINE_ASM_EXTERNAL 1
3616 # define RT_INLINE_ASM_EXTERNAL 0
3619 /** @def RT_INLINE_ASM_GNU_STYLE
3620 * Defined as 1 if the compiler understands GNU style inline assembly.
3622 #if defined(_MSC_VER) || defined(__WATCOMC__)
3623 # define RT_INLINE_ASM_GNU_STYLE 0
3625 # define RT_INLINE_ASM_GNU_STYLE 1
3628 /** @def RT_INLINE_ASM_USES_INTRIN
3629 * Defined as the major MSC version if the compiler have and uses intrin.h.
3630 * Otherwise it is 0. */
3632 # if _MSC_VER >= 1700 /* Visual C++ v11.0 / 2012 */
3633 # define RT_INLINE_ASM_USES_INTRIN 17
3634 # elif _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3635 # define RT_INLINE_ASM_USES_INTRIN 16
3636 # elif _MSC_VER >= 1500 /* Visual C++ v9.0 / 2008 */
3637 # define RT_INLINE_ASM_USES_INTRIN 15
3638 # elif _MSC_VER >= 1400 /* Visual C++ v8.0 / 2005 */
3639 # define RT_INLINE_ASM_USES_INTRIN 14
3642 #ifndef RT_INLINE_ASM_USES_INTRIN
3643 # define RT_INLINE_ASM_USES_INTRIN 0
3646 /** @def RT_COMPILER_SUPPORTS_LAMBDA
3647 * If the defined, the compiler supports lambda expressions. These expressions
3648 * are useful for embedding assertions and type checks into macros. */
3649 #if defined(_MSC_VER) && defined(__cplusplus)
3650 # if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3651 # define RT_COMPILER_SUPPORTS_LAMBDA
3653 #elif defined(__GNUC__) && defined(__cplusplus)
3654 /* 4.5 or later, I think, if in ++11 mode... */
3657 /** @def RT_DATA_IS_FAR
3658 * Set to 1 if we're in 16-bit mode and use far pointers.
3660 #if ARCH_BITS == 16 && defined(__WATCOMC__) \
3661 && (defined(__COMPACT__) || defined(__LARGE__))
3662 # define RT_DATA_IS_FAR 1
3664 # define RT_DATA_IS_FAR 0
3668 * For indicating far pointers in 16-bit code.
3669 * Does nothing in 32-bit and 64-bit code. */
3671 * For indicating near pointers in 16-bit code.
3672 * Does nothing in 32-bit and 64-bit code. */
3673 /** @def RT_FAR_CODE
3674 * For indicating far 16-bit functions.
3675 * Does nothing in 32-bit and 64-bit code. */
3676 /** @def RT_NEAR_CODE
3677 * For indicating near 16-bit functions.
3678 * Does nothing in 32-bit and 64-bit code. */
3679 /** @def RT_FAR_DATA
3680 * For indicating far 16-bit external data, i.e. in a segment other than DATA16.
3681 * Does nothing in 32-bit and 64-bit code. */
3683 # define RT_FAR __far
3684 # define RT_NEAR __near
3685 # define RT_FAR_CODE __far
3686 # define RT_NEAR_CODE __near
3687 # define RT_FAR_DATA __far
3691 # define RT_FAR_CODE
3692 # define RT_NEAR_CODE
3693 # define RT_FAR_DATA
3700 /** @defgroup grp_rt_cdefs_cpp Special Macros for C++
3701 * @ingroup grp_rt_cdefs
3707 /** @def DECLEXPORT_CLASS
3708 * How to declare an exported class. Place this macro after the 'class'
3709 * keyword in the declaration of every class you want to export.
3711 * @note It is necessary to use this macro even for inner classes declared
3712 * inside the already exported classes. This is a GCC specific requirement,
3713 * but it seems not to harm other compilers.
3715 #if defined(_MSC_VER) || defined(RT_OS_OS2)
3716 # define DECLEXPORT_CLASS __declspec(dllexport)
3717 #elif defined(RT_USE_VISIBILITY_DEFAULT)
3718 # define DECLEXPORT_CLASS __attribute__((visibility("default")))
3720 # define DECLEXPORT_CLASS
3723 /** @def DECLIMPORT_CLASS
3724 * How to declare an imported class Place this macro after the 'class'
3725 * keyword in the declaration of every class you want to export.
3727 * @note It is necessary to use this macro even for inner classes declared
3728 * inside the already exported classes. This is a GCC specific requirement,
3729 * but it seems not to harm other compilers.
3731 #if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
3732 # define DECLIMPORT_CLASS __declspec(dllimport)
3733 #elif defined(RT_USE_VISIBILITY_DEFAULT)
3734 # define DECLIMPORT_CLASS __attribute__((visibility("default")))
3736 # define DECLIMPORT_CLASS
3739 /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP
3740 * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity
3741 * resolver. The following snippet clearly demonstrates the code causing this
3747 * operator bool() const { return false; }
3748 * operator int*() const { return NULL; }
3758 * The code itself seems pretty valid to me and GCC thinks the same.
3760 * This macro fixes the compiler error by explicitly overloading implicit
3761 * global operators !, && and || that take the given class instance as one of
3764 * The best is to use this macro right after the class declaration.
3766 * @note The macro expands to nothing for compilers other than MSVC.
3768 * @param Cls Class to apply the workaround to
3770 #if defined(_MSC_VER)
3771 # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
3772 inline bool operator! (const Cls &that) { return !bool (that); } \
3773 inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
3774 inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
3775 inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
3776 inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
3778 # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
3781 /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL
3782 * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes.
3784 * @param Tpl Name of the template class to apply the workaround to
3785 * @param ArgsDecl arguments of the template, as declared in |<>| after the
3786 * |template| keyword, including |<>|
3787 * @param Args arguments of the template, as specified in |<>| after the
3788 * template class name when using the, including |<>|
3792 * // template class declaration
3793 * template <class C>
3794 * class Foo { ... };
3795 * // applied workaround
3796 * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
3799 #if defined(_MSC_VER)
3800 # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
3802 inline bool operator! (const Tpl Args &that) { return !bool (that); } \
3804 inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
3806 inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
3808 inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
3810 inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
3812 # define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
3816 /** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP
3817 * Declares the copy constructor and the assignment operation as inlined no-ops
3818 * (non-existent functions) for the given class. Use this macro inside the
3819 * private section if you want to effectively disable these operations for your
3822 * @param Cls class name to declare for
3824 #define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
3825 inline Cls(const Cls &); \
3826 inline Cls &operator= (const Cls &)
3829 /** @def DECLARE_CLS_NEW_DELETE_NOOP
3830 * Declares the new and delete operations as no-ops (non-existent functions)
3831 * for the given class. Use this macro inside the private section if you want
3832 * to effectively limit creating class instances on the stack only.
3834 * @note The destructor of the given class must not be virtual, otherwise a
3835 * compile time error will occur. Note that this is not a drawback: having
3836 * the virtual destructor for a stack-based class is absolutely useless
3837 * (the real class of the stack-based instance is always known to the compiler
3838 * at compile time, so it will always call the correct destructor).
3840 * @param Cls class name to declare for
3842 #define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
3843 inline static void *operator new (size_t); \
3844 inline static void operator delete (void *)
3846 #endif /* __cplusplus */