VirtualBox

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

Last change on this file since 60843 was 60843, checked in by vboxsync, 9 years ago

iprt/cdefs.h: Added RT_MSC_PREREQ, RT_MSC_PREREQ_EX and RT_GCC_PREREQ_EX. With the two MSC macros are a bunch of version value defines, RT_MSC_VER_XXX, for the most recent Visual C++ compilers.

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

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