Defines.h#
Fully qualified name: carb/Defines.h
File members: carb/Defines.h
// SPDX-FileCopyrightText: Copyright (c) 2018-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#include "Architecture.h"
#include "Platform.h"
#include "Compiler.h"
#define CARB_VIZ
#define CARB_ABI
#define CARB_DEPAREN(pack_) CARB_IDENTITY pack_
#define CARB_IDENTITY(...) __VA_ARGS__
#define CARB_MIN(a, b) (((a) < (b)) ? (a) : (b))
#define CARB_MAX(a, b) (((a) > (b)) ? (a) : (b))
#define CARB_CLAMP(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))
#define CARB_ROUNDUP(value, to) ((((value) + (to)-1) / (to)) * (to))
#ifndef DOXYGEN_BUILD
// CARB_JOIN will join together `a` and `b` and also work properly if either parameter is another macro like __LINE__.
// This requires two macros since the preprocessor will only recurse macro expansion if # and ## are not present.
# define __CARB_JOIN_HELPER(a, b) a##b
#endif
#define CARB_JOIN(a, b) __CARB_JOIN_HELPER(a, b)
#if defined(__COUNTER__) || defined(DOXYGEN_BUILD)
# define CARB_ANONYMOUS_VAR(str) CARB_JOIN(str, __COUNTER__)
#else
# define CARB_ANONYMOUS_VAR(str) CARB_JOIN(str, __LINE__)
#endif
#define CARB_PREVENT_COPY(classname) \
classname(const classname&) = delete; \
classname& operator=(const classname&) = delete
#define CARB_PREVENT_MOVE(classname) \
classname(classname&&) = delete; \
classname& operator=(classname&&) = delete
#define CARB_PREVENT_COPY_AND_MOVE(classname) \
CARB_PREVENT_COPY(classname); \
CARB_PREVENT_MOVE(classname)
#ifndef DOXYGEN_BUILD
// clang-format off
# define __CARB_STRINGIFY_HELPER(x) #x
// clang-format on
# define CARB_ENSURE_LITERAL(x) "" x
#else
# define CARB_ENSURE_LITERAL(x) x
#endif
#define CARB_STRINGIFY(x) __CARB_STRINGIFY_HELPER(x)
#ifdef DOXYGEN_BUILD
# define CARB_UNUSED(...)
#else
template <class... Args>
void CARB_UNUSED(Args&&...)
{
}
#endif
#if defined(CARB_INCLUDE_PURIFY_NAME) && !defined(DOXYGEN_BUILD)
# define CARB_INCLUDE_PURIFY_TEST(...) \
inline void CARB_ANONYMOUS_VAR(CARB_INCLUDE_PURIFY_NAME)() __VA_ARGS__ static_assert(true, "Semicolon required")
#else
# define CARB_INCLUDE_PURIFY_TEST(...)
#endif
#define CARB_STATIC_CACHE(...) \
([&] { \
static auto cached = (__VA_ARGS__); \
return cached; \
}())
#ifndef CARB_PROFILING
# define CARB_PROFILING 1
#endif