VirtualBox

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

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

iprt/*.h: 16-bit watcom / DOS adjustments.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 137.6 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/**
1554 * String constant tuple - string constant, strlen(string constant).
1555 *
1556 * @param a_szConst String constant.
1557 * @sa RTSTRTUPLE
1558 */
1559#define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
1560
1561
1562/**
1563 * Macro for using in switch statements that turns constants into strings.
1564 *
1565 * @param a_Const The constant (not string).
1566 */
1567#define RT_CASE_RET_STR(a_Const) case a_Const: return #a_Const
1568
1569
1570/** @def RT_BIT
1571 * Convert a bit number into an integer bitmask (unsigned).
1572 * @param bit The bit number.
1573 */
1574#define RT_BIT(bit) ( 1U << (bit) )
1575
1576/** @def RT_BIT_32
1577 * Convert a bit number into a 32-bit bitmask (unsigned).
1578 * @param bit The bit number.
1579 */
1580#define RT_BIT_32(bit) ( UINT32_C(1) << (bit) )
1581
1582/** @def RT_BIT_64
1583 * Convert a bit number into a 64-bit bitmask (unsigned).
1584 * @param bit The bit number.
1585 */
1586#define RT_BIT_64(bit) ( UINT64_C(1) << (bit) )
1587
1588
1589/** @def RT_BF_GET
1590 * Gets the value of a bit field in an integer value.
1591 *
1592 * This requires a couple of macros to be defined for the field:
1593 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1594 * - \<a_FieldNm\>_MASK: The field mask.
1595 *
1596 * @returns The bit field value.
1597 * @param a_uValue The integer value containing the field.
1598 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1599 * _MASK macros.
1600 * @sa #RT_BF_CLEAR, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
1601 */
1602#define RT_BF_GET(a_uValue, a_FieldNm) ( ((a_uValue) >> RT_CONCAT(a_FieldNm,_SHIFT)) & RT_BF_ZMASK(a_FieldNm) )
1603
1604/** @def RT_BF_SET
1605 * Sets the given bit field in the integer value.
1606 *
1607 * This requires a couple of macros to be defined for the field:
1608 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1609 * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
1610 * integer value!!
1611 *
1612 * @returns Integer value with bit field set to @a a_uFieldValue.
1613 * @param a_uValue The integer value containing the field.
1614 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1615 * _MASK macros.
1616 * @param a_uFieldValue The new field value.
1617 * @sa #RT_BF_GET, #RT_BF_CLEAR, #RT_BF_MAKE, #RT_BF_ZMASK
1618 */
1619#define RT_BF_SET(a_uValue, a_FieldNm, a_uFieldValue) ( RT_BF_CLEAR(a_uValue, a_FieldNm) | RT_BF_MAKE(a_FieldNm, a_uFieldValue) )
1620
1621/** @def RT_BF_CLEAR
1622 * Clears the given bit field in the integer value.
1623 *
1624 * This requires a couple of macros to be defined for the field:
1625 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1626 * - \<a_FieldNm\>_MASK: The field mask. Must have the same type as the
1627 * integer value!!
1628 *
1629 * @returns Integer value with bit field set to zero.
1630 * @param a_uValue The integer value containing the field.
1631 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1632 * _MASK macros.
1633 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_MAKE, #RT_BF_ZMASK
1634 */
1635#define RT_BF_CLEAR(a_uValue, a_FieldNm) ( (a_uValue) & ~RT_CONCAT(a_FieldNm,_MASK) )
1636
1637/** @def RT_BF_MAKE
1638 * Shifts and masks a bit field value into position in the integer value.
1639 *
1640 * This requires a couple of macros to be defined for the field:
1641 * - \<a_FieldNm\>_SHIFT: The shift count to get to the field.
1642 * - \<a_FieldNm\>_MASK: The field mask.
1643 *
1644 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1645 * _MASK macros.
1646 * @param a_uFieldValue The field value that should be masked and shifted
1647 * into position.
1648 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_ZMASK
1649 */
1650#define RT_BF_MAKE(a_FieldNm, a_uFieldValue) ( ((a_uFieldValue) & RT_BF_ZMASK(a_FieldNm) ) << RT_CONCAT(a_FieldNm,_SHIFT) )
1651
1652/** @def RT_BF_ZMASK
1653 * Helper for getting the field mask shifted to bit position zero.
1654 *
1655 * @param a_FieldNm The field name prefix for getting at the _SHIFT and
1656 * _MASK macros.
1657 * @sa #RT_BF_GET, #RT_BF_SET, #RT_BF_CLEAR, #RT_BF_MAKE
1658 */
1659#define RT_BF_ZMASK(a_FieldNm) ( RT_CONCAT(a_FieldNm,_MASK) >> RT_CONCAT(a_FieldNm,_SHIFT) )
1660
1661/** Bit field compile time check helper
1662 * @internal */
1663#define RT_BF_CHECK_DO_XOR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) ^ RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
1664/** Bit field compile time check helper
1665 * @internal */
1666#define RT_BF_CHECK_DO_OR_MASK(a_uLeft, a_RightPrefix, a_FieldNm) ((a_uLeft) | RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK))
1667/** Bit field compile time check helper
1668 * @internal */
1669#define RT_BF_CHECK_DO_1ST_MASK_BIT(a_uLeft, a_RightPrefix, a_FieldNm) \
1670 ((a_uLeft) && ( (RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U ) )
1671/** Used to check that a bit field mask does not start too early.
1672 * @internal */
1673#define RT_BF_CHECK_DO_MASK_START(a_uLeft, a_RightPrefix, a_FieldNm) \
1674 ( (a_uLeft) \
1675 && ( RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT) == 0 \
1676 || ( ( ( ((RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK) >> RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) & 1U) \
1677 << RT_CONCAT3(a_RightPrefix, a_FieldNm, _SHIFT)) /* => single bit mask, correct type */ \
1678 - 1U) /* => mask of all bits below the field */ \
1679 & RT_CONCAT3(a_RightPrefix, a_FieldNm, _MASK)) == 0 ) )
1680/** @name Bit field compile time check recursion workers.
1681 * @internal
1682 * @{ */
1683#define RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix, f1) \
1684 a_DoThis(a_uLeft, a_RightPrefix, f1)
1685#define RT_BF_CHECK_DO_2(a_DoThis, a_uLeft, a_RightPrefix, f1, f2) \
1686 RT_BF_CHECK_DO_1(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2)
1687#define RT_BF_CHECK_DO_3(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3) \
1688 RT_BF_CHECK_DO_2(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3)
1689#define RT_BF_CHECK_DO_4(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4) \
1690 RT_BF_CHECK_DO_3(a_DoThis, RT_BF_CHECK_DO_1(a_DoThis, a_uLeft, a_RightPrefix,f1), a_RightPrefix, f2, f3, f4)
1691#define RT_BF_CHECK_DO_5(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5) \
1692 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)
1693#define RT_BF_CHECK_DO_6(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6) \
1694 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)
1695#define RT_BF_CHECK_DO_7(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7) \
1696 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)
1697#define RT_BF_CHECK_DO_8(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8) \
1698 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)
1699#define RT_BF_CHECK_DO_9(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9) \
1700 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)
1701#define RT_BF_CHECK_DO_10(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10) \
1702 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)
1703#define RT_BF_CHECK_DO_11(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) \
1704 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)
1705#define RT_BF_CHECK_DO_12(a_DoThis, a_uLeft, a_RightPrefix, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) \
1706 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)
1707#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) \
1708 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)
1709#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) \
1710 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)
1711#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) \
1712 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)
1713#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) \
1714 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)
1715#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) \
1716 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)
1717#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) \
1718 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)
1719#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) \
1720 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)
1721#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) \
1722 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)
1723#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) \
1724 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)
1725#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) \
1726 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)
1727#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) \
1728 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)
1729#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) \
1730 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)
1731#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) \
1732 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)
1733#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) \
1734 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)
1735#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) \
1736 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)
1737#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) \
1738 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)
1739#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) \
1740 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)
1741#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) \
1742 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)
1743#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) \
1744 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)
1745#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) \
1746 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)
1747#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) \
1748 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)
1749#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) \
1750 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)
1751#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) \
1752 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)
1753#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) \
1754 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)
1755#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) \
1756 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)
1757#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) \
1758 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)
1759#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) \
1760 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)
1761#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) \
1762 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)
1763#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) \
1764 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)
1765#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) \
1766 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)
1767#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) \
1768 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)
1769#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) \
1770 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)
1771#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) \
1772 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)
1773#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) \
1774 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)
1775#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) \
1776 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)
1777#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) \
1778 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)
1779#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) \
1780 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)
1781#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) \
1782 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)
1783#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) \
1784 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)
1785#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) \
1786 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)
1787#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) \
1788 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)
1789#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) \
1790 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)
1791#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) \
1792 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)
1793#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) \
1794 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)
1795#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) \
1796 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)
1797#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) \
1798 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)
1799#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) \
1800 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)
1801#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) \
1802 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)
1803#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) \
1804 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)
1805#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) \
1806 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)
1807#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) \
1808 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)
1809#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) \
1810 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)
1811/** @} */
1812
1813/** @def RT_BF_ASSERT_COMPILE_CHECKS
1814 * Emits a series of AssertCompile statements checking that the bit-field
1815 * declarations doesn't overlap, has holes, and generally makes some sense.
1816 *
1817 * This requires variadic macros because its too much to type otherwise.
1818 */
1819#if defined(RT_COMPILER_SUPPORTS_VA_ARGS) || defined(DOXYGEN_RUNNING)
1820# define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) \
1821 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_OR_MASK, a_uZero, a_Prefix, RT_UNPACK_ARGS a_Fields ) == a_uCovered); \
1822 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_XOR_MASK, a_uCovered, a_Prefix, RT_UNPACK_ARGS a_Fields ) == 0); \
1823 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_1ST_MASK_BIT, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true); \
1824 AssertCompile(RT_BF_CHECK_DO_N(RT_BF_CHECK_DO_MASK_START, true, a_Prefix, RT_UNPACK_ARGS a_Fields ) == true)
1825/** Bit field compile time check helper
1826 * @internal */
1827# define RT_BF_CHECK_DO_N(a_DoThis, a_uLeft, a_RightPrefix, ...) \
1828 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__))
1829#else
1830# define RT_BF_ASSERT_COMPILE_CHECKS(a_Prefix, a_uZero, a_uCovered, a_Fields) AssertCompile(true)
1831#endif
1832
1833
1834/** @def RT_ALIGN
1835 * Align macro.
1836 * @param u Value to align.
1837 * @param uAlignment The alignment. Power of two!
1838 *
1839 * @remark Be extremely careful when using this macro with type which sizeof != sizeof int.
1840 * When possible use any of the other RT_ALIGN_* macros. And when that's not
1841 * possible, make 101% sure that uAlignment is specified with a right sized type.
1842 *
1843 * Specifying an unsigned 32-bit alignment constant with a 64-bit value will give
1844 * you a 32-bit return value!
1845 *
1846 * In short: Don't use this macro. Use RT_ALIGN_T() instead.
1847 */
1848#define RT_ALIGN(u, uAlignment) ( ((u) + ((uAlignment) - 1)) & ~((uAlignment) - 1) )
1849
1850/** @def RT_ALIGN_T
1851 * Align macro.
1852 * @param u Value to align.
1853 * @param uAlignment The alignment. Power of two!
1854 * @param type Integer type to use while aligning.
1855 * @remark This macro is the preferred alignment macro, it doesn't have any of the pitfalls RT_ALIGN has.
1856 */
1857#define RT_ALIGN_T(u, uAlignment, type) ( ((type)(u) + ((uAlignment) - 1)) & ~(type)((uAlignment) - 1) )
1858
1859/** @def RT_ALIGN_32
1860 * Align macro for a 32-bit value.
1861 * @param u32 Value to align.
1862 * @param uAlignment The alignment. Power of two!
1863 */
1864#define RT_ALIGN_32(u32, uAlignment) RT_ALIGN_T(u32, uAlignment, uint32_t)
1865
1866/** @def RT_ALIGN_64
1867 * Align macro for a 64-bit value.
1868 * @param u64 Value to align.
1869 * @param uAlignment The alignment. Power of two!
1870 */
1871#define RT_ALIGN_64(u64, uAlignment) RT_ALIGN_T(u64, uAlignment, uint64_t)
1872
1873/** @def RT_ALIGN_Z
1874 * Align macro for size_t.
1875 * @param cb Value to align.
1876 * @param uAlignment The alignment. Power of two!
1877 */
1878#define RT_ALIGN_Z(cb, uAlignment) RT_ALIGN_T(cb, uAlignment, size_t)
1879
1880/** @def RT_ALIGN_P
1881 * Align macro for pointers.
1882 * @param pv Value to align.
1883 * @param uAlignment The alignment. Power of two!
1884 */
1885#define RT_ALIGN_P(pv, uAlignment) RT_ALIGN_PT(pv, uAlignment, void *)
1886
1887/** @def RT_ALIGN_PT
1888 * Align macro for pointers with type cast.
1889 * @param u Value to align.
1890 * @param uAlignment The alignment. Power of two!
1891 * @param CastType The type to cast the result to.
1892 */
1893#define RT_ALIGN_PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, uintptr_t) )
1894
1895/** @def RT_ALIGN_R3PT
1896 * Align macro for ring-3 pointers with type cast.
1897 * @param u Value to align.
1898 * @param uAlignment The alignment. Power of two!
1899 * @param CastType The type to cast the result to.
1900 */
1901#define RT_ALIGN_R3PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR3UINTPTR) )
1902
1903/** @def RT_ALIGN_R0PT
1904 * Align macro for ring-0 pointers with type cast.
1905 * @param u Value to align.
1906 * @param uAlignment The alignment. Power of two!
1907 * @param CastType The type to cast the result to.
1908 */
1909#define RT_ALIGN_R0PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR0UINTPTR) )
1910
1911/** @def RT_ALIGN_GCPT
1912 * Align macro for GC pointers with type cast.
1913 * @param u Value to align.
1914 * @param uAlignment The alignment. Power of two!
1915 * @param CastType The type to cast the result to.
1916 */
1917#define RT_ALIGN_GCPT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTGCUINTPTR) )
1918
1919
1920/** @def RT_OFFSETOF
1921 * Our own special offsetof() variant, returns a signed result.
1922 *
1923 * This differs from the usual offsetof() in that it's not relying on builtin
1924 * compiler stuff and thus can use variables in arrays the structure may
1925 * contain. This is useful to determine the sizes of structures ending
1926 * with a variable length field. For gcc >= 4.4 see @bugref{7775}.
1927 *
1928 * @returns offset into the structure of the specified member. signed.
1929 * @param type Structure type.
1930 * @param member Member.
1931 */
1932#if defined(__GNUC__) && defined(__cplusplus) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1933# define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 )
1934#else
1935# define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) )
1936#endif
1937
1938/** @def RT_UOFFSETOF
1939 * Our own special offsetof() variant, returns an unsigned result.
1940 *
1941 * This differs from the usual offsetof() in that it's not relying on builtin
1942 * compiler stuff and thus can use variables in arrays the structure may
1943 * contain. This is useful to determine the sizes of structures ending
1944 * with a variable length field. For gcc >= 4.4 see @bugref{7775}.
1945 *
1946 * @returns offset into the structure of the specified member. unsigned.
1947 * @param type Structure type.
1948 * @param member Member.
1949 */
1950#if defined(__GNUC__) && defined(__cplusplus) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1951# define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 )
1952#else
1953# define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) )
1954#endif
1955
1956/** @def RT_OFFSETOF_ADD
1957 * RT_OFFSETOF with an addend.
1958 *
1959 * @returns offset into the structure of the specified member. signed.
1960 * @param type Structure type.
1961 * @param member Member.
1962 * @param addend The addend to add to the offset.
1963 */
1964#define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) )
1965
1966/** @def RT_UOFFSETOF_ADD
1967 * RT_UOFFSETOF with an addend.
1968 *
1969 * @returns offset into the structure of the specified member. signed.
1970 * @param type Structure type.
1971 * @param member Member.
1972 * @param addend The addend to add to the offset.
1973 */
1974#define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) )
1975
1976/** @def RT_SIZEOFMEMB
1977 * Get the size of a structure member.
1978 *
1979 * @returns size of the structure member.
1980 * @param type Structure type.
1981 * @param member Member.
1982 */
1983#define RT_SIZEOFMEMB(type, member) ( sizeof(((type *)(void *)0)->member) )
1984
1985/** @def RT_FROM_MEMBER
1986 * Convert a pointer to a structure member into a pointer to the structure.
1987 *
1988 * @returns pointer to the structure.
1989 * @param pMem Pointer to the member.
1990 * @param Type Structure type.
1991 * @param Member Member name.
1992 */
1993#define RT_FROM_MEMBER(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
1994
1995/** @def RT_FROM_CPP_MEMBER
1996 * Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
1997 * invalid access to non-static data member of NULL object.
1998 *
1999 * @returns pointer to the structure.
2000 * @param pMem Pointer to the member.
2001 * @param Type Structure type.
2002 * @param Member Member name.
2003 *
2004 * @remarks Using the __builtin_offsetof does not shut up the compiler.
2005 */
2006#if defined(__GNUC__) && defined(__cplusplus)
2007# define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
2008 ( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
2009#else
2010# define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
2011#endif
2012
2013/** @def RT_ELEMENTS
2014 * Calculates the number of elements in a statically sized array.
2015 * @returns Element count.
2016 * @param aArray Array in question.
2017 */
2018#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
2019
2020/**
2021 * Checks if the value is a power of two.
2022 *
2023 * @returns true if power of two, false if not.
2024 * @param uVal The value to test.
2025 * @remarks 0 is a power of two.
2026 * @see VERR_NOT_POWER_OF_TWO
2027 */
2028#define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
2029
2030#ifdef RT_OS_OS2
2031/* Undefine RT_MAX since there is an unfortunate clash with the max
2032 resource type define in os2.h. */
2033# undef RT_MAX
2034#endif
2035
2036/** @def RT_MAX
2037 * Finds the maximum value.
2038 * @returns The higher of the two.
2039 * @param Value1 Value 1
2040 * @param Value2 Value 2
2041 */
2042#define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
2043
2044/** @def RT_MIN
2045 * Finds the minimum value.
2046 * @returns The lower of the two.
2047 * @param Value1 Value 1
2048 * @param Value2 Value 2
2049 */
2050#define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
2051
2052/** @def RT_CLAMP
2053 * Clamps the value to minimum and maximum values.
2054 * @returns The clamped value.
2055 * @param Value The value to check.
2056 * @param Min Minimum value.
2057 * @param Max Maximum value.
2058 */
2059#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
2060
2061/** @def RT_ABS
2062 * Get the absolute (non-negative) value.
2063 * @returns The absolute value of Value.
2064 * @param Value The value.
2065 */
2066#define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
2067
2068/** @def RT_BOOL
2069 * Turn non-zero/zero into true/false
2070 * @returns The resulting boolean value.
2071 * @param Value The value.
2072 */
2073#define RT_BOOL(Value) ( !!(Value) )
2074
2075/** @def RT_LO_U8
2076 * Gets the low uint8_t of a uint16_t or something equivalent. */
2077#ifdef __GNUC__
2078# define RT_LO_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)(a); })
2079#else
2080# define RT_LO_U8(a) ( (uint8_t)(a) )
2081#endif
2082/** @def RT_HI_U8
2083 * Gets the high uint8_t of a uint16_t or something equivalent. */
2084#ifdef __GNUC__
2085# define RT_HI_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)((a) >> 8); })
2086#else
2087# define RT_HI_U8(a) ( (uint8_t)((a) >> 8) )
2088#endif
2089
2090/** @def RT_LO_U16
2091 * Gets the low uint16_t of a uint32_t or something equivalent. */
2092#ifdef __GNUC__
2093# define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)(a); })
2094#else
2095# define RT_LO_U16(a) ( (uint16_t)(a) )
2096#endif
2097/** @def RT_HI_U16
2098 * Gets the high uint16_t of a uint32_t or something equivalent. */
2099#ifdef __GNUC__
2100# define RT_HI_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)((a) >> 16); })
2101#else
2102# define RT_HI_U16(a) ( (uint16_t)((a) >> 16) )
2103#endif
2104
2105/** @def RT_LO_U32
2106 * Gets the low uint32_t of a uint64_t or something equivalent. */
2107#ifdef __GNUC__
2108# define RT_LO_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
2109#else
2110# define RT_LO_U32(a) ( (uint32_t)(a) )
2111#endif
2112/** @def RT_HI_U32
2113 * Gets the high uint32_t of a uint64_t or something equivalent. */
2114#ifdef __GNUC__
2115# define RT_HI_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)((a) >> 32); })
2116#else
2117# define RT_HI_U32(a) ( (uint32_t)((a) >> 32) )
2118#endif
2119
2120/** @def RT_BYTE1
2121 * Gets the first byte of something. */
2122#define RT_BYTE1(a) ( (a) & 0xff )
2123/** @def RT_BYTE2
2124 * Gets the second byte of something. */
2125#define RT_BYTE2(a) ( ((a) >> 8) & 0xff )
2126/** @def RT_BYTE3
2127 * Gets the second byte of something. */
2128#define RT_BYTE3(a) ( ((a) >> 16) & 0xff )
2129/** @def RT_BYTE4
2130 * Gets the fourth byte of something. */
2131#define RT_BYTE4(a) ( ((a) >> 24) & 0xff )
2132/** @def RT_BYTE5
2133 * Gets the fifth byte of something. */
2134#define RT_BYTE5(a) ( ((a) >> 32) & 0xff )
2135/** @def RT_BYTE6
2136 * Gets the sixth byte of something. */
2137#define RT_BYTE6(a) ( ((a) >> 40) & 0xff )
2138/** @def RT_BYTE7
2139 * Gets the seventh byte of something. */
2140#define RT_BYTE7(a) ( ((a) >> 48) & 0xff )
2141/** @def RT_BYTE8
2142 * Gets the eight byte of something. */
2143#define RT_BYTE8(a) ( ((a) >> 56) & 0xff )
2144
2145
2146/** @def RT_LODWORD
2147 * Gets the low dword (=uint32_t) of something.
2148 * @deprecated Use RT_LO_U32. */
2149#define RT_LODWORD(a) ( (uint32_t)(a) )
2150/** @def RT_HIDWORD
2151 * Gets the high dword (=uint32_t) of a 64-bit of something.
2152 * @deprecated Use RT_HI_U32. */
2153#define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
2154
2155/** @def RT_LOWORD
2156 * Gets the low word (=uint16_t) of something.
2157 * @deprecated Use RT_LO_U16. */
2158#define RT_LOWORD(a) ( (a) & 0xffff )
2159/** @def RT_HIWORD
2160 * Gets the high word (=uint16_t) of a 32-bit something.
2161 * @deprecated Use RT_HI_U16. */
2162#define RT_HIWORD(a) ( (a) >> 16 )
2163
2164/** @def RT_LOBYTE
2165 * Gets the low byte of something.
2166 * @deprecated Use RT_LO_U8. */
2167#define RT_LOBYTE(a) ( (a) & 0xff )
2168/** @def RT_HIBYTE
2169 * Gets the high byte of a 16-bit something.
2170 * @deprecated Use RT_HI_U8. */
2171#define RT_HIBYTE(a) ( (a) >> 8 )
2172
2173
2174/** @def RT_MAKE_U64
2175 * Constructs a uint64_t value from two uint32_t values.
2176 */
2177#define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
2178
2179/** @def RT_MAKE_U64_FROM_U16
2180 * Constructs a uint64_t value from four uint16_t values.
2181 */
2182#define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
2183 ((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
2184 | (uint64_t)((uint16_t)(w2)) << 32 \
2185 | (uint32_t)((uint16_t)(w1)) << 16 \
2186 | (uint16_t)(w0) ))
2187
2188/** @def RT_MAKE_U64_FROM_U8
2189 * Constructs a uint64_t value from eight uint8_t values.
2190 */
2191#define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
2192 ((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
2193 | (uint64_t)((uint8_t)(b6)) << 48 \
2194 | (uint64_t)((uint8_t)(b5)) << 40 \
2195 | (uint64_t)((uint8_t)(b4)) << 32 \
2196 | (uint32_t)((uint8_t)(b3)) << 24 \
2197 | (uint32_t)((uint8_t)(b2)) << 16 \
2198 | (uint16_t)((uint8_t)(b1)) << 8 \
2199 | (uint8_t)(b0) ))
2200
2201/** @def RT_MAKE_U32
2202 * Constructs a uint32_t value from two uint16_t values.
2203 */
2204#define RT_MAKE_U32(Lo, Hi) \
2205 ((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
2206 | (uint16_t)(Lo) ))
2207
2208/** @def RT_MAKE_U32_FROM_U8
2209 * Constructs a uint32_t value from four uint8_t values.
2210 */
2211#define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
2212 ((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
2213 | (uint32_t)((uint8_t)(b2)) << 16 \
2214 | (uint16_t)((uint8_t)(b1)) << 8 \
2215 | (uint8_t)(b0) ))
2216
2217/** @def RT_MAKE_U16
2218 * Constructs a uint16_t value from two uint8_t values.
2219 */
2220#define RT_MAKE_U16(Lo, Hi) \
2221 ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
2222 | (uint8_t)(Lo) ))
2223
2224
2225/** @def RT_BSWAP_U64
2226 * Reverses the byte order of an uint64_t value. */
2227#if 0
2228# define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64)
2229#elif defined(__GNUC__)
2230# define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) \
2231 ? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
2232#else
2233# define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
2234#endif
2235
2236/** @def RT_BSWAP_U32
2237 * Reverses the byte order of an uint32_t value. */
2238#if 0
2239# define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32)
2240#elif defined(__GNUC__)
2241# define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) \
2242 ? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
2243#else
2244# define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
2245#endif
2246
2247/** @def RT_BSWAP_U16
2248 * Reverses the byte order of an uint16_t value. */
2249#if 0
2250# define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16)
2251#elif defined(__GNUC__)
2252# define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) \
2253 ? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
2254#else
2255# define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
2256#endif
2257
2258
2259/** @def RT_BSWAP_U64_C
2260 * Reverses the byte order of an uint64_t constant. */
2261#define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
2262
2263/** @def RT_BSWAP_U32_C
2264 * Reverses the byte order of an uint32_t constant. */
2265#define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
2266
2267/** @def RT_BSWAP_U16_C
2268 * Reverses the byte order of an uint16_t constant. */
2269#define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
2270
2271
2272/** @def RT_H2LE_U64
2273 * Converts an uint64_t value from host to little endian byte order. */
2274#ifdef RT_BIG_ENDIAN
2275# define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
2276#else
2277# define RT_H2LE_U64(u64) (u64)
2278#endif
2279
2280/** @def RT_H2LE_U64_C
2281 * Converts an uint64_t constant from host to little endian byte order. */
2282#ifdef RT_BIG_ENDIAN
2283# define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
2284#else
2285# define RT_H2LE_U64_C(u64) (u64)
2286#endif
2287
2288/** @def RT_H2LE_U32
2289 * Converts an uint32_t value from host to little endian byte order. */
2290#ifdef RT_BIG_ENDIAN
2291# define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
2292#else
2293# define RT_H2LE_U32(u32) (u32)
2294#endif
2295
2296/** @def RT_H2LE_U32_C
2297 * Converts an uint32_t constant from host to little endian byte order. */
2298#ifdef RT_BIG_ENDIAN
2299# define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
2300#else
2301# define RT_H2LE_U32_C(u32) (u32)
2302#endif
2303
2304/** @def RT_H2LE_U16
2305 * Converts an uint16_t value from host to little endian byte order. */
2306#ifdef RT_BIG_ENDIAN
2307# define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
2308#else
2309# define RT_H2LE_U16(u16) (u16)
2310#endif
2311
2312/** @def RT_H2LE_U16_C
2313 * Converts an uint16_t constant from host to little endian byte order. */
2314#ifdef RT_BIG_ENDIAN
2315# define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
2316#else
2317# define RT_H2LE_U16_C(u16) (u16)
2318#endif
2319
2320
2321/** @def RT_LE2H_U64
2322 * Converts an uint64_t value from little endian to host byte order. */
2323#ifdef RT_BIG_ENDIAN
2324# define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
2325#else
2326# define RT_LE2H_U64(u64) (u64)
2327#endif
2328
2329/** @def RT_LE2H_U64_C
2330 * Converts an uint64_t constant from little endian to host byte order. */
2331#ifdef RT_BIG_ENDIAN
2332# define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
2333#else
2334# define RT_LE2H_U64_C(u64) (u64)
2335#endif
2336
2337/** @def RT_LE2H_U32
2338 * Converts an uint32_t value from little endian to host byte order. */
2339#ifdef RT_BIG_ENDIAN
2340# define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
2341#else
2342# define RT_LE2H_U32(u32) (u32)
2343#endif
2344
2345/** @def RT_LE2H_U32_C
2346 * Converts an uint32_t constant from little endian to host byte order. */
2347#ifdef RT_BIG_ENDIAN
2348# define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
2349#else
2350# define RT_LE2H_U32_C(u32) (u32)
2351#endif
2352
2353/** @def RT_LE2H_U16
2354 * Converts an uint16_t value from little endian to host byte order. */
2355#ifdef RT_BIG_ENDIAN
2356# define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
2357#else
2358# define RT_LE2H_U16(u16) (u16)
2359#endif
2360
2361/** @def RT_LE2H_U16_C
2362 * Converts an uint16_t constant from little endian to host byte order. */
2363#ifdef RT_BIG_ENDIAN
2364# define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
2365#else
2366# define RT_LE2H_U16_C(u16) (u16)
2367#endif
2368
2369
2370/** @def RT_H2BE_U64
2371 * Converts an uint64_t value from host to big endian byte order. */
2372#ifdef RT_BIG_ENDIAN
2373# define RT_H2BE_U64(u64) (u64)
2374#else
2375# define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
2376#endif
2377
2378/** @def RT_H2BE_U64_C
2379 * Converts an uint64_t constant from host to big endian byte order. */
2380#ifdef RT_BIG_ENDIAN
2381# define RT_H2BE_U64_C(u64) (u64)
2382#else
2383# define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
2384#endif
2385
2386/** @def RT_H2BE_U32
2387 * Converts an uint32_t value from host to big endian byte order. */
2388#ifdef RT_BIG_ENDIAN
2389# define RT_H2BE_U32(u32) (u32)
2390#else
2391# define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
2392#endif
2393
2394/** @def RT_H2BE_U32_C
2395 * Converts an uint32_t constant from host to big endian byte order. */
2396#ifdef RT_BIG_ENDIAN
2397# define RT_H2BE_U32_C(u32) (u32)
2398#else
2399# define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
2400#endif
2401
2402/** @def RT_H2BE_U16
2403 * Converts an uint16_t value from host to big endian byte order. */
2404#ifdef RT_BIG_ENDIAN
2405# define RT_H2BE_U16(u16) (u16)
2406#else
2407# define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
2408#endif
2409
2410/** @def RT_H2BE_U16_C
2411 * Converts an uint16_t constant from host to big endian byte order. */
2412#ifdef RT_BIG_ENDIAN
2413# define RT_H2BE_U16_C(u16) (u16)
2414#else
2415# define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
2416#endif
2417
2418/** @def RT_BE2H_U64
2419 * Converts an uint64_t value from big endian to host byte order. */
2420#ifdef RT_BIG_ENDIAN
2421# define RT_BE2H_U64(u64) (u64)
2422#else
2423# define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
2424#endif
2425
2426/** @def RT_BE2H_U64
2427 * Converts an uint64_t constant from big endian to host byte order. */
2428#ifdef RT_BIG_ENDIAN
2429# define RT_BE2H_U64_C(u64) (u64)
2430#else
2431# define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
2432#endif
2433
2434/** @def RT_BE2H_U32
2435 * Converts an uint32_t value from big endian to host byte order. */
2436#ifdef RT_BIG_ENDIAN
2437# define RT_BE2H_U32(u32) (u32)
2438#else
2439# define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
2440#endif
2441
2442/** @def RT_BE2H_U32_C
2443 * Converts an uint32_t value from big endian to host byte order. */
2444#ifdef RT_BIG_ENDIAN
2445# define RT_BE2H_U32_C(u32) (u32)
2446#else
2447# define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
2448#endif
2449
2450/** @def RT_BE2H_U16
2451 * Converts an uint16_t value from big endian to host byte order. */
2452#ifdef RT_BIG_ENDIAN
2453# define RT_BE2H_U16(u16) (u16)
2454#else
2455# define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
2456#endif
2457
2458/** @def RT_BE2H_U16_C
2459 * Converts an uint16_t constant from big endian to host byte order. */
2460#ifdef RT_BIG_ENDIAN
2461# define RT_BE2H_U16_C(u16) (u16)
2462#else
2463# define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
2464#endif
2465
2466
2467/** @def RT_H2N_U64
2468 * Converts an uint64_t value from host to network byte order. */
2469#define RT_H2N_U64(u64) RT_H2BE_U64(u64)
2470
2471/** @def RT_H2N_U64_C
2472 * Converts an uint64_t constant from host to network byte order. */
2473#define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
2474
2475/** @def RT_H2N_U32
2476 * Converts an uint32_t value from host to network byte order. */
2477#define RT_H2N_U32(u32) RT_H2BE_U32(u32)
2478
2479/** @def RT_H2N_U32_C
2480 * Converts an uint32_t constant from host to network byte order. */
2481#define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
2482
2483/** @def RT_H2N_U16
2484 * Converts an uint16_t value from host to network byte order. */
2485#define RT_H2N_U16(u16) RT_H2BE_U16(u16)
2486
2487/** @def RT_H2N_U16_C
2488 * Converts an uint16_t constant from host to network byte order. */
2489#define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
2490
2491/** @def RT_N2H_U64
2492 * Converts an uint64_t value from network to host byte order. */
2493#define RT_N2H_U64(u64) RT_BE2H_U64(u64)
2494
2495/** @def RT_N2H_U64_C
2496 * Converts an uint64_t constant from network to host byte order. */
2497#define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
2498
2499/** @def RT_N2H_U32
2500 * Converts an uint32_t value from network to host byte order. */
2501#define RT_N2H_U32(u32) RT_BE2H_U32(u32)
2502
2503/** @def RT_N2H_U32_C
2504 * Converts an uint32_t constant from network to host byte order. */
2505#define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
2506
2507/** @def RT_N2H_U16
2508 * Converts an uint16_t value from network to host byte order. */
2509#define RT_N2H_U16(u16) RT_BE2H_U16(u16)
2510
2511/** @def RT_N2H_U16_C
2512 * Converts an uint16_t value from network to host byte order. */
2513#define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
2514
2515
2516/*
2517 * The BSD sys/param.h + machine/param.h file is a major source of
2518 * namespace pollution. Kill off some of the worse ones unless we're
2519 * compiling kernel code.
2520 */
2521#if defined(RT_OS_DARWIN) \
2522 && !defined(KERNEL) \
2523 && !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
2524 && ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
2525/* sys/param.h: */
2526# undef PSWP
2527# undef PVM
2528# undef PINOD
2529# undef PRIBO
2530# undef PVFS
2531# undef PZERO
2532# undef PSOCK
2533# undef PWAIT
2534# undef PLOCK
2535# undef PPAUSE
2536# undef PUSER
2537# undef PRIMASK
2538# undef MINBUCKET
2539# undef MAXALLOCSAVE
2540# undef FSHIFT
2541# undef FSCALE
2542
2543/* i386/machine.h: */
2544# undef ALIGN
2545# undef ALIGNBYTES
2546# undef DELAY
2547# undef STATUS_WORD
2548# undef USERMODE
2549# undef BASEPRI
2550# undef MSIZE
2551# undef CLSIZE
2552# undef CLSIZELOG2
2553#endif
2554
2555/** @def NIL_OFFSET
2556 * NIL offset.
2557 * Whenever we use offsets instead of pointers to save space and relocation effort
2558 * NIL_OFFSET shall be used as the equivalent to NULL.
2559 */
2560#define NIL_OFFSET (~0U)
2561
2562/** @def NOREF
2563 * Keeps the compiler from bitching about an unused parameter.
2564 */
2565#define NOREF(var) (void)(var)
2566
2567/** @def RT_BREAKPOINT
2568 * Emit a debug breakpoint instruction.
2569 *
2570 * @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
2571 * to force gdb to remain at the int3 source line.
2572 * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
2573 * x86/amd64.
2574 */
2575#ifdef __GNUC__
2576# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
2577# if !defined(__L4ENV__)
2578# define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
2579# else
2580# define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
2581# endif
2582# elif defined(RT_ARCH_SPARC64)
2583# define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
2584# elif defined(RT_ARCH_SPARC)
2585# define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
2586# endif
2587#endif
2588#ifdef _MSC_VER
2589# define RT_BREAKPOINT() __debugbreak()
2590#endif
2591#if defined(__IBMC__) || defined(__IBMCPP__)
2592# define RT_BREAKPOINT() __interrupt(3)
2593#endif
2594#if defined(__WATCOMC__)
2595# define RT_BREAKPOINT() _asm { int 3 }
2596#endif
2597#ifndef RT_BREAKPOINT
2598# error "This compiler/arch is not supported!"
2599#endif
2600
2601
2602/** @defgroup grp_rt_cdefs_size Size Constants
2603 * (Of course, these are binary computer terms, not SI.)
2604 * @{
2605 */
2606/** 1 K (Kilo) (1 024). */
2607#define _1K 0x00000400
2608/** 2 K (Kilo) (2 048). */
2609#define _2K 0x00000800
2610/** 4 K (Kilo) (4 096). */
2611#define _4K 0x00001000
2612/** 8 K (Kilo) (8 192). */
2613#define _8K 0x00002000
2614/** 16 K (Kilo) (16 384). */
2615#define _16K 0x00004000
2616/** 32 K (Kilo) (32 678). */
2617#define _32K 0x00008000
2618/** 64 K (Kilo) (65 536). */
2619#if ARCH_BITS != 16
2620# define _64K 0x00010000
2621#else
2622# define _64K UINT32_C(0x00010000)
2623#endif
2624/** 128 K (Kilo) (131 072). */
2625#if ARCH_BITS != 16
2626# define _128K 0x00020000
2627#else
2628# define _128K UINT32_C(0x00020000)
2629#endif
2630/** 256 K (Kilo) (262 144). */
2631#if ARCH_BITS != 16
2632# define _256K 0x00040000
2633#else
2634# define _256K UINT32_C(0x00040000)
2635#endif
2636/** 512 K (Kilo) (524 288). */
2637#if ARCH_BITS != 16
2638# define _512K 0x00080000
2639#else
2640# define _512K UINT32_C(0x00080000)
2641#endif
2642/** 1 M (Mega) (1 048 576). */
2643#if ARCH_BITS != 16
2644# define _1M 0x00100000
2645#else
2646# define _1M UINT32_C(0x00100000)
2647#endif
2648/** 2 M (Mega) (2 097 152). */
2649#if ARCH_BITS != 16
2650# define _2M 0x00200000
2651#else
2652# define _2M UINT32_C(0x00200000)
2653#endif
2654/** 4 M (Mega) (4 194 304). */
2655#if ARCH_BITS != 16
2656# define _4M 0x00400000
2657#else
2658# define _4M UINT32_C(0x00400000)
2659#endif
2660/** 8 M (Mega) (8 388 608). */
2661#define _8M UINT32_C(0x00800000)
2662/** 16 M (Mega) (16 777 216). */
2663#define _16M UINT32_C(0x01000000)
2664/** 32 M (Mega) (33 554 432). */
2665#define _32M UINT32_C(0x02000000)
2666/** 64 M (Mega) (67 108 864). */
2667#define _64M UINT32_C(0x04000000)
2668/** 128 M (Mega) (134 217 728). */
2669#define _128M UINT32_C(0x08000000)
2670/** 256 M (Mega) (268 435 456). */
2671#define _256M UINT32_C(0x10000000)
2672/** 512 M (Mega) (536 870 912). */
2673#define _512M UINT32_C(0x20000000)
2674/** 1 G (Giga) (1 073 741 824). (32-bit) */
2675#if ARCH_BITS != 16
2676# define _1G 0x40000000
2677#else
2678# define _1G UINT32_C(0x40000000)
2679#endif
2680/** 1 G (Giga) (1 073 741 824). (64-bit) */
2681#if ARCH_BITS != 16
2682# define _1G64 0x40000000LL
2683#else
2684# define _1G64 UINT64_C(0x40000000)
2685#endif
2686/** 2 G (Giga) (2 147 483 648). (32-bit) */
2687#define _2G32 UINT32_C(0x80000000)
2688/** 2 G (Giga) (2 147 483 648). (64-bit) */
2689#if ARCH_BITS != 16
2690# define _2G 0x0000000080000000LL
2691#else
2692# define _2G UINT64_C(0x0000000080000000)
2693#endif
2694/** 4 G (Giga) (4 294 967 296). */
2695#if ARCH_BITS != 16
2696# define _4G 0x0000000100000000LL
2697#else
2698# define _4G UINT64_C(0x0000000100000000)
2699#endif
2700/** 1 T (Tera) (1 099 511 627 776). */
2701#if ARCH_BITS != 16
2702# define _1T 0x0000010000000000LL
2703#else
2704# define _1T UINT64_C(0x0000010000000000)
2705#endif
2706/** 1 P (Peta) (1 125 899 906 842 624). */
2707#if ARCH_BITS != 16
2708# define _1P 0x0004000000000000LL
2709#else
2710# define _1P UINT64_C(0x0004000000000000)
2711#endif
2712/** 1 E (Exa) (1 152 921 504 606 846 976). */
2713#if ARCH_BITS != 16
2714# define _1E 0x1000000000000000LL
2715#else
2716# define _1E UINT64_C(0x1000000000000000)
2717#endif
2718/** 2 E (Exa) (2 305 843 009 213 693 952). */
2719#if ARCH_BITS != 16
2720# define _2E 0x2000000000000000ULL
2721#else
2722# define _2E UINT64_C(0x2000000000000000)
2723#endif
2724/** @} */
2725
2726/** @defgroup grp_rt_cdefs_decimal_grouping Decimal Constant Grouping Macros
2727 * @{ */
2728#define RT_D1(g1) g1
2729#define RT_D2(g1, g2) g1#g2
2730#define RT_D3(g1, g2, g3) g1#g2#g3
2731#define RT_D4(g1, g2, g3, g4) g1#g2#g3#g4
2732#define RT_D5(g1, g2, g3, g4, g5) g1#g2#g3#g4#g5
2733#define RT_D6(g1, g2, g3, g4, g5, g6) g1#g2#g3#g4#g5#g6
2734#define RT_D7(g1, g2, g3, g4, g5, g6, g7) g1#g2#g3#g4#g5#g6#g7
2735
2736#define RT_D1_U(g1) UINT32_C(g1)
2737#define RT_D2_U(g1, g2) UINT32_C(g1#g2)
2738#define RT_D3_U(g1, g2, g3) UINT32_C(g1#g2#g3)
2739#define RT_D4_U(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
2740#define RT_D5_U(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
2741#define RT_D6_U(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
2742#define RT_D7_U(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
2743
2744#define RT_D1_S(g1) INT32_C(g1)
2745#define RT_D2_S(g1, g2) INT32_C(g1#g2)
2746#define RT_D3_S(g1, g2, g3) INT32_C(g1#g2#g3)
2747#define RT_D4_S(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
2748#define RT_D5_S(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
2749#define RT_D6_S(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
2750#define RT_D7_S(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
2751
2752#define RT_D1_U32(g1) UINT32_C(g1)
2753#define RT_D2_U32(g1, g2) UINT32_C(g1#g2)
2754#define RT_D3_U32(g1, g2, g3) UINT32_C(g1#g2#g3)
2755#define RT_D4_U32(g1, g2, g3, g4) UINT32_C(g1#g2#g3#g4)
2756
2757#define RT_D1_S32(g1) INT32_C(g1)
2758#define RT_D2_S32(g1, g2) INT32_C(g1#g2)
2759#define RT_D3_S32(g1, g2, g3) INT32_C(g1#g2#g3)
2760#define RT_D4_S32(g1, g2, g3, g4) INT32_C(g1#g2#g3#g4)
2761
2762#define RT_D1_U64(g1) UINT64_C(g1)
2763#define RT_D2_U64(g1, g2) UINT64_C(g1#g2)
2764#define RT_D3_U64(g1, g2, g3) UINT64_C(g1#g2#g3)
2765#define RT_D4_U64(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
2766#define RT_D5_U64(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
2767#define RT_D6_U64(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
2768#define RT_D7_U64(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
2769
2770#define RT_D1_S64(g1) INT64_C(g1)
2771#define RT_D2_S64(g1, g2) INT64_C(g1#g2)
2772#define RT_D3_S64(g1, g2, g3) INT64_C(g1#g2#g3)
2773#define RT_D4_S64(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
2774#define RT_D5_S64(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
2775#define RT_D6_S64(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
2776#define RT_D7_S64(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
2777/** @} */
2778
2779
2780/** @defgroup grp_rt_cdefs_time Time Constants
2781 * @{
2782 */
2783/** 1 hour expressed in nanoseconds (64-bit). */
2784#define RT_NS_1HOUR UINT64_C(3600000000000)
2785/** 1 minute expressed in nanoseconds (64-bit). */
2786#define RT_NS_1MIN UINT64_C(60000000000)
2787/** 45 second expressed in nanoseconds. */
2788#define RT_NS_45SEC UINT64_C(45000000000)
2789/** 30 second expressed in nanoseconds. */
2790#define RT_NS_30SEC UINT64_C(30000000000)
2791/** 20 second expressed in nanoseconds. */
2792#define RT_NS_20SEC UINT64_C(20000000000)
2793/** 15 second expressed in nanoseconds. */
2794#define RT_NS_15SEC UINT64_C(15000000000)
2795/** 10 second expressed in nanoseconds. */
2796#define RT_NS_10SEC UINT64_C(10000000000)
2797/** 1 second expressed in nanoseconds. */
2798#define RT_NS_1SEC UINT32_C(1000000000)
2799/** 100 millsecond expressed in nanoseconds. */
2800#define RT_NS_100MS UINT32_C(100000000)
2801/** 10 millsecond expressed in nanoseconds. */
2802#define RT_NS_10MS UINT32_C(10000000)
2803/** 1 millsecond expressed in nanoseconds. */
2804#define RT_NS_1MS UINT32_C(1000000)
2805/** 100 microseconds expressed in nanoseconds. */
2806#define RT_NS_100US UINT32_C(100000)
2807/** 10 microseconds expressed in nanoseconds. */
2808#define RT_NS_10US UINT32_C(10000)
2809/** 1 microsecond expressed in nanoseconds. */
2810#define RT_NS_1US UINT32_C(1000)
2811
2812/** 1 second expressed in nanoseconds - 64-bit type. */
2813#define RT_NS_1SEC_64 UINT64_C(1000000000)
2814/** 100 millsecond expressed in nanoseconds - 64-bit type. */
2815#define RT_NS_100MS_64 UINT64_C(100000000)
2816/** 10 millsecond expressed in nanoseconds - 64-bit type. */
2817#define RT_NS_10MS_64 UINT64_C(10000000)
2818/** 1 millsecond expressed in nanoseconds - 64-bit type. */
2819#define RT_NS_1MS_64 UINT64_C(1000000)
2820/** 100 microseconds expressed in nanoseconds - 64-bit type. */
2821#define RT_NS_100US_64 UINT64_C(100000)
2822/** 10 microseconds expressed in nanoseconds - 64-bit type. */
2823#define RT_NS_10US_64 UINT64_C(10000)
2824/** 1 microsecond expressed in nanoseconds - 64-bit type. */
2825#define RT_NS_1US_64 UINT64_C(1000)
2826
2827/** 1 hour expressed in microseconds. */
2828#define RT_US_1HOUR UINT32_C(3600000000)
2829/** 1 minute expressed in microseconds. */
2830#define RT_US_1MIN UINT32_C(60000000)
2831/** 1 second expressed in microseconds. */
2832#define RT_US_1SEC UINT32_C(1000000)
2833/** 100 millsecond expressed in microseconds. */
2834#define RT_US_100MS UINT32_C(100000)
2835/** 10 millsecond expressed in microseconds. */
2836#define RT_US_10MS UINT32_C(10000)
2837/** 1 millsecond expressed in microseconds. */
2838#define RT_US_1MS UINT32_C(1000)
2839
2840/** 1 hour expressed in microseconds - 64-bit type. */
2841#define RT_US_1HOUR_64 UINT64_C(3600000000)
2842/** 1 minute expressed in microseconds - 64-bit type. */
2843#define RT_US_1MIN_64 UINT64_C(60000000)
2844/** 1 second expressed in microseconds - 64-bit type. */
2845#define RT_US_1SEC_64 UINT64_C(1000000)
2846/** 100 millsecond expressed in microseconds - 64-bit type. */
2847#define RT_US_100MS_64 UINT64_C(100000)
2848/** 10 millsecond expressed in microseconds - 64-bit type. */
2849#define RT_US_10MS_64 UINT64_C(10000)
2850/** 1 millsecond expressed in microseconds - 64-bit type. */
2851#define RT_US_1MS_64 UINT64_C(1000)
2852
2853/** 1 hour expressed in milliseconds. */
2854#define RT_MS_1HOUR UINT32_C(3600000)
2855/** 1 minute expressed in milliseconds. */
2856#define RT_MS_1MIN UINT32_C(60000)
2857/** 1 second expressed in milliseconds. */
2858#define RT_MS_1SEC UINT32_C(1000)
2859
2860/** 1 hour expressed in milliseconds - 64-bit type. */
2861#define RT_MS_1HOUR_64 UINT64_C(3600000)
2862/** 1 minute expressed in milliseconds - 64-bit type. */
2863#define RT_MS_1MIN_64 UINT64_C(60000)
2864/** 1 second expressed in milliseconds - 64-bit type. */
2865#define RT_MS_1SEC_64 UINT64_C(1000)
2866
2867/** The number of seconds per week. */
2868#define RT_SEC_1WEEK UINT32_C(604800)
2869/** The number of seconds per day. */
2870#define RT_SEC_1DAY UINT32_C(86400)
2871/** The number of seconds per hour. */
2872#define RT_SEC_1HOUR UINT32_C(3600)
2873
2874/** The number of seconds per week - 64-bit type. */
2875#define RT_SEC_1WEEK_64 UINT64_C(604800)
2876/** The number of seconds per day - 64-bit type. */
2877#define RT_SEC_1DAY_64 UINT64_C(86400)
2878/** The number of seconds per hour - 64-bit type. */
2879#define RT_SEC_1HOUR_64 UINT64_C(3600)
2880/** @} */
2881
2882
2883/** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
2884 * @{ */
2885/** Other format. */
2886#define RT_DBGTYPE_OTHER RT_BIT_32(0)
2887/** Stabs. */
2888#define RT_DBGTYPE_STABS RT_BIT_32(1)
2889/** Debug With Arbitrary Record Format (DWARF). */
2890#define RT_DBGTYPE_DWARF RT_BIT_32(2)
2891/** Microsoft Codeview debug info. */
2892#define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
2893/** Watcom debug info. */
2894#define RT_DBGTYPE_WATCOM RT_BIT_32(4)
2895/** IBM High Level Language debug info. */
2896#define RT_DBGTYPE_HLL RT_BIT_32(5)
2897/** Old OS/2 and Windows symbol file. */
2898#define RT_DBGTYPE_SYM RT_BIT_32(6)
2899/** Map file. */
2900#define RT_DBGTYPE_MAP RT_BIT_32(7)
2901/** @} */
2902
2903
2904/** @defgroup grp_rt_cdefs_exetype Executable Image Types
2905 * @{ */
2906/** Some other format. */
2907#define RT_EXETYPE_OTHER RT_BIT_32(0)
2908/** Portable Executable. */
2909#define RT_EXETYPE_PE RT_BIT_32(1)
2910/** Linear eXecutable. */
2911#define RT_EXETYPE_LX RT_BIT_32(2)
2912/** Linear Executable. */
2913#define RT_EXETYPE_LE RT_BIT_32(3)
2914/** New Executable. */
2915#define RT_EXETYPE_NE RT_BIT_32(4)
2916/** DOS Executable (Mark Zbikowski). */
2917#define RT_EXETYPE_MZ RT_BIT_32(5)
2918/** COM Executable. */
2919#define RT_EXETYPE_COM RT_BIT_32(6)
2920/** a.out Executable. */
2921#define RT_EXETYPE_AOUT RT_BIT_32(7)
2922/** Executable and Linkable Format. */
2923#define RT_EXETYPE_ELF RT_BIT_32(8)
2924/** Mach-O Executable (including FAT ones). */
2925#define RT_EXETYPE_MACHO RT_BIT_32(9)
2926/** TE from UEFI. */
2927#define RT_EXETYPE_TE RT_BIT_32(9)
2928/** @} */
2929
2930
2931/** @def VALID_PTR
2932 * Pointer validation macro.
2933 * @param ptr The pointer.
2934 */
2935#if defined(RT_ARCH_AMD64)
2936# ifdef IN_RING3
2937# if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
2938# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
2939 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
2940# elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
2941# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
2942 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
2943 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
2944# else
2945# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
2946 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
2947# endif
2948# else /* !IN_RING3 */
2949# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
2950 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
2951 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
2952# endif /* !IN_RING3 */
2953
2954#elif defined(RT_ARCH_X86)
2955# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
2956
2957#elif defined(RT_ARCH_SPARC64)
2958# ifdef IN_RING3
2959# if defined(RT_OS_SOLARIS)
2960/** Sparc64 user mode: According to Figure 9.4 in solaris internals */
2961/** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
2962# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
2963# else
2964# error "Port me"
2965# endif
2966# else /* !IN_RING3 */
2967# if defined(RT_OS_SOLARIS)
2968/** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
2969 * internals. Verify in sources. */
2970# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
2971# else
2972# error "Port me"
2973# endif
2974# endif /* !IN_RING3 */
2975
2976#elif defined(RT_ARCH_SPARC)
2977# ifdef IN_RING3
2978# ifdef RT_OS_SOLARIS
2979/** Sparc user mode: According to
2980 * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
2981# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
2982
2983# else
2984# error "Port me"
2985# endif
2986# else /* !IN_RING3 */
2987# ifdef RT_OS_SOLARIS
2988/** @todo Sparc kernel mode: Check the sources! */
2989# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
2990# else
2991# error "Port me"
2992# endif
2993# endif /* !IN_RING3 */
2994
2995#elif defined(RT_ARCH_ARM)
2996/* ASSUMES that at least the last and first 4K are out of bounds. */
2997# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
2998
2999#else
3000# error "Architecture identifier missing / not implemented."
3001#endif
3002
3003/** Old name for RT_VALID_PTR. */
3004#define VALID_PTR(ptr) RT_VALID_PTR(ptr)
3005
3006/** @def RT_VALID_ALIGNED_PTR
3007 * Pointer validation macro that also checks the alignment.
3008 * @param ptr The pointer.
3009 * @param align The alignment, must be a power of two.
3010 */
3011#define RT_VALID_ALIGNED_PTR(ptr, align) \
3012 ( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
3013 && VALID_PTR(ptr) )
3014
3015
3016/** @def VALID_PHYS32
3017 * 32 bits physical address validation macro.
3018 * @param Phys The RTGCPHYS address.
3019 */
3020#define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
3021
3022/** @def N_
3023 * The \#define N_ is used to mark a string for translation. This is usable in
3024 * any part of the code, as it is only used by the tools that create message
3025 * catalogs. This macro is a no-op as far as the compiler and code generation
3026 * is concerned.
3027 *
3028 * If you want to both mark a string for translation and translate it, use _().
3029 */
3030#define N_(s) (s)
3031
3032/** @def _
3033 * The \#define _ is used to mark a string for translation and to translate it
3034 * in one step.
3035 *
3036 * If you want to only mark a string for translation, use N_().
3037 */
3038#define _(s) gettext(s)
3039
3040
3041/** @def __PRETTY_FUNCTION__
3042 * With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
3043 * for the other compilers.
3044 */
3045#if !defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)
3046# ifdef _MSC_VER
3047# define __PRETTY_FUNCTION__ __FUNCSIG__
3048# else
3049# define __PRETTY_FUNCTION__ __FUNCTION__
3050# endif
3051#endif
3052
3053
3054/** @def RT_STRICT
3055 * The \#define RT_STRICT controls whether or not assertions and other runtime
3056 * checks should be compiled in or not. This is defined when DEBUG is defined.
3057 * If RT_NO_STRICT is defined, it will unconditionally be undefined.
3058 *
3059 * If you want assertions which are not subject to compile time options use
3060 * the AssertRelease*() flavors.
3061 */
3062#if !defined(RT_STRICT) && defined(DEBUG)
3063# define RT_STRICT
3064#endif
3065#ifdef RT_NO_STRICT
3066# undef RT_STRICT
3067#endif
3068
3069/** @todo remove this: */
3070#if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
3071# define RT_LOCK_NO_STRICT
3072#endif
3073#if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
3074# define RT_LOCK_NO_STRICT_ORDER
3075#endif
3076
3077/** @def RT_LOCK_STRICT
3078 * The \#define RT_LOCK_STRICT controls whether deadlock detection and related
3079 * checks are done in the lock and semaphore code. It is by default enabled in
3080 * RT_STRICT builds, but this behavior can be overridden by defining
3081 * RT_LOCK_NO_STRICT. */
3082#if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
3083# define RT_LOCK_STRICT
3084#endif
3085/** @def RT_LOCK_NO_STRICT
3086 * The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
3087#if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
3088# undef RT_LOCK_STRICT
3089#endif
3090
3091/** @def RT_LOCK_STRICT_ORDER
3092 * The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
3093 * by the lock and semaphore code. It is by default enabled in RT_STRICT
3094 * builds, but this behavior can be overridden by defining
3095 * RT_LOCK_NO_STRICT_ORDER. */
3096#if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
3097# define RT_LOCK_STRICT_ORDER
3098#endif
3099/** @def RT_LOCK_NO_STRICT_ORDER
3100 * The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
3101#if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
3102# undef RT_LOCK_STRICT_ORDER
3103#endif
3104
3105
3106/** Source position. */
3107#define RT_SRC_POS __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
3108
3109/** Source position declaration. */
3110#define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
3111
3112/** Source position arguments. */
3113#define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
3114
3115/** Applies NOREF() to the source position arguments. */
3116#define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
3117
3118
3119/** @def RT_INLINE_ASM_EXTERNAL
3120 * Defined as 1 if the compiler does not support inline assembly.
3121 * The ASM* functions will then be implemented in external .asm files.
3122 */
3123#if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
3124 || (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86)) \
3125 || defined(__WATCOMC__)
3126# define RT_INLINE_ASM_EXTERNAL 1
3127#else
3128# define RT_INLINE_ASM_EXTERNAL 0
3129#endif
3130
3131/** @def RT_INLINE_ASM_GNU_STYLE
3132 * Defined as 1 if the compiler understands GNU style inline assembly.
3133 */
3134#if defined(_MSC_VER) || defined(__WATCOMC__)
3135# define RT_INLINE_ASM_GNU_STYLE 0
3136#else
3137# define RT_INLINE_ASM_GNU_STYLE 1
3138#endif
3139
3140/** @def RT_INLINE_ASM_USES_INTRIN
3141 * Defined as the major MSC version if the compiler have and uses intrin.h.
3142 * Otherwise it is 0. */
3143#ifdef _MSC_VER
3144# if _MSC_VER >= 1700 /* Visual C++ v11.0 / 2012 */
3145# define RT_INLINE_ASM_USES_INTRIN 17
3146# elif _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3147# define RT_INLINE_ASM_USES_INTRIN 16
3148# elif _MSC_VER >= 1500 /* Visual C++ v9.0 / 2008 */
3149# define RT_INLINE_ASM_USES_INTRIN 15
3150# elif _MSC_VER >= 1400 /* Visual C++ v8.0 / 2005 */
3151# define RT_INLINE_ASM_USES_INTRIN 14
3152# endif
3153#endif
3154#ifndef RT_INLINE_ASM_USES_INTRIN
3155# define RT_INLINE_ASM_USES_INTRIN 0
3156#endif
3157
3158/** @def RT_COMPILER_SUPPORTS_LAMBDA
3159 * If the defined, the compiler supports lambda expressions. These expressions
3160 * are useful for embedding assertions and type checks into macros. */
3161#if defined(_MSC_VER) && defined(__cplusplus)
3162# if _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
3163# define RT_COMPILER_SUPPORTS_LAMBDA
3164# endif
3165#elif defined(__GNUC__) && defined(__cplusplus)
3166/* 4.5 or later, I think, if in ++11 mode... */
3167#endif
3168
3169/** @def RT_FAR_DATA
3170 * Set to 1 if we're in 16-bit mode and use far pointers.
3171 */
3172#if ARCH_BITS == 16 && defined(__WATCOMC__) \
3173 && (defined(__COMPACT__) || defined(__LARGE__))
3174# define RT_FAR_DATA 1
3175#else
3176# define RT_FAR_DATA 0
3177#endif
3178
3179/** @} */
3180
3181
3182/** @defgroup grp_rt_cdefs_cpp Special Macros for C++
3183 * @ingroup grp_rt_cdefs
3184 * @{
3185 */
3186
3187#ifdef __cplusplus
3188
3189/** @def DECLEXPORT_CLASS
3190 * How to declare an exported class. Place this macro after the 'class'
3191 * keyword in the declaration of every class you want to export.
3192 *
3193 * @note It is necessary to use this macro even for inner classes declared
3194 * inside the already exported classes. This is a GCC specific requirement,
3195 * but it seems not to harm other compilers.
3196 */
3197#if defined(_MSC_VER) || defined(RT_OS_OS2)
3198# define DECLEXPORT_CLASS __declspec(dllexport)
3199#elif defined(RT_USE_VISIBILITY_DEFAULT)
3200# define DECLEXPORT_CLASS __attribute__((visibility("default")))
3201#else
3202# define DECLEXPORT_CLASS
3203#endif
3204
3205/** @def DECLIMPORT_CLASS
3206 * How to declare an imported class Place this macro after the 'class'
3207 * keyword in the declaration of every class you want to export.
3208 *
3209 * @note It is necessary to use this macro even for inner classes declared
3210 * inside the already exported classes. This is a GCC specific requirement,
3211 * but it seems not to harm other compilers.
3212 */
3213#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
3214# define DECLIMPORT_CLASS __declspec(dllimport)
3215#elif defined(RT_USE_VISIBILITY_DEFAULT)
3216# define DECLIMPORT_CLASS __attribute__((visibility("default")))
3217#else
3218# define DECLIMPORT_CLASS
3219#endif
3220
3221/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP
3222 * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity
3223 * resolver. The following snippet clearly demonstrates the code causing this
3224 * error:
3225 * @code
3226 * class A
3227 * {
3228 * public:
3229 * operator bool() const { return false; }
3230 * operator int*() const { return NULL; }
3231 * };
3232 * int main()
3233 * {
3234 * A a;
3235 * if (!a);
3236 * if (a && 0);
3237 * return 0;
3238 * }
3239 * @endcode
3240 * The code itself seems pretty valid to me and GCC thinks the same.
3241 *
3242 * This macro fixes the compiler error by explicitly overloading implicit
3243 * global operators !, && and || that take the given class instance as one of
3244 * their arguments.
3245 *
3246 * The best is to use this macro right after the class declaration.
3247 *
3248 * @note The macro expands to nothing for compilers other than MSVC.
3249 *
3250 * @param Cls Class to apply the workaround to
3251 */
3252#if defined(_MSC_VER)
3253# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
3254 inline bool operator! (const Cls &that) { return !bool (that); } \
3255 inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
3256 inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
3257 inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
3258 inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
3259#else
3260# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
3261#endif
3262
3263/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL
3264 * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes.
3265 *
3266 * @param Tpl Name of the template class to apply the workaround to
3267 * @param ArgsDecl arguments of the template, as declared in |<>| after the
3268 * |template| keyword, including |<>|
3269 * @param Args arguments of the template, as specified in |<>| after the
3270 * template class name when using the, including |<>|
3271 *
3272 * Example:
3273 * @code
3274 * // template class declaration
3275 * template <class C>
3276 * class Foo { ... };
3277 * // applied workaround
3278 * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
3279 * @endcode
3280 */
3281#if defined(_MSC_VER)
3282# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
3283 template ArgsDecl \
3284 inline bool operator! (const Tpl Args &that) { return !bool (that); } \
3285 template ArgsDecl \
3286 inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
3287 template ArgsDecl \
3288 inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
3289 template ArgsDecl \
3290 inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
3291 template ArgsDecl \
3292 inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
3293#else
3294# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
3295#endif
3296
3297
3298/** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP
3299 * Declares the copy constructor and the assignment operation as inlined no-ops
3300 * (non-existent functions) for the given class. Use this macro inside the
3301 * private section if you want to effectively disable these operations for your
3302 * class.
3303 *
3304 * @param Cls class name to declare for
3305 */
3306
3307#define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
3308 inline Cls (const Cls &); \
3309 inline Cls &operator= (const Cls &);
3310
3311
3312/** @def DECLARE_CLS_NEW_DELETE_NOOP
3313 * Declares the new and delete operations as no-ops (non-existent functions)
3314 * for the given class. Use this macro inside the private section if you want
3315 * to effectively limit creating class instances on the stack only.
3316 *
3317 * @note The destructor of the given class must not be virtual, otherwise a
3318 * compile time error will occur. Note that this is not a drawback: having
3319 * the virtual destructor for a stack-based class is absolutely useless
3320 * (the real class of the stack-based instance is always known to the compiler
3321 * at compile time, so it will always call the correct destructor).
3322 *
3323 * @param Cls class name to declare for
3324 */
3325#define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
3326 inline static void *operator new (size_t); \
3327 inline static void operator delete (void *);
3328
3329#endif /* __cplusplus */
3330
3331/** @} */
3332
3333#endif
3334
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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