VirtualBox

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

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

iprt/cdefs.h: doxygen fix

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