VirtualBox

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

Last change on this file since 37012 was 37012, checked in by vboxsync, 14 years ago

iprt/cdefs.h: DECL_NO_INLINE typo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.1 KB
Line 
1/** @file
2 * IPRT - Common C and C++ definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2010 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/*
35 * Include sys/cdefs.h if present, if not define the stuff we need.
36 */
37#ifdef HAVE_SYS_CDEFS_H
38# if defined(RT_ARCH_LINUX) && defined(__KERNEL__)
39# error "oops"
40# endif
41# include <sys/cdefs.h>
42#else
43
44/** @def RT_C_DECLS_BEGIN
45 * Used to start a block of function declarations which are shared
46 * between C and C++ program.
47 */
48
49/** @def RT_C_DECLS_END
50 * Used to end a block of function declarations which are shared
51 * between C and C++ program.
52 */
53
54# if defined(__cplusplus)
55# define RT_C_DECLS_BEGIN extern "C" {
56# define RT_C_DECLS_END }
57# else
58# define RT_C_DECLS_BEGIN
59# define RT_C_DECLS_END
60# endif
61
62#endif
63
64
65/*
66 * Shut up DOXYGEN warnings and guide it properly thru the code.
67 */
68#ifdef DOXYGEN_RUNNING
69# define __AMD64__
70# define __X86__
71# define RT_ARCH_AMD64
72# define RT_ARCH_X86
73# define IN_RING0
74# define IN_RING3
75# define IN_RC
76# define IN_RC
77# define IN_RT_RC
78# define IN_RT_R0
79# define IN_RT_R3
80# define IN_RT_STATIC
81# define RT_STRICT
82# define RT_LOCK_STRICT
83# define RT_LOCK_NO_STRICT
84# define RT_LOCK_STRICT_ORDER
85# define RT_LOCK_NO_STRICT_ORDER
86# define Breakpoint
87# define RT_NO_DEPRECATED_MACROS
88# define RT_EXCEPTIONS_ENABLED
89# define RT_BIG_ENDIAN
90# define RT_LITTLE_ENDIAN
91# define RT_COMPILER_GROKS_64BIT_BITFIELDS
92# define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
93# define RT_NO_VISIBILITY_HIDDEN
94#endif /* DOXYGEN_RUNNING */
95
96/** @def RT_ARCH_X86
97 * Indicates that we're compiling for the X86 architecture.
98 */
99
100/** @def RT_ARCH_AMD64
101 * Indicates that we're compiling for the AMD64 architecture.
102 */
103
104/** @def RT_ARCH_SPARC
105 * Indicates that we're compiling for the SPARC V8 architecture (32-bit).
106 */
107
108/** @def RT_ARCH_SPARC64
109 * Indicates that we're compiling for the SPARC V9 architecture (64-bit).
110 */
111#if !defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64) && !defined(RT_ARCH_SPARC) && !defined(RT_ARCH_SPARC64)
112# if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || defined(__AMD64__)
113# define RT_ARCH_AMD64
114# elif defined(__i386__) || defined(_M_IX86) || defined(__X86__)
115# define RT_ARCH_X86
116# elif defined(__sparcv9)
117# define RT_ARCH_SPARC64
118# elif defined(__sparc__)
119# define RT_ARCH_SPARC
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#endif
137
138
139/** @def __X86__
140 * Indicates that we're compiling for the X86 architecture.
141 * @deprecated
142 */
143
144/** @def __AMD64__
145 * Indicates that we're compiling for the AMD64 architecture.
146 * @deprecated
147 */
148#if !defined(__X86__) && !defined(__AMD64__) && !defined(RT_ARCH_SPARC) && !defined(RT_ARCH_SPARC64)
149# if defined(RT_ARCH_AMD64)
150# define __AMD64__
151# elif defined(RT_ARCH_X86)
152# define __X86__
153# else
154# error "Check what predefined macros your compiler uses to indicate architecture."
155# endif
156#elif defined(__X86__) && defined(__AMD64__)
157# error "Both __X86__ and __AMD64__ cannot be defined at the same time!"
158#elif defined(__X86__) && !defined(RT_ARCH_X86)
159# error "Both __X86__ without RT_ARCH_X86!"
160#elif defined(__AMD64__) && !defined(RT_ARCH_AMD64)
161# error "Both __AMD64__ without RT_ARCH_AMD64!"
162#endif
163
164/** @def RT_BIG_ENDIAN
165 * Defined if the architecture is big endian. */
166/** @def RT_LITTLE_ENDIAN
167 * Defined if the architecture is little endian. */
168#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
169# define RT_LITTLE_ENDIAN
170#elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
171# define RT_BIG_ENDIAN
172#else
173# error "PORTME: architecture endianess"
174#endif
175#if defined(RT_BIG_ENDIAN) && defined(RT_LITTLE_ENDIAN)
176# error "Both RT_BIG_ENDIAN and RT_LITTLE_ENDIAN are defined"
177#endif
178
179
180/** @def IN_RING0
181 * Used to indicate that we're compiling code which is running
182 * in Ring-0 Host Context.
183 */
184
185/** @def IN_RING3
186 * Used to indicate that we're compiling code which is running
187 * in Ring-3 Host Context.
188 */
189
190/** @def IN_RC
191 * Used to indicate that we're compiling code which is running
192 * in the Raw-mode Context (implies R0).
193 */
194#if !defined(IN_RING3) && !defined(IN_RING0) && !defined(IN_RC) && !defined(IN_RC)
195# error "You must define which context the compiled code should run in; IN_RING3, IN_RING0 or IN_RC"
196#endif
197#if (defined(IN_RING3) && (defined(IN_RING0) || defined(IN_RC)) ) \
198 || (defined(IN_RING0) && (defined(IN_RING3) || defined(IN_RC)) ) \
199 || (defined(IN_RC) && (defined(IN_RING3) || defined(IN_RING0)) )
200# error "Only one of the IN_RING3, IN_RING0, IN_RC defines should be defined."
201#endif
202
203
204/** @def ARCH_BITS
205 * Defines the bit count of the current context.
206 */
207#if !defined(ARCH_BITS) || defined(DOXYGEN_RUNNING)
208# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64)
209# define ARCH_BITS 64
210# else
211# define ARCH_BITS 32
212# endif
213#endif
214
215/** @def HC_ARCH_BITS
216 * Defines the host architecture bit count.
217 */
218#if !defined(HC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
219# ifndef IN_RC
220# define HC_ARCH_BITS ARCH_BITS
221# else
222# define HC_ARCH_BITS 32
223# endif
224#endif
225
226/** @def GC_ARCH_BITS
227 * Defines the guest architecture bit count.
228 */
229#if !defined(GC_ARCH_BITS) && !defined(DOXYGEN_RUNNING)
230# ifdef VBOX_WITH_64_BITS_GUESTS
231# define GC_ARCH_BITS 64
232# else
233# define GC_ARCH_BITS 32
234# endif
235#endif
236
237/** @def R3_ARCH_BITS
238 * Defines the host ring-3 architecture bit count.
239 */
240#if !defined(R3_ARCH_BITS) || defined(DOXYGEN_RUNNING)
241# ifdef IN_RING3
242# define R3_ARCH_BITS ARCH_BITS
243# else
244# define R3_ARCH_BITS HC_ARCH_BITS
245# endif
246#endif
247
248/** @def R0_ARCH_BITS
249 * Defines the host ring-0 architecture bit count.
250 */
251#if !defined(R0_ARCH_BITS) || defined(DOXYGEN_RUNNING)
252# ifdef IN_RING0
253# define R0_ARCH_BITS ARCH_BITS
254# else
255# define R0_ARCH_BITS HC_ARCH_BITS
256# endif
257#endif
258
259/** @def GC_ARCH_BITS
260 * Defines the guest architecture bit count.
261 */
262#if !defined(GC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
263# ifdef IN_RC
264# define GC_ARCH_BITS ARCH_BITS
265# else
266# define GC_ARCH_BITS 32
267# endif
268#endif
269
270
271/** @def CTXTYPE
272 * Declare a type differently in GC, R3 and R0.
273 *
274 * @param GCType The GC type.
275 * @param R3Type The R3 type.
276 * @param R0Type The R0 type.
277 * @remark For pointers used only in one context use RCPTRTYPE(), R3R0PTRTYPE(), R3PTRTYPE() or R0PTRTYPE().
278 */
279#ifdef IN_RC
280# define CTXTYPE(GCType, R3Type, R0Type) GCType
281#elif defined(IN_RING3)
282# define CTXTYPE(GCType, R3Type, R0Type) R3Type
283#else
284# define CTXTYPE(GCType, R3Type, R0Type) R0Type
285#endif
286
287/** @def RCPTRTYPE
288 * Declare a pointer which is used in the raw mode context but appears in structure(s) used by
289 * both HC and RC. The main purpose is to make sure structures have the same
290 * size when built for different architectures.
291 *
292 * @param RCType The RC type.
293 */
294#define RCPTRTYPE(RCType) CTXTYPE(RCType, RTRCPTR, RTRCPTR)
295
296/** @def R3R0PTRTYPE
297 * Declare a pointer which is used in HC, is explicitly valid in ring 3 and 0,
298 * but appears in structure(s) used by both HC and GC. The main purpose is to
299 * make sure structures have the same size when built for different architectures.
300 *
301 * @param R3R0Type The R3R0 type.
302 * @remarks This used to be called HCPTRTYPE.
303 */
304#define R3R0PTRTYPE(R3R0Type) CTXTYPE(RTHCPTR, R3R0Type, R3R0Type)
305
306/** @def R3PTRTYPE
307 * Declare a pointer which is used in R3 but appears in structure(s) used by
308 * both HC and GC. The main purpose is to make sure structures have the same
309 * size when built for different architectures.
310 *
311 * @param R3Type The R3 type.
312 */
313#define R3PTRTYPE(R3Type) CTXTYPE(RTHCUINTPTR, R3Type, RTHCUINTPTR)
314
315/** @def R0PTRTYPE
316 * Declare a pointer which is used in R0 but appears in structure(s) used by
317 * both HC and GC. The main purpose is to make sure structures have the same
318 * size when built for different architectures.
319 *
320 * @param R0Type The R0 type.
321 */
322#define R0PTRTYPE(R0Type) CTXTYPE(RTHCUINTPTR, RTHCUINTPTR, R0Type)
323
324/** @def CTXSUFF
325 * Adds the suffix of the current context to the passed in
326 * identifier name. The suffix is HC or GC.
327 *
328 * This is macro should only be used in shared code to avoid a forest of ifdefs.
329 * @param var Identifier name.
330 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
331 */
332/** @def OTHERCTXSUFF
333 * Adds the suffix of the other context to the passed in
334 * identifier name. The suffix is HC or GC.
335 *
336 * This is macro should only be used in shared code to avoid a forest of ifdefs.
337 * @param var Identifier name.
338 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
339 */
340#ifdef IN_RC
341# define CTXSUFF(var) var##GC
342# define OTHERCTXSUFF(var) var##HC
343#else
344# define CTXSUFF(var) var##HC
345# define OTHERCTXSUFF(var) var##GC
346#endif
347
348/** @def CTXALLSUFF
349 * Adds the suffix of the current context to the passed in
350 * identifier name. The suffix is R3, R0 or GC.
351 *
352 * This is macro should only be used in shared code to avoid a forest of ifdefs.
353 * @param var Identifier name.
354 * @deprecated Use CTX_SUFF. Do NOT use this for new code.
355 */
356#ifdef IN_RC
357# define CTXALLSUFF(var) var##GC
358#elif defined(IN_RING0)
359# define CTXALLSUFF(var) var##R0
360#else
361# define CTXALLSUFF(var) var##R3
362#endif
363
364/** @def CTX_SUFF
365 * Adds the suffix of the current context to the passed in
366 * identifier name. The suffix is R3, R0 or RC.
367 *
368 * This is macro should only be used in shared code to avoid a forest of ifdefs.
369 * @param var Identifier name.
370 *
371 * @remark This will replace CTXALLSUFF and CTXSUFF before long.
372 */
373#ifdef IN_RC
374# define CTX_SUFF(var) var##RC
375#elif defined(IN_RING0)
376# define CTX_SUFF(var) var##R0
377#else
378# define CTX_SUFF(var) var##R3
379#endif
380
381/** @def CTX_SUFF_Z
382 * Adds the suffix of the current context to the passed in
383 * identifier name, combining RC and R0 into RZ.
384 * The suffix thus is R3 or RZ.
385 *
386 * This is macro should only be used in shared code to avoid a forest of ifdefs.
387 * @param var Identifier name.
388 *
389 * @remark This will replace CTXALLSUFF and CTXSUFF before long.
390 */
391#ifdef IN_RING3
392# define CTX_SUFF_Z(var) var##R3
393#else
394# define CTX_SUFF_Z(var) var##RZ
395#endif
396
397
398/** @def CTXMID
399 * Adds the current context as a middle name of an identifier name
400 * The middle name is HC or GC.
401 *
402 * This is macro should only be used in shared code to avoid a forest of ifdefs.
403 * @param first First name.
404 * @param last Surname.
405 */
406/** @def OTHERCTXMID
407 * Adds the other context as a middle name of an identifier name
408 * The middle name is HC or GC.
409 *
410 * This is macro should only be used in shared code to avoid a forest of ifdefs.
411 * @param first First name.
412 * @param last Surname.
413 * @deprecated use CTX_MID or CTX_MID_Z
414 */
415#ifdef IN_RC
416# define CTXMID(first, last) first##GC##last
417# define OTHERCTXMID(first, last) first##HC##last
418#else
419# define CTXMID(first, last) first##HC##last
420# define OTHERCTXMID(first, last) first##GC##last
421#endif
422
423/** @def CTXALLMID
424 * Adds the current context as a middle name of an identifier name.
425 * The middle name is R3, R0 or GC.
426 *
427 * This is macro should only be used in shared code to avoid a forest of ifdefs.
428 * @param first First name.
429 * @param last Surname.
430 * @deprecated use CTX_MID or CTX_MID_Z
431 */
432#ifdef IN_RC
433# define CTXALLMID(first, last) first##GC##last
434#elif defined(IN_RING0)
435# define CTXALLMID(first, last) first##R0##last
436#else
437# define CTXALLMID(first, last) first##R3##last
438#endif
439
440/** @def CTX_MID
441 * Adds the current context as a middle name of an identifier name.
442 * The middle name is R3, R0 or RC.
443 *
444 * This is macro should only be used in shared code to avoid a forest of ifdefs.
445 * @param first First name.
446 * @param last Surname.
447 */
448#ifdef IN_RC
449# define CTX_MID(first, last) first##RC##last
450#elif defined(IN_RING0)
451# define CTX_MID(first, last) first##R0##last
452#else
453# define CTX_MID(first, last) first##R3##last
454#endif
455
456/** @def CTX_MID_Z
457 * Adds the current context as a middle name of an identifier name, combining RC
458 * and R0 into RZ.
459 * The middle name thus is either R3 or RZ.
460 *
461 * This is macro should only be used in shared code to avoid a forest of ifdefs.
462 * @param first First name.
463 * @param last Surname.
464 */
465#ifdef IN_RING3
466# define CTX_MID_Z(first, last) first##R3##last
467#else
468# define CTX_MID_Z(first, last) first##RZ##last
469#endif
470
471
472/** @def R3STRING
473 * A macro which in GC and R0 will return a dummy string while in R3 it will return
474 * the parameter.
475 *
476 * This is typically used to wrap description strings in structures shared
477 * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING3 mess.
478 *
479 * @param pR3String The R3 string. Only referenced in R3.
480 * @see R0STRING and GCSTRING
481 */
482#ifdef IN_RING3
483# define R3STRING(pR3String) (pR3String)
484#else
485# define R3STRING(pR3String) ("<R3_STRING>")
486#endif
487
488/** @def R0STRING
489 * A macro which in GC and R3 will return a dummy string while in R0 it will return
490 * the parameter.
491 *
492 * This is typically used to wrap description strings in structures shared
493 * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING0 mess.
494 *
495 * @param pR0String The R0 string. Only referenced in R0.
496 * @see R3STRING and GCSTRING
497 */
498#ifdef IN_RING0
499# define R0STRING(pR0String) (pR0String)
500#else
501# define R0STRING(pR0String) ("<R0_STRING>")
502#endif
503
504/** @def RCSTRING
505 * A macro which in R3 and R0 will return a dummy string while in RC it will return
506 * the parameter.
507 *
508 * This is typically used to wrap description strings in structures shared
509 * between R3, R0 and/or RC. The intention is to avoid the \#ifdef IN_RC mess.
510 *
511 * @param pRCString The RC string. Only referenced in RC.
512 * @see R3STRING, R0STRING
513 */
514#ifdef IN_RC
515# define RCSTRING(pRCString) (pRCString)
516#else
517# define RCSTRING(pRCString) ("<RC_STRING>")
518#endif
519
520
521/** @def RT_NOTHING
522 * A macro that expands to nothing.
523 * This is primarily intended as a dummy argument for macros to avoid the
524 * undefined behavior passing empty arguments to an macro (ISO C90 and C++98,
525 * gcc v4.4 warns about it).
526 */
527#define RT_NOTHING
528
529/** @def RT_GCC_EXTENSION
530 * Macro for shutting up GCC warnings about using language extensions. */
531#ifdef __GNUC__
532# define RT_GCC_EXTENSION __extension__
533#else
534# define RT_GCC_EXTENSION
535#endif
536
537/** @def RT_COMPILER_GROKS_64BIT_BITFIELDS
538 * Macro that is defined if the compiler understands 64-bit bitfields. */
539#if !defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__))
540# define RT_COMPILER_GROKS_64BIT_BITFIELDS
541#endif
542
543/** @def RT_COMPILER_WITH_80BIT_LONG_DOUBLE
544 * Macro that is defined if the compiler implements long double as the
545 * IEEE extended precision floating. */
546#if (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) && !defined(RT_OS_WINDOWS)
547# define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
548#endif
549
550
551/** @def RT_EXCEPTIONS_ENABLED
552 * Defined when C++ exceptions are enabled.
553 */
554#if !defined(RT_EXCEPTIONS_ENABLED) \
555 && defined(__cplusplus) \
556 && ( (defined(_MSC_VER) && defined(_CPPUNWIND)) \
557 || (defined(__GNUC__) && defined(__EXCEPTIONS)))
558# define RT_EXCEPTIONS_ENABLED
559#endif
560
561/** @def RT_NO_THROW
562 * How to express that a function doesn't throw C++ exceptions
563 * and the compiler can thus save itself the bother of trying
564 * to catch any of them. Put this between the closing parenthesis
565 * and the semicolon in function prototypes (and implementation if C++).
566 */
567#ifdef RT_EXCEPTIONS_ENABLED
568# define RT_NO_THROW throw()
569#else
570# define RT_NO_THROW
571#endif
572
573/** @def RT_THROW
574 * How to express that a method or function throws a type of exceptions. Some
575 * compilers does not want this kind of information and will warning about it.
576 *
577 * @param type The type exception.
578 *
579 * @remarks If the actual throwing is done from the header, enclose it by
580 * \#ifdef RT_EXCEPTIONS_ENABLED ... \#else ... \#endif so the header
581 * compiles cleanly without exceptions enabled.
582 *
583 * Do NOT use this for the actual throwing of exceptions!
584 */
585#ifdef RT_EXCEPTIONS_ENABLED
586# ifdef _MSC_VER
587# if _MSC_VER >= 1400
588# define RT_THROW(type)
589# else
590# define RT_THROW(type) throw(type)
591# endif
592# else
593# define RT_THROW(type) throw(type)
594# endif
595#else
596# define RT_THROW(type)
597#endif
598
599/** @def RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
600 * Indicates that the "hidden" visibility attribute can be used (GCC) */
601#if defined(__GNUC__)
602# if __GNUC__ >= 4 && !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
603# define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
604# endif
605#endif
606
607/** @def RTCALL
608 * The standard calling convention for the Runtime interfaces.
609 */
610#ifdef _MSC_VER
611# define RTCALL __cdecl
612#elif defined(RT_OS_OS2)
613# define RTCALL __cdecl
614#elif defined(__GNUC__) && defined(IN_RING0) \
615 && !(defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)) /* the latter is kernel/gcc */
616# define RTCALL __attribute__((cdecl,regparm(0)))
617#else
618# define RTCALL
619#endif
620
621/** @def DECLEXPORT
622 * How to declare an exported function.
623 * @param type The return type of the function declaration.
624 */
625#if defined(_MSC_VER) || defined(RT_OS_OS2)
626# define DECLEXPORT(type) __declspec(dllexport) type
627#elif defined(RT_USE_VISIBILITY_DEFAULT)
628# define DECLEXPORT(type) __attribute__((visibility("default"))) type
629#else
630# define DECLEXPORT(type) type
631#endif
632
633/** @def DECLIMPORT
634 * How to declare an imported function.
635 * @param type The return type of the function declaration.
636 */
637#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
638# define DECLIMPORT(type) __declspec(dllimport) type
639#else
640# define DECLIMPORT(type) type
641#endif
642
643/** @def DECLHIDDEN
644 * How to declare a non-exported function or variable.
645 * @param type The return type of the function or the data type of the variable.
646 */
647#if !defined(RT_GCC_SUPPORTS_VISIBILITY_HIDDEN) || defined(RT_NO_VISIBILITY_HIDDEN)
648# define DECLHIDDEN(type) type
649#else
650# define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
651#endif
652
653/** @def DECL_HIDDEN_CONST
654 * Workaround for g++ warnings when applying the hidden attribute to a const
655 * definition. Use DECLHIDDEN for the declaration.
656 * @param a_Type The return type of the function or the data type of
657 * the variable.
658 */
659#if defined(__cplusplus) && defined(__GNUC__)
660# define DECL_HIDDEN_CONST(a_Type) a_Type
661#else
662# define DECL_HIDDEN_CONST(a_Type) DECLHIDDEN(a_Type)
663#endif
664
665/** @def DECL_INVALID
666 * How to declare a function not available for linking in the current context.
667 * The purpose is to create compile or like time errors when used. This isn't
668 * possible on all platforms.
669 * @param type The return type of the function.
670 */
671#if defined(_MSC_VER)
672# define DECL_INVALID(type) __declspec(dllimport) type __stdcall
673#elif defined(__GNUC__) && defined(__cplusplus)
674# define DECL_INVALID(type) extern "C++" type
675#else
676# define DECL_INVALID(type) type
677#endif
678
679/** @def DECLASM
680 * How to declare an internal assembly function.
681 * @param type The return type of the function declaration.
682 */
683#ifdef __cplusplus
684# ifdef _MSC_VER
685# define DECLASM(type) extern "C" type __cdecl
686# else
687# define DECLASM(type) extern "C" type
688# endif
689#else
690# ifdef _MSC_VER
691# define DECLASM(type) type __cdecl
692# else
693# define DECLASM(type) type
694# endif
695#endif
696
697/** @def DECLASMTYPE
698 * How to declare an internal assembly function type.
699 * @param type The return type of the function.
700 */
701#ifdef _MSC_VER
702# define DECLASMTYPE(type) type __cdecl
703#else
704# define DECLASMTYPE(type) type
705#endif
706
707/** @def DECLNORETURN
708 * How to declare a function which does not return.
709 * @note: This macro can be combined with other macros, for example
710 * @code
711 * EMR3DECL(DECLNORETURN(void)) foo(void);
712 * @endcode
713 */
714#ifdef _MSC_VER
715# define DECLNORETURN(type) __declspec(noreturn) type
716#elif defined(__GNUC__)
717# define DECLNORETURN(type) __attribute__((noreturn)) type
718#else
719# define DECLNORETURN(type) type
720#endif
721
722/** @def DECLCALLBACK
723 * How to declare an call back function type.
724 * @param type The return type of the function declaration.
725 */
726#define DECLCALLBACK(type) type RTCALL
727
728/** @def DECLCALLBACKPTR
729 * How to declare an call back function pointer.
730 * @param type The return type of the function declaration.
731 * @param name The name of the variable member.
732 */
733#define DECLCALLBACKPTR(type, name) type (RTCALL * name)
734
735/** @def DECLCALLBACKMEMBER
736 * How to declare an call back function pointer member.
737 * @param type The return type of the function declaration.
738 * @param name The name of the struct/union/class member.
739 */
740#define DECLCALLBACKMEMBER(type, name) type (RTCALL * name)
741
742/** @def DECLR3CALLBACKMEMBER
743 * How to declare an call back function pointer member - R3 Ptr.
744 * @param type The return type of the function declaration.
745 * @param name The name of the struct/union/class member.
746 * @param args The argument list enclosed in parentheses.
747 */
748#ifdef IN_RING3
749# define DECLR3CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
750#else
751# define DECLR3CALLBACKMEMBER(type, name, args) RTR3PTR name
752#endif
753
754/** @def DECLRCCALLBACKMEMBER
755 * How to declare an call back function pointer member - RC Ptr.
756 * @param type The return type of the function declaration.
757 * @param name The name of the struct/union/class member.
758 * @param args The argument list enclosed in parentheses.
759 */
760#ifdef IN_RC
761# define DECLRCCALLBACKMEMBER(type, name, args) type (RTCALL * name) args
762#else
763# define DECLRCCALLBACKMEMBER(type, name, args) RTRCPTR name
764#endif
765
766/** @def DECLR0CALLBACKMEMBER
767 * How to declare an call back function pointer member - R0 Ptr.
768 * @param type The return type of the function declaration.
769 * @param name The name of the struct/union/class member.
770 * @param args The argument list enclosed in parentheses.
771 */
772#ifdef IN_RING0
773# define DECLR0CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
774#else
775# define DECLR0CALLBACKMEMBER(type, name, args) RTR0PTR name
776#endif
777
778/** @def DECLINLINE
779 * How to declare a function as inline.
780 * @param type The return type of the function declaration.
781 * @remarks Don't use this macro on C++ methods.
782 */
783#ifdef __GNUC__
784# define DECLINLINE(type) static __inline__ type
785#elif defined(__cplusplus)
786# define DECLINLINE(type) inline type
787#elif defined(_MSC_VER)
788# define DECLINLINE(type) _inline type
789#elif defined(__IBMC__)
790# define DECLINLINE(type) _Inline type
791#else
792# define DECLINLINE(type) inline type
793#endif
794
795
796/** @def DECL_FORCE_INLINE
797 * How to declare a function as inline and try convince the compiler to always
798 * inline it regardless of optimization switches.
799 * @param type The return type of the function declaration.
800 * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
801 */
802#ifdef __GNUC__
803# define DECL_FORCE_INLINE(type) __attribute__((__always_inline__)) DECLINLINE(type)
804#elif defined(_MSC_VER)
805# define DECL_FORCE_INLINE(type) __forceinline type
806#else
807# define DECL_FORCE_INLINE(type) DECLINLINE(type)
808#endif
809
810
811/** @def DECL_NO_INLINE
812 * How to declare a function telling the compiler not to inline it.
813 * @param scope The function scope, static or RT_NOTHING.
814 * @param type The return type of the function declaration.
815 * @remarks Don't use this macro on C++ methods.
816 */
817#ifdef __GNUC__
818# define DECL_NO_INLINE(scope,type) __attribute__((noinline)) scope type
819#elif defined(_MSC_VER)
820# define DECL_NO_INLINE(scope,type) __declspec(noinline) scope type
821#else
822# define DECL_NO_INLINE(scope,type) scope type
823#endif
824
825
826/** @def IN_RT_STATIC
827 * Used to indicate whether we're linking against a static IPRT
828 * or not. The IPRT symbols will be declared as hidden (if
829 * supported). Note that this define has no effect without setting
830 * IN_RT_R0, IN_RT_R3 or IN_RT_RC indicators are set first.
831 */
832
833/** @def IN_RT_R0
834 * Used to indicate whether we're inside the same link module as
835 * the HC Ring-0 Runtime Library.
836 */
837/** @def RTR0DECL(type)
838 * Runtime Library HC Ring-0 export or import declaration.
839 * @param type The return type of the function declaration.
840 */
841#ifdef IN_RT_R0
842# ifdef IN_RT_STATIC
843# define RTR0DECL(type) DECLHIDDEN(type) RTCALL
844# else
845# define RTR0DECL(type) DECLEXPORT(type) RTCALL
846# endif
847#else
848# define RTR0DECL(type) DECLIMPORT(type) RTCALL
849#endif
850
851/** @def IN_RT_R3
852 * Used to indicate whether we're inside the same link module as
853 * the HC Ring-3 Runtime Library.
854 */
855/** @def RTR3DECL(type)
856 * Runtime Library HC Ring-3 export or import declaration.
857 * @param type The return type of the function declaration.
858 */
859#ifdef IN_RT_R3
860# ifdef IN_RT_STATIC
861# define RTR3DECL(type) DECLHIDDEN(type) RTCALL
862# else
863# define RTR3DECL(type) DECLEXPORT(type) RTCALL
864# endif
865#else
866# define RTR3DECL(type) DECLIMPORT(type) RTCALL
867#endif
868
869/** @def IN_RT_RC
870 * Used to indicate whether we're inside the same link module as the raw-mode
871 * context (RC) runtime library.
872 */
873/** @def RTRCDECL(type)
874 * Runtime Library raw-mode context export or import declaration.
875 * @param type The return type of the function declaration.
876 */
877#ifdef IN_RT_RC
878# ifdef IN_RT_STATIC
879# define RTRCDECL(type) DECLHIDDEN(type) RTCALL
880# else
881# define RTRCDECL(type) DECLEXPORT(type) RTCALL
882# endif
883#else
884# define RTRCDECL(type) DECLIMPORT(type) RTCALL
885#endif
886
887/** @def RTDECL(type)
888 * Runtime Library export or import declaration.
889 * Functions declared using this macro exists in all contexts.
890 * @param type The return type of the function declaration.
891 */
892#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
893# ifdef IN_RT_STATIC
894# define RTDECL(type) DECLHIDDEN(type) RTCALL
895# else
896# define RTDECL(type) DECLEXPORT(type) RTCALL
897# endif
898#else
899# define RTDECL(type) DECLIMPORT(type) RTCALL
900#endif
901
902/** @def RTDATADECL(type)
903 * Runtime Library export or import declaration.
904 * Data declared using this macro exists in all contexts.
905 * @param type The return type of the function declaration.
906 */
907#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
908# ifdef IN_RT_STATIC
909# define RTDATADECL(type) DECLHIDDEN(type)
910# else
911# define RTDATADECL(type) DECLEXPORT(type)
912# endif
913#else
914# define RTDATADECL(type) DECLIMPORT(type)
915#endif
916
917/** @def RT_DECL_CLASS
918 * Declares an class living in the runtime.
919 */
920#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
921# ifdef IN_RT_STATIC
922# define RT_DECL_CLASS
923# else
924# define RT_DECL_CLASS DECLEXPORT_CLASS
925# endif
926#else
927# define RT_DECL_CLASS DECLIMPORT_CLASS
928#endif
929
930
931/** @def RT_NOCRT
932 * Symbol name wrapper for the No-CRT bits.
933 *
934 * In order to coexist in the same process as other CRTs, we need to
935 * decorate the symbols such that they don't conflict the ones in the
936 * other CRTs. The result of such conflicts / duplicate symbols can
937 * confuse the dynamic loader on Unix like systems.
938 *
939 * Define RT_WITHOUT_NOCRT_WRAPPERS to drop the wrapping.
940 * Define RT_WITHOUT_NOCRT_WRAPPER_ALIASES to drop the aliases to the
941 * wrapped names.
942 */
943/** @def RT_NOCRT_STR
944 * Same as RT_NOCRT only it'll return a double quoted string of the result.
945 */
946#ifndef RT_WITHOUT_NOCRT_WRAPPERS
947# define RT_NOCRT(name) nocrt_ ## name
948# define RT_NOCRT_STR(name) "nocrt_" # name
949#else
950# define RT_NOCRT(name) name
951# define RT_NOCRT_STR(name) #name
952#endif
953
954
955
956/** @def RT_LIKELY
957 * Give the compiler a hint that an expression is very likely to hold true.
958 *
959 * Some compilers support explicit branch prediction so that the CPU backend
960 * can hint the processor and also so that code blocks can be reordered such
961 * that the predicted path sees a more linear flow, thus improving cache
962 * behaviour, etc.
963 *
964 * IPRT provides the macros RT_LIKELY() and RT_UNLIKELY() as a way to utilize
965 * this compiler feature when present.
966 *
967 * A few notes about the usage:
968 *
969 * - Generally, use RT_UNLIKELY() with error condition checks (unless you
970 * have some _strong_ reason to do otherwise, in which case document it),
971 * and/or RT_LIKELY() with success condition checks, assuming you want
972 * to optimize for the success path.
973 *
974 * - Other than that, if you don't know the likelihood of a test succeeding
975 * from empirical or other 'hard' evidence, don't make predictions unless
976 * you happen to be a Dirk Gently.
977 *
978 * - These macros are meant to be used in places that get executed a lot. It
979 * is wasteful to make predictions in code that is executed rarely (e.g.
980 * at subsystem initialization time) as the basic block reordering that this
981 * affects can often generate larger code.
982 *
983 * - Note that RT_SUCCESS() and RT_FAILURE() already makes use of RT_LIKELY()
984 * and RT_UNLIKELY(). Should you wish for prediction free status checks,
985 * use the RT_SUCCESS_NP() and RT_FAILURE_NP() macros instead.
986 *
987 *
988 * @returns the boolean result of the expression.
989 * @param expr The expression that's very likely to be true.
990 * @see RT_UNLIKELY
991 */
992/** @def RT_UNLIKELY
993 * Give the compiler a hint that an expression is highly unlikely to hold true.
994 *
995 * See the usage instructions give in the RT_LIKELY() docs.
996 *
997 * @returns the boolean result of the expression.
998 * @param expr The expression that's very unlikely to be true.
999 * @see RT_LIKELY
1000 */
1001#if defined(__GNUC__)
1002# if __GNUC__ >= 3 && !defined(FORTIFY_RUNNING)
1003# define RT_LIKELY(expr) __builtin_expect(!!(expr), 1)
1004# define RT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1005# else
1006# define RT_LIKELY(expr) (expr)
1007# define RT_UNLIKELY(expr) (expr)
1008# endif
1009#else
1010# define RT_LIKELY(expr) (expr)
1011# define RT_UNLIKELY(expr) (expr)
1012#endif
1013
1014
1015/** @def RT_STR
1016 * Returns the argument as a string constant.
1017 * @param str Argument to stringify. */
1018#define RT_STR(str) #str
1019/** @def RT_XSTR
1020 * Returns the expanded argument as a string.
1021 * @param str Argument to expand and stringy. */
1022#define RT_XSTR(str) RT_STR(str)
1023
1024/** @def RT_CONCAT
1025 * Concatenate the expanded arguments without any extra spaces in between.
1026 *
1027 * @param a The first part.
1028 * @param b The second part.
1029 */
1030#define RT_CONCAT(a,b) RT_CONCAT_HLP(a,b)
1031/** RT_CONCAT helper, don't use. */
1032#define RT_CONCAT_HLP(a,b) a##b
1033
1034/** @def RT_CONCAT
1035 * Concatenate the expanded arguments without any extra spaces in between.
1036 *
1037 * @param a The 1st part.
1038 * @param b The 2nd part.
1039 * @param c The 3rd part.
1040 */
1041#define RT_CONCAT3(a,b,c) RT_CONCAT3_HLP(a,b,c)
1042/** RT_CONCAT3 helper, don't use. */
1043#define RT_CONCAT3_HLP(a,b,c) a##b##c
1044
1045/** @def RT_CONCAT
1046 * Concatenate the expanded arguments without any extra spaces in between.
1047 *
1048 * @param a The 1st part.
1049 * @param b The 2nd part.
1050 * @param c The 3rd part.
1051 */
1052#define RT_CONCAT4(a,b,c,d) RT_CONCAT4_HLP(a,b,c,d)
1053/** RT_CONCAT4 helper, don't use. */
1054#define RT_CONCAT4_HLP(a,b,c,d) a##b##c##d
1055
1056
1057/** @def RT_BIT
1058 * Convert a bit number into an integer bitmask (unsigned).
1059 * @param bit The bit number.
1060 */
1061#define RT_BIT(bit) ( 1U << (bit) )
1062
1063/** @def RT_BIT_32
1064 * Convert a bit number into a 32-bit bitmask (unsigned).
1065 * @param bit The bit number.
1066 */
1067#define RT_BIT_32(bit) ( UINT32_C(1) << (bit) )
1068
1069/** @def RT_BIT_64
1070 * Convert a bit number into a 64-bit bitmask (unsigned).
1071 * @param bit The bit number.
1072 */
1073#define RT_BIT_64(bit) ( UINT64_C(1) << (bit) )
1074
1075/** @def RT_ALIGN
1076 * Align macro.
1077 * @param u Value to align.
1078 * @param uAlignment The alignment. Power of two!
1079 *
1080 * @remark Be extremely careful when using this macro with type which sizeof != sizeof int.
1081 * When possible use any of the other RT_ALIGN_* macros. And when that's not
1082 * possible, make 101% sure that uAlignment is specified with a right sized type.
1083 *
1084 * Specifying an unsigned 32-bit alignment constant with a 64-bit value will give
1085 * you a 32-bit return value!
1086 *
1087 * In short: Don't use this macro. Use RT_ALIGN_T() instead.
1088 */
1089#define RT_ALIGN(u, uAlignment) ( ((u) + ((uAlignment) - 1)) & ~((uAlignment) - 1) )
1090
1091/** @def RT_ALIGN_T
1092 * Align macro.
1093 * @param u Value to align.
1094 * @param uAlignment The alignment. Power of two!
1095 * @param type Integer type to use while aligning.
1096 * @remark This macro is the preferred alignment macro, it doesn't have any of the pitfalls RT_ALIGN has.
1097 */
1098#define RT_ALIGN_T(u, uAlignment, type) ( ((type)(u) + ((uAlignment) - 1)) & ~(type)((uAlignment) - 1) )
1099
1100/** @def RT_ALIGN_32
1101 * Align macro for a 32-bit value.
1102 * @param u32 Value to align.
1103 * @param uAlignment The alignment. Power of two!
1104 */
1105#define RT_ALIGN_32(u32, uAlignment) RT_ALIGN_T(u32, uAlignment, uint32_t)
1106
1107/** @def RT_ALIGN_64
1108 * Align macro for a 64-bit value.
1109 * @param u64 Value to align.
1110 * @param uAlignment The alignment. Power of two!
1111 */
1112#define RT_ALIGN_64(u64, uAlignment) RT_ALIGN_T(u64, uAlignment, uint64_t)
1113
1114/** @def RT_ALIGN_Z
1115 * Align macro for size_t.
1116 * @param cb Value to align.
1117 * @param uAlignment The alignment. Power of two!
1118 */
1119#define RT_ALIGN_Z(cb, uAlignment) RT_ALIGN_T(cb, uAlignment, size_t)
1120
1121/** @def RT_ALIGN_P
1122 * Align macro for pointers.
1123 * @param pv Value to align.
1124 * @param uAlignment The alignment. Power of two!
1125 */
1126#define RT_ALIGN_P(pv, uAlignment) RT_ALIGN_PT(pv, uAlignment, void *)
1127
1128/** @def RT_ALIGN_PT
1129 * Align macro for pointers with type cast.
1130 * @param u Value to align.
1131 * @param uAlignment The alignment. Power of two!
1132 * @param CastType The type to cast the result to.
1133 */
1134#define RT_ALIGN_PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, uintptr_t) )
1135
1136/** @def RT_ALIGN_R3PT
1137 * Align macro for ring-3 pointers with type cast.
1138 * @param u Value to align.
1139 * @param uAlignment The alignment. Power of two!
1140 * @param CastType The type to cast the result to.
1141 */
1142#define RT_ALIGN_R3PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR3UINTPTR) )
1143
1144/** @def RT_ALIGN_R0PT
1145 * Align macro for ring-0 pointers with type cast.
1146 * @param u Value to align.
1147 * @param uAlignment The alignment. Power of two!
1148 * @param CastType The type to cast the result to.
1149 */
1150#define RT_ALIGN_R0PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR0UINTPTR) )
1151
1152/** @def RT_ALIGN_GCPT
1153 * Align macro for GC pointers with type cast.
1154 * @param u Value to align.
1155 * @param uAlignment The alignment. Power of two!
1156 * @param CastType The type to cast the result to.
1157 */
1158#define RT_ALIGN_GCPT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTGCUINTPTR) )
1159
1160
1161/** @def RT_OFFSETOF
1162 * Our own special offsetof() variant, returns a signed result.
1163 *
1164 * This differs from the usual offsetof() in that it's not relying on builtin
1165 * compiler stuff and thus can use variables in arrays the structure may
1166 * contain. This is useful to determine the sizes of structures ending
1167 * with a variable length field.
1168 *
1169 * @returns offset into the structure of the specified member. signed.
1170 * @param type Structure type.
1171 * @param member Member.
1172 */
1173#define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) )
1174
1175/** @def RT_UOFFSETOF
1176 * Our own special offsetof() variant, returns an unsigned result.
1177 *
1178 * This differs from the usual offsetof() in that it's not relying on builtin
1179 * compiler stuff and thus can use variables in arrays the structure may
1180 * contain. This is useful to determine the sizes of structures ending
1181 * with a variable length field.
1182 *
1183 * @returns offset into the structure of the specified member. unsigned.
1184 * @param type Structure type.
1185 * @param member Member.
1186 */
1187#define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) )
1188
1189/** @def RT_OFFSETOF_ADD
1190 * RT_OFFSETOF with an addend.
1191 *
1192 * @returns offset into the structure of the specified member. signed.
1193 * @param type Structure type.
1194 * @param member Member.
1195 * @param addend The addend to add to the offset.
1196 */
1197#define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) )
1198
1199/** @def RT_UOFFSETOF_ADD
1200 * RT_UOFFSETOF with an addend.
1201 *
1202 * @returns offset into the structure of the specified member. signed.
1203 * @param type Structure type.
1204 * @param member Member.
1205 * @param addend The addend to add to the offset.
1206 */
1207#define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) )
1208
1209/** @def RT_SIZEOFMEMB
1210 * Get the size of a structure member.
1211 *
1212 * @returns size of the structure member.
1213 * @param type Structure type.
1214 * @param member Member.
1215 */
1216#define RT_SIZEOFMEMB(type, member) ( sizeof(((type *)(void *)0)->member) )
1217
1218/** @def RT_FROM_MEMBER
1219 * Convert a pointer to a structure member into a pointer to the structure.
1220 *
1221 * @returns pointer to the structure.
1222 * @param pMem Pointer to the member.
1223 * @param Type Structure type.
1224 * @param Member Member name.
1225 */
1226#define RT_FROM_MEMBER(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
1227
1228/** @def RT_FROM_CPP_MEMBER
1229 * Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
1230 * invalid access to non-static data member of NULL object.
1231 *
1232 * @returns pointer to the structure.
1233 * @param pMem Pointer to the member.
1234 * @param Type Structure type.
1235 * @param Member Member name.
1236 *
1237 * @remarks Using the __builtin_offsetof does not shut up the compiler.
1238 */
1239#if defined(__GNUC__) && defined(__cplusplus)
1240# define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
1241 ( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
1242#else
1243# define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
1244#endif
1245
1246/** @def RT_ELEMENTS
1247 * Calculates the number of elements in a statically sized array.
1248 * @returns Element count.
1249 * @param aArray Array in question.
1250 */
1251#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
1252
1253/**
1254 * Checks if the value is a power of two.
1255 *
1256 * @returns true if power of two, false if not.
1257 * @param uVal The value to test.
1258 * @remarks 0 is a power of two.
1259 * @see VERR_NOT_POWER_OF_TWO
1260 */
1261#define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
1262
1263#ifdef RT_OS_OS2
1264/* Undefine RT_MAX since there is an unfortunate clash with the max
1265 resource type define in os2.h. */
1266# undef RT_MAX
1267#endif
1268
1269/** @def RT_MAX
1270 * Finds the maximum value.
1271 * @returns The higher of the two.
1272 * @param Value1 Value 1
1273 * @param Value2 Value 2
1274 */
1275#define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
1276
1277/** @def RT_MIN
1278 * Finds the minimum value.
1279 * @returns The lower of the two.
1280 * @param Value1 Value 1
1281 * @param Value2 Value 2
1282 */
1283#define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
1284
1285/** @def RT_CLAMP
1286 * Clamps the value to minimum and maximum values.
1287 * @returns The clamped value.
1288 * @param Value The value to check.
1289 * @param Min Minimum value.
1290 * @param Max Maximum value.
1291 */
1292#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
1293
1294/** @def RT_ABS
1295 * Get the absolute (non-negative) value.
1296 * @returns The absolute value of Value.
1297 * @param Value The value.
1298 */
1299#define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
1300
1301/** @def RT_BOOL
1302 * Turn non-zero/zero into true/false
1303 * @returns The resulting boolean value.
1304 * @param Value The value.
1305 */
1306#define RT_BOOL(Value) ( !!(Value) )
1307
1308/** @def RT_LODWORD
1309 * Gets the low dword (=uint32_t) of something. */
1310#define RT_LODWORD(a) ( (uint32_t)(a) )
1311
1312/** @def RT_HIDWORD
1313 * Gets the high dword (=uint32_t) of a 64-bit of something. */
1314#define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
1315
1316/** @def RT_LOWORD
1317 * Gets the low word (=uint16_t) of something. */
1318#define RT_LOWORD(a) ( (a) & 0xffff )
1319
1320/** @def RT_HIWORD
1321 * Gets the high word (=uint16_t) of a 32-bit something. */
1322#define RT_HIWORD(a) ( (a) >> 16 )
1323
1324/** @def RT_LOBYTE
1325 * Gets the low byte of something. */
1326#define RT_LOBYTE(a) ( (a) & 0xff )
1327
1328/** @def RT_HIBYTE
1329 * Gets the low byte of a 16-bit something. */
1330#define RT_HIBYTE(a) ( (a) >> 8 )
1331
1332/** @def RT_BYTE1
1333 * Gets the first byte of something. */
1334#define RT_BYTE1(a) ( (a) & 0xff )
1335
1336/** @def RT_BYTE2
1337 * Gets the second byte of something. */
1338#define RT_BYTE2(a) ( ((a) >> 8) & 0xff )
1339
1340/** @def RT_BYTE3
1341 * Gets the second byte of something. */
1342#define RT_BYTE3(a) ( ((a) >> 16) & 0xff )
1343
1344/** @def RT_BYTE4
1345 * Gets the fourth byte of something. */
1346#define RT_BYTE4(a) ( ((a) >> 24) & 0xff )
1347
1348/** @def RT_BYTE5
1349 * Gets the fifth byte of something. */
1350#define RT_BYTE5(a) (((a) >> 32) & 0xff)
1351
1352/** @def RT_BYTE6
1353 * Gets the sixth byte of something. */
1354#define RT_BYTE6(a) (((a) >> 40) & 0xff)
1355
1356/** @def RT_BYTE7
1357 * Gets the seventh byte of something. */
1358#define RT_BYTE7(a) (((a) >> 48) & 0xff)
1359
1360/** @def RT_BYTE8
1361 * Gets the eight byte of something. */
1362#define RT_BYTE8(a) (((a) >> 56) & 0xff)
1363
1364
1365/** @def RT_MAKE_U64
1366 * Constructs a uint64_t value from two uint32_t values.
1367 */
1368#define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
1369
1370/** @def RT_MAKE_U64_FROM_U16
1371 * Constructs a uint64_t value from four uint16_t values.
1372 */
1373#define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
1374 ((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
1375 | (uint64_t)((uint16_t)(w2)) << 32 \
1376 | (uint32_t)((uint16_t)(w1)) << 16 \
1377 | (uint16_t)(w0) ))
1378
1379/** @def RT_MAKE_U64_FROM_U8
1380 * Constructs a uint64_t value from eight uint8_t values.
1381 */
1382#define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
1383 ((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
1384 | (uint64_t)((uint8_t)(b6)) << 48 \
1385 | (uint64_t)((uint8_t)(b5)) << 40 \
1386 | (uint64_t)((uint8_t)(b4)) << 32 \
1387 | (uint32_t)((uint8_t)(b3)) << 24 \
1388 | (uint32_t)((uint8_t)(b2)) << 16 \
1389 | (uint16_t)((uint8_t)(b1)) << 8 \
1390 | (uint8_t)(b0) ))
1391
1392/** @def RT_MAKE_U32
1393 * Constructs a uint32_t value from two uint16_t values.
1394 */
1395#define RT_MAKE_U32(Lo, Hi) \
1396 ((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
1397 | (uint16_t)(Lo) ))
1398
1399/** @def RT_MAKE_U32_FROM_U8
1400 * Constructs a uint32_t value from four uint8_t values.
1401 */
1402#define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
1403 ((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
1404 | (uint32_t)((uint8_t)(b2)) << 16 \
1405 | (uint16_t)((uint8_t)(b1)) << 8 \
1406 | (uint8_t)(b0) ))
1407
1408/** @def RT_MAKE_U16
1409 * Constructs a uint16_t value from two uint8_t values.
1410 */
1411#define RT_MAKE_U16(Lo, Hi) \
1412 ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
1413 | (uint8_t)(Lo) ))
1414
1415
1416/** @def RT_BSWAP_U64
1417 * Reverses the byte order of an uint64_t value. */
1418#if 0
1419# define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64)
1420#elif defined(__GNUC__)
1421# define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) \
1422 ? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
1423#else
1424# define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
1425#endif
1426
1427/** @def RT_BSWAP_U32
1428 * Reverses the byte order of an uint32_t value. */
1429#if 0
1430# define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32)
1431#elif defined(__GNUC__)
1432# define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) \
1433 ? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
1434#else
1435# define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
1436#endif
1437
1438/** @def RT_BSWAP_U16
1439 * Reverses the byte order of an uint16_t value. */
1440#if 0
1441# define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16)
1442#elif defined(__GNUC__)
1443# define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) \
1444 ? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
1445#else
1446# define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
1447#endif
1448
1449
1450/** @def RT_BSWAP_U64_C
1451 * Reverses the byte order of an uint64_t constant. */
1452#define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
1453
1454/** @def RT_BSWAP_U32_C
1455 * Reverses the byte order of an uint32_t constant. */
1456#define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
1457
1458/** @def RT_BSWAP_U16_C
1459 * Reverses the byte order of an uint16_t constant. */
1460#define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
1461
1462
1463/** @def RT_H2LE_U64
1464 * Converts an uint64_t value from host to little endian byte order. */
1465#ifdef RT_BIG_ENDIAN
1466# define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
1467#else
1468# define RT_H2LE_U64(u64) (u64)
1469#endif
1470
1471/** @def RT_H2LE_U64_C
1472 * Converts an uint64_t constant from host to little endian byte order. */
1473#ifdef RT_BIG_ENDIAN
1474# define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
1475#else
1476# define RT_H2LE_U64_C(u64) (u64)
1477#endif
1478
1479/** @def RT_H2LE_U32
1480 * Converts an uint32_t value from host to little endian byte order. */
1481#ifdef RT_BIG_ENDIAN
1482# define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
1483#else
1484# define RT_H2LE_U32(u32) (u32)
1485#endif
1486
1487/** @def RT_H2LE_U32_C
1488 * Converts an uint32_t constant from host to little endian byte order. */
1489#ifdef RT_BIG_ENDIAN
1490# define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
1491#else
1492# define RT_H2LE_U32_C(u32) (u32)
1493#endif
1494
1495/** @def RT_H2LE_U16
1496 * Converts an uint16_t value from host to little endian byte order. */
1497#ifdef RT_BIG_ENDIAN
1498# define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
1499#else
1500# define RT_H2LE_U16(u16) (u16)
1501#endif
1502
1503/** @def RT_H2LE_U16_C
1504 * Converts an uint16_t constant from host to little endian byte order. */
1505#ifdef RT_BIG_ENDIAN
1506# define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
1507#else
1508# define RT_H2LE_U16_C(u16) (u16)
1509#endif
1510
1511
1512/** @def RT_LE2H_U64
1513 * Converts an uint64_t value from little endian to host byte order. */
1514#ifdef RT_BIG_ENDIAN
1515# define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
1516#else
1517# define RT_LE2H_U64(u64) (u64)
1518#endif
1519
1520/** @def RT_LE2H_U64_C
1521 * Converts an uint64_t constant from little endian to host byte order. */
1522#ifdef RT_BIG_ENDIAN
1523# define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
1524#else
1525# define RT_LE2H_U64_C(u64) (u64)
1526#endif
1527
1528/** @def RT_LE2H_U32
1529 * Converts an uint32_t value from little endian to host byte order. */
1530#ifdef RT_BIG_ENDIAN
1531# define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
1532#else
1533# define RT_LE2H_U32(u32) (u32)
1534#endif
1535
1536/** @def RT_LE2H_U32_C
1537 * Converts an uint32_t constant from little endian to host byte order. */
1538#ifdef RT_BIG_ENDIAN
1539# define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
1540#else
1541# define RT_LE2H_U32_C(u32) (u32)
1542#endif
1543
1544/** @def RT_LE2H_U16
1545 * Converts an uint16_t value from little endian to host byte order. */
1546#ifdef RT_BIG_ENDIAN
1547# define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
1548#else
1549# define RT_LE2H_U16(u16) (u16)
1550#endif
1551
1552/** @def RT_LE2H_U16_C
1553 * Converts an uint16_t constant from little endian to host byte order. */
1554#ifdef RT_BIG_ENDIAN
1555# define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
1556#else
1557# define RT_LE2H_U16_C(u16) (u16)
1558#endif
1559
1560
1561/** @def RT_H2BE_U64
1562 * Converts an uint64_t value from host to big endian byte order. */
1563#ifdef RT_BIG_ENDIAN
1564# define RT_H2BE_U64(u64) (u64)
1565#else
1566# define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
1567#endif
1568
1569/** @def RT_H2BE_U64_C
1570 * Converts an uint64_t constant from host to big endian byte order. */
1571#ifdef RT_BIG_ENDIAN
1572# define RT_H2BE_U64_C(u64) (u64)
1573#else
1574# define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
1575#endif
1576
1577/** @def RT_H2BE_U32
1578 * Converts an uint32_t value from host to big endian byte order. */
1579#ifdef RT_BIG_ENDIAN
1580# define RT_H2BE_U32(u32) (u32)
1581#else
1582# define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
1583#endif
1584
1585/** @def RT_H2BE_U32_C
1586 * Converts an uint32_t constant from host to big endian byte order. */
1587#ifdef RT_BIG_ENDIAN
1588# define RT_H2BE_U32_C(u32) (u32)
1589#else
1590# define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
1591#endif
1592
1593/** @def RT_H2BE_U16
1594 * Converts an uint16_t value from host to big endian byte order. */
1595#ifdef RT_BIG_ENDIAN
1596# define RT_H2BE_U16(u16) (u16)
1597#else
1598# define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
1599#endif
1600
1601/** @def RT_H2BE_U16_C
1602 * Converts an uint16_t constant from host to big endian byte order. */
1603#ifdef RT_BIG_ENDIAN
1604# define RT_H2BE_U16_C(u16) (u16)
1605#else
1606# define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
1607#endif
1608
1609/** @def RT_BE2H_U64
1610 * Converts an uint64_t value from big endian to host byte order. */
1611#ifdef RT_BIG_ENDIAN
1612# define RT_BE2H_U64(u64) (u64)
1613#else
1614# define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
1615#endif
1616
1617/** @def RT_BE2H_U64
1618 * Converts an uint64_t constant from big endian to host byte order. */
1619#ifdef RT_BIG_ENDIAN
1620# define RT_BE2H_U64_C(u64) (u64)
1621#else
1622# define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
1623#endif
1624
1625/** @def RT_BE2H_U32
1626 * Converts an uint32_t value from big endian to host byte order. */
1627#ifdef RT_BIG_ENDIAN
1628# define RT_BE2H_U32(u32) (u32)
1629#else
1630# define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
1631#endif
1632
1633/** @def RT_BE2H_U32_C
1634 * Converts an uint32_t value from big endian to host byte order. */
1635#ifdef RT_BIG_ENDIAN
1636# define RT_BE2H_U32_C(u32) (u32)
1637#else
1638# define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
1639#endif
1640
1641/** @def RT_BE2H_U16
1642 * Converts an uint16_t value from big endian to host byte order. */
1643#ifdef RT_BIG_ENDIAN
1644# define RT_BE2H_U16(u16) (u16)
1645#else
1646# define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
1647#endif
1648
1649/** @def RT_BE2H_U16_C
1650 * Converts an uint16_t constant from big endian to host byte order. */
1651#ifdef RT_BIG_ENDIAN
1652# define RT_BE2H_U16_C(u16) (u16)
1653#else
1654# define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
1655#endif
1656
1657
1658/** @def RT_H2N_U64
1659 * Converts an uint64_t value from host to network byte order. */
1660#define RT_H2N_U64(u64) RT_H2BE_U64(u64)
1661
1662/** @def RT_H2N_U64_C
1663 * Converts an uint64_t constant from host to network byte order. */
1664#define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
1665
1666/** @def RT_H2N_U32
1667 * Converts an uint32_t value from host to network byte order. */
1668#define RT_H2N_U32(u32) RT_H2BE_U32(u32)
1669
1670/** @def RT_H2N_U32_C
1671 * Converts an uint32_t constant from host to network byte order. */
1672#define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
1673
1674/** @def RT_H2N_U16
1675 * Converts an uint16_t value from host to network byte order. */
1676#define RT_H2N_U16(u16) RT_H2BE_U16(u16)
1677
1678/** @def RT_H2N_U16_C
1679 * Converts an uint16_t constant from host to network byte order. */
1680#define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
1681
1682/** @def RT_N2H_U64
1683 * Converts an uint64_t value from network to host byte order. */
1684#define RT_N2H_U64(u64) RT_BE2H_U64(u64)
1685
1686/** @def RT_N2H_U64_C
1687 * Converts an uint64_t constant from network to host byte order. */
1688#define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
1689
1690/** @def RT_N2H_U32
1691 * Converts an uint32_t value from network to host byte order. */
1692#define RT_N2H_U32(u32) RT_BE2H_U32(u32)
1693
1694/** @def RT_N2H_U32_C
1695 * Converts an uint32_t constant from network to host byte order. */
1696#define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
1697
1698/** @def RT_N2H_U16
1699 * Converts an uint16_t value from network to host byte order. */
1700#define RT_N2H_U16(u16) RT_BE2H_U16(u16)
1701
1702/** @def RT_N2H_U16_C
1703 * Converts an uint16_t value from network to host byte order. */
1704#define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
1705
1706
1707/*
1708 * The BSD sys/param.h + machine/param.h file is a major source of
1709 * namespace pollution. Kill off some of the worse ones unless we're
1710 * compiling kernel code.
1711 */
1712#if defined(RT_OS_DARWIN) \
1713 && !defined(KERNEL) \
1714 && !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
1715 && ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
1716/* sys/param.h: */
1717# undef PSWP
1718# undef PVM
1719# undef PINOD
1720# undef PRIBO
1721# undef PVFS
1722# undef PZERO
1723# undef PSOCK
1724# undef PWAIT
1725# undef PLOCK
1726# undef PPAUSE
1727# undef PUSER
1728# undef PRIMASK
1729# undef MINBUCKET
1730# undef MAXALLOCSAVE
1731# undef FSHIFT
1732# undef FSCALE
1733
1734/* i386/machine.h: */
1735# undef ALIGN
1736# undef ALIGNBYTES
1737# undef DELAY
1738# undef STATUS_WORD
1739# undef USERMODE
1740# undef BASEPRI
1741# undef MSIZE
1742# undef CLSIZE
1743# undef CLSIZELOG2
1744#endif
1745
1746
1747/** @def NULL
1748 * NULL pointer.
1749 */
1750#ifndef NULL
1751# ifdef __cplusplus
1752# define NULL 0
1753# else
1754# define NULL ((void*)0)
1755# endif
1756#endif
1757
1758/** @def NIL_OFFSET
1759 * NIL offset.
1760 * Whenever we use offsets instead of pointers to save space and relocation effort
1761 * NIL_OFFSET shall be used as the equivalent to NULL.
1762 */
1763#define NIL_OFFSET (~0U)
1764
1765/** @def NOREF
1766 * Keeps the compiler from bitching about an unused parameter.
1767 */
1768#define NOREF(var) (void)(var)
1769
1770/** @def RT_BREAKPOINT
1771 * Emit a debug breakpoint instruction.
1772 *
1773 * @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
1774 * to force gdb to remain at the int3 source line.
1775 * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
1776 * x86/amd64.
1777 */
1778#ifdef __GNUC__
1779# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
1780# if !defined(__L4ENV__)
1781# define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
1782# else
1783# define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
1784# endif
1785# elif defined(RT_ARCH_SPARC64)
1786# define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
1787# elif defined(RT_ARCH_SPARC)
1788# define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
1789# endif
1790#endif
1791#ifdef _MSC_VER
1792# define RT_BREAKPOINT() __debugbreak()
1793#endif
1794#if defined(__IBMC__) || defined(__IBMCPP__)
1795# define RT_BREAKPOINT() __interrupt(3)
1796#endif
1797#ifndef RT_BREAKPOINT
1798# error "This compiler/arch is not supported!"
1799#endif
1800
1801
1802/** @defgroup grp_rt_cdefs_size Size Constants
1803 * (Of course, these are binary computer terms, not SI.)
1804 * @{
1805 */
1806/** 1 K (Kilo) (1 024). */
1807#define _1K 0x00000400
1808/** 4 K (Kilo) (4 096). */
1809#define _4K 0x00001000
1810/** 32 K (Kilo) (32 678). */
1811#define _32K 0x00008000
1812/** 64 K (Kilo) (65 536). */
1813#define _64K 0x00010000
1814/** 128 K (Kilo) (131 072). */
1815#define _128K 0x00020000
1816/** 256 K (Kilo) (262 144). */
1817#define _256K 0x00040000
1818/** 512 K (Kilo) (524 288). */
1819#define _512K 0x00080000
1820/** 1 M (Mega) (1 048 576). */
1821#define _1M 0x00100000
1822/** 2 M (Mega) (2 097 152). */
1823#define _2M 0x00200000
1824/** 4 M (Mega) (4 194 304). */
1825#define _4M 0x00400000
1826/** 1 G (Giga) (1 073 741 824). (32-bit) */
1827#define _1G 0x40000000
1828/** 1 G (Giga) (1 073 741 824). (64-bit) */
1829#define _1G64 0x40000000LL
1830/** 2 G (Giga) (2 147 483 648). (32-bit) */
1831#define _2G32 0x80000000U
1832/** 2 G (Giga) (2 147 483 648). (64-bit) */
1833#define _2G 0x0000000080000000LL
1834/** 4 G (Giga) (4 294 967 296). */
1835#define _4G 0x0000000100000000LL
1836/** 1 T (Tera) (1 099 511 627 776). */
1837#define _1T 0x0000010000000000LL
1838/** 1 P (Peta) (1 125 899 906 842 624). */
1839#define _1P 0x0004000000000000LL
1840/** 1 E (Exa) (1 152 921 504 606 846 976). */
1841#define _1E 0x1000000000000000LL
1842/** 2 E (Exa) (2 305 843 009 213 693 952). */
1843#define _2E 0x2000000000000000ULL
1844/** @} */
1845
1846
1847/** @defgroup grp_rt_cdefs_time Time Constants
1848 * @{
1849 */
1850/** 1 hour expressed in nanoseconds (64-bit). */
1851#define RT_NS_1HOUR UINT64_C(3600000000000)
1852/** 1 minute expressed in nanoseconds (64-bit). */
1853#define RT_NS_1MIN UINT64_C(60000000000)
1854/** 1 second expressed in nanoseconds. */
1855#define RT_NS_1SEC UINT32_C(1000000000)
1856/** 100 millsecond expressed in nanoseconds. */
1857#define RT_NS_100MS UINT32_C(100000000)
1858/** 10 millsecond expressed in nanoseconds. */
1859#define RT_NS_10MS UINT32_C(10000000)
1860/** 1 millsecond expressed in nanoseconds. */
1861#define RT_NS_1MS UINT32_C(1000000)
1862/** 100 microseconds expressed in nanoseconds. */
1863#define RT_NS_100US UINT32_C(100000)
1864/** 10 microseconds expressed in nanoseconds. */
1865#define RT_NS_10US UINT32_C(10000)
1866/** 1 microsecond expressed in nanoseconds. */
1867#define RT_NS_1US UINT32_C(1000)
1868
1869/** 1 second expressed in nanoseconds - 64-bit type. */
1870#define RT_NS_1SEC_64 UINT64_C(1000000000)
1871/** 100 millsecond expressed in nanoseconds - 64-bit type. */
1872#define RT_NS_100MS_64 UINT64_C(100000000)
1873/** 10 millsecond expressed in nanoseconds - 64-bit type. */
1874#define RT_NS_10MS_64 UINT64_C(10000000)
1875/** 1 millsecond expressed in nanoseconds - 64-bit type. */
1876#define RT_NS_1MS_64 UINT64_C(1000000)
1877/** 100 microseconds expressed in nanoseconds - 64-bit type. */
1878#define RT_NS_100US_64 UINT64_C(100000)
1879/** 10 microseconds expressed in nanoseconds - 64-bit type. */
1880#define RT_NS_10US_64 UINT64_C(10000)
1881/** 1 microsecond expressed in nanoseconds - 64-bit type. */
1882#define RT_NS_1US_64 UINT64_C(1000)
1883
1884/** 1 hour expressed in microseconds. */
1885#define RT_US_1HOUR UINT32_C(3600000000)
1886/** 1 minute expressed in microseconds. */
1887#define RT_US_1MIN UINT32_C(60000000)
1888/** 1 second expressed in microseconds. */
1889#define RT_US_1SEC UINT32_C(1000000)
1890/** 100 millsecond expressed in microseconds. */
1891#define RT_US_100MS UINT32_C(100000)
1892/** 10 millsecond expressed in microseconds. */
1893#define RT_US_10MS UINT32_C(10000)
1894/** 1 millsecond expressed in microseconds. */
1895#define RT_US_1MS UINT32_C(1000)
1896
1897/** 1 hour expressed in microseconds - 64-bit type. */
1898#define RT_US_1HOUR_64 UINT64_C(3600000000)
1899/** 1 minute expressed in microseconds - 64-bit type. */
1900#define RT_US_1MIN_64 UINT64_C(60000000)
1901/** 1 second expressed in microseconds - 64-bit type. */
1902#define RT_US_1SEC_64 UINT64_C(1000000)
1903/** 100 millsecond expressed in microseconds - 64-bit type. */
1904#define RT_US_100MS_64 UINT64_C(100000)
1905/** 10 millsecond expressed in microseconds - 64-bit type. */
1906#define RT_US_10MS_64 UINT64_C(10000)
1907/** 1 millsecond expressed in microseconds - 64-bit type. */
1908#define RT_US_1MS_64 UINT64_C(1000)
1909
1910/** 1 hour expressed in milliseconds. */
1911#define RT_MS_1HOUR UINT32_C(3600000)
1912/** 1 minute expressed in milliseconds. */
1913#define RT_MS_1MIN UINT32_C(60000)
1914/** 1 second expressed in milliseconds. */
1915#define RT_MS_1SEC UINT32_C(1000)
1916
1917/** 1 hour expressed in milliseconds - 64-bit type. */
1918#define RT_MS_1HOUR_64 UINT64_C(3600000)
1919/** 1 minute expressed in milliseconds - 64-bit type. */
1920#define RT_MS_1MIN_64 UINT64_C(60000)
1921/** 1 second expressed in milliseconds - 64-bit type. */
1922#define RT_MS_1SEC_64 UINT64_C(1000)
1923
1924/** The number of seconds per week. */
1925#define RT_SEC_1WEEK UINT32_C(604800)
1926/** The number of seconds per day. */
1927#define RT_SEC_1DAY UINT32_C(86400)
1928/** The number of seconds per hour. */
1929#define RT_SEC_1HOUR UINT32_C(3600)
1930
1931/** The number of seconds per week - 64-bit type. */
1932#define RT_SEC_1WEEK_64 UINT64_C(604800)
1933/** The number of seconds per day - 64-bit type. */
1934#define RT_SEC_1DAY_64 UINT64_C(86400)
1935/** The number of seconds per hour - 64-bit type. */
1936#define RT_SEC_1HOUR_64 UINT64_C(3600)
1937/** @} */
1938
1939
1940/** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
1941 * @{ */
1942/** Other format. */
1943#define RT_DBGTYPE_OTHER RT_BIT_32(0)
1944/** Stabs. */
1945#define RT_DBGTYPE_STABS RT_BIT_32(1)
1946/** Debug With Arbitrary Record Format (DWARF). */
1947#define RT_DBGTYPE_DWARF RT_BIT_32(2)
1948/** Microsoft Codeview debug info. */
1949#define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
1950/** Watcom debug info. */
1951#define RT_DBGTYPE_WATCOM RT_BIT_32(4)
1952/** IBM High Level Language debug info. */
1953#define RT_DBGTYPE_HLL RT_BIT_32(5)
1954/** Old OS/2 and Windows symbol file. */
1955#define RT_DBGTYPE_SYM RT_BIT_32(6)
1956/** Map file. */
1957#define RT_DBGTYPE_MAP RT_BIT_32(7)
1958/** @} */
1959
1960
1961/** @defgroup grp_rt_cdefs_exetype Executable Image Types
1962 * @{ */
1963/** Some other format. */
1964#define RT_EXETYPE_OTHER RT_BIT_32(0)
1965/** Portable Executable. */
1966#define RT_EXETYPE_PE RT_BIT_32(1)
1967/** Linear eXecutable. */
1968#define RT_EXETYPE_LX RT_BIT_32(2)
1969/** Linear Executable. */
1970#define RT_EXETYPE_LE RT_BIT_32(3)
1971/** New Executable. */
1972#define RT_EXETYPE_NE RT_BIT_32(4)
1973/** DOS Executable (Mark Zbikowski). */
1974#define RT_EXETYPE_MZ RT_BIT_32(5)
1975/** COM Executable. */
1976#define RT_EXETYPE_COM RT_BIT_32(6)
1977/** a.out Executable. */
1978#define RT_EXETYPE_AOUT RT_BIT_32(7)
1979/** Executable and Linkable Format. */
1980#define RT_EXETYPE_ELF RT_BIT_32(8)
1981/** Mach-O Executable (including FAT ones). */
1982#define RT_EXETYPE_MACHO RT_BIT_32(9)
1983/** TE from UEFI. */
1984#define RT_EXETYPE_TE RT_BIT_32(9)
1985/** @} */
1986
1987
1988/** @def VALID_PTR
1989 * Pointer validation macro.
1990 * @param ptr The pointer.
1991 */
1992#if defined(RT_ARCH_AMD64)
1993# ifdef IN_RING3
1994# if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
1995# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
1996 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
1997# elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
1998# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
1999 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
2000 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
2001# else
2002# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
2003 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
2004# endif
2005# else /* !IN_RING3 */
2006# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
2007 && ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
2008 || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
2009# endif /* !IN_RING3 */
2010
2011#elif defined(RT_ARCH_X86)
2012# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
2013
2014#elif defined(RT_ARCH_SPARC64)
2015# ifdef IN_RING3
2016# if defined(RT_OS_SOLARIS)
2017/** Sparc64 user mode: According to Figure 9.4 in solaris internals */
2018/** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
2019# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
2020# else
2021# error "Port me"
2022# endif
2023# else /* !IN_RING3 */
2024# if defined(RT_OS_SOLARIS)
2025/** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
2026 * internals. Verify in sources. */
2027# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
2028# else
2029# error "Port me"
2030# endif
2031# endif /* !IN_RING3 */
2032
2033#elif defined(RT_ARCH_SPARC)
2034# ifdef IN_RING3
2035# ifdef RT_OS_SOLARIS
2036/** Sparc user mode: According to
2037 * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
2038# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
2039
2040# else
2041# error "Port me"
2042# endif
2043# else /* !IN_RING3 */
2044# ifdef RT_OS_SOLARIS
2045/** @todo Sparc kernel mode: Check the sources! */
2046# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
2047# else
2048# error "Port me"
2049# endif
2050# endif /* !IN_RING3 */
2051
2052#else
2053# error "Architecture identifier missing / not implemented."
2054#endif
2055
2056/** Old name for RT_VALID_PTR. */
2057#define VALID_PTR(ptr) RT_VALID_PTR(ptr)
2058
2059/** @def RT_VALID_ALIGNED_PTR
2060 * Pointer validation macro that also checks the alignment.
2061 * @param ptr The pointer.
2062 * @param align The alignment, must be a power of two.
2063 */
2064#define RT_VALID_ALIGNED_PTR(ptr, align) \
2065 ( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
2066 && VALID_PTR(ptr) )
2067
2068
2069/** @def VALID_PHYS32
2070 * 32 bits physical address validation macro.
2071 * @param Phys The RTGCPHYS address.
2072 */
2073#define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
2074
2075/** @def N_
2076 * The \#define N_ is used to mark a string for translation. This is usable in
2077 * any part of the code, as it is only used by the tools that create message
2078 * catalogs. This macro is a no-op as far as the compiler and code generation
2079 * is concerned.
2080 *
2081 * If you want to both mark a string for translation and translate it, use _().
2082 */
2083#define N_(s) (s)
2084
2085/** @def _
2086 * The \#define _ is used to mark a string for translation and to translate it
2087 * in one step.
2088 *
2089 * If you want to only mark a string for translation, use N_().
2090 */
2091#define _(s) gettext(s)
2092
2093
2094/** @def __PRETTY_FUNCTION__
2095 * With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
2096 * for the other compilers.
2097 */
2098#if !defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)
2099# define __PRETTY_FUNCTION__ __FUNCTION__
2100#endif
2101
2102
2103/** @def RT_STRICT
2104 * The \#define RT_STRICT controls whether or not assertions and other runtime
2105 * checks should be compiled in or not.
2106 *
2107 * If you want assertions which are not subject to compile time options use
2108 * the AssertRelease*() flavors.
2109 */
2110#if !defined(RT_STRICT) && defined(DEBUG)
2111# define RT_STRICT
2112#endif
2113
2114/** @todo remove this: */
2115#if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
2116# define RT_LOCK_NO_STRICT
2117#endif
2118#if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
2119# define RT_LOCK_NO_STRICT_ORDER
2120#endif
2121
2122/** @def RT_LOCK_STRICT
2123 * The \#define RT_LOCK_STRICT controls whether deadlock detection and related
2124 * checks are done in the lock and semaphore code. It is by default enabled in
2125 * RT_STRICT builds, but this behavior can be overridden by defining
2126 * RT_LOCK_NO_STRICT. */
2127#if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
2128# define RT_LOCK_STRICT
2129#endif
2130/** @def RT_LOCK_NO_STRICT
2131 * The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
2132#if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
2133# undef RT_LOCK_STRICT
2134#endif
2135
2136/** @def RT_LOCK_STRICT_ORDER
2137 * The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
2138 * by the lock and semaphore code. It is by default enabled in RT_STRICT
2139 * builds, but this behavior can be overridden by defining
2140 * RT_LOCK_NO_STRICT_ORDER. */
2141#if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
2142# define RT_LOCK_STRICT_ORDER
2143#endif
2144/** @def RT_LOCK_NO_STRICT_ORDER
2145 * The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
2146#if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
2147# undef RT_LOCK_STRICT_ORDER
2148#endif
2149
2150
2151/** Source position. */
2152#define RT_SRC_POS __FILE__, __LINE__, __PRETTY_FUNCTION__
2153
2154/** Source position declaration. */
2155#define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
2156
2157/** Source position arguments. */
2158#define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
2159
2160/** Applies NOREF() to the source position arguments. */
2161#define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
2162
2163
2164/** @def RT_INLINE_ASM_EXTERNAL
2165 * Defined as 1 if the compiler does not support inline assembly.
2166 * The ASM* functions will then be implemented in external .asm files.
2167 */
2168#if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
2169 || (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86))
2170# define RT_INLINE_ASM_EXTERNAL 1
2171#else
2172# define RT_INLINE_ASM_EXTERNAL 0
2173#endif
2174
2175/** @def RT_INLINE_ASM_GNU_STYLE
2176 * Defined as 1 if the compiler understands GNU style inline assembly.
2177 */
2178#if defined(_MSC_VER)
2179# define RT_INLINE_ASM_GNU_STYLE 0
2180#else
2181# define RT_INLINE_ASM_GNU_STYLE 1
2182#endif
2183
2184/** @def RT_INLINE_ASM_USES_INTRIN
2185 * Defined as 1 if the compiler have and uses intrin.h. Otherwise it is 0. */
2186#ifdef _MSC_VER
2187# if _MSC_VER >= 1400
2188# define RT_INLINE_ASM_USES_INTRIN 1
2189# endif
2190#endif
2191#ifndef RT_INLINE_ASM_USES_INTRIN
2192# define RT_INLINE_ASM_USES_INTRIN 0
2193#endif
2194
2195/** @} */
2196
2197
2198/** @defgroup grp_rt_cdefs_cpp Special Macros for C++
2199 * @ingroup grp_rt_cdefs
2200 * @{
2201 */
2202
2203#ifdef __cplusplus
2204
2205/** @def DECLEXPORT_CLASS
2206 * How to declare an exported class. Place this macro after the 'class'
2207 * keyword in the declaration of every class you want to export.
2208 *
2209 * @note It is necessary to use this macro even for inner classes declared
2210 * inside the already exported classes. This is a GCC specific requirement,
2211 * but it seems not to harm other compilers.
2212 */
2213#if defined(_MSC_VER) || defined(RT_OS_OS2)
2214# define DECLEXPORT_CLASS __declspec(dllexport)
2215#elif defined(RT_USE_VISIBILITY_DEFAULT)
2216# define DECLEXPORT_CLASS __attribute__((visibility("default")))
2217#else
2218# define DECLEXPORT_CLASS
2219#endif
2220
2221/** @def DECLIMPORT_CLASS
2222 * How to declare an imported class Place this macro after the 'class'
2223 * keyword in the declaration of every class you want to export.
2224 *
2225 * @note It is necessary to use this macro even for inner classes declared
2226 * inside the already exported classes. This is a GCC specific requirement,
2227 * but it seems not to harm other compilers.
2228 */
2229#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
2230# define DECLIMPORT_CLASS __declspec(dllimport)
2231#elif defined(RT_USE_VISIBILITY_DEFAULT)
2232# define DECLIMPORT_CLASS __attribute__((visibility("default")))
2233#else
2234# define DECLIMPORT_CLASS
2235#endif
2236
2237/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP
2238 * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity
2239 * resolver. The following snippet clearly demonstrates the code causing this
2240 * error:
2241 * @code
2242 * class A
2243 * {
2244 * public:
2245 * operator bool() const { return false; }
2246 * operator int*() const { return NULL; }
2247 * };
2248 * int main()
2249 * {
2250 * A a;
2251 * if (!a);
2252 * if (a && 0);
2253 * return 0;
2254 * }
2255 * @endcode
2256 * The code itself seems pretty valid to me and GCC thinks the same.
2257 *
2258 * This macro fixes the compiler error by explicitly overloading implicit
2259 * global operators !, && and || that take the given class instance as one of
2260 * their arguments.
2261 *
2262 * The best is to use this macro right after the class declaration.
2263 *
2264 * @note The macro expands to nothing for compilers other than MSVC.
2265 *
2266 * @param Cls Class to apply the workaround to
2267 */
2268#if defined(_MSC_VER)
2269# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
2270 inline bool operator! (const Cls &that) { return !bool (that); } \
2271 inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
2272 inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
2273 inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
2274 inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
2275#else
2276# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
2277#endif
2278
2279/** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL
2280 * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes.
2281 *
2282 * @param Tpl Name of the template class to apply the workaround to
2283 * @param ArgsDecl arguments of the template, as declared in |<>| after the
2284 * |template| keyword, including |<>|
2285 * @param Args arguments of the template, as specified in |<>| after the
2286 * template class name when using the, including |<>|
2287 *
2288 * Example:
2289 * @code
2290 * // template class declaration
2291 * template <class C>
2292 * class Foo { ... };
2293 * // applied workaround
2294 * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
2295 * @endcode
2296 */
2297#if defined(_MSC_VER)
2298# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
2299 template ArgsDecl \
2300 inline bool operator! (const Tpl Args &that) { return !bool (that); } \
2301 template ArgsDecl \
2302 inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
2303 template ArgsDecl \
2304 inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
2305 template ArgsDecl \
2306 inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
2307 template ArgsDecl \
2308 inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
2309#else
2310# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
2311#endif
2312
2313
2314/** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP
2315 * Declares the copy constructor and the assignment operation as inlined no-ops
2316 * (non-existent functions) for the given class. Use this macro inside the
2317 * private section if you want to effectively disable these operations for your
2318 * class.
2319 *
2320 * @param Cls class name to declare for
2321 */
2322
2323#define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
2324 inline Cls (const Cls &); \
2325 inline Cls &operator= (const Cls &);
2326
2327
2328/** @def DECLARE_CLS_NEW_DELETE_NOOP
2329 * Declares the new and delete operations as no-ops (non-existent functions)
2330 * for the given class. Use this macro inside the private section if you want
2331 * to effectively limit creating class instances on the stack only.
2332 *
2333 * @note The destructor of the given class must not be virtual, otherwise a
2334 * compile time error will occur. Note that this is not a drawback: having
2335 * the virtual destructor for a stack-based class is absolutely useless
2336 * (the real class of the stack-based instance is always known to the compiler
2337 * at compile time, so it will always call the correct destructor).
2338 *
2339 * @param Cls class name to declare for
2340 */
2341#define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
2342 inline static void *operator new (size_t); \
2343 inline static void operator delete (void *);
2344
2345#endif /* __cplusplus */
2346
2347/** @} */
2348
2349#endif
2350
Note: See TracBrowser for help on using the repository browser.

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