VirtualBox

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

最後變更 在這個檔案從59965是 59664,由 vboxsync 提交於 9 年 前

iprt/cdefs.h: RT_CONCAT5 and RT_CONCAT6.

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

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