Utils.h#
Fully qualified name: omni/observability/Utils.h
File members: omni/observability/Utils.h
// SPDX-FileCopyrightText: Copyright (c) 2025 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 <stdint.h>
// ********************************** Platform Helper Macros **************************************
#define OMNI_OTEL_UNSUPPORTED_PLATFORM() static_assert(false, "Unsupported platform!")
// ****** Platform Identification Macros ******
#ifdef DOXYGEN_BUILD
# define OMNI_OTEL_PLATFORM_LINUX 0
# define OMNI_OTEL_PLATFORM_WINDOWS 1
#else
# ifdef _WIN32
# define OMNI_OTEL_PLATFORM_LINUX 0
# define OMNI_OTEL_PLATFORM_WINDOWS 1
# elif defined(__linux__)
# define OMNI_OTEL_PLATFORM_LINUX 1
# define OMNI_OTEL_PLATFORM_WINDOWS 0
# endif
#endif
// ****** Compiler Identification Macros ******
#ifdef DOXYGEN_BUILD
# define OMNI_OTEL_COMPILER_MSC 0
# define OMNI_OTEL_COMPILER_GNUC 1
#elif defined(OMNI_OTEL_COMPILER_MSC) && defined(OMNI_OTEL_COMPILER_GNUC)
# if (!!OMNI_OTEL_COMPILER_MSC) + (!!OMNI_OTEL_COMPILER_GNUC) != 1
# define OMNI_OTEL_COMPILER_MSC // Show previous definition
# define OMNI_OTEL_COMPILER_GNUC // Show previous definition
# error Exactly one of OMNI_OTEL_COMPILER_MSC or OMNI_OTEL_COMPILER_GNUC must be non-zero.
# endif
#elif !defined(OMNI_OTEL_COMPILER_MSC) && !defined(OMNI_OTEL_COMPILER_GNUC)
# ifndef OMNI_OTEL_COMPILER_MSC
# if defined(_MSC_VER)
# define OMNI_OTEL_COMPILER_MSC 1
# define OMNI_OTEL_COMPILER_GNUC 0
# elif defined(__GNUC__)
# define OMNI_OTEL_COMPILER_MSC 0
# define OMNI_OTEL_COMPILER_GNUC 1
# else
# error "Unsupported compiler."
# endif
# endif
#else
# error "Must define OMNI_OTEL_COMPILER_MSC and OMNI_OTEL_COMPILER_GNUC or neither."
#endif
#ifdef DOXYGEN_BUILD
# define OMNI_OTEL_TOOLCHAIN_CLANG 0
#elif !defined(OMNI_OTEL_TOOLCHAIN_CLANG)
# if defined(__clang__)
# define OMNI_OTEL_TOOLCHAIN_CLANG 1
# else
# define OMNI_OTEL_TOOLCHAIN_CLANG 0
# endif
#endif
// ****** Symbol Export and Compiler Helper Macros ******
#if defined(__cplusplus) || defined(DOXYGEN_BUILD)
# define OMNI_OTEL_EXTERN_C extern "C"
#endif
#define OMNI_OTEL_IMPORT OMNI_OTEL_EXTERN_C
#ifdef DOXYGEN_BUILD
# define OMNI_OTEL_ATTRIBUTE(...)
# define OMNI_OTEL_DECLSPEC(...)
#else
# if OMNI_OTEL_COMPILER_MSC
# if OMNI_OTEL_TOOLCHAIN_CLANG
# define OMNI_OTEL_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# else
# define OMNI_OTEL_ATTRIBUTE(...)
# endif
# define OMNI_OTEL_DECLSPEC(...) __declspec(__VA_ARGS__)
# elif OMNI_OTEL_COMPILER_GNUC
# define OMNI_OTEL_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# define OMNI_OTEL_DECLSPEC(...)
# endif
#endif
#define OMNI_OTEL_EXPORT OMNI_OTEL_EXTERN_C OMNI_OTEL_DECLSPEC(dllexport) OMNI_OTEL_ATTRIBUTE(visibility("default"))
#if defined(OMNI_OTEL_EXPORTS) || defined(DOXYGEN_BUILD)
# define OMNI_OTEL_DYNAMICLINK OMNI_OTEL_EXPORT
#else
# define OMNI_OTEL_DYNAMICLINK OMNI_OTEL_IMPORT
#endif
// ********************************** General Helper Macros ***************************************
#define OMNI_COUNTOF(x) (sizeof(x) / sizeof((x)[0]))
// ************************************* Logging Helpers ******************************************
namespace omni
{
namespace observability
{
using LoggerId = int64_t;
constexpr LoggerId kInvalidLoggerId = -1;
using ProcessId = int64_t;
using ThreadId = int64_t;
#define PRI_ThreadId PRId64
#define PRI_ProcessId PRId64
} // namespace observability
} // namespace omni