cdefs.h revision f95917a3bdcc968d668b50e45404ca3dda27945d
5fc50ecb8dc8ef74adfc1c1f0d4e144d7f4d8faestoddard/** @file
4ed92248676a091e0d73db61773d9059b36d0861stoddard * IPRT - Common C and C++ definitions.
4ed92248676a091e0d73db61773d9059b36d0861stoddard */
4ed92248676a091e0d73db61773d9059b36d0861stoddard
4ed92248676a091e0d73db61773d9059b36d0861stoddard/*
4ed92248676a091e0d73db61773d9059b36d0861stoddard * Copyright (C) 2006-2010 Oracle Corporation
4ed92248676a091e0d73db61773d9059b36d0861stoddard *
4ed92248676a091e0d73db61773d9059b36d0861stoddard * This file is part of VirtualBox Open Source Edition (OSE), as
4ed92248676a091e0d73db61773d9059b36d0861stoddard * available from http://www.virtualbox.org. This file is free software;
4ed92248676a091e0d73db61773d9059b36d0861stoddard * you can redistribute it and/or modify it under the terms of the GNU
b4b458e66e24979631466a69c4bae3090a7e50fewrowe * General Public License (GPL) as published by the Free Software
4ed92248676a091e0d73db61773d9059b36d0861stoddard * Foundation, in version 2 as it comes in the "COPYING" file of the
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4ed92248676a091e0d73db61773d9059b36d0861stoddard * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe *
752c83c97683b1fb9879ba874593a135155a043cwrowe * The contents of this file may alternatively be used under the terms
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * of the Common Development and Distribution License Version 1.0
6b441c81aae632befd971e634b4a36780c71d18ewrowe * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
424303d026faabb9e9752310911d00fa737b603awrowe * VirtualBox OSE distribution, in which case the provisions of the
424303d026faabb9e9752310911d00fa737b603awrowe * CDDL are applicable instead of those of the GPL.
424303d026faabb9e9752310911d00fa737b603awrowe *
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh * You may elect to license modified versions of this file under the
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * terms and conditions of either the GPL or the CDDL or both.
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe */
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#ifndef ___iprt_cdefs_h
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan#define ___iprt_cdefs_h
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe/** @defgroup grp_rt_cdefs IPRT Common Definitions and Macros
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * @{
4ed92248676a091e0d73db61773d9059b36d0861stoddard */
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh/*
38c8e9fef8d0536fb150af3be396f41a32d687adwrowe * Include sys/cdefs.h if present, if not define the stuff we need.
bcd36d1522403b4387451f8a17a528e632915e8dwrowe */
bcd36d1522403b4387451f8a17a528e632915e8dwrowe#ifdef HAVE_SYS_CDEFS_H
4ed92248676a091e0d73db61773d9059b36d0861stoddard# if defined(RT_ARCH_LINUX) && defined(__KERNEL__)
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# error "oops"
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# endif
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# include <sys/cdefs.h>
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe#else
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe/** @def RT_C_DECLS_BEGIN
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * Used to start a block of function declarations which are shared
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * between C and C++ program.
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe */
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe/** @def RT_C_DECLS_END
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * Used to end a block of function declarations which are shared
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * between C and C++ program.
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe */
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# if defined(__cplusplus)
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define RT_C_DECLS_BEGIN extern "C" {
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# define RT_C_DECLS_END }
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# else
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define RT_C_DECLS_BEGIN
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define RT_C_DECLS_END
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe# endif
6173077ec421fe85891d4b914c87175beb0a9293wrowe
c71d15c4b41b9d89e90e936d49b4e5a6db19244ewrowe#endif
6173077ec421fe85891d4b914c87175beb0a9293wrowe
6173077ec421fe85891d4b914c87175beb0a9293wrowe
c71d15c4b41b9d89e90e936d49b4e5a6db19244ewrowe/*
6173077ec421fe85891d4b914c87175beb0a9293wrowe * Shut up DOXYGEN warnings and guide it properly thru the code.
6173077ec421fe85891d4b914c87175beb0a9293wrowe */
b4b458e66e24979631466a69c4bae3090a7e50fewrowe#ifdef DOXYGEN_RUNNING
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define __AMD64__
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define __X86__
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define RT_ARCH_AMD64
6166dacd3c3d034394c1f8c131919ea7452835a7wrowe# define RT_ARCH_X86
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define IN_RING0
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define IN_RING3
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define IN_RC
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define IN_RC
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define IN_RT_RC
b4b458e66e24979631466a69c4bae3090a7e50fewrowe# define IN_RT_R0
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# define IN_RT_R3
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define IN_RT_STATIC
fa3f183306fa2ec98249f2afec904d403643a015wrowe# define RT_STRICT
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define RT_NO_STRICT
743aeb835754aadabaec38c00742899668eb9dd1wrowe# define RT_LOCK_STRICT
fa3f183306fa2ec98249f2afec904d403643a015wrowe# define RT_LOCK_NO_STRICT
a78b700fa90213df137e4178a9bd9c81aadd39d3wrowe# define RT_LOCK_STRICT_ORDER
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe# define RT_LOCK_NO_STRICT_ORDER
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define Breakpoint
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define RT_NO_DEPRECATED_MACROS
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define RT_EXCEPTIONS_ENABLED
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe# define RT_BIG_ENDIAN
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define RT_LITTLE_ENDIAN
743aeb835754aadabaec38c00742899668eb9dd1wrowe# define RT_COMPILER_GROKS_64BIT_BITFIELDS
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define RT_NO_VISIBILITY_HIDDEN
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe#endif /* DOXYGEN_RUNNING */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def RT_ARCH_X86
b4b458e66e24979631466a69c4bae3090a7e50fewrowe * Indicates that we're compiling for the X86 architecture.
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe */
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe/** @def RT_ARCH_AMD64
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * Indicates that we're compiling for the AMD64 architecture.
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe */
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def RT_ARCH_SPARC
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * Indicates that we're compiling for the SPARC V8 architecture (32-bit).
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def RT_ARCH_SPARC64
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * Indicates that we're compiling for the SPARC V9 architecture (64-bit).
92fb4b4faaea055db085fc0864950c2a5edd0de2jwoolley */
fa3f183306fa2ec98249f2afec904d403643a015wrowe#if !defined(RT_ARCH_X86) \
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe && !defined(RT_ARCH_AMD64) \
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe && !defined(RT_ARCH_SPARC) \
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe && !defined(RT_ARCH_SPARC64) \
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe && !defined(RT_ARCH_ARM)
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe# if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || defined(__AMD64__)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define RT_ARCH_AMD64
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# elif defined(__i386__) || defined(_M_IX86) || defined(__X86__)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define RT_ARCH_X86
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# elif defined(__sparcv9)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define RT_ARCH_SPARC64
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# elif defined(__sparc__)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define RT_ARCH_SPARC
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# elif defined(__arm__) || defined(__arm32__)
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# define RT_ARCH_ARM
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe# else /* PORTME: append test for new archs. */
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe# error "Check what predefined macros your compiler uses to indicate architecture."
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# endif
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe/* PORTME: append new archs checks. */
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe#elif defined(RT_ARCH_X86) && defined(RT_ARCH_AMD64)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_X86 and RT_ARCH_AMD64 cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_X86 and RT_ARCH_SPARC cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_X86) && defined(RT_ARCH_SPARC64)
413043ed189411cd1c673fc4911b583cb85c2c39wrowe# error "Both RT_ARCH_X86 and RT_ARCH_SPARC64 cannot be defined at the same time!"
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan#elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC)
7a9d2ce2e2f592e97c0d4819e0e6567efcc4ba7bwrowe# error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC cannot be defined at the same time!"
413043ed189411cd1c673fc4911b583cb85c2c39wrowe#elif defined(RT_ARCH_AMD64) && defined(RT_ARCH_SPARC64)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_AMD64 and RT_ARCH_SPARC64 cannot be defined at the same time!"
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan#elif defined(RT_ARCH_SPARC) && defined(RT_ARCH_SPARC64)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_SPARC and RT_ARCH_SPARC64 cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_ARM) && defined(RT_ARCH_AMD64)
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan# error "Both RT_ARCH_ARM and RT_ARCH_AMD64 cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_ARM) && defined(RT_ARCH_X86)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_ARM and RT_ARCH_X86 cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_ARM) && defined(RT_ARCH_SPARC64)
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe# error "Both RT_ARCH_ARM and RT_ARCH_SPARC64 cannot be defined at the same time!"
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe#elif defined(RT_ARCH_ARM) && defined(RT_ARCH_SPARC)
4ed92248676a091e0d73db61773d9059b36d0861stoddard# error "Both RT_ARCH_ARM and RT_ARCH_SPARC cannot be defined at the same time!"
071646a05417cc437fcffec9512588f75bd39a03wrowe#endif
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
424303d026faabb9e9752310911d00fa737b603awrowe
424303d026faabb9e9752310911d00fa737b603awrowe/** @def __X86__
424303d026faabb9e9752310911d00fa737b603awrowe * Indicates that we're compiling for the X86 architecture.
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * @deprecated
424303d026faabb9e9752310911d00fa737b603awrowe */
424303d026faabb9e9752310911d00fa737b603awrowe
424303d026faabb9e9752310911d00fa737b603awrowe/** @def __AMD64__
424303d026faabb9e9752310911d00fa737b603awrowe * Indicates that we're compiling for the AMD64 architecture.
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * @deprecated
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe */
f397bb616fba8b3a5a9b3c57a5c89ad0e254b673mturk#if !defined(__X86__) && !defined(__AMD64__) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh# if defined(RT_ARCH_AMD64)
6b441c81aae632befd971e634b4a36780c71d18ewrowe# define __AMD64__
6b441c81aae632befd971e634b4a36780c71d18ewrowe# elif defined(RT_ARCH_X86)
6b441c81aae632befd971e634b4a36780c71d18ewrowe# define __X86__
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# else
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# error "Check what predefined macros your compiler uses to indicate architecture."
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# endif
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe#elif defined(__X86__) && defined(__AMD64__)
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe# error "Both __X86__ and __AMD64__ cannot be defined at the same time!"
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe#elif defined(__X86__) && !defined(RT_ARCH_X86)
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe# error "__X86__ without RT_ARCH_X86!"
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe#elif defined(__AMD64__) && !defined(RT_ARCH_AMD64)
6b441c81aae632befd971e634b4a36780c71d18ewrowe# error "__AMD64__ without RT_ARCH_AMD64!"
7ffdcdd65e145ef18d9193d89bffff10c5da4961wrowe#endif
6b441c81aae632befd971e634b4a36780c71d18ewrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe/** @def RT_BIG_ENDIAN
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe * Defined if the architecture is big endian. */
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe/** @def RT_LITTLE_ENDIAN
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * Defined if the architecture is little endian. */
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_ARM)
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe# define RT_LITTLE_ENDIAN
4ed92248676a091e0d73db61773d9059b36d0861stoddard#elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe# define RT_BIG_ENDIAN
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe#else
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe# error "PORTME: architecture endianess"
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe#endif
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe#if defined(RT_BIG_ENDIAN) && defined(RT_LITTLE_ENDIAN)
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe# error "Both RT_BIG_ENDIAN and RT_LITTLE_ENDIAN are defined"
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe#endif
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe/** @def IN_RING0
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe * Used to indicate that we're compiling code which is running
98086904a5df1d6127b49bf06af39f23ff844889wrowe * in Ring-0 Host Context.
98086904a5df1d6127b49bf06af39f23ff844889wrowe */
b4b458e66e24979631466a69c4bae3090a7e50fewrowe
b4b458e66e24979631466a69c4bae3090a7e50fewrowe/** @def IN_RING3
b4b458e66e24979631466a69c4bae3090a7e50fewrowe * Used to indicate that we're compiling code which is running
b4b458e66e24979631466a69c4bae3090a7e50fewrowe * in Ring-3 Host Context.
b4b458e66e24979631466a69c4bae3090a7e50fewrowe */
4ed92248676a091e0d73db61773d9059b36d0861stoddard
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe/** @def IN_RC
4ed92248676a091e0d73db61773d9059b36d0861stoddard * Used to indicate that we're compiling code which is running
4ed92248676a091e0d73db61773d9059b36d0861stoddard * in the Raw-mode Context (implies R0).
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe */
4ed92248676a091e0d73db61773d9059b36d0861stoddard#if !defined(IN_RING3) && !defined(IN_RING0) && !defined(IN_RC) && !defined(IN_RC)
4ed92248676a091e0d73db61773d9059b36d0861stoddard# error "You must define which context the compiled code should run in; IN_RING3, IN_RING0 or IN_RC"
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe#endif
4ed92248676a091e0d73db61773d9059b36d0861stoddard#if (defined(IN_RING3) && (defined(IN_RING0) || defined(IN_RC)) ) \
4ed92248676a091e0d73db61773d9059b36d0861stoddard || (defined(IN_RING0) && (defined(IN_RING3) || defined(IN_RC)) ) \
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe || (defined(IN_RC) && (defined(IN_RING3) || defined(IN_RING0)) )
4ed92248676a091e0d73db61773d9059b36d0861stoddard# error "Only one of the IN_RING3, IN_RING0, IN_RC defines should be defined."
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe#endif
90f3e85cc3332e202aa198786798709fc55505d9wrowe
b4b458e66e24979631466a69c4bae3090a7e50fewrowe
b4b458e66e24979631466a69c4bae3090a7e50fewrowe/** @def ARCH_BITS
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe * Defines the bit count of the current context.
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe */
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe#if !defined(ARCH_BITS) || defined(DOXYGEN_RUNNING)
b4b458e66e24979631466a69c4bae3090a7e50fewrowe# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64)
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe# define ARCH_BITS 64
4ed92248676a091e0d73db61773d9059b36d0861stoddard# else
4ed92248676a091e0d73db61773d9059b36d0861stoddard# define ARCH_BITS 32
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe# endif
4ed92248676a091e0d73db61773d9059b36d0861stoddard#endif
4ed92248676a091e0d73db61773d9059b36d0861stoddard
4ed92248676a091e0d73db61773d9059b36d0861stoddard/** @def HC_ARCH_BITS
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * Defines the host architecture bit count.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#if !defined(HC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
4ed92248676a091e0d73db61773d9059b36d0861stoddard# ifndef IN_RC
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe# define HC_ARCH_BITS ARCH_BITS
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe# else
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe# define HC_ARCH_BITS 32
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# endif
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe#endif
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe/** @def GC_ARCH_BITS
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe * Defines the guest architecture bit count.
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe */
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe#if !defined(GC_ARCH_BITS) && !defined(DOXYGEN_RUNNING)
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# ifdef VBOX_WITH_64_BITS_GUESTS
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe# define GC_ARCH_BITS 64
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# else
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# define GC_ARCH_BITS 32
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# endif
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe#endif
06bd11dc20356466f38185ddb47fc798b4508d5fwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/** @def R3_ARCH_BITS
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Defines the host ring-3 architecture bit count.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#if !defined(R3_ARCH_BITS) || defined(DOXYGEN_RUNNING)
413043ed189411cd1c673fc4911b583cb85c2c39wrowe# ifdef IN_RING3
5158d1bbe54607d02bb5e5b2219e7aed4684e41btdonovan# define R3_ARCH_BITS ARCH_BITS
413043ed189411cd1c673fc4911b583cb85c2c39wrowe# else
413043ed189411cd1c673fc4911b583cb85c2c39wrowe# define R3_ARCH_BITS HC_ARCH_BITS
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan# endif
7a9d2ce2e2f592e97c0d4819e0e6567efcc4ba7bwrowe#endif
413043ed189411cd1c673fc4911b583cb85c2c39wrowe
413043ed189411cd1c673fc4911b583cb85c2c39wrowe/** @def R0_ARCH_BITS
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * Defines the host ring-0 architecture bit count.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#if !defined(R0_ARCH_BITS) || defined(DOXYGEN_RUNNING)
c3200c488bb3f941a88d5bed94abef0f46946bd3wrowe# ifdef IN_RING0
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe# define R0_ARCH_BITS ARCH_BITS
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# else
4ed92248676a091e0d73db61773d9059b36d0861stoddard# define R0_ARCH_BITS HC_ARCH_BITS
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# endif
14d27a22a8fdb25e6e82d8af853a63bd4c6bd894wrowe#endif
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe/** @def GC_ARCH_BITS
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe * Defines the guest architecture bit count.
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe */
9106bbba512da6e81bb4feb268bbd17435354d79wrowe#if !defined(GC_ARCH_BITS) || defined(DOXYGEN_RUNNING)
9106bbba512da6e81bb4feb268bbd17435354d79wrowe# ifdef IN_RC
9106bbba512da6e81bb4feb268bbd17435354d79wrowe# define GC_ARCH_BITS ARCH_BITS
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe# else
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe# define GC_ARCH_BITS 32
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe# endif
1a1462ebfd091853d54071a693fc7ad4c5573f8awrowe#endif
483ed5892604266e702d65db4d0b2b621c488a09wrowe
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe
bc21ce13cec2409c8fdb7122154636b2df97715ajerenkrantz/** @def CTXTYPE
34e753c9dba1e821f54f0d4179f8774f854123eecolm * Declare a type differently in GC, R3 and R0.
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe *
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe * @param GCType The GC type.
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe * @param R3Type The R3 type.
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * @param R0Type The R0 type.
ac19b3a64a76401bc7e4e378b51c245a7e8516a5mturk * @remark For pointers used only in one context use RCPTRTYPE(), R3R0PTRTYPE(), R3PTRTYPE() or R0PTRTYPE().
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe */
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe#ifdef IN_RC
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe# define CTXTYPE(GCType, R3Type, R0Type) GCType
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe#elif defined(IN_RING3)
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe# define CTXTYPE(GCType, R3Type, R0Type) R3Type
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe#else
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe# define CTXTYPE(GCType, R3Type, R0Type) R0Type
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe#endif
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/** @def RCPTRTYPE
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Declare a pointer which is used in the raw mode context but appears in structure(s) used by
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * both HC and RC. The main purpose is to make sure structures have the same
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk * size when built for different architectures.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk * @param RCType The RC type.
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk */
483ed5892604266e702d65db4d0b2b621c488a09wrowe#define RCPTRTYPE(RCType) CTXTYPE(RCType, RTRCPTR, RTRCPTR)
483ed5892604266e702d65db4d0b2b621c488a09wrowe
483ed5892604266e702d65db4d0b2b621c488a09wrowe/** @def R3R0PTRTYPE
483ed5892604266e702d65db4d0b2b621c488a09wrowe * Declare a pointer which is used in HC, is explicitly valid in ring 3 and 0,
483ed5892604266e702d65db4d0b2b621c488a09wrowe * but appears in structure(s) used by both HC and GC. The main purpose is to
483ed5892604266e702d65db4d0b2b621c488a09wrowe * make sure structures have the same size when built for different architectures.
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe *
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * @param R3R0Type The R3R0 type.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * @remarks This used to be called HCPTRTYPE.
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe */
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe#define R3R0PTRTYPE(R3R0Type) CTXTYPE(RTHCPTR, R3R0Type, R3R0Type)
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe/** @def R3PTRTYPE
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * Declare a pointer which is used in R3 but appears in structure(s) used by
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * both HC and GC. The main purpose is to make sure structures have the same
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * size when built for different architectures.
0f488df653e7e8cf4ee0006a3138f9474ca1d375wrowe *
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * @param R3Type The R3 type.
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe */
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe#define R3PTRTYPE(R3Type) CTXTYPE(RTHCUINTPTR, R3Type, RTHCUINTPTR)
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe/** @def R0PTRTYPE
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * Declare a pointer which is used in R0 but appears in structure(s) used by
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * both HC and GC. The main purpose is to make sure structures have the same
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * size when built for different architectures.
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe *
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * @param R0Type The R0 type.
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe */
b23117c3c7034b6e61dac1b0ffebd256950abb56wrowe#define R0PTRTYPE(R0Type) CTXTYPE(RTHCUINTPTR, RTHCUINTPTR, R0Type)
483ed5892604266e702d65db4d0b2b621c488a09wrowe
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe/** @def CTXSUFF
b23117c3c7034b6e61dac1b0ffebd256950abb56wrowe * Adds the suffix of the current context to the passed in
483ed5892604266e702d65db4d0b2b621c488a09wrowe * identifier name. The suffix is HC or GC.
b23117c3c7034b6e61dac1b0ffebd256950abb56wrowe *
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
175ab758dce807990c2cfd281ffced0dd8f7d2f4nd * @param var Identifier name.
92e403ad9206eea8af7bd426fd1a19d531816d83wrowe * @deprecated Use CTX_SUFF. Do NOT use this for new code.
58b8ccdd4dbf4b314e016de6eeebfe45be45451end */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def OTHERCTXSUFF
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * Adds the suffix of the other context to the passed in
255d4d329b2d41e4ac0c3ade5cfe528a078ef682wrowe * identifier name. The suffix is HC or GC.
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
483ed5892604266e702d65db4d0b2b621c488a09wrowe * @param var Identifier name.
3e156d3e4514cf57f8ac77e275a68d1c12a3b937wrowe * @deprecated Use CTX_SUFF. Do NOT use this for new code.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe#ifdef IN_RC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTXSUFF(var) var##GC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define OTHERCTXSUFF(var) var##HC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#else
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTXSUFF(var) var##HC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define OTHERCTXSUFF(var) var##GC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/** @def CTXALLSUFF
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Adds the suffix of the current context to the passed in
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * identifier name. The suffix is R3, R0 or GC.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
24b0a59507af2a3621f586fa2a2aafc3640aa3d2nd * This is macro should only be used in shared code to avoid a forest of ifdefs.
5a51653135041ee35b24fa67453bff4e9f8e3591wrowe * @param var Identifier name.
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * @deprecated Use CTX_SUFF. Do NOT use this for new code.
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#ifdef IN_RC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTXALLSUFF(var) var##GC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#elif defined(IN_RING0)
0e6bee8eb9112f77eb50766e58424afac61104d9wrowe# define CTXALLSUFF(var) var##R0
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#else
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTXALLSUFF(var) var##R3
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
995f5596d461cdd916f9ae5b7b4dcd27efbc3c2fwrowe/** @def CTX_SUFF
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * Adds the suffix of the current context to the passed in
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe * identifier name. The suffix is R3, R0 or RC.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * @param var Identifier name.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
3ea7933c5a74b8d8d54ec2689190a865a0689420wrowe * @remark This will replace CTXALLSUFF and CTXSUFF before long.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#ifdef IN_RC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTX_SUFF(var) var##RC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#elif defined(IN_RING0)
a21b3b9d8ebb12fd51fa1d17e44d5644a35a9a5fnd# define CTX_SUFF(var) var##R0
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe#else
f4b681ff0aa05efee56b42a893911f28c3ad931ewrowe# define CTX_SUFF(var) var##R3
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
522c5d883dd6489e5b3583c52502365e09d64382mturk
522c5d883dd6489e5b3583c52502365e09d64382mturk/** @def CTX_SUFF_Z
2d7d2ccd828d0424f046b62d57e5551cf8ee293fwrowe * Adds the suffix of the current context to the passed in
50c06405bc48121db2913925549407fd3e79bcedmturk * identifier name, combining RC and R0 into RZ.
2d7d2ccd828d0424f046b62d57e5551cf8ee293fwrowe * The suffix thus is R3 or RZ.
2d7d2ccd828d0424f046b62d57e5551cf8ee293fwrowe *
f4b681ff0aa05efee56b42a893911f28c3ad931ewrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
483ed5892604266e702d65db4d0b2b621c488a09wrowe * @param var Identifier name.
483ed5892604266e702d65db4d0b2b621c488a09wrowe *
483ed5892604266e702d65db4d0b2b621c488a09wrowe * @remark This will replace CTXALLSUFF and CTXSUFF before long.
483ed5892604266e702d65db4d0b2b621c488a09wrowe */
483ed5892604266e702d65db4d0b2b621c488a09wrowe#ifdef IN_RING3
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define CTX_SUFF_Z(var) var##R3
483ed5892604266e702d65db4d0b2b621c488a09wrowe#else
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define CTX_SUFF_Z(var) var##RZ
483ed5892604266e702d65db4d0b2b621c488a09wrowe#endif
483ed5892604266e702d65db4d0b2b621c488a09wrowe
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe
483ed5892604266e702d65db4d0b2b621c488a09wrowe/** @def CTXMID
483ed5892604266e702d65db4d0b2b621c488a09wrowe * Adds the current context as a middle name of an identifier name
483ed5892604266e702d65db4d0b2b621c488a09wrowe * The middle name is HC or GC.
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe *
fa3f183306fa2ec98249f2afec904d403643a015wrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe * @param first First name.
743aeb835754aadabaec38c00742899668eb9dd1wrowe * @param last Surname.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
743aeb835754aadabaec38c00742899668eb9dd1wrowe/** @def OTHERCTXMID
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe * Adds the other context as a middle name of an identifier name
91884afe32b87f355822244b8c123ea5b770368fwrowe * The middle name is HC or GC.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe *
ea63537bfba2de6945fb6b4e5ceddf130e3bc0ecwrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
c82ccb99a59cb210c31b096a567e393e59d558f3colm * @param first First name.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * @param last Surname.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * @deprecated use CTX_MID or CTX_MID_Z
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe#ifdef IN_RC
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define CTXMID(first, last) first##GC##last
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define OTHERCTXMID(first, last) first##HC##last
91884afe32b87f355822244b8c123ea5b770368fwrowe#else
29fc13ae8c586a980b0d4e8cba4546b370a951e6wrowe# define CTXMID(first, last) first##HC##last
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define OTHERCTXMID(first, last) first##GC##last
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
29fc13ae8c586a980b0d4e8cba4546b370a951e6wrowe
4ed92248676a091e0d73db61773d9059b36d0861stoddard/** @def CTXALLMID
4c35be7cad99269afb697fccc1b9ba85dd2ce702wrowe * Adds the current context as a middle name of an identifier name.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * The middle name is R3, R0 or GC.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe *
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * @param first First name.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * @param last Surname.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * @deprecated use CTX_MID or CTX_MID_Z
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe */
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe#ifdef IN_RC
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define CTXALLMID(first, last) first##GC##last
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe#elif defined(IN_RING0)
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe# define CTXALLMID(first, last) first##R0##last
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe#else
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe# define CTXALLMID(first, last) first##R3##last
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe#endif
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe/** @def CTX_MID
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * Adds the current context as a middle name of an identifier name.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * The middle name is R3, R0 or RC.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe *
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * @param first First name.
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe * @param last Surname.
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe */
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe#ifdef IN_RC
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define CTX_MID(first, last) first##RC##last
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe#elif defined(IN_RING0)
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe# define CTX_MID(first, last) first##R0##last
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe#else
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe# define CTX_MID(first, last) first##R3##last
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe#endif
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe/** @def CTX_MID_Z
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * Adds the current context as a middle name of an identifier name, combining RC
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * and R0 into RZ.
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * The middle name thus is either R3 or RZ.
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe *
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * This is macro should only be used in shared code to avoid a forest of ifdefs.
634c70c6512b0ae61fb1ee130266e6e9af170803wrowe * @param first First name.
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * @param last Surname.
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe */
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe#ifdef IN_RING3
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe# define CTX_MID_Z(first, last) first##R3##last
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe#else
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe# define CTX_MID_Z(first, last) first##RZ##last
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe#endif
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
634c70c6512b0ae61fb1ee130266e6e9af170803wrowe/** @def R3STRING
743aeb835754aadabaec38c00742899668eb9dd1wrowe * A macro which in GC and R0 will return a dummy string while in R3 it will return
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe * the parameter.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe *
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe * This is typically used to wrap description strings in structures shared
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING3 mess.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe *
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe * @param pR3String The R3 string. Only referenced in R3.
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe * @see R0STRING and GCSTRING
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#ifdef IN_RING3
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define R3STRING(pR3String) (pR3String)
14d27a22a8fdb25e6e82d8af853a63bd4c6bd894wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define R3STRING(pR3String) ("<R3_STRING>")
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe#endif
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe/** @def R0STRING
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe * A macro which in GC and R3 will return a dummy string while in R0 it will return
a04a085d201d1620c077ba6ecaa7022b417b1cd5tdonovan * the parameter.
721a5708aab94cd3587ecff3c5775c985efb7125wrowe *
cfab5b5b6dc82c578597b582f76491c96b86eeb7wrowe * This is typically used to wrap description strings in structures shared
f71283367c234bf49ddc8ba7b23d3d3829db0d8dmturk * between R3, R0 and/or GC. The intention is to avoid the \#ifdef IN_RING0 mess.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe *
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @param pR0String The R0 string. Only referenced in R0.
483ed5892604266e702d65db4d0b2b621c488a09wrowe * @see R3STRING and GCSTRING
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
bc21ce13cec2409c8fdb7122154636b2df97715ajerenkrantz#ifdef IN_RING0
34e753c9dba1e821f54f0d4179f8774f854123eecolm# define R0STRING(pR0String) (pR0String)
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define R0STRING(pR0String) ("<R0_STRING>")
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe/** @def RCSTRING
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * A macro which in R3 and R0 will return a dummy string while in RC it will return
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * the parameter.
ac19b3a64a76401bc7e4e378b51c245a7e8516a5mturk *
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * This is typically used to wrap description strings in structures shared
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * between R3, R0 and/or RC. The intention is to avoid the \#ifdef IN_RC mess.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe *
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * @param pRCString The RC string. Only referenced in RC.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @see R3STRING, R0STRING
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk#ifdef IN_RC
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RCSTRING(pRCString) (pRCString)
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk#else
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk# define RCSTRING(pRCString) ("<RC_STRING>")
483ed5892604266e702d65db4d0b2b621c488a09wrowe#endif
483ed5892604266e702d65db4d0b2b621c488a09wrowe
483ed5892604266e702d65db4d0b2b621c488a09wrowe
483ed5892604266e702d65db4d0b2b621c488a09wrowe/** @def RT_NOTHING
ee8892ba26f52316734c59d8002ab349c2e3fdbdcolm * A macro that expands to nothing.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * This is primarily intended as a dummy argument for macros to avoid the
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * undefined behavior passing empty arguments to an macro (ISO C90 and C++98,
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * gcc v4.4 warns about it).
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe */
0f488df653e7e8cf4ee0006a3138f9474ca1d375wrowe#define RT_NOTHING
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe
0f488df653e7e8cf4ee0006a3138f9474ca1d375wrowe/** @def RT_GCC_EXTENSION
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe * Macro for shutting up GCC warnings about using language extensions. */
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe#ifdef __GNUC__
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_GCC_EXTENSION __extension__
483ed5892604266e702d65db4d0b2b621c488a09wrowe#else
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_GCC_EXTENSION
483ed5892604266e702d65db4d0b2b621c488a09wrowe#endif
7c11b20dfccedb7381518b3cc3cc9ef9e6731cb1wrowe
7bffd59eadbb9e58f17fd29655fce6509fc1bb36niq/** @def RT_COMPILER_GROKS_64BIT_BITFIELDS
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * Macro that is defined if the compiler understands 64-bit bitfields. */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#if !defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__))
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe# define RT_COMPILER_GROKS_64BIT_BITFIELDS
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe#endif
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def RT_COMPILER_WITH_80BIT_LONG_DOUBLE
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * Macro that is defined if the compiler implements long double as the
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe * IEEE extended precision floating. */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#if (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) && !defined(RT_OS_WINDOWS)
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_COMPILER_WITH_80BIT_LONG_DOUBLE
3e156d3e4514cf57f8ac77e275a68d1c12a3b937wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def RT_EXCEPTIONS_ENABLED
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * Defined when C++ exceptions are enabled.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#if !defined(RT_EXCEPTIONS_ENABLED) \
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe && defined(__cplusplus) \
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe && ( (defined(_MSC_VER) && defined(_CPPUNWIND)) \
24b0a59507af2a3621f586fa2a2aafc3640aa3d2nd || (defined(__GNUC__) && defined(__EXCEPTIONS)))
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RT_EXCEPTIONS_ENABLED
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def RT_NO_THROW
0e6bee8eb9112f77eb50766e58424afac61104d9wrowe * How to express that a function doesn't throw C++ exceptions
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * and the compiler can thus save itself the bother of trying
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * to catch any of them. Put this between the closing parenthesis
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * and the semicolon in function prototypes (and implementation if C++).
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#ifdef RT_EXCEPTIONS_ENABLED
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RT_NO_THROW throw()
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RT_NO_THROW
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def RT_THROW
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * How to express that a method or function throws a type of exceptions. Some
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * compilers does not want this kind of information and will warning about it.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe *
a21b3b9d8ebb12fd51fa1d17e44d5644a35a9a5fnd * @param type The type exception.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe *
522c5d883dd6489e5b3583c52502365e09d64382mturk * @remarks If the actual throwing is done from the header, enclose it by
522c5d883dd6489e5b3583c52502365e09d64382mturk * \#ifdef RT_EXCEPTIONS_ENABLED ... \#else ... \#endif so the header
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * compiles cleanly without exceptions enabled.
50c06405bc48121db2913925549407fd3e79bcedmturk *
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * Do NOT use this for the actual throwing of exceptions!
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
483ed5892604266e702d65db4d0b2b621c488a09wrowe#ifdef RT_EXCEPTIONS_ENABLED
483ed5892604266e702d65db4d0b2b621c488a09wrowe# ifdef _MSC_VER
483ed5892604266e702d65db4d0b2b621c488a09wrowe# if _MSC_VER >= 1310
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_THROW(type)
483ed5892604266e702d65db4d0b2b621c488a09wrowe# else
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_THROW(type) throw(type)
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# endif
483ed5892604266e702d65db4d0b2b621c488a09wrowe# else
483ed5892604266e702d65db4d0b2b621c488a09wrowe# define RT_THROW(type) throw(type)
483ed5892604266e702d65db4d0b2b621c488a09wrowe# endif
752c83c97683b1fb9879ba874593a135155a043cwrowe#else
752c83c97683b1fb9879ba874593a135155a043cwrowe# define RT_THROW(type)
752c83c97683b1fb9879ba874593a135155a043cwrowe#endif
752c83c97683b1fb9879ba874593a135155a043cwrowe
752c83c97683b1fb9879ba874593a135155a043cwrowe/** @def RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * Indicates that the "hidden" visibility attribute can be used (GCC) */
752c83c97683b1fb9879ba874593a135155a043cwrowe#if defined(__GNUC__)
ea63537bfba2de6945fb6b4e5ceddf130e3bc0ecwrowe# if __GNUC__ >= 4 && !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
c82ccb99a59cb210c31b096a567e393e59d558f3colm# define RT_GCC_SUPPORTS_VISIBILITY_HIDDEN
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
c639d9d16cb8ac0ea8163c8c46e34ef9c6810ce2wrowe/** @def RTCALL
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * The standard calling convention for the Runtime interfaces.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#ifdef _MSC_VER
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RTCALL __cdecl
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#elif defined(RT_OS_OS2)
287f1ad541b1b895b2e5c7150d47471713100d1emturk# define RTCALL __cdecl
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#elif defined(__GNUC__) && defined(IN_RING0) \
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe && !(defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)) /* the latter is kernel/gcc */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RTCALL __attribute__((cdecl,regparm(0)))
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define RTCALL
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
087e59fbe3a245960f2cbc9750181a9aba7a4f24wrowe/** @def DECLEXPORT
18062914633d6aa27c5f07c6ed20e3d169714c89wrowe * How to declare an exported function.
18062914633d6aa27c5f07c6ed20e3d169714c89wrowe * @param type The return type of the function declaration.
1462f24d09bed587fcdfb69abf1e858598a06382wrowe */
1462f24d09bed587fcdfb69abf1e858598a06382wrowe#if defined(_MSC_VER) || defined(RT_OS_OS2)
bdf8917ac686167be51db99d7cf238fa51f5be02wrowe# define DECLEXPORT(type) __declspec(dllexport) type
37e7fdce0a4809a6c4cd3c102fc4668a6659ca95wrowe#elif defined(RT_USE_VISIBILITY_DEFAULT)
1462f24d09bed587fcdfb69abf1e858598a06382wrowe# define DECLEXPORT(type) __attribute__((visibility("default"))) type
25813a71353f3b45ca1ddda037b395cced603564slive#else
424303d026faabb9e9752310911d00fa737b603awrowe# define DECLEXPORT(type) type
424303d026faabb9e9752310911d00fa737b603awrowe#endif
0bfd482e54583b43b826299aa6c9853f703191edwrowe
37e7fdce0a4809a6c4cd3c102fc4668a6659ca95wrowe/** @def DECLIMPORT
341fe490659bc00823087e34c84ae13567d9fb8fwrowe * How to declare an imported function.
37e7fdce0a4809a6c4cd3c102fc4668a6659ca95wrowe * @param type The return type of the function declaration.
37e7fdce0a4809a6c4cd3c102fc4668a6659ca95wrowe */
37e7fdce0a4809a6c4cd3c102fc4668a6659ca95wrowe#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
1462f24d09bed587fcdfb69abf1e858598a06382wrowe# define DECLIMPORT(type) __declspec(dllimport) type
1462f24d09bed587fcdfb69abf1e858598a06382wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define DECLIMPORT(type) type
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def DECLHIDDEN
fdc76d3c3f3fea82ba0f1d8af646f8ea5e4734a2wrowe * How to declare a non-exported function or variable.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @param type The return type of the function or the data type of the variable.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#if !defined(RT_GCC_SUPPORTS_VISIBILITY_HIDDEN) || defined(RT_NO_VISIBILITY_HIDDEN)
875f57a863e8f7522f78c370e25db2a552231ca8wrowe# define DECLHIDDEN(type) type
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe# define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
752c83c97683b1fb9879ba874593a135155a043cwrowe#endif
875f57a863e8f7522f78c370e25db2a552231ca8wrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def DECL_HIDDEN_CONST
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * Workaround for g++ warnings when applying the hidden attribute to a const
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * definition. Use DECLHIDDEN for the declaration.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * @param a_Type The return type of the function or the data type of
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * the variable.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe#if defined(__cplusplus) && defined(__GNUC__)
f99d4fa2605925f385a184ba3789be3423690533wrowe# define DECL_HIDDEN_CONST(a_Type) a_Type
f99d4fa2605925f385a184ba3789be3423690533wrowe#else
25b0d23db56d263195cb27b77ee4c06a4bac92a3wrowe# define DECL_HIDDEN_CONST(a_Type) DECLHIDDEN(a_Type)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe#endif
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def DECL_INVALID
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * How to declare a function not available for linking in the current context.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * The purpose is to create compile or like time errors when used. This isn't
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * possible on all platforms.
f2f6daffb4236c6781e779e57561581c92a1f539wrowe * @param type The return type of the function.
19725e678f8b916b0952a002356d2098301e9727wrowe */
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe#if defined(_MSC_VER)
19725e678f8b916b0952a002356d2098301e9727wrowe# define DECL_INVALID(type) __declspec(dllimport) type __stdcall
19725e678f8b916b0952a002356d2098301e9727wrowe#elif defined(__GNUC__) && defined(__cplusplus)
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# define DECL_INVALID(type) extern "C++" type
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe#else
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe# define DECL_INVALID(type) type
19725e678f8b916b0952a002356d2098301e9727wrowe#endif
19725e678f8b916b0952a002356d2098301e9727wrowe
19725e678f8b916b0952a002356d2098301e9727wrowe/** @def DECLASM
823627d210d6c8bf02aec333587428584b29b6e2wrowe * How to declare an internal assembly function.
823627d210d6c8bf02aec333587428584b29b6e2wrowe * @param type The return type of the function declaration.
823627d210d6c8bf02aec333587428584b29b6e2wrowe */
19725e678f8b916b0952a002356d2098301e9727wrowe#ifdef __cplusplus
75202015bdb6602aaea6d187db3e2a922dd2526ewrowe# if defined(_MSC_VER) || defined(RT_OS_OS2)
19725e678f8b916b0952a002356d2098301e9727wrowe# define DECLASM(type) extern "C" type __cdecl
f2f6daffb4236c6781e779e57561581c92a1f539wrowe# elif defined(__GNUC__) && defined(RT_ARCH_X86)
f2f6daffb4236c6781e779e57561581c92a1f539wrowe# define DECLASM(type) extern "C" type __attribute__((cdecl,regparm(0)))
f2f6daffb4236c6781e779e57561581c92a1f539wrowe# else
19725e678f8b916b0952a002356d2098301e9727wrowe# define DECLASM(type) extern "C" type
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# endif
19725e678f8b916b0952a002356d2098301e9727wrowe#else
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# if defined(_MSC_VER) || defined(RT_OS_OS2)
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# define DECLASM(type) type __cdecl
19725e678f8b916b0952a002356d2098301e9727wrowe# elif defined(__GNUC__) && defined(RT_ARCH_X86)
25b0d23db56d263195cb27b77ee4c06a4bac92a3wrowe# define DECLASM(type) type __attribute__((cdecl,regparm(0)))
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# else
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# define DECLASM(type) type
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe# endif
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe#endif
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe/** @def DECLASMTYPE
19725e678f8b916b0952a002356d2098301e9727wrowe * How to declare an internal assembly function type.
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe * @param type The return type of the function.
032eeda9f618fa26f635c9e8dfd854c17e76262fwrowe */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# if defined(_MSC_VER) || defined(RT_OS_OS2)
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe# define DECLASMTYPE(type) type __cdecl
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe#else
19725e678f8b916b0952a002356d2098301e9727wrowe# define DECLASMTYPE(type) type
823627d210d6c8bf02aec333587428584b29b6e2wrowe#endif
823627d210d6c8bf02aec333587428584b29b6e2wrowe
823627d210d6c8bf02aec333587428584b29b6e2wrowe/** @def DECLNORETURN
19725e678f8b916b0952a002356d2098301e9727wrowe * How to declare a function which does not return.
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe * @note: This macro can be combined with other macros, for example
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe * @code
f1b8465dec39c934d4bef4a2366139ffdd021851wrowe * EMR3DECL(DECLNORETURN(void)) foo(void);
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * @endcode
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe#ifdef _MSC_VER
19725e678f8b916b0952a002356d2098301e9727wrowe# define DECLNORETURN(type) __declspec(noreturn) type
19725e678f8b916b0952a002356d2098301e9727wrowe#elif defined(__GNUC__)
746e483939cf8224eb881df41df75ef524d18223wrowe# define DECLNORETURN(type) __attribute__((noreturn)) type
19725e678f8b916b0952a002356d2098301e9727wrowe#else
f2f6daffb4236c6781e779e57561581c92a1f539wrowe# define DECLNORETURN(type) type
f2f6daffb4236c6781e779e57561581c92a1f539wrowe#endif
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def DECLCALLBACK
875f57a863e8f7522f78c370e25db2a552231ca8wrowe * How to declare an call back function type.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * @param type The return type of the function declaration.
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe */
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe#define DECLCALLBACK(type) type RTCALL
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe/** @def DECLCALLBACKPTR
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * How to declare an call back function pointer.
f99d4fa2605925f385a184ba3789be3423690533wrowe * @param type The return type of the function declaration.
f99d4fa2605925f385a184ba3789be3423690533wrowe * @param name The name of the variable member.
72347cd608351452f99d5f4411d3e0c089d0293awrowe */
f99d4fa2605925f385a184ba3789be3423690533wrowe#define DECLCALLBACKPTR(type, name) type (RTCALL * name)
f99d4fa2605925f385a184ba3789be3423690533wrowe
f99d4fa2605925f385a184ba3789be3423690533wrowe/** @def DECLCALLBACKMEMBER
f99d4fa2605925f385a184ba3789be3423690533wrowe * How to declare an call back function pointer member.
8dda6d649a6e3be9888cd49f1d8c703d3740a06fwrowe * @param type The return type of the function declaration.
8dda6d649a6e3be9888cd49f1d8c703d3740a06fwrowe * @param name The name of the struct/union/class member.
8dda6d649a6e3be9888cd49f1d8c703d3740a06fwrowe */
72347cd608351452f99d5f4411d3e0c089d0293awrowe#define DECLCALLBACKMEMBER(type, name) type (RTCALL * name)
f99d4fa2605925f385a184ba3789be3423690533wrowe
f99d4fa2605925f385a184ba3789be3423690533wrowe/** @def DECLR3CALLBACKMEMBER
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe * How to declare an call back function pointer member - R3 Ptr.
d0b14e6c6aabb4ed84bc056df6caeae146973c21wrowe * @param type The return type of the function declaration.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @param name The name of the struct/union/class member.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @param args The argument list enclosed in parentheses.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#ifdef IN_RING3
a901f6f8425b207639fe2d1e22b102d96f8e64ffwrowe# define DECLR3CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
752c83c97683b1fb9879ba874593a135155a043cwrowe# define DECLR3CALLBACKMEMBER(type, name, args) RTR3PTR name
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
a901f6f8425b207639fe2d1e22b102d96f8e64ffwrowe/** @def DECLRCCALLBACKMEMBER
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * How to declare an call back function pointer member - RC Ptr.
bfd8c94a05d51f9af59fc84ed65b1336acdf95a8nd * @param type The return type of the function declaration.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * @param name The name of the struct/union/class member.
59f8d8a98364ee033d23dbb8e459858946aaecb3wrowe * @param args The argument list enclosed in parentheses.
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe */
fdc76d3c3f3fea82ba0f1d8af646f8ea5e4734a2wrowe#ifdef IN_RC
f99d4fa2605925f385a184ba3789be3423690533wrowe# define DECLRCCALLBACKMEMBER(type, name, args) type (RTCALL * name) args
c2e5fcbd499ae7b5093d4877ff42e6c5ec74352bwrowe#else
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define DECLRCCALLBACKMEMBER(type, name, args) RTRCPTR name
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
72347cd608351452f99d5f4411d3e0c089d0293awrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/** @def DECLR0CALLBACKMEMBER
72347cd608351452f99d5f4411d3e0c089d0293awrowe * How to declare an call back function pointer member - R0 Ptr.
72347cd608351452f99d5f4411d3e0c089d0293awrowe * @param type The return type of the function declaration.
72347cd608351452f99d5f4411d3e0c089d0293awrowe * @param name The name of the struct/union/class member.
72347cd608351452f99d5f4411d3e0c089d0293awrowe * @param args The argument list enclosed in parentheses.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe */
c2e5fcbd499ae7b5093d4877ff42e6c5ec74352bwrowe#ifdef IN_RING0
c2e5fcbd499ae7b5093d4877ff42e6c5ec74352bwrowe# define DECLR0CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#else
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe# define DECLR0CALLBACKMEMBER(type, name, args) RTR0PTR name
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe/** @def DECLINLINE
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe * How to declare a function as inline.
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe * @param type The return type of the function declaration.
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe * @remarks Don't use this macro on C++ methods.
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe */
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe#ifdef __GNUC__
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe# define DECLINLINE(type) static __inline__ type
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe#elif defined(__cplusplus)
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe# define DECLINLINE(type) inline type
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe#elif defined(_MSC_VER)
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe# define DECLINLINE(type) _inline type
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe#elif defined(__IBMC__)
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe# define DECLINLINE(type) _Inline type
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe#else
edf585d6f44e9019b3ab45be869d7d2ad23e5daewrowe# define DECLINLINE(type) inline type
edf585d6f44e9019b3ab45be869d7d2ad23e5daewrowe#endif
edf585d6f44e9019b3ab45be869d7d2ad23e5daewrowe
edf585d6f44e9019b3ab45be869d7d2ad23e5daewrowe
9fb3226780b297bcc320cb19cc3ec23194fac8e1wrowe/** @def DECL_FORCE_INLINE
a19c94edefc000de60a6925b4ca15637e2f785f1wrowe * How to declare a function as inline and try convince the compiler to always
a19c94edefc000de60a6925b4ca15637e2f785f1wrowe * inline it regardless of optimization switches.
a19c94edefc000de60a6925b4ca15637e2f785f1wrowe * @param type The return type of the function declaration.
a19c94edefc000de60a6925b4ca15637e2f785f1wrowe * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
59f8d8a98364ee033d23dbb8e459858946aaecb3wrowe */
a19c94edefc000de60a6925b4ca15637e2f785f1wrowe#ifdef __GNUC__
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe# define DECL_FORCE_INLINE(type) __attribute__((__always_inline__)) DECLINLINE(type)
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe#elif defined(_MSC_VER)
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe# define DECL_FORCE_INLINE(type) __forceinline type
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe#else
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe# define DECL_FORCE_INLINE(type) DECLINLINE(type)
6bc96ef510ce100bfdeefd80b8f05c010373ed13wrowe#endif
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe/** @def DECL_NO_INLINE
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe * How to declare a function telling the compiler not to inline it.
c4101f4a8c23dce65b76e5c41b0fca7fadeb2941wrowe * @param scope The function scope, static or RT_NOTHING.
424303d026faabb9e9752310911d00fa737b603awrowe * @param type The return type of the function declaration.
424303d026faabb9e9752310911d00fa737b603awrowe * @remarks Don't use this macro on C++ methods.
424303d026faabb9e9752310911d00fa737b603awrowe */
c4101f4a8c23dce65b76e5c41b0fca7fadeb2941wrowe#ifdef __GNUC__
f99d4fa2605925f385a184ba3789be3423690533wrowe# define DECL_NO_INLINE(scope,type) __attribute__((noinline)) scope type
1f0a9798d1c29e1e0cbdb339a0262ba287a29ed4wrowe#elif defined(_MSC_VER)
1e83c8de3aa48b316b28057d53995272baf1260cwrowe# define DECL_NO_INLINE(scope,type) __declspec(noinline) scope type
525973b478c06cd0e8c457ade5c378dcae7485d2wrowe#else
0b54189e53778165cf497165f6b04af200fab8cawrowe# define DECL_NO_INLINE(scope,type) scope type
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
22390e3a41c29735e7c138ab3ea50b876b82b0e6wrowe
22390e3a41c29735e7c138ab3ea50b876b82b0e6wrowe
e3c59608a643aac0e86a0e8cf2d62f8ef655337fwrowe/** @def IN_RT_STATIC
e3c59608a643aac0e86a0e8cf2d62f8ef655337fwrowe * Used to indicate 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_RC indicators are set first.
*/
/** @def IN_RT_R0
* Used to indicate whether we're inside the same link module as
* the HC Ring-0 Runtime Library.
*/
/** @def RTR0DECL(type)
* Runtime Library HC Ring-0 export or import declaration.
* @param type The return type of the function declaration.
*/
#ifdef IN_RT_R0
# ifdef IN_RT_STATIC
# define RTR0DECL(type) DECLHIDDEN(type) RTCALL
# else
# define RTR0DECL(type) DECLEXPORT(type) RTCALL
# endif
#else
# define RTR0DECL(type) DECLIMPORT(type) RTCALL
#endif
/** @def IN_RT_R3
* Used to indicate whether we're inside the same link module as
* the HC Ring-3 Runtime Library.
*/
/** @def RTR3DECL(type)
* Runtime Library HC Ring-3 export or import declaration.
* @param type The return type of the function declaration.
*/
#ifdef IN_RT_R3
# ifdef IN_RT_STATIC
# define RTR3DECL(type) DECLHIDDEN(type) RTCALL
# else
# define RTR3DECL(type) DECLEXPORT(type) RTCALL
# endif
#else
# define RTR3DECL(type) DECLIMPORT(type) RTCALL
#endif
/** @def IN_RT_RC
* Used to indicate whether we're inside the same link module as the raw-mode
* context (RC) runtime library.
*/
/** @def RTRCDECL(type)
* Runtime Library raw-mode context export or import declaration.
* @param type The return type of the function declaration.
*/
#ifdef IN_RT_RC
# ifdef IN_RT_STATIC
# define RTRCDECL(type) DECLHIDDEN(type) RTCALL
# else
# define RTRCDECL(type) DECLEXPORT(type) RTCALL
# endif
#else
# define RTRCDECL(type) DECLIMPORT(type) RTCALL
#endif
/** @def RTDECL(type)
* Runtime Library export or import declaration.
* Functions declared using this macro exists in all contexts.
* @param type The return type of the function declaration.
*/
#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
# ifdef IN_RT_STATIC
# define RTDECL(type) DECLHIDDEN(type) RTCALL
# else
# define RTDECL(type) DECLEXPORT(type) RTCALL
# endif
#else
# define RTDECL(type) DECLIMPORT(type) RTCALL
#endif
/** @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.
*/
#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
# ifdef IN_RT_STATIC
# define RTDATADECL(type) DECLHIDDEN(type)
# else
# define RTDATADECL(type) DECLEXPORT(type)
# endif
#else
# define RTDATADECL(type) DECLIMPORT(type)
#endif
/** @def RT_DECL_CLASS
* Declares an class living in the runtime.
*/
#if defined(IN_RT_R3) || defined(IN_RT_RC) || defined(IN_RT_R0)
# ifdef IN_RT_STATIC
# define RT_DECL_CLASS
# else
# define RT_DECL_CLASS DECLEXPORT_CLASS
# endif
#else
# define RT_DECL_CLASS DECLIMPORT_CLASS
#endif
/** @def RT_NOCRT
* 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
* wrapped names.
*/
/** @def RT_NOCRT_STR
* Same as RT_NOCRT only it'll return a double quoted string of the result.
*/
#ifndef RT_WITHOUT_NOCRT_WRAPPERS
# define RT_NOCRT(name) nocrt_ ## name
# define RT_NOCRT_STR(name) "nocrt_" # name
#else
# define RT_NOCRT(name) name
# define RT_NOCRT_STR(name) #name
#endif
/** @def RT_LIKELY
* 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
* behaviour, etc.
*
* 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 rarely (e.g.
* at subsystem initialization time) as the basic block reordering that this
* affects 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.
* @see RT_UNLIKELY
*/
/** @def RT_UNLIKELY
* 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.
* @see RT_LIKELY
*/
#if defined(__GNUC__)
# if __GNUC__ >= 3 && !defined(FORTIFY_RUNNING)
# define RT_LIKELY(expr) __builtin_expect(!!(expr), 1)
# define RT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
# else
# define RT_LIKELY(expr) (expr)
# define RT_UNLIKELY(expr) (expr)
# endif
#else
# define RT_LIKELY(expr) (expr)
# define RT_UNLIKELY(expr) (expr)
#endif
/** @def RT_STR
* Returns the argument as a string constant.
* @param str Argument to stringify. */
#define RT_STR(str) #str
/** @def RT_XSTR
* Returns the expanded argument as a string.
* @param str Argument to expand and stringy. */
#define RT_XSTR(str) RT_STR(str)
/** @def RT_CONCAT
* Concatenate the expanded arguments without any extra spaces in between.
*
* @param a The first part.
* @param b The second part.
*/
#define RT_CONCAT(a,b) RT_CONCAT_HLP(a,b)
/** RT_CONCAT helper, don't use. */
#define RT_CONCAT_HLP(a,b) a##b
/** @def RT_CONCAT
* Concatenate the expanded arguments without any extra spaces in between.
*
* @param a The 1st part.
* @param b The 2nd part.
* @param c The 3rd part.
*/
#define RT_CONCAT3(a,b,c) RT_CONCAT3_HLP(a,b,c)
/** RT_CONCAT3 helper, don't use. */
#define RT_CONCAT3_HLP(a,b,c) a##b##c
/** @def RT_CONCAT
* Concatenate the expanded arguments without any extra spaces in between.
*
* @param a The 1st part.
* @param b The 2nd part.
* @param c The 3rd part.
*/
#define RT_CONCAT4(a,b,c,d) RT_CONCAT4_HLP(a,b,c,d)
/** RT_CONCAT4 helper, don't use. */
#define RT_CONCAT4_HLP(a,b,c,d) a##b##c##d
/**
* String constant tuple - string constant, strlen(string constant).
*
* @param a_szConst String constant.
*/
#define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
/** @def RT_BIT
* Convert a bit number into an integer bitmask (unsigned).
* @param bit The bit number.
*/
#define RT_BIT(bit) ( 1U << (bit) )
/** @def RT_BIT_32
* Convert a bit number into a 32-bit bitmask (unsigned).
* @param bit The bit number.
*/
#define RT_BIT_32(bit) ( UINT32_C(1) << (bit) )
/** @def RT_BIT_64
* Convert a bit number into a 64-bit bitmask (unsigned).
* @param bit The bit number.
*/
#define RT_BIT_64(bit) ( UINT64_C(1) << (bit) )
/** @def RT_ALIGN
* Align macro.
* @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.
*/
#define RT_ALIGN(u, uAlignment) ( ((u) + ((uAlignment) - 1)) & ~((uAlignment) - 1) )
/** @def RT_ALIGN_T
* Align macro.
* @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 preferred alignment macro, it doesn't have any of the pitfalls RT_ALIGN has.
*/
#define RT_ALIGN_T(u, uAlignment, type) ( ((type)(u) + ((uAlignment) - 1)) & ~(type)((uAlignment) - 1) )
/** @def RT_ALIGN_32
* Align macro for a 32-bit value.
* @param u32 Value to align.
* @param uAlignment The alignment. Power of two!
*/
#define RT_ALIGN_32(u32, uAlignment) RT_ALIGN_T(u32, uAlignment, uint32_t)
/** @def RT_ALIGN_64
* Align macro for a 64-bit value.
* @param u64 Value to align.
* @param uAlignment The alignment. Power of two!
*/
#define RT_ALIGN_64(u64, uAlignment) RT_ALIGN_T(u64, uAlignment, uint64_t)
/** @def RT_ALIGN_Z
* Align macro for size_t.
* @param cb Value to align.
* @param uAlignment The alignment. Power of two!
*/
#define RT_ALIGN_Z(cb, uAlignment) RT_ALIGN_T(cb, uAlignment, size_t)
/** @def RT_ALIGN_P
* Align macro for pointers.
* @param pv Value to align.
* @param uAlignment The alignment. Power of two!
*/
#define RT_ALIGN_P(pv, uAlignment) RT_ALIGN_PT(pv, uAlignment, void *)
/** @def RT_ALIGN_PT
* 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.
*/
#define RT_ALIGN_PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, uintptr_t) )
/** @def RT_ALIGN_R3PT
* 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.
*/
#define RT_ALIGN_R3PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR3UINTPTR) )
/** @def RT_ALIGN_R0PT
* 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.
*/
#define RT_ALIGN_R0PT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTR0UINTPTR) )
/** @def RT_ALIGN_GCPT
* 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.
*/
#define RT_ALIGN_GCPT(u, uAlignment, CastType) ( (CastType)RT_ALIGN_T(u, uAlignment, RTGCUINTPTR) )
/** @def RT_OFFSETOF
* 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. This is useful to determine the sizes of structures ending
* with a variable length field.
*
* @returns offset into the structure of the specified member. signed.
* @param type Structure type.
* @param member Member.
*/
#define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) )
/** @def RT_UOFFSETOF
* 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. This is useful to determine the sizes of structures ending
* with a variable length field.
*
* @returns offset into the structure of the specified member. unsigned.
* @param type Structure type.
* @param member Member.
*/
#define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) )
/** @def RT_OFFSETOF_ADD
* RT_OFFSETOF with an addend.
*
* @returns offset into the structure of the specified member. signed.
* @param type Structure type.
* @param member Member.
* @param addend The addend to add to the offset.
*/
#define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) )
/** @def RT_UOFFSETOF_ADD
* RT_UOFFSETOF with an addend.
*
* @returns offset into the structure of the specified member. signed.
* @param type Structure type.
* @param member Member.
* @param addend The addend to add to the offset.
*/
#define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) )
/** @def RT_SIZEOFMEMB
* Get the size of a structure member.
*
* @returns size of the structure member.
* @param type Structure type.
* @param member Member.
*/
#define RT_SIZEOFMEMB(type, member) ( sizeof(((type *)(void *)0)->member) )
/** @def RT_FROM_MEMBER
* Convert a pointer to a structure member into a pointer to the structure.
*
* @returns pointer to the structure.
* @param pMem Pointer to the member.
* @param Type Structure type.
* @param Member Member name.
*/
#define RT_FROM_MEMBER(pMem, Type, Member) ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
/** @def RT_FROM_CPP_MEMBER
* Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
* invalid access to non-static data member of NULL object.
*
* @returns pointer to the structure.
* @param pMem Pointer to the member.
* @param Type Structure type.
* @param Member Member name.
*
* @remarks Using the __builtin_offsetof does not shut up the compiler.
*/
#if defined(__GNUC__) && defined(__cplusplus)
# define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
#else
# define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
#endif
/** @def RT_ELEMENTS
* Calculates the number of elements in a statically sized array.
* @returns Element count.
* @param aArray Array in question.
*/
#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
/**
* Checks if the value is a power of two.
*
* @returns true if power of two, false if not.
* @param uVal The value to test.
* @remarks 0 is a power of two.
* @see VERR_NOT_POWER_OF_TWO
*/
#define RT_IS_POWER_OF_TWO(uVal) ( ((uVal) & ((uVal) - 1)) == 0)
#ifdef RT_OS_OS2
/* Undefine RT_MAX since there is an unfortunate clash with the max
resource type define in os2.h. */
# undef RT_MAX
#endif
/** @def RT_MAX
* Finds the maximum value.
* @returns The higher of the two.
* @param Value1 Value 1
* @param Value2 Value 2
*/
#define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
/** @def RT_MIN
* Finds the minimum value.
* @returns The lower of the two.
* @param Value1 Value 1
* @param Value2 Value 2
*/
#define RT_MIN(Value1, Value2) ( (Value1) <= (Value2) ? (Value1) : (Value2) )
/** @def RT_CLAMP
* Clamps the value to minimum and maximum values.
* @returns The clamped value.
* @param Value The value to check.
* @param Min Minimum value.
* @param Max Maximum value.
*/
#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
/** @def RT_ABS
* Get the absolute (non-negative) value.
* @returns The absolute value of Value.
* @param Value The value.
*/
#define RT_ABS(Value) ( (Value) >= 0 ? (Value) : -(Value) )
/** @def RT_BOOL
* Turn non-zero/zero into true/false
* @returns The resulting boolean value.
* @param Value The value.
*/
#define RT_BOOL(Value) ( !!(Value) )
/** @def RT_LO_U8
* Gets the low uint8_t of a uint16_t or something equivalent. */
#ifdef __GNUC__
# define RT_LO_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)(a); })
#else
# define RT_LO_U8(a) ( (uint8_t)(a) )
#endif
/** @def RT_HI_U16
* Gets the high uint16_t of a uint32_t or something equivalent). */
#ifdef __GNUC__
# define RT_HI_U8(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint16_t)); (uint8_t)((a) >> 8); })
#else
# define RT_HI_U8(a) ( (uint8_t)((a) >> 8) )
#endif
/** @def RT_LO_U16
* Gets the low uint16_t of a uint32_t or something equivalent. */
#ifdef __GNUC__
# define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
#else
# define RT_LO_U16(a) ( (uint32_t)(a) )
#endif
/** @def RT_HI_U16
* Gets the high uint16_t of a uint32_t or something equivalent). */
#ifdef __GNUC__
# define RT_HI_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)((a) >> 16); })
#else
# define RT_HI_U16(a) ( (uint16_t)((a) >> 16) )
#endif
/** @def RT_LO_U32
* Gets the low uint32_t of a uint64_t or something equivalent. */
#ifdef __GNUC__
# define RT_LO_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
#else
# define RT_LO_U32(a) ( (uint32_t)(a) )
#endif
/** @def RT_HI_U32
* Gets the high uint32_t of a uint64_t or something equivalent). */
#ifdef __GNUC__
# define RT_HI_U32(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)((a) >> 32); })
#else
# define RT_HI_U32(a) ( (uint32_t)((a) >> 32) )
#endif
/** @def RT_BYTE1
* Gets the first byte of something. */
#define RT_BYTE1(a) ( (a) & 0xff )
/** @def RT_BYTE2
* Gets the second byte of something. */
#define RT_BYTE2(a) ( ((a) >> 8) & 0xff )
/** @def RT_BYTE3
* Gets the second byte of something. */
#define RT_BYTE3(a) ( ((a) >> 16) & 0xff )
/** @def RT_BYTE4
* Gets the fourth byte of something. */
#define RT_BYTE4(a) ( ((a) >> 24) & 0xff )
/** @def RT_BYTE5
* Gets the fifth byte of something. */
#define RT_BYTE5(a) ( ((a) >> 32) & 0xff )
/** @def RT_BYTE6
* Gets the sixth byte of something. */
#define RT_BYTE6(a) ( ((a) >> 40) & 0xff )
/** @def RT_BYTE7
* Gets the seventh byte of something. */
#define RT_BYTE7(a) ( ((a) >> 48) & 0xff )
/** @def RT_BYTE8
* Gets the eight byte of something. */
#define RT_BYTE8(a) ( ((a) >> 56) & 0xff )
/** @def RT_LODWORD
* Gets the low dword (=uint32_t) of something.
* @deprecated Use RT_LO_U32. */
#define RT_LODWORD(a) ( (uint32_t)(a) )
/** @def RT_HIDWORD
* Gets the high dword (=uint32_t) of a 64-bit of something.
* @deprecated Use RT_HI_U32. */
#define RT_HIDWORD(a) ( (uint32_t)((a) >> 32) )
/** @def RT_LOWORD
* Gets the low word (=uint16_t) of something.
* @deprecated Use RT_LO_U16. */
#define RT_LOWORD(a) ( (a) & 0xffff )
/** @def RT_HIWORD
* Gets the high word (=uint16_t) of a 32-bit something.
* @deprecated Use RT_HI_U16. */
#define RT_HIWORD(a) ( (a) >> 16 )
/** @def RT_LOBYTE
* Gets the low byte of something.
* @deprecated Use RT_LO_U8. */
#define RT_LOBYTE(a) ( (a) & 0xff )
/** @def RT_HIBYTE
* Gets the low byte of a 16-bit something.
* @deprecated Use RT_HI_U8. */
#define RT_HIBYTE(a) ( (a) >> 8 )
/** @def RT_MAKE_U64
* Constructs a uint64_t value from two uint32_t values.
*/
#define RT_MAKE_U64(Lo, Hi) ( (uint64_t)((uint32_t)(Hi)) << 32 | (uint32_t)(Lo) )
/** @def RT_MAKE_U64_FROM_U16
* Constructs a uint64_t value from four uint16_t values.
*/
#define RT_MAKE_U64_FROM_U16(w0, w1, w2, w3) \
((uint64_t)( (uint64_t)((uint16_t)(w3)) << 48 \
| (uint64_t)((uint16_t)(w2)) << 32 \
| (uint32_t)((uint16_t)(w1)) << 16 \
| (uint16_t)(w0) ))
/** @def RT_MAKE_U64_FROM_U8
* Constructs a uint64_t value from eight uint8_t values.
*/
#define RT_MAKE_U64_FROM_U8(b0, b1, b2, b3, b4, b5, b6, b7) \
((uint64_t)( (uint64_t)((uint8_t)(b7)) << 56 \
| (uint64_t)((uint8_t)(b6)) << 48 \
| (uint64_t)((uint8_t)(b5)) << 40 \
| (uint64_t)((uint8_t)(b4)) << 32 \
| (uint32_t)((uint8_t)(b3)) << 24 \
| (uint32_t)((uint8_t)(b2)) << 16 \
| (uint16_t)((uint8_t)(b1)) << 8 \
| (uint8_t)(b0) ))
/** @def RT_MAKE_U32
* Constructs a uint32_t value from two uint16_t values.
*/
#define RT_MAKE_U32(Lo, Hi) \
((uint32_t)( (uint32_t)((uint16_t)(Hi)) << 16 \
| (uint16_t)(Lo) ))
/** @def RT_MAKE_U32_FROM_U8
* Constructs a uint32_t value from four uint8_t values.
*/
#define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) \
((uint32_t)( (uint32_t)((uint8_t)(b3)) << 24 \
| (uint32_t)((uint8_t)(b2)) << 16 \
| (uint16_t)((uint8_t)(b1)) << 8 \
| (uint8_t)(b0) ))
/** @def RT_MAKE_U16
* Constructs a uint16_t value from two uint8_t values.
*/
#define RT_MAKE_U16(Lo, Hi) \
((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 \
| (uint8_t)(Lo) ))
/** @def RT_BSWAP_U64
* Reverses the byte order of an uint64_t value. */
#if 0
# define RT_BSWAP_U64(u64) RT_BSWAP_U64_C(u64)
#elif defined(__GNUC__)
# define RT_BSWAP_U64(u64) (__builtin_constant_p((u64)) \
? RT_BSWAP_U64_C(u64) : ASMByteSwapU64(u64))
#else
# define RT_BSWAP_U64(u64) ASMByteSwapU64(u64)
#endif
/** @def RT_BSWAP_U32
* Reverses the byte order of an uint32_t value. */
#if 0
# define RT_BSWAP_U32(u32) RT_BSWAP_U32_C(u32)
#elif defined(__GNUC__)
# define RT_BSWAP_U32(u32) (__builtin_constant_p((u32)) \
? RT_BSWAP_U32_C(u32) : ASMByteSwapU32(u32))
#else
# define RT_BSWAP_U32(u32) ASMByteSwapU32(u32)
#endif
/** @def RT_BSWAP_U16
* Reverses the byte order of an uint16_t value. */
#if 0
# define RT_BSWAP_U16(u16) RT_BSWAP_U16_C(u16)
#elif defined(__GNUC__)
# define RT_BSWAP_U16(u16) (__builtin_constant_p((u16)) \
? RT_BSWAP_U16_C(u16) : ASMByteSwapU16(u16))
#else
# define RT_BSWAP_U16(u16) ASMByteSwapU16(u16)
#endif
/** @def RT_BSWAP_U64_C
* Reverses the byte order of an uint64_t constant. */
#define RT_BSWAP_U64_C(u64) RT_MAKE_U64(RT_BSWAP_U32_C((u64) >> 32), RT_BSWAP_U32_C((u64) & 0xffffffff))
/** @def RT_BSWAP_U32_C
* Reverses the byte order of an uint32_t constant. */
#define RT_BSWAP_U32_C(u32) RT_MAKE_U32_FROM_U8(RT_BYTE4(u32), RT_BYTE3(u32), RT_BYTE2(u32), RT_BYTE1(u32))
/** @def RT_BSWAP_U16_C
* Reverses the byte order of an uint16_t constant. */
#define RT_BSWAP_U16_C(u16) RT_MAKE_U16(RT_HIBYTE(u16), RT_LOBYTE(u16))
/** @def RT_H2LE_U64
* Converts an uint64_t value from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U64(u64) RT_BSWAP_U64(u64)
#else
# define RT_H2LE_U64(u64) (u64)
#endif
/** @def RT_H2LE_U64_C
* Converts an uint64_t constant from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U64_C(u64) RT_BSWAP_U64_C(u64)
#else
# define RT_H2LE_U64_C(u64) (u64)
#endif
/** @def RT_H2LE_U32
* Converts an uint32_t value from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U32(u32) RT_BSWAP_U32(u32)
#else
# define RT_H2LE_U32(u32) (u32)
#endif
/** @def RT_H2LE_U32_C
* Converts an uint32_t constant from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U32_C(u32) RT_BSWAP_U32_C(u32)
#else
# define RT_H2LE_U32_C(u32) (u32)
#endif
/** @def RT_H2LE_U16
* Converts an uint16_t value from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U16(u16) RT_BSWAP_U16(u16)
#else
# define RT_H2LE_U16(u16) (u16)
#endif
/** @def RT_H2LE_U16_C
* Converts an uint16_t constant from host to little endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2LE_U16_C(u16) RT_BSWAP_U16_C(u16)
#else
# define RT_H2LE_U16_C(u16) (u16)
#endif
/** @def RT_LE2H_U64
* Converts an uint64_t value from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U64(u64) RT_BSWAP_U64(u64)
#else
# define RT_LE2H_U64(u64) (u64)
#endif
/** @def RT_LE2H_U64_C
* Converts an uint64_t constant from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
#else
# define RT_LE2H_U64_C(u64) (u64)
#endif
/** @def RT_LE2H_U32
* Converts an uint32_t value from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U32(u32) RT_BSWAP_U32(u32)
#else
# define RT_LE2H_U32(u32) (u32)
#endif
/** @def RT_LE2H_U32_C
* Converts an uint32_t constant from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
#else
# define RT_LE2H_U32_C(u32) (u32)
#endif
/** @def RT_LE2H_U16
* Converts an uint16_t value from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U16(u16) RT_BSWAP_U16(u16)
#else
# define RT_LE2H_U16(u16) (u16)
#endif
/** @def RT_LE2H_U16_C
* Converts an uint16_t constant from little endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_LE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
#else
# define RT_LE2H_U16_C(u16) (u16)
#endif
/** @def RT_H2BE_U64
* Converts an uint64_t value from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U64(u64) (u64)
#else
# define RT_H2BE_U64(u64) RT_BSWAP_U64(u64)
#endif
/** @def RT_H2BE_U64_C
* Converts an uint64_t constant from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U64_C(u64) (u64)
#else
# define RT_H2BE_U64_C(u64) RT_BSWAP_U64_C(u64)
#endif
/** @def RT_H2BE_U32
* Converts an uint32_t value from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U32(u32) (u32)
#else
# define RT_H2BE_U32(u32) RT_BSWAP_U32(u32)
#endif
/** @def RT_H2BE_U32_C
* Converts an uint32_t constant from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U32_C(u32) (u32)
#else
# define RT_H2BE_U32_C(u32) RT_BSWAP_U32_C(u32)
#endif
/** @def RT_H2BE_U16
* Converts an uint16_t value from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U16(u16) (u16)
#else
# define RT_H2BE_U16(u16) RT_BSWAP_U16(u16)
#endif
/** @def RT_H2BE_U16_C
* Converts an uint16_t constant from host to big endian byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_H2BE_U16_C(u16) (u16)
#else
# define RT_H2BE_U16_C(u16) RT_BSWAP_U16_C(u16)
#endif
/** @def RT_BE2H_U64
* Converts an uint64_t value from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U64(u64) (u64)
#else
# define RT_BE2H_U64(u64) RT_BSWAP_U64(u64)
#endif
/** @def RT_BE2H_U64
* Converts an uint64_t constant from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U64_C(u64) (u64)
#else
# define RT_BE2H_U64_C(u64) RT_BSWAP_U64_C(u64)
#endif
/** @def RT_BE2H_U32
* Converts an uint32_t value from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U32(u32) (u32)
#else
# define RT_BE2H_U32(u32) RT_BSWAP_U32(u32)
#endif
/** @def RT_BE2H_U32_C
* Converts an uint32_t value from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U32_C(u32) (u32)
#else
# define RT_BE2H_U32_C(u32) RT_BSWAP_U32_C(u32)
#endif
/** @def RT_BE2H_U16
* Converts an uint16_t value from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U16(u16) (u16)
#else
# define RT_BE2H_U16(u16) RT_BSWAP_U16(u16)
#endif
/** @def RT_BE2H_U16_C
* Converts an uint16_t constant from big endian to host byte order. */
#ifdef RT_BIG_ENDIAN
# define RT_BE2H_U16_C(u16) (u16)
#else
# define RT_BE2H_U16_C(u16) RT_BSWAP_U16_C(u16)
#endif
/** @def RT_H2N_U64
* Converts an uint64_t value from host to network byte order. */
#define RT_H2N_U64(u64) RT_H2BE_U64(u64)
/** @def RT_H2N_U64_C
* Converts an uint64_t constant from host to network byte order. */
#define RT_H2N_U64_C(u64) RT_H2BE_U64_C(u64)
/** @def RT_H2N_U32
* Converts an uint32_t value from host to network byte order. */
#define RT_H2N_U32(u32) RT_H2BE_U32(u32)
/** @def RT_H2N_U32_C
* Converts an uint32_t constant from host to network byte order. */
#define RT_H2N_U32_C(u32) RT_H2BE_U32_C(u32)
/** @def RT_H2N_U16
* Converts an uint16_t value from host to network byte order. */
#define RT_H2N_U16(u16) RT_H2BE_U16(u16)
/** @def RT_H2N_U16_C
* Converts an uint16_t constant from host to network byte order. */
#define RT_H2N_U16_C(u16) RT_H2BE_U16_C(u16)
/** @def RT_N2H_U64
* Converts an uint64_t value from network to host byte order. */
#define RT_N2H_U64(u64) RT_BE2H_U64(u64)
/** @def RT_N2H_U64_C
* Converts an uint64_t constant from network to host byte order. */
#define RT_N2H_U64_C(u64) RT_BE2H_U64_C(u64)
/** @def RT_N2H_U32
* Converts an uint32_t value from network to host byte order. */
#define RT_N2H_U32(u32) RT_BE2H_U32(u32)
/** @def RT_N2H_U32_C
* Converts an uint32_t constant from network to host byte order. */
#define RT_N2H_U32_C(u32) RT_BE2H_U32_C(u32)
/** @def RT_N2H_U16
* Converts an uint16_t value from network to host byte order. */
#define RT_N2H_U16(u16) RT_BE2H_U16(u16)
/** @def RT_N2H_U16_C
* Converts an uint16_t value from network to host byte order. */
#define RT_N2H_U16_C(u16) RT_BE2H_U16_C(u16)
/*
* The BSD sys/param.h + machine/param.h file is a major source of
* namespace pollution. Kill off some of the worse ones unless we're
* compiling kernel code.
*/
#if defined(RT_OS_DARWIN) \
&& !defined(KERNEL) \
&& !defined(RT_NO_BSD_PARAM_H_UNDEFING) \
&& ( defined(_SYS_PARAM_H_) || defined(_I386_PARAM_H_) )
/* sys/param.h: */
# undef PSWP
# undef PVM
# undef PINOD
# undef PRIBO
# undef PVFS
# undef PZERO
# undef PSOCK
# undef PWAIT
# undef PLOCK
# undef PPAUSE
# undef PUSER
# undef PRIMASK
# undef MINBUCKET
# undef MAXALLOCSAVE
# undef FSHIFT
# undef FSCALE
/* i386/machine.h: */
# undef ALIGN
# undef ALIGNBYTES
# undef DELAY
# undef STATUS_WORD
# undef USERMODE
# undef BASEPRI
# undef MSIZE
# undef CLSIZE
# undef CLSIZELOG2
#endif
/** @def NULL
* NULL pointer.
*/
#ifndef NULL
# ifdef __cplusplus
# define NULL 0
# else
# define NULL ((void*)0)
# endif
#endif
/** @def NIL_OFFSET
* NIL offset.
* Whenever we use offsets instead of pointers to save space and relocation effort
* NIL_OFFSET shall be used as the equivalent to NULL.
*/
#define NIL_OFFSET (~0U)
/** @def NOREF
* Keeps the compiler from bitching about an unused parameter.
*/
#define NOREF(var) (void)(var)
/** @def RT_BREAKPOINT
* Emit a debug breakpoint instruction.
*
* @remarks In the x86/amd64 gnu world we add a nop instruction after the int3
* to force gdb to remain at the int3 source line.
* @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp on
* x86/amd64.
*/
#ifdef __GNUC__
# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
# if !defined(__L4ENV__)
# define RT_BREAKPOINT() __asm__ __volatile__("int $3\n\tnop\n\t")
# else
# define RT_BREAKPOINT() __asm__ __volatile__("int3; jmp 1f; 1:\n\t")
# endif
# elif defined(RT_ARCH_SPARC64)
# define RT_BREAKPOINT() __asm__ __volatile__("illtrap 0\n\t") /** @todo Sparc64: this is just a wild guess. */
# elif defined(RT_ARCH_SPARC)
# define RT_BREAKPOINT() __asm__ __volatile__("unimp 0\n\t") /** @todo Sparc: this is just a wild guess (same as Sparc64, just different name). */
# endif
#endif
#ifdef _MSC_VER
# define RT_BREAKPOINT() __debugbreak()
#endif
#if defined(__IBMC__) || defined(__IBMCPP__)
# define RT_BREAKPOINT() __interrupt(3)
#endif
#ifndef RT_BREAKPOINT
# error "This compiler/arch is not supported!"
#endif
/** @defgroup grp_rt_cdefs_size Size Constants
* (Of course, these are binary computer terms, not SI.)
* @{
*/
/** 1 K (Kilo) (1 024). */
#define _1K 0x00000400
/** 4 K (Kilo) (4 096). */
#define _4K 0x00001000
/** 32 K (Kilo) (32 678). */
#define _32K 0x00008000
/** 64 K (Kilo) (65 536). */
#define _64K 0x00010000
/** 128 K (Kilo) (131 072). */
#define _128K 0x00020000
/** 256 K (Kilo) (262 144). */
#define _256K 0x00040000
/** 512 K (Kilo) (524 288). */
#define _512K 0x00080000
/** 1 M (Mega) (1 048 576). */
#define _1M 0x00100000
/** 2 M (Mega) (2 097 152). */
#define _2M 0x00200000
/** 4 M (Mega) (4 194 304). */
#define _4M 0x00400000
/** 1 G (Giga) (1 073 741 824). (32-bit) */
#define _1G 0x40000000
/** 1 G (Giga) (1 073 741 824). (64-bit) */
#define _1G64 0x40000000LL
/** 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
/** @} */
/** @defgroup grp_rt_cdefs_decimal_grouping Decimal Constant Grouping Macros
* @{ */
#define RT_D1(g1) g1
#define RT_D2(g1, g2) g1#g2
#define RT_D3(g1, g2, g3) g1#g2#g3
#define RT_D4(g1, g2, g3, g4) g1#g2#g3#g4
#define RT_D5(g1, g2, g3, g4, g5) g1#g2#g3#g4#g5
#define RT_D6(g1, g2, g3, g4, g5, g6) g1#g2#g3#g4#g5#g6
#define RT_D7(g1, g2, g3, g4, g5, g6, g7) g1#g2#g3#g4#g5#g6#g7
#define RT_D1_U(g1) UINT32_C(g1)
#define RT_D2_U(g1, g2) UINT32_C(g1#g2)
#define RT_D3_U(g1, g2, g3) UINT32_C(g1#g2#g3)
#define RT_D4_U(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
#define RT_D5_U(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
#define RT_D6_U(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
#define RT_D7_U(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
#define RT_D1_S(g1) INT32_C(g1)
#define RT_D2_S(g1, g2) INT32_C(g1#g2)
#define RT_D3_S(g1, g2, g3) INT32_C(g1#g2#g3)
#define RT_D4_S(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
#define RT_D5_S(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
#define RT_D6_S(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
#define RT_D7_S(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
#define RT_D1_U32(g1) UINT32_C(g1)
#define RT_D2_U32(g1, g2) UINT32_C(g1#g2)
#define RT_D3_U32(g1, g2, g3) UINT32_C(g1#g2#g3)
#define RT_D4_U32(g1, g2, g3, g4) UINT32_C(g1#g2#g3#g4)
#define RT_D1_S32(g1) INT32_C(g1)
#define RT_D2_S32(g1, g2) INT32_C(g1#g2)
#define RT_D3_S32(g1, g2, g3) INT32_C(g1#g2#g3)
#define RT_D4_S32(g1, g2, g3, g4) INT32_C(g1#g2#g3#g4)
#define RT_D1_U64(g1) UINT64_C(g1)
#define RT_D2_U64(g1, g2) UINT64_C(g1#g2)
#define RT_D3_U64(g1, g2, g3) UINT64_C(g1#g2#g3)
#define RT_D4_U64(g1, g2, g3, g4) UINT64_C(g1#g2#g3#g4)
#define RT_D5_U64(g1, g2, g3, g4, g5) UINT64_C(g1#g2#g3#g4#g5)
#define RT_D6_U64(g1, g2, g3, g4, g5, g6) UINT64_C(g1#g2#g3#g4#g5#g6)
#define RT_D7_U64(g1, g2, g3, g4, g5, g6, g7) UINT64_C(g1#g2#g3#g4#g5#g6#g7)
#define RT_D1_S64(g1) INT64_C(g1)
#define RT_D2_S64(g1, g2) INT64_C(g1#g2)
#define RT_D3_S64(g1, g2, g3) INT64_C(g1#g2#g3)
#define RT_D4_S64(g1, g2, g3, g4) INT64_C(g1#g2#g3#g4)
#define RT_D5_S64(g1, g2, g3, g4, g5) INT64_C(g1#g2#g3#g4#g5)
#define RT_D6_S64(g1, g2, g3, g4, g5, g6) INT64_C(g1#g2#g3#g4#g5#g6)
#define RT_D7_S64(g1, g2, g3, g4, g5, g6, g7) INT64_C(g1#g2#g3#g4#g5#g6#g7)
/** @} */
/** @defgroup grp_rt_cdefs_time Time Constants
* @{
*/
/** 1 hour expressed in nanoseconds (64-bit). */
#define RT_NS_1HOUR UINT64_C(3600000000000)
/** 1 minute expressed in nanoseconds (64-bit). */
#define RT_NS_1MIN UINT64_C(60000000000)
/** 45 second expressed in nanoseconds. */
#define RT_NS_45SEC UINT64_C(45000000000)
/** 30 second expressed in nanoseconds. */
#define RT_NS_30SEC UINT64_C(30000000000)
/** 20 second expressed in nanoseconds. */
#define RT_NS_20SEC UINT64_C(20000000000)
/** 15 second expressed in nanoseconds. */
#define RT_NS_15SEC UINT64_C(15000000000)
/** 10 second expressed in nanoseconds. */
#define RT_NS_10SEC UINT64_C(10000000000)
/** 1 second expressed in nanoseconds. */
#define RT_NS_1SEC UINT32_C(1000000000)
/** 100 millsecond expressed in nanoseconds. */
#define RT_NS_100MS UINT32_C(100000000)
/** 10 millsecond expressed in nanoseconds. */
#define RT_NS_10MS UINT32_C(10000000)
/** 1 millsecond expressed in nanoseconds. */
#define RT_NS_1MS UINT32_C(1000000)
/** 100 microseconds expressed in nanoseconds. */
#define RT_NS_100US UINT32_C(100000)
/** 10 microseconds expressed in nanoseconds. */
#define RT_NS_10US UINT32_C(10000)
/** 1 microsecond expressed in nanoseconds. */
#define RT_NS_1US UINT32_C(1000)
/** 1 second expressed in nanoseconds - 64-bit type. */
#define RT_NS_1SEC_64 UINT64_C(1000000000)
/** 100 millsecond expressed in nanoseconds - 64-bit type. */
#define RT_NS_100MS_64 UINT64_C(100000000)
/** 10 millsecond expressed in nanoseconds - 64-bit type. */
#define RT_NS_10MS_64 UINT64_C(10000000)
/** 1 millsecond expressed in nanoseconds - 64-bit type. */
#define RT_NS_1MS_64 UINT64_C(1000000)
/** 100 microseconds expressed in nanoseconds - 64-bit type. */
#define RT_NS_100US_64 UINT64_C(100000)
/** 10 microseconds expressed in nanoseconds - 64-bit type. */
#define RT_NS_10US_64 UINT64_C(10000)
/** 1 microsecond expressed in nanoseconds - 64-bit type. */
#define RT_NS_1US_64 UINT64_C(1000)
/** 1 hour expressed in microseconds. */
#define RT_US_1HOUR UINT32_C(3600000000)
/** 1 minute expressed in microseconds. */
#define RT_US_1MIN UINT32_C(60000000)
/** 1 second expressed in microseconds. */
#define RT_US_1SEC UINT32_C(1000000)
/** 100 millsecond expressed in microseconds. */
#define RT_US_100MS UINT32_C(100000)
/** 10 millsecond expressed in microseconds. */
#define RT_US_10MS UINT32_C(10000)
/** 1 millsecond expressed in microseconds. */
#define RT_US_1MS UINT32_C(1000)
/** 1 hour expressed in microseconds - 64-bit type. */
#define RT_US_1HOUR_64 UINT64_C(3600000000)
/** 1 minute expressed in microseconds - 64-bit type. */
#define RT_US_1MIN_64 UINT64_C(60000000)
/** 1 second expressed in microseconds - 64-bit type. */
#define RT_US_1SEC_64 UINT64_C(1000000)
/** 100 millsecond expressed in microseconds - 64-bit type. */
#define RT_US_100MS_64 UINT64_C(100000)
/** 10 millsecond expressed in microseconds - 64-bit type. */
#define RT_US_10MS_64 UINT64_C(10000)
/** 1 millsecond expressed in microseconds - 64-bit type. */
#define RT_US_1MS_64 UINT64_C(1000)
/** 1 hour expressed in milliseconds. */
#define RT_MS_1HOUR UINT32_C(3600000)
/** 1 minute expressed in milliseconds. */
#define RT_MS_1MIN UINT32_C(60000)
/** 1 second expressed in milliseconds. */
#define RT_MS_1SEC UINT32_C(1000)
/** 1 hour expressed in milliseconds - 64-bit type. */
#define RT_MS_1HOUR_64 UINT64_C(3600000)
/** 1 minute expressed in milliseconds - 64-bit type. */
#define RT_MS_1MIN_64 UINT64_C(60000)
/** 1 second expressed in milliseconds - 64-bit type. */
#define RT_MS_1SEC_64 UINT64_C(1000)
/** The number of seconds per week. */
#define RT_SEC_1WEEK UINT32_C(604800)
/** The number of seconds per day. */
#define RT_SEC_1DAY UINT32_C(86400)
/** The number of seconds per hour. */
#define RT_SEC_1HOUR UINT32_C(3600)
/** The number of seconds per week - 64-bit type. */
#define RT_SEC_1WEEK_64 UINT64_C(604800)
/** The number of seconds per day - 64-bit type. */
#define RT_SEC_1DAY_64 UINT64_C(86400)
/** The number of seconds per hour - 64-bit type. */
#define RT_SEC_1HOUR_64 UINT64_C(3600)
/** @} */
/** @defgroup grp_rt_cdefs_dbgtype Debug Info Types
* @{ */
/** Other format. */
#define RT_DBGTYPE_OTHER RT_BIT_32(0)
/** Stabs. */
#define RT_DBGTYPE_STABS RT_BIT_32(1)
/** Debug With Arbitrary Record Format (DWARF). */
#define RT_DBGTYPE_DWARF RT_BIT_32(2)
/** Microsoft Codeview debug info. */
#define RT_DBGTYPE_CODEVIEW RT_BIT_32(3)
/** Watcom debug info. */
#define RT_DBGTYPE_WATCOM RT_BIT_32(4)
/** IBM High Level Language debug info. */
#define RT_DBGTYPE_HLL RT_BIT_32(5)
/** Old OS/2 and Windows symbol file. */
#define RT_DBGTYPE_SYM RT_BIT_32(6)
/** Map file. */
#define RT_DBGTYPE_MAP RT_BIT_32(7)
/** @} */
/** @defgroup grp_rt_cdefs_exetype Executable Image Types
* @{ */
/** Some other format. */
#define RT_EXETYPE_OTHER RT_BIT_32(0)
/** Portable Executable. */
#define RT_EXETYPE_PE RT_BIT_32(1)
/** Linear eXecutable. */
#define RT_EXETYPE_LX RT_BIT_32(2)
/** Linear Executable. */
#define RT_EXETYPE_LE RT_BIT_32(3)
/** New Executable. */
#define RT_EXETYPE_NE RT_BIT_32(4)
/** DOS Executable (Mark Zbikowski). */
#define RT_EXETYPE_MZ RT_BIT_32(5)
/** COM Executable. */
#define RT_EXETYPE_COM RT_BIT_32(6)
/** a.out Executable. */
#define RT_EXETYPE_AOUT RT_BIT_32(7)
/** Executable and Linkable Format. */
#define RT_EXETYPE_ELF RT_BIT_32(8)
/** Mach-O Executable (including FAT ones). */
#define RT_EXETYPE_MACHO RT_BIT_32(9)
/** TE from UEFI. */
#define RT_EXETYPE_TE RT_BIT_32(9)
/** @} */
/** @def VALID_PTR
* Pointer validation macro.
* @param ptr The pointer.
*/
#if defined(RT_ARCH_AMD64)
# ifdef IN_RING3
# if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= _4G \
&& !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
# elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
&& ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
|| ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
# else
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
&& !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
# endif
# else /* !IN_RING3 */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
&& ( ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
|| ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
# endif /* !IN_RING3 */
#elif defined(RT_ARCH_X86)
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
#elif defined(RT_ARCH_SPARC64)
# ifdef IN_RING3
# if defined(RT_OS_SOLARIS)
/** Sparc64 user mode: According to Figure 9.4 in solaris internals */
/** @todo # define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80004000U >= 0x80004000U + 0x100000000ULL ) - figure this. */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x80000000U >= 0x80000000U + 0x100000000ULL )
# else
# error "Port me"
# endif
# else /* !IN_RING3 */
# if defined(RT_OS_SOLARIS)
/** @todo Sparc64 kernel mode: This is according to Figure 11.1 in solaris
* internals. Verify in sources. */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) >= 0x01000000U )
# else
# error "Port me"
# endif
# endif /* !IN_RING3 */
#elif defined(RT_ARCH_SPARC)
# ifdef IN_RING3
# ifdef RT_OS_SOLARIS
/** Sparc user mode: According to
* http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#510 */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x400000U >= 0x400000U + 0x2000U )
# else
# error "Port me"
# endif
# else /* !IN_RING3 */
# ifdef RT_OS_SOLARIS
/** @todo Sparc kernel mode: Check the sources! */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
# else
# error "Port me"
# endif
# endif /* !IN_RING3 */
#elif defined(RT_ARCH_ARM)
/* ASSUMES that at least the last and first 4K are out of bounds. */
# define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
#else
# error "Architecture identifier missing / not implemented."
#endif
/** Old name for RT_VALID_PTR. */
#define VALID_PTR(ptr) RT_VALID_PTR(ptr)
/** @def RT_VALID_ALIGNED_PTR
* Pointer validation macro that also checks the alignment.
* @param ptr The pointer.
* @param align The alignment, must be a power of two.
*/
#define RT_VALID_ALIGNED_PTR(ptr, align) \
( !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
&& VALID_PTR(ptr) )
/** @def VALID_PHYS32
* 32 bits physical address validation macro.
* @param Phys The RTGCPHYS address.
*/
#define VALID_PHYS32(Phys) ( (uint64_t)(Phys) < (uint64_t)_4G )
/** @def N_
* The \#define N_ is used to 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
* is concerned.
*
* If you want to both mark a string for translation and translate it, use _().
*/
#define N_(s) (s)
/** @def _
* The \#define _ is used to mark a string for translation and to translate it
* in one step.
*
* If you want to only mark a string for translation, use N_().
*/
#define _(s) gettext(s)
/** @def __PRETTY_FUNCTION__
* With GNU C we'd like to use the builtin __PRETTY_FUNCTION__, so define that
* for the other compilers.
*/
#if !defined(__GNUC__) && !defined(__PRETTY_FUNCTION__)
# ifdef _MSC_VER
# define __PRETTY_FUNCTION__ __FUNCSIG__
# else
# define __PRETTY_FUNCTION__ __FUNCTION__
# endif
#endif
/** @def RT_STRICT
* The \#define RT_STRICT controls whether or not assertions and other runtime
* checks should be compiled in or not. This is defined when DEBUG is defined.
* If RT_NO_STRICT is defined, it will unconditionally be undefined.
*
* If you want assertions which are not subject to compile time options use
* the AssertRelease*() flavors.
*/
#if !defined(RT_STRICT) && defined(DEBUG)
# define RT_STRICT
#endif
#ifdef RT_NO_STRICT
# undef RT_STRICT
#endif
/** @todo remove this: */
#if !defined(RT_LOCK_STRICT) && !defined(DEBUG_bird)
# define RT_LOCK_NO_STRICT
#endif
#if !defined(RT_LOCK_STRICT_ORDER) && !defined(DEBUG_bird)
# define RT_LOCK_NO_STRICT_ORDER
#endif
/** @def RT_LOCK_STRICT
* The \#define RT_LOCK_STRICT controls whether deadlock detection and related
* checks are done in the lock and semaphore code. It is by default enabled in
* RT_STRICT builds, but this behavior can be overridden by defining
* RT_LOCK_NO_STRICT. */
#if !defined(RT_LOCK_STRICT) && !defined(RT_LOCK_NO_STRICT) && defined(RT_STRICT)
# define RT_LOCK_STRICT
#endif
/** @def RT_LOCK_NO_STRICT
* The \#define RT_LOCK_NO_STRICT disables RT_LOCK_STRICT. */
#if defined(RT_LOCK_NO_STRICT) && defined(RT_LOCK_STRICT)
# undef RT_LOCK_STRICT
#endif
/** @def RT_LOCK_STRICT_ORDER
* The \#define RT_LOCK_STRICT_ORDER controls whether locking order is checked
* by the lock and semaphore code. It is by default enabled in RT_STRICT
* builds, but this behavior can be overridden by defining
* RT_LOCK_NO_STRICT_ORDER. */
#if !defined(RT_LOCK_STRICT_ORDER) && !defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_STRICT)
# define RT_LOCK_STRICT_ORDER
#endif
/** @def RT_LOCK_NO_STRICT_ORDER
* The \#define RT_LOCK_NO_STRICT_ORDER disables RT_LOCK_STRICT_ORDER. */
#if defined(RT_LOCK_NO_STRICT_ORDER) && defined(RT_LOCK_STRICT_ORDER)
# undef RT_LOCK_STRICT_ORDER
#endif
/** Source position. */
#define RT_SRC_POS __FILE__, __LINE__, __PRETTY_FUNCTION__
/** Source position declaration. */
#define RT_SRC_POS_DECL const char *pszFile, unsigned iLine, const char *pszFunction
/** Source position arguments. */
#define RT_SRC_POS_ARGS pszFile, iLine, pszFunction
/** Applies NOREF() to the source position arguments. */
#define RT_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
/** @def RT_INLINE_ASM_EXTERNAL
* Defined as 1 if the compiler does not support inline assembly.
* The ASM* functions will then be implemented in external .asm files.
*/
#if (defined(_MSC_VER) && defined(RT_ARCH_AMD64)) \
|| (!defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86))
# define RT_INLINE_ASM_EXTERNAL 1
#else
# define RT_INLINE_ASM_EXTERNAL 0
#endif
/** @def RT_INLINE_ASM_GNU_STYLE
* Defined as 1 if the compiler understands GNU style inline assembly.
*/
#if defined(_MSC_VER)
# define RT_INLINE_ASM_GNU_STYLE 0
#else
# define RT_INLINE_ASM_GNU_STYLE 1
#endif
/** @def RT_INLINE_ASM_USES_INTRIN
* Defined as 1 if the compiler have and uses intrin.h. Otherwise it is 0. */
#ifdef _MSC_VER
# if _MSC_VER >= 1400
# define RT_INLINE_ASM_USES_INTRIN 1
# endif
#endif
#ifndef RT_INLINE_ASM_USES_INTRIN
# define RT_INLINE_ASM_USES_INTRIN 0
#endif
/** @} */
/** @defgroup grp_rt_cdefs_cpp Special Macros for C++
* @ingroup grp_rt_cdefs
* @{
*/
#ifdef __cplusplus
/** @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.
*/
#if defined(_MSC_VER) || defined(RT_OS_OS2)
# define DECLEXPORT_CLASS __declspec(dllexport)
#elif defined(RT_USE_VISIBILITY_DEFAULT)
# define DECLEXPORT_CLASS __attribute__((visibility("default")))
#else
# define DECLEXPORT_CLASS
#endif
/** @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.
*/
#if defined(_MSC_VER) || (defined(RT_OS_OS2) && !defined(__IBMC__) && !defined(__IBMCPP__))
# define DECLIMPORT_CLASS __declspec(dllimport)
#elif defined(RT_USE_VISIBILITY_DEFAULT)
# define DECLIMPORT_CLASS __attribute__((visibility("default")))
#else
# define DECLIMPORT_CLASS
#endif
/** @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
* error:
* @code
* class A
* {
* public:
* operator bool() const { return false; }
* operator int*() const { return NULL; }
* };
* int main()
* {
* A a;
* if (!a);
* if (a && 0);
* return 0;
* }
* @endcode
* 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
* their arguments.
*
* 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
*/
#if defined(_MSC_VER)
# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
inline bool operator! (const Cls &that) { return !bool (that); } \
inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
#else
# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
#endif
/** @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 |<>|
*
* Example:
* @code
* // template class declaration
* template <class C>
* class Foo { ... };
* // applied workaround
* WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL (Foo, <class C>, <C>)
* @endcode
*/
#if defined(_MSC_VER)
# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args) \
template ArgsDecl \
inline bool operator! (const Tpl Args &that) { return !bool (that); } \
template ArgsDecl \
inline bool operator&& (const Tpl Args &that, bool b) { return bool (that) && b; } \
template ArgsDecl \
inline bool operator|| (const Tpl Args &that, bool b) { return bool (that) || b; } \
template ArgsDecl \
inline bool operator&& (bool b, const Tpl Args &that) { return b && bool (that); } \
template ArgsDecl \
inline bool operator|| (bool b, const Tpl Args &that) { return b || bool (that); }
#else
# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP_TPL(Tpl, ArgsDecl, Args)
#endif
/** @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
* class.
*
* @param Cls class name to declare for
*/
#define DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Cls) \
inline Cls (const Cls &); \
inline Cls &operator= (const Cls &);
/** @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
*/
#define DECLARE_CLS_NEW_DELETE_NOOP(Cls) \
inline static void *operator new (size_t); \
inline static void operator delete (void *);
#endif /* __cplusplus */
/** @} */
#endif