VirtualBox

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

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

iprt/cdefs.h,setjmp.h: Added DECL_RETURNS_TWICE and renamed DECLNORETURN to DECL_NO_RETURN.

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

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