cdefs.h revision 5a4feaad69f041d8bfea6d541b339cdf630e9deb
* Defines the guest architecture bit count. * Declare a type differently in GC, R3 and R0. * @param GCType The GC type. * @param R3Type The R3 type. * @param R0Type The R0 type. * @remark For pointers used only in one context use RCPTRTYPE(), R3R0PTRTYPE(), R3PTRTYPE() or R0PTRTYPE(). * Declare a pointer which is used in the raw mode context but appears in structure(s) used by * both HC and RC. The main purpose is to make sure structures have the same * size when built for different architectures. * @param RCType The RC type. * Declare a pointer which is used in HC, is explicitely valid in ring 3 and 0, * but appears in structure(s) used by both HC and GC. The main purpose is to * make sure structures have the same size when built for different architectures. * @param R3R0Type The R3R0 type. * @remarks This used to be called HCPTRTYPE. * Declare a pointer which is used in R3 but appears in structure(s) used by * both HC and GC. The main purpose is to make sure structures have the same * size when built for different architectures. * @param R3Type The R3 type. * Declare a pointer which is used in R0 but appears in structure(s) used by * both HC and GC. The main purpose is to make sure structures have the same * size when built for different architectures. * @param R0Type The R0 type. * Adds the suffix of the current context to the passed in * identifier name. The suffix is HC or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param var Identifier name. * @deprecated Use CTX_SUFF. Do NOT use this for new code. * Adds the suffix of the other context to the passed in * identifier name. The suffix is HC or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param var Identifier name. * @deprecated Use CTX_SUFF. Do NOT use this for new code. * Adds the suffix of the current context to the passed in * identifier name. The suffix is R3, R0 or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param var Identifier name. * @deprecated Use CTX_SUFF. Do NOT use this for new code. * Adds the suffix of the current context to the passed in * identifier name. The suffix is R3, R0 or RC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param var Identifier name. * @remark This will replace CTXALLSUFF and CTXSUFF before long. * Adds the suffix of the current context to the passed in * identifier name, combining RC and R0 into RZ. * The suffix thus is R3 or RZ. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param var Identifier name. * @remark This will replace CTXALLSUFF and CTXSUFF before long. * Adds the current context as a middle name of an identifier name * The middle name is HC or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param first First name. * Adds the other context as a middle name of an identifier name * The middle name is HC or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param first First name. * @deprecated use CTX_MID or CTX_MID_Z * Adds the current context as a middle name of an identifier name. * The middle name is R3, R0 or GC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param first First name. * @deprecated use CTX_MID or CTX_MID_Z * Adds the current context as a middle name of an identifier name. * The middle name is R3, R0 or RC. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param first First name. * Adds the current context as a middle name of an identifier name, combining RC * The middle name thus is either R3 or RZ. * This is macro should only be used in shared code to avoid a forrest of ifdefs. * @param first First name. * A macro which in GC and R0 will return a dummy string while in R3 it will return * This is typically used to wrap description strings in structures shared * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING3 mess. * @param pR3String The R3 string. Only referenced in R3. * @see R0STRING and GCSTRING * A macro which in GC and R3 will return a dummy string while in R0 it will return * This is typically used to wrap description strings in structures shared * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING0 mess. * @param pR0String The R0 string. Only referenced in R0. * @see R3STRING and GCSTRING * A macro which in R3 and R0 will return a dummy string while in RC it will return * This is typically used to wrap description strings in structures shared * between R3, R0 and/or RC. The intention is to avoid the \#ifdef IN_RC mess. * @param pR0String The RC string. Only referenced in RC. * @see R3STRING, R0STRING * The standard calling convention for the Runtime interfaces. * How to express that a function doesn't throw C++ exceptions * and the compiler can thus save itself the bother of trying * to catch any of them. Put this between the closing parenthesis * and the semicolon in function prototypes (and implementation if C++). * How to declare an exported function. * @param type The return type of the function declaration. * How to declare an imported function. * @param type The return type of the function declaration. * How to declare a non-exported function or variable. * @param type The return type of the function or the data type of the variable. * How to declare an internal assembly function. * @param type The return type of the function declaration. * How to declare an internal assembly function type. * @param type The return type of the function. * How to declare a function which does not return. * @note: This macro can be combined with other macros, for example * EMR3DECL(DECLNORETURN(void)) foo(void); * How to declare an call back function type. * @param type The return type of the function declaration. * How to declare an call back function pointer. * @param type The return type of the function declaration. * @param name The name of the variable member. /** @def DECLCALLBACKMEMBER * How to declare an call back function pointer member. * @param type The return type of the function declaration. /** @def DECLR3CALLBACKMEMBER * How to declare an call back function pointer member - R3 Ptr. * @param type The return type of the function declaration. * @param args The argument list enclosed in parentheses. /** @def DECLRCCALLBACKMEMBER * How to declare an call back function pointer member - RC Ptr. * @param type The return type of the function declaration. * @param args The argument list enclosed in parentheses. /** @def DECLR0CALLBACKMEMBER * How to declare an call back function pointer member - R0 Ptr. * @param type The return type of the function declaration. * @param args The argument list enclosed in parentheses. * How to declare a function as inline. * @param type The return type of the function declaration. * @remarks Don't use this macro on C++ methods. * Used to inidicate whether we're linking against a static IPRT * or not. The IPRT symbols will be declared as hidden (if * supported). Note that this define has no effect without setting * IN_RT_R0, IN_RT_R3 or IN_RT_GC indicators are set first. * Used to indicate whether we're inside the same link module as * the HC Ring-0 Runtime Library. * Runtime Library HC Ring-0 export or import declaration. * @param type The return type of the function declaration. * Used to indicate whether we're inside the same link module as * the HC Ring-3 Runtime Library. * Runtime Library HC Ring-3 export or import declaration. * @param type The return type of the function declaration. * Used to indicate whether we're inside the same link module as * the GC Runtime Library. * Runtime Library HC Ring-3 export or import declaration. * @param type The return type of the function declaration. * Runtime Library export or import declaration. * Functions declared using this macro exists in all contexts. * @param type The return type of the function declaration. /** @def RTDATADECL(type) * Runtime Library export or import declaration. * Data declared using this macro exists in all contexts. * @param type The return type of the function declaration. * Symbol name wrapper for the No-CRT bits. * In order to coexist in the same process as other CRTs, we need to * decorate the symbols such that they don't conflict the ones in the * other CRTs. The result of such conflicts / duplicate symbols can * confuse the dynamic loader on unix like systems. * Define RT_WITHOUT_NOCRT_WRAPPERS to drop the wrapping. * Define RT_WITHOUT_NOCRT_WRAPPER_ALIASES to drop the aliases to the * Same as RT_NOCRT only it'll return a double quoted string of the result. * Give the compiler a hint that an expression is very likely to hold true. * Some compilers support explicit branch prediction so that the CPU backend * can hint the processor and also so that code blocks can be reordered such * that the predicted path sees a more linear flow, thus improving cache * IPRT provides the macros RT_LIKELY() and RT_UNLIKELY() as a way to utilize * this compiler feature when present. * A few notes about the usage: * - Generally, use RT_UNLIKELY() with error condition checks (unless you * have some _strong_ reason to do otherwise, in which case document it), * and/or RT_LIKELY() with success condition checks, assuming you want * to optimize for the success path. * - Other than that, if you don't know the likelihood of a test succeeding * from empirical or other 'hard' evidence, don't make predictions unless * you happen to be a Dirk Gently. * - These macros are meant to be used in places that get executed a lot. It * is wasteful to make predictions in code that is executed seldomly (e.g. * at subsystem initialization time) as the basic block reording that this * affecs can often generate larger code. * - Note that RT_SUCCESS() and RT_FAILURE() already makes use of RT_LIKELY() * and RT_UNLIKELY(). Should you wish for prediction free status checks, * use the RT_SUCCESS_NP() and RT_FAILURE_NP() macros instead. * @returns the boolean result of the expression. * @param expr The expression that's very likely to be true. * Give the compiler a hint that an expression is highly unlikely to hold true. * See the usage instructions give in the RT_LIKELY() docs. * @returns the boolean result of the expression. * @param expr The expression that's very unlikely to be true. * Make a bitmask for one integer sized bit. * Make a 32-bit bitmask for one bit. * Make a 64-bit bitmask for one bit. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @remark Be extremely careful when using this macro with type which sizeof != sizeof int. * When possible use any of the other RT_ALIGN_* macros. And when that's not * possible, make 101% sure that uAlignment is specified with a right sized type. * Specifying an unsigned 32-bit alignment constant with a 64-bit value will give * you a 32-bit return value! * In short: Don't use this macro. Use RT_ALIGN_T() instead. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @param type Integer type to use while aligning. * @remark This macro is the prefered alignment macro, it doesn't have any of the pitfalls RT_ALIGN has. * Align macro for a 32-bit value. * @param u32 Value to align. * @param uAlignment The alignment. Power of two! * Align macro for a 64-bit value. * @param u64 Value to align. * @param uAlignment The alignment. Power of two! * Align macro for size_t. * @param cb Value to align. * @param uAlignment The alignment. Power of two! * Align macro for pointers. * @param pv Value to align. * @param uAlignment The alignment. Power of two! * Align macro for pointers with type cast. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @param CastType The type to cast the result to. * Align macro for ring-3 pointers with type cast. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @param CastType The type to cast the result to. * Align macro for ring-0 pointers with type cast. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @param CastType The type to cast the result to. * Align macro for GC pointers with type cast. * @param u Value to align. * @param uAlignment The alignment. Power of two! * @param CastType The type to cast the result to. * Our own special offsetof() variant, returns a signed result. * This differs from the usual offsetof() in that it's not relying on builtin * compiler stuff and thus can use variables in arrays the structure may * contain. If in this usful to determin the sizes of structures ending * with a variable length field. * @returns offset into the structure of the specified member. signed. * @param type Structure type. * Our own special offsetof() variant, returns an unsigned result. * This differs from the usual offsetof() in that it's not relying on builtin * compiler stuff and thus can use variables in arrays the structure may * contain. If in this usful to determin the sizes of structures ending * with a variable length field. * @returns offset into the structure of the specified member. unsigned. * @param type Structure type. * Get the size of a structure member. * @returns size of the structure member. * @param type Structure type. * Calcs the number of elements in an array. * @returns Element count. * @param aArray Array in question. /* Undefine RT_MAX since there is an unfortunate clash with the max resource type define in os2.h. */ * Finds the maximum value. * @returns The higher of the two. * Finds the minimum value. * @returns The lower of the two. * Get the absolute (non-negative) value. * @returns The absolute value of Value. * @param Value The value. * Gets the low dword (=uint32_t) of something. */ * Gets the high dword (=uint32_t) of a 64-bit of something. */ * Gets the low word (=uint16_t) of something. */ * Gets the high word (=uint16_t) of a 32-bit something. */ * Gets the low byte of something. */ * Gets the low byte of a 16-bit something. */ * Gets first byte of something. */ * Gets second byte of something. */ * Gets second byte of something. */ #
define RT_BYTE3(a) (((a) >>
16) &
0xff)
* Gets fourth byte of something. */ #
define RT_BYTE4(a) (((a) >>
24) &
0xff)
* Constructs a uint64_t value from two uint32_t values. /** @def RT_MAKE_U64_FROM_U16 * Constructs a uint64_t value from four uint16_t values. /** @def RT_MAKE_U64_FROM_U8 * Constructs a uint64_t value from eight uint8_t values. * Constructs a uint32_t value from two uint16_t values. /** @def RT_MAKE_U32_FROM_U8 * Constructs a uint32_t value from four uint8_t values. * Constructs a uint32_t value from two uint16_t values. * Reverses the byte order of an uint64_t value. */ /** @todo use __builtin_constant_p? */ * Reverses the byte order of an uint32_t value. */ /** @todo use __builtin_constant_p? */ * Reverses the byte order of an uint16_t value. */ /** @todo use __builtin_constant_p? */ * Reverses the byte order of an uint64_t constant. */ * Reverses the byte order of an uint32_t constant. */ * Reverses the byte order of an uint16_t constant. */ * Converts an uint64_t value from host to little endian byte order. */ * Converts an uint64_t constant from host to little endian byte order. */ * Converts an uint32_t value from host to little endian byte order. */ * Converts an uint32_t constant from host to little endian byte order. */ * Converts an uint16_t value from host to little endian byte order. */ * Converts an uint16_t constant from host to little endian byte order. */ * Converts an uint64_t value from little endian to host byte order. */ * Converts an uint64_t constant from little endian to host byte order. */ * Converts an uint32_t value from little endian to host byte order. */ * Converts an uint32_t constant from little endian to host byte order. */ * Converts an uint16_t value from little endian to host byte order. */ * Converts an uint16_t constant from little endian to host byte order. */ * Converts an uint64_t value from host to big endian byte order. */ * Converts an uint64_t constant from host to big endian byte order. */ * Converts an uint32_t value from host to big endian byte order. */ * Converts an uint32_t constant from host to big endian byte order. */ * Converts an uint16_t value from host to big endian byte order. */ * Converts an uint16_t constant from host to big endian byte order. */ * Converts an uint64_t value from big endian to host byte order. */ * Converts an uint64_t constant from big endian to host byte order. */ * Converts an uint32_t value from big endian to host byte order. */ * Converts an uint32_t value from big endian to host byte order. */ * Converts an uint16_t value from big endian to host byte order. */ * Converts an uint16_t constant from big endian to host byte order. */ * Converts an uint64_t value from host to network byte order. */ * Converts an uint64_t constant from host to network byte order. */ * Converts an uint32_t value from host to network byte order. */ * Converts an uint32_t constant from host to network byte order. */ * Converts an uint16_t value from host to network byte order. */ * Converts an uint16_t constant from host to network byte order. */ * Converts an uint64_t value from network to host byte order. */ * Converts an uint64_t constant from network to host byte order. */ * Converts an uint32_t value from network to host byte order. */ * Converts an uint32_t constant from network to host byte order. */ * Converts an uint16_t value from network to host byte order. */ * Converts an uint16_t value from network to host byte order. */ * namespace pollution. Kill off some of the worse ones unless we're * Whenever we use offsets instead of pointers to save space and relocation effort * NIL_OFFSET shall be used as the equivalent to NULL. * Keeps the compiler from bitching about an unused parameters. * Emit a debug breakpoint instruction. * Use this for instrumenting a debugging session only! * No comitted code shall use Breakpoint(). #
error "This compiler is not supported!" * (Of course, these are binary computer terms, not SI.) /** 1 K (Kilo) (1 024). */ /** 4 K (Kilo) (4 096). */ /** 32 K (Kilo) (32 678). */ /** 64 K (Kilo) (65 536). */ /** 128 K (Kilo) (131 072). */ /** 256 K (Kilo) (262 144). */ /** 512 K (Kilo) (524 288). */ /** 1 M (Mega) (1 048 576). */ /** 2 M (Mega) (2 097 152). */ /** 4 M (Mega) (4 194 304). */ /** 1 G (Giga) (1 073 741 824). */ /** 2 G (Giga) (2 147 483 648). (32-bit) */ #
define _2G32 0x80000000U/** 2 G (Giga) (2 147 483 648). (64-bit) */ #
define _2G 0x0000000080000000LL/** 4 G (Giga) (4 294 967 296). */ #
define _4G 0x0000000100000000LL/** 1 T (Tera) (1 099 511 627 776). */ #
define _1T 0x0000010000000000LL/** 1 P (Peta) (1 125 899 906 842 624). */ #
define _1P 0x0004000000000000LL/** 1 E (Exa) (1 152 921 504 606 846 976). */ #
define _1E 0x1000000000000000LL/** 2 E (Exa) (2 305 843 009 213 693 952). */ #
define _2E 0x2000000000000000ULL * Pointer validation macro. #
if defined(
RT_OS_DARWIN)
/* first 4GB is reserved for legacy kernel. */#
elif defined(
RT_OS_SOLARIS)
/* The kernel only used the top 2TB, but keep it simple. */ && ( ((
uintptr_t)(
ptr) &
0xffff800000000000ULL) ==
0xffff800000000000ULL \
&& ( ((
uintptr_t)(
ptr) &
0xffff800000000000ULL) ==
0xffff800000000000ULL \
#
error "Architecture identifier missing / not implemented." * 32 bits physical address validation macro. * @param Phys The RTGCPHYS address. * The \#define N_ is used mark a string for translation. This is usable in * any part of the code, as it is only used by the tools that create message * catalogs. This macro is a no-op as far as the compiler and code generation * If you want to both mark a string for translation and translate it, use _. * The \#define _ is used mark a string for translation and to translate it in * If you want to only mark a string for translation, use N_. /** @def __PRETTY_FUNCTION__ * With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that for the other compilers. * The \#define RT_STRICT controls whether or not assertions and other runtime checks * should be compiled in or not. * If you want assertions which are not a subject to compile time options use * the AssertRelease*() flavors. /** Source position declaration. */ /** Source position arguments. */ /** @defgroup grp_rt_cdefs_cpp Special Macros for C++ /** @def DECLEXPORT_CLASS * How to declare an exported class. Place this macro after the 'class' * keyword in the declaration of every class you want to export. * @note It is necessary to use this macro even for inner classes declared * inside the already exported classes. This is a GCC specific requirement, * but it seems not to harm other compilers. /** @def DECLIMPORT_CLASS * How to declare an imported class Place this macro after the 'class' * keyword in the declaration of every class you want to export. * @note It is necessary to use this macro even for inner classes declared * inside the already exported classes. This is a GCC specific requirement, * but it seems not to harm other compilers. /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP * Macro to work around error C2593 of the not-so-smart MSVC 7.x ambiguity * resolver. The following snippet clearly demonstrates the code causing this * operator bool() const { return false; } * operator int*() const { return NULL; } * The code itself seems pretty valid to me and GCC thinks the same. * This macro fixes the compiler error by explicitly overloading implicit * global operators !, && and || that take the given class instance as one of * The best is to use this macro right after the class declaration. * @note The macro expands to nothing for compilers other than MSVC. * @param Cls Class to apply the workaround to /** @def WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL * Version of WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP for template classes. * @param Tpl Name of the template class to apply the workaround to * @param ArgsDecl arguments of the template, as declared in |<>| after the * |template| keyword, including |<>| * @param Args arguments of the template, as specified in |<>| after the * template class name when using the, including |<>| * // template class declaration * WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>) /** @def DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP * Declares the copy constructor and the assignment operation as inlined no-ops * (non-existent functions) for the given class. Use this macro inside the * private section if you want to effectively disable these operations for your * @param Cls class name to declare for /** @def DECLARE_CLS_NEW_DELETE_NOOP * Declares the new and delete operations as no-ops (non-existent functions) * for the given class. Use this macro inside the private section if you want * to effectively limit creating class instances on the stack only. * @note The destructor of the given class must not be virtual, otherwise a * compile time error will occur. Note that this is not a drawback: having * the virtual destructor for a stack-based class is absolutely useless * (the real class of the stack-based instance is always known to the compiler * at compile time, so it will always call the correct destructor). * @param Cls class name to declare for #
endif /* defined(__cplusplus) */