carb/Defines.h

↰ Parent directory: carb/

Carbonite basic defines and helper functions.

Source: carb/Defines.h

Included By

Namespaces

  • carb: The main Carbonite namespace.

Classes

  • carb::InitBoth: An empty class tag type used with carb::EmptyMemberPair constructors.

  • carb::ValueInitFirst: An empty class tag type used with carb::EmptyMemberPair constructors.

  • carb::EmptyMemberPair: Attempts to invoke the Empty Member Optimization by inheriting from the First element if possible, which, if empty will eliminate the storage necessary for an empty class; the Second element is always stored as a separate member. The First element is inherited from if it is an empty class/struct and is not declared final.

Enums

Functions

Defines

  • CARB_AARCH64: A macro defined as 1 if compilation is targeting the AArch64 platform; 0 otherwise. May not be overridden on the command line or by defining before including this file. Set to 1 if __aarch64__ is defined, 0 if __x86_64__ or _M_X64 are defined, and left undefined otherwise.

  • CARB_ABI: Defined as __cdecl on Windows and an empty define on Linux. Used to explicitly state ABI calling convention for API functions.

  • CARB_ALIGN: Aligns a number or pointer to the next multiple of a provided alignment.

  • CARB_ALIGN_AS: Defined as alignas(T).

  • CARB_ALIGN_OF: Returns the required alignment of a type.

  • CARB_ALIGNED_SIZE: Aligns a size to the given alignment.

  • CARB_ALLOCA: This is a wrapper for the platform-specific call to the non-standard but almost universal alloca() function.

  • CARB_ALWAYS_INLINE: Instructs the compiler to force inline of the decorated function.

  • CARB_ANONYMOUS_VAR: A helper macro that appends a number to the given name to create a unique name.

  • CARB_ARCH_NAME: The name of the current architecture as a string.

  • CARB_ARCH_NAME: The name of the current architecture as a string.

  • CARB_ASAN_ENABLED: A macro defined as 1 if a GNU toolchain is building the current file with -fsanitize=address, that is, if both CARB_COMPILER_GNUC is 1 and __SANITIZE_ADDRESS__ is defined; 0 otherwise. May be overridden by defining a different value before including this file or by specifying a different value on the compiler command line.

  • CARB_ASSERT: Optionally performs an assertion, by default for debug builds only.

  • CARB_ASSERT_ENABLED: Indicates whether asserts are enabled. May be overridden by defining this before including this file. By default, is set to 1 if CARB_DEBUG is non-zero. If this is overridden to a non-zero value and CARB_ASSERT is not defined, CARB_ASSERT will receive the default implementation.

  • CARB_ASSERT_MEMBERS_MATCH: A helper to determine if member A.a matches the offset and size of B.b, causing a static assert if unmatched.

  • CARB_ASSERT_STRUCTS_MATCH: A helper to determine if the size and alignment of two given structures match, causing a static assert if unmatched.

  • CARB_ATTRIBUTE: GCC only, defined as __attribute__((__VA_ARGS__)); ignored on non-GCC compilers.

  • CARB_BREAK_POINT: On Windows platforms, defined as __debugbreak(); on Linux, raise(SIGTRAP). Used to break into the debugger.

  • CARB_CACHELINE_ALIGN: Defined as CARB_ALIGN_AS(CARB_CACHELINE_SIZE).

  • CARB_CACHELINE_SIZE: Minimum offset between two objects to avoid false sharing, i.e. cacheline size. If C++17 is not supported, falls back to the default value of 64 bytes.

  • CARB_CHECK: Optionally performs a runtime check assertion, by default for both debug and release builds.

  • CARB_CHECK_ENABLED: Indicates whether runtime checking is enabled. May be overridden by defining this before including this file. By default, is set to 1 always. If this is overridden to a non-zero value and CARB_CHECK is not defined, CARB_CHECK will receive the default implementation.

  • CARB_CLAMP: A macro the returns the largest of two values.

  • CARB_COMPILER_GNUC: A macro defined as 1 if compilation is using GNU C Compiler (GCC), that is, if _MSC_VER is not defined but __GNUC__ is defined. May be overridden by defining a different value before including this file or by specifying a different value on the compiler command line, however, only one of CARB_COMPILER_MSC and CARB_COMPILER_GNUC must be set to 1; the other macro(s) must be set to 0.

  • CARB_COMPILER_MSC: A macro defined as 1 if compilation is using Microsoft Visual C++, that is, if _MSC_VER is defined. May be overridden by defining a different value before including this file or by specifying a different value on the compiler command line, however, only one of CARB_COMPILER_MSC and CARB_COMPILER_GNUC must be set to 1; the other macro(s) must be set to 0.

  • CARB_COUNTOF: Returns the count of an array as a size_t at compile time.

  • CARB_COUNTOF32: Returns the count of an array as a uint32_t at compile time.

  • CARB_CPP17_CONSTEXPR: Defined as constexpr if the current compiler supports C++17; empty otherwise.

  • CARB_CPP20_CONSTEXPR: Defined as constexpr if the current compiler supports C++20; empty otherwise.

  • CARB_DEBUG: A macro indicating whether the current compilation unit is built in debug mode. Always defined as either 0 or 1. Can be overridden by defining before this file is included or by passing on the compiler command line. Defined as 0 if NDEBUG is defined; 1 otherwise.

  • CARB_DECLSPEC: MSVC only, defined as __declspec(__VA_ARGS__); ignored on non-MSVC compilers.

  • CARB_DEPRECATED: Declares a function as deprected.

  • CARB_DIVIDE_CEIL: Divides size by divisor and returns the closest integer greater than or equal to the division result.

  • CARB_DOC_CONSTEXPR: Macro to work around Exhale tripping over constexpr sometimes and reporting things like: Invalid C++ declaration: Expected identifier in nested name, got keyword: static

  • CARB_DOC_ONLY: Conditionally includes text only when documenting (i.e. when DOXYGEN_BUILD is defined).

  • CARB_DYNAMICLINK: Conditional (import/export) dynamic linking.

  • CARB_EXCEPTIONS_ENABLED: Indicates whether exceptions are enabled for the current compilation unit. Value depends on parameters passed to the compiler.

  • CARB_EXPORT: Grants a function external linkage in a dynamic library or executable.

  • CARB_EXPORTS: Instructs CARB_DYNAMICLINK to export instead of import.

  • CARB_EXTERN_C: Defined as extern "C" for C++ compilation, that is, when __cplusplus is defined; empty define otherwise.

  • CARB_FALLTHROUGH: Defined as [[fallthrough]] if the current compiler supports C++17; empty otherwise.

  • CARB_FATAL_UNLESS: Terminates the application if a check fails.

  • CARB_FLOAT_MAX: The maximum value that can be represented by float.

  • CARB_FREE: Frees memory previously allocated using CARB_MALLOC.

  • CARB_HARDWARE_PAUSE: Instructs the underlying hardware to idle the CPU pipelines and reduce the penalty from memory order violations.

  • CARB_HAS_CPP14: Defined as 1 if the current compiler supports C++14; 0 otherwise. C++14 is the minimum required for using Carbonite (though building Carbonite requires C++17).

  • CARB_HAS_CPP17: Defined as 1 if the current compiler supports C++17; 0 otherwise.

  • CARB_HAS_CPP20: Defined as 1 if the current compiler supports C++20; 0 otherwise.

  • CARB_HASH_STRING: Computes a literal string hash at compile time.

  • CARB_HASH_TYPE: Syntactic sugar for CARB_HASH_STRING(CARB_STRINGIFY(T)).

  • CARB_HIDDEN: Syntactic sugar for CARB_ATTRIBUTE(visibility("hidden")); ignored on compilers other than GCC.

  • CARB_IGNOREWARNING_CLANG: For CLang only, disables a specific compiler warning for the current compilation warning configuration. Defined as _Pragma("GCC diagnostic ignored <warning>") for CLang only; ignored by other compilers.

  • CARB_IGNOREWARNING_CLANG_POP: For CLang only, pops the compilation warning configuration previously pushed with CARB_IGNOREWARNING_CLANG_PUSH, overwriting the current state. Defined as _Pragma("GCC diagnostic pop") for CLang only; ignored by other compilers.

  • CARB_IGNOREWARNING_CLANG_PUSH: For CLang only, pushes the current compilation warning configuration. Defined as _Pragma("GCC diagnostic push") for CLang only; ignored by other compilers.

  • CARB_IGNOREWARNING_CLANG_WITH_PUSH: Syntactic sugar for CARB_IGNOREWARNING_CLANG_PUSH followed by CARB_IGNOREWARNING_CLANG.

  • CARB_IGNOREWARNING_GNUC: For GCC only, disables a specific compiler warning for the current compilation warning configuration. Defined as _Pragma("GCC diagnostic ignored <warning>") for GCC only; ignored by other compilers.

  • CARB_IGNOREWARNING_GNUC_POP: For GCC only, pops the compilation warning configuration previously pushed with CARB_IGNOREWARNING_GNUC_PUSH, overwriting the current state. Defined as _Pragma("GCC diagnostic pop") for GCC only; ignored by other compilers.

  • CARB_IGNOREWARNING_GNUC_PUSH: For GCC only, pushes the current compilation warning configuration. Defined as _Pragma("GCC diagnostic push") for GCC only; ignored by other compilers.

  • CARB_IGNOREWARNING_GNUC_WITH_PUSH: Syntactic sugar for CARB_IGNOREWARNING_GNUC_PUSH followed by CARB_IGNOREWARNING_GNUC.

  • CARB_IGNOREWARNING_MSC: For MSVC only, disables a specific compiler warning for the current compilation warning configuration. Defined as __pragma(warning(disable : <w>)) for MSVC only; ignored by other compilers.

  • CARB_IGNOREWARNING_MSC_POP: For MSVC only, pops the compilation warning configuration previously pushed with CARB_IGNOREWARNING_MSC_PUSH, overwriting the current state. Defined as __pragma(warning(pop)) for MSVC only; ignored by other compilers.

  • CARB_IGNOREWARNING_MSC_PUSH: For MSVC only, pushes the current compilation warning configuration. Defined as __pragma(warning(push)) for MSVC only; ignored by other compilers.

  • CARB_IGNOREWARNING_MSC_WITH_PUSH: Syntactic sugar for CARB_IGNOREWARNING_MSC_PUSH followed by CARB_IGNOREWARNING_MSC.

  • CARB_IMPORT: Imports a function with external linkage from a shared object or DLL.

  • CARB_JOIN: A macro that joins two parts to create one symbol allowing one or more parameters to be a macro, as if by the ## preprocessor operator. Example: CARB_JOIN(test, __LINE__) on line 579 produces test579.

  • CARB_LIKELY: Defined as ([[likely]] !!(<expr>)) if the current compiler supports C++20. If the current compiler is GCC, as a fallback, __builtin_expect(!!(<expr>), 1) will be used. Otherwise, defined as (!!(<expr>))

  • CARB_MACOS_UNIMPLEMENTED: A macro to mark placeholder functions on MacOS while the porting effort is in progress.

  • CARB_MALLOC: Allocates memory from the heap.

  • CARB_MAX: A macro the returns the largest of two values.

  • CARB_MAYBE_UNUSED: Defined as [[maybe_unused]] if the current compiler supports C++17; empty otherwise.

  • CARB_MIN: A macro that returns the least of two values.

  • CARB_NO_DOC: Declares a value or statement in a way that prevents Doxygen and Sphinx from getting confused about matching symbols. There seems to be a bug in Sphinx that prevents at least templated symbols from being matched to the ones generated by Doxygen when keywords such as decltype are used. This is effectively the opposite operation as CARB_DOC_ONLY.

  • CARB_NO_OPTIMIZE_GNUC_CLANG: Disables optimizations for the function that is tagged with this attribute. This only affects the single function that it tags. Optimizations will be restored to the previous settings for the translation unit outside of the tagged function.

  • CARB_NO_UNIQUE_ADDRESS: Defined as [[no_unique_address]] if the current compiler supports C++20; empty otherwise.

  • CARB_NODISCARD: Defined as [[nodiscard]] if the current compiler supports C++17; empty otherwise.

  • CARB_NOEXCEPT: Declares that a function will not throw any exceptions.

  • CARB_NOINLINE: A macro that declares that a function may not be inlined.

  • CARB_OFFSETOF: Returns the offset of a member of a class at compile time.

  • CARB_OPTIMIZE_OFF_MSC: Turns optimizations off at the function level until a CARB_OPTIMIZE_ON_MSC call is seen. This must be called outside of the body of any function and will remain in effect until either a CARB_OPTIMIZE_ON_MSC call is seen or the end of the translation unit. This unfortunately needs to be a separate set of macros versus the one for GCC and CLang due to the different style of disabling and enabling optimizations under the MSC compiler.

  • CARB_OPTIMIZE_ON_MSC: Restores previous optimizations that were temporarily disable due to an earlier call to CARB_OPTIMIZE_OFF_MSC. This must be called outside the body of any function. If this call is not made, the previous optimization state will remain until the end of the current translation unit.

  • CARB_PLATFORM_LINUX: A macro defined as 1 if compilation is targeting Linux; 0 otherwise. Exactly one of the CARB_PLATFORM_* macros will be set to 1. May be overridden by defining before this file is included or by passing on the compiler command line. By default, set to 1 if _WIN32 is not defined and __linux__ is defined.

  • CARB_PLATFORM_MACOS: A macro defined as 1 if compilation is targeting Mac OS; 0 otherwise. Exactly one of the CARB_PLATFORM_* macros will be set to 1. May be overridden by defining before this file is included or by passing on the compiler command line. By default, set to 1 if _WIN32 and __linux__ are not defined and __APPLE__ is defined.

  • CARB_PLATFORM_NAME: The name of the current platform as a string.

  • CARB_PLATFORM_WINDOWS: A macro defined as 1 if compilation is targeting Windows; 0 otherwise. Exactly one of the CARB_PLATFORM_* macros will be set to 1. May be overridden by defining before this file is included or by passing on the compiler command line. By default, set to 1 if _WIN32 is defined.

  • CARB_POSIX: This is set to _POSIX_VERSION platforms that are mostly-compliant with POSIX.

  • CARB_PRAGMA_GNUC: GCC only, defined as _Pragma(__VA_ARGS__); ignored on non-GCC compilers.

  • CARB_PRAGMA_MSC: MSVC only, defined as __pragma(__VA_ARGS__); ignored on non-MSVC compilers.

  • CARB_PREFETCH: Attempts to prefetch from memory using a compiler intrinsic.

  • CARB_PRETTY_FUNCTION: Acts as a char[] with the current full function signature.

  • CARB_PREVENT_COPY: A macro that deletes the copy-construct and copy-assign functions for the given classname.

  • CARB_PREVENT_COPY_AND_MOVE: Syntactic sugar for both CARB_PREVENT_COPY and CARB_PREVENT_MOVE.

  • CARB_PREVENT_MOVE: A macro that deletes the move-construct and move-assign functions for the given classname.

  • CARB_PRINTF_FUNCTION: Requests that the compiler validate any variadic arguments as printf-style format specifiers, if supported by the compiler. Causes a compilation error if the printf-style format specifier doesn’t match the given variadic types.

  • CARB_PROFILING: When set to a non-zero value, profiling macros in include/carb/profiler/Profile.h will report to the profiler; otherwise the profiling macros have no effect. Always set to 1 by default, but may be overridden by defining a different value before including this file or by specifying a different value on the compiler command line.

  • CARB_RETRY_EINTR: A macro to retry operations if they return -1 and errno is set to EINTR.

  • CARB_ROUNDUP: Rounds a given value to the next highest multiple of another given value.

  • CARB_STACK_ALLOC: Attempts to allocate an array of the given type on the stack.

  • CARB_STRINGIFY: Turns a name into a string, resolving macros (i.e. CARB_STRINGIFY(__LINE__) on line 815 will produce "815").

  • CARB_TEGRA: A macro defined as 1 if compilation is targeting the Tegra platform. By default set to 1 only if __aarch64__ and __LINARO_RELEASE__ are defined; 0 otherwise. May be overridden by defining a different value before including this file or by specifying a different value on the compiler command line.

  • CARB_TOOLCHAIN_CLANG: A macro defined as 1 if a Clang-infrastructure toolchain is building the current file, that is, if __clang__ is defined; 0 if not. May be overridden by defining a different value before including this file or by specifying a different value on the compiler command line.

  • CARB_UINT16_MAX: The maximum value that can be represented by uint16_t.

  • CARB_UINT32_MAX: The maximum value that can be represented by uint32_t.

  • CARB_UINT64_MAX: The maximum value that can be represented by uint64_t.

  • CARB_ULLONG_MAX: The maximum value that can be represented by unsigned long long.

  • CARB_UNIMPLEMENTED: A macro to mark functionality that has not been implemented yet.

  • CARB_UNLIKELY: Defined as ([[unlikely]] !!(<expr>)) if the current compiler supports C++20. If the current compiler is GCC, as a fallback, __builtin_expect(!!(<expr>), 0) will be used. Otherwise, defined as (!!(<expr>))

  • CARB_UNSUPPORTED_ARCHITECTURE: A macro to put into the #else branches when writing CPU architecture specific code.

  • CARB_UNSUPPORTED_PLATFORM: A macro to put into #else branches when writing platform-specific code.

  • CARB_USHRT_MAX: The maximum value that can be represented by unsigned short.

  • CARB_WEAKLINK: Syntactic sugar for None, used to enable weak linking.

  • CARB_X86_64: A macro defined as 1 if compilation is targeting the x86-64 platform; 0 otherwise. May not be overridden on the command line or by defining before including this file. Set to 0 if __aarch64__ is defined, 1 if __x86_64__ or _M_X64 are defined, and left undefined otherwise.

  • DOXYGEN_EMPTY_CLASS: Used when declaring opaque types to prevent Doxygen from getting confused about not finding any implementation.

Variables