diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c04d83175..5b78ca7ecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,6 @@ if(WITH_ABSEIL) add_definitions(-DHAVE_ABSEIL) find_package(absl CONFIG REQUIRED) - # Abseil headers-only lib is needed for absl::variant to work vs2015. - # `nostd::mpark::variant` is not compiling in vs2015. set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city) # target_link_libraries(main PRIVATE absl::any absl::base absl::bits @@ -62,6 +60,12 @@ if(WITH_ABSEIL) endif() if(WITH_STL) + # These definitions are needed for test projects that do not link against + # opentelemetry-api library directly. We ensure that variant implementation + # (absl::variant or std::variant) in variant unit test code is consistent with + # the global project build definitions. + add_definitions(-DHAVE_CPP_STDLIB) + add_definitions(-DHAVE_GSL) # Require at least C++17. C++20 is needed to avoid gsl::span if(CMAKE_MINOR_VERSION VERSION_GREATER "3.18") # Ask for 20, may get anything below diff --git a/api/include/opentelemetry/common/attribute_value.h b/api/include/opentelemetry/common/attribute_value.h index 5ea9b99d11..af4cc83d42 100644 --- a/api/include/opentelemetry/common/attribute_value.h +++ b/api/include/opentelemetry/common/attribute_value.h @@ -40,6 +40,7 @@ using AttributeValue = int64_t, uint32_t, double, + const char *, nostd::string_view, nostd::span, nostd::span, @@ -64,6 +65,7 @@ enum AttributeType kTypeInt64, kTypeUInt, kTypeDouble, + kTypeCString, kTypeString, kTypeSpanBool, kTypeSpanInt, diff --git a/api/include/opentelemetry/nostd/absl/README.md b/api/include/opentelemetry/nostd/absl/README.md index 1c03ceaaf5..6a40855704 100644 --- a/api/include/opentelemetry/nostd/absl/README.md +++ b/api/include/opentelemetry/nostd/absl/README.md @@ -2,13 +2,3 @@ This is a snapshot of Abseil Variant `absl::variant` from Abseil `v2020-03-03#8`. - -This code is required to compile OpenTelemetry code in vs2015 because MPark -Variant implementation is not compatible with vs2015. - -Build option `HAVE_ABSEIL_VARIANT` allows to enable the build with -`absl::variant`, `absl::get` and `absl::visit` as defalt implementation for -`nostd::` classes. - -Going forward it makes sense to use `absl::variant` as default implementation -for Windows OS and vs2015, vs2017, vs2019 and newer compilers. diff --git a/api/include/opentelemetry/nostd/absl/base/attributes.h b/api/include/opentelemetry/nostd/absl/base/attributes.h index ff138629d1..72901a84c5 100644 --- a/api/include/opentelemetry/nostd/absl/base/attributes.h +++ b/api/include/opentelemetry/nostd/absl/base/attributes.h @@ -57,10 +57,10 @@ // // Since these macro names are only supported by GCC and Clang, we only check // for `__GNUC__` (GCC or Clang) and the above macros. -#ifndef ABSL_BASE_ATTRIBUTES_H_ -#define ABSL_BASE_ATTRIBUTES_H_ +#ifndef OTABSL_BASE_ATTRIBUTES_H_ +#define OTABSL_BASE_ATTRIBUTES_H_ -// ABSL_HAVE_ATTRIBUTE +// OTABSL_HAVE_ATTRIBUTE // // A function-like feature checking macro that is a wrapper around // `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a @@ -71,12 +71,12 @@ // GCC: https://gcc.gnu.org/gcc-5/changes.html // Clang: https://clang.llvm.org/docs/LanguageExtensions.html #ifdef __has_attribute -#define ABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) +#define OTABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) #else -#define ABSL_HAVE_ATTRIBUTE(x) 0 +#define OTABSL_HAVE_ATTRIBUTE(x) 0 #endif -// ABSL_HAVE_CPP_ATTRIBUTE +// OTABSL_HAVE_CPP_ATTRIBUTE // // A function-like feature checking macro that accepts C++11 style attributes. // It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 @@ -85,9 +85,9 @@ #if defined(__cplusplus) && defined(__has_cpp_attribute) // NOTE: requiring __cplusplus above should not be necessary, but // works around https://bugs.llvm.org/show_bug.cgi?id=23435. -#define ABSL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#define OTABSL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #else -#define ABSL_HAVE_CPP_ATTRIBUTE(x) 0 +#define OTABSL_HAVE_CPP_ATTRIBUTE(x) 0 #endif // ----------------------------------------------------------------------------- @@ -97,8 +97,8 @@ // GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html // Clang: https://clang.llvm.org/docs/AttributeReference.html -// ABSL_PRINTF_ATTRIBUTE -// ABSL_SCANF_ATTRIBUTE +// OTABSL_PRINTF_ATTRIBUTE +// OTABSL_SCANF_ATTRIBUTE // // Tells the compiler to perform `printf` format string checking if the // compiler supports it; see the 'format' attribute in @@ -107,52 +107,52 @@ // Note: As the GCC manual states, "[s]ince non-static C++ methods // have an implicit 'this' argument, the arguments of such methods // should be counted from two, not one." -#if ABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \ +#if OTABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \ __attribute__((__format__(__printf__, string_index, first_to_check))) -#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \ +#define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \ __attribute__((__format__(__scanf__, string_index, first_to_check))) #else -#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) -#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check) +#define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) +#define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) #endif -// ABSL_ATTRIBUTE_ALWAYS_INLINE -// ABSL_ATTRIBUTE_NOINLINE +// OTABSL_ATTRIBUTE_ALWAYS_INLINE +// OTABSL_ATTRIBUTE_NOINLINE // // Forces functions to either inline or not inline. Introduced in gcc 3.1. -#if ABSL_HAVE_ATTRIBUTE(always_inline) || \ +#if OTABSL_HAVE_ATTRIBUTE(always_inline) || \ (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) -#define ABSL_HAVE_ATTRIBUTE_ALWAYS_INLINE 1 +#define OTABSL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) +#define OTABSL_HAVE_ATTRIBUTE_ALWAYS_INLINE 1 #else -#define ABSL_ATTRIBUTE_ALWAYS_INLINE +#define OTABSL_ATTRIBUTE_ALWAYS_INLINE #endif -#if ABSL_HAVE_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_NOINLINE __attribute__((noinline)) -#define ABSL_HAVE_ATTRIBUTE_NOINLINE 1 +#if OTABSL_HAVE_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_NOINLINE __attribute__((noinline)) +#define OTABSL_HAVE_ATTRIBUTE_NOINLINE 1 #else -#define ABSL_ATTRIBUTE_NOINLINE +#define OTABSL_ATTRIBUTE_NOINLINE #endif -// ABSL_ATTRIBUTE_NO_TAIL_CALL +// OTABSL_ATTRIBUTE_NO_TAIL_CALL // // Prevents the compiler from optimizing away stack frames for functions which // end in a call to another function. -#if ABSL_HAVE_ATTRIBUTE(disable_tail_calls) -#define ABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 -#define ABSL_ATTRIBUTE_NO_TAIL_CALL __attribute__((disable_tail_calls)) +#if OTABSL_HAVE_ATTRIBUTE(disable_tail_calls) +#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 +#define OTABSL_ATTRIBUTE_NO_TAIL_CALL __attribute__((disable_tail_calls)) #elif defined(__GNUC__) && !defined(__clang__) -#define ABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 -#define ABSL_ATTRIBUTE_NO_TAIL_CALL \ +#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 +#define OTABSL_ATTRIBUTE_NO_TAIL_CALL \ __attribute__((optimize("no-optimize-sibling-calls"))) #else -#define ABSL_ATTRIBUTE_NO_TAIL_CALL -#define ABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 0 +#define OTABSL_ATTRIBUTE_NO_TAIL_CALL +#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 0 #endif -// ABSL_ATTRIBUTE_WEAK +// OTABSL_ATTRIBUTE_WEAK // // Tags a function as weak for the purposes of compilation and linking. // Weak attributes currently do not work properly in LLVM's Windows backend, @@ -160,18 +160,18 @@ // for further information. // The MinGW compiler doesn't complain about the weak attribute until the link // step, presumably because Windows doesn't use ELF binaries. -#if (ABSL_HAVE_ATTRIBUTE(weak) || \ +#if (OTABSL_HAVE_ATTRIBUTE(weak) || \ (defined(__GNUC__) && !defined(__clang__))) && \ !(defined(__llvm__) && defined(_WIN32)) && !defined(__MINGW32__) -#undef ABSL_ATTRIBUTE_WEAK -#define ABSL_ATTRIBUTE_WEAK __attribute__((weak)) -#define ABSL_HAVE_ATTRIBUTE_WEAK 1 +#undef OTABSL_ATTRIBUTE_WEAK +#define OTABSL_ATTRIBUTE_WEAK __attribute__((weak)) +#define OTABSL_HAVE_ATTRIBUTE_WEAK 1 #else -#define ABSL_ATTRIBUTE_WEAK -#define ABSL_HAVE_ATTRIBUTE_WEAK 0 +#define OTABSL_ATTRIBUTE_WEAK +#define OTABSL_HAVE_ATTRIBUTE_WEAK 0 #endif -// ABSL_ATTRIBUTE_NONNULL +// OTABSL_ATTRIBUTE_NONNULL // // Tells the compiler either (a) that a particular function parameter // should be a non-null pointer, or (b) that all pointer arguments should @@ -191,42 +191,42 @@ // Example: // // /* arg_a cannot be null, but arg_b can */ -// void Function(void* arg_a, void* arg_b) ABSL_ATTRIBUTE_NONNULL(1); +// void Function(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(1); // // class C { // /* arg_a cannot be null, but arg_b can */ -// void Method(void* arg_a, void* arg_b) ABSL_ATTRIBUTE_NONNULL(2); +// void Method(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(2); // // /* arg_a cannot be null, but arg_b can */ // static void StaticMethod(void* arg_a, void* arg_b) -// ABSL_ATTRIBUTE_NONNULL(1); +// OTABSL_ATTRIBUTE_NONNULL(1); // }; // // If no arguments are provided, then all pointer arguments should be non-null. // // /* No pointer arguments may be null. */ -// void Function(void* arg_a, void* arg_b, int arg_c) ABSL_ATTRIBUTE_NONNULL(); +// void Function(void* arg_a, void* arg_b, int arg_c) OTABSL_ATTRIBUTE_NONNULL(); // // NOTE: The GCC nonnull attribute actually accepts a list of arguments, but -// ABSL_ATTRIBUTE_NONNULL does not. -#if ABSL_HAVE_ATTRIBUTE(nonnull) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_NONNULL(arg_index) __attribute__((nonnull(arg_index))) +// OTABSL_ATTRIBUTE_NONNULL does not. +#if OTABSL_HAVE_ATTRIBUTE(nonnull) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_NONNULL(arg_index) __attribute__((nonnull(arg_index))) #else -#define ABSL_ATTRIBUTE_NONNULL(...) +#define OTABSL_ATTRIBUTE_NONNULL(...) #endif -// ABSL_ATTRIBUTE_NORETURN +// OTABSL_ATTRIBUTE_NORETURN // // Tells the compiler that a given function never returns. -#if ABSL_HAVE_ATTRIBUTE(noreturn) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_NORETURN __attribute__((noreturn)) +#if OTABSL_HAVE_ATTRIBUTE(noreturn) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) -#define ABSL_ATTRIBUTE_NORETURN __declspec(noreturn) +#define OTABSL_ATTRIBUTE_NORETURN __declspec(noreturn) #else -#define ABSL_ATTRIBUTE_NORETURN +#define OTABSL_ATTRIBUTE_NORETURN #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS +// OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS // // Tells the AddressSanitizer (or other memory testing tools) to ignore a given // function. Useful for cases when a function reads random locations on stack, @@ -235,12 +235,12 @@ // NOTE: GCC supports AddressSanitizer(asan) since 4.8. // https://gcc.gnu.org/gcc-4.8/changes.html #if defined(__GNUC__) -#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +#define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS +#define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY +// OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY // // Tells the MemorySanitizer to relax the handling of a given function. All // "Use of uninitialized value" warnings from such functions will be suppressed, @@ -249,23 +249,23 @@ // with initialized-ness rather than addressability issues. // NOTE: MemorySanitizer(msan) is supported by Clang but not GCC. #if defined(__clang__) -#define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory)) +#define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory)) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY +#define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_THREAD +// OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD // // Tells the ThreadSanitizer to not instrument a given function. // NOTE: GCC supports ThreadSanitizer(tsan) since 4.8. // https://gcc.gnu.org/gcc-4.8/changes.html #if defined(__GNUC__) -#define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) +#define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_THREAD +#define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED +// OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED // // Tells the UndefinedSanitizer to ignore a given function. Useful for cases // where certain behavior (eg. division by zero) is being used intentionally. @@ -273,147 +273,147 @@ // https://gcc.gnu.org/gcc-4.9/changes.html #if defined(__GNUC__) && \ (defined(UNDEFINED_BEHAVIOR_SANITIZER) || defined(ADDRESS_SANITIZER)) -#define ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED \ +#define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED \ __attribute__((no_sanitize("undefined"))) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED +#define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_CFI +// OTABSL_ATTRIBUTE_NO_SANITIZE_CFI // // Tells the ControlFlowIntegrity sanitizer to not instrument a given function. // See https://clang.llvm.org/docs/ControlFlowIntegrity.html for details. #if defined(__GNUC__) && defined(CONTROL_FLOW_INTEGRITY) -#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI __attribute__((no_sanitize("cfi"))) +#define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI __attribute__((no_sanitize("cfi"))) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI +#define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI #endif -// ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK +// OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK // // Tells the SafeStack to not instrument a given function. // See https://clang.llvm.org/docs/SafeStack.html for details. #if defined(__GNUC__) && defined(SAFESTACK_SANITIZER) -#define ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK \ +#define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK \ __attribute__((no_sanitize("safe-stack"))) #else -#define ABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK +#define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK #endif -// ABSL_ATTRIBUTE_RETURNS_NONNULL +// OTABSL_ATTRIBUTE_RETURNS_NONNULL // // Tells the compiler that a particular function never returns a null pointer. -#if ABSL_HAVE_ATTRIBUTE(returns_nonnull) || \ +#if OTABSL_HAVE_ATTRIBUTE(returns_nonnull) || \ (defined(__GNUC__) && \ (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && \ !defined(__clang__)) -#define ABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) +#define OTABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #else -#define ABSL_ATTRIBUTE_RETURNS_NONNULL +#define OTABSL_ATTRIBUTE_RETURNS_NONNULL #endif -// ABSL_HAVE_ATTRIBUTE_SECTION +// OTABSL_HAVE_ATTRIBUTE_SECTION // // Indicates whether labeled sections are supported. Weak symbol support is // a prerequisite. Labeled sections are not supported on Darwin/iOS. -#ifdef ABSL_HAVE_ATTRIBUTE_SECTION -#error ABSL_HAVE_ATTRIBUTE_SECTION cannot be directly set -#elif (ABSL_HAVE_ATTRIBUTE(section) || \ +#ifdef OTABSL_HAVE_ATTRIBUTE_SECTION +#error OTABSL_HAVE_ATTRIBUTE_SECTION cannot be directly set +#elif (OTABSL_HAVE_ATTRIBUTE(section) || \ (defined(__GNUC__) && !defined(__clang__))) && \ - !defined(__APPLE__) && ABSL_HAVE_ATTRIBUTE_WEAK -#define ABSL_HAVE_ATTRIBUTE_SECTION 1 + !defined(__APPLE__) && OTABSL_HAVE_ATTRIBUTE_WEAK +#define OTABSL_HAVE_ATTRIBUTE_SECTION 1 -// ABSL_ATTRIBUTE_SECTION +// OTABSL_ATTRIBUTE_SECTION // // Tells the compiler/linker to put a given function into a section and define // `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. // This functionality is supported by GNU linker. Any function annotated with -// `ABSL_ATTRIBUTE_SECTION` must not be inlined, or it will be placed into +// `OTABSL_ATTRIBUTE_SECTION` must not be inlined, or it will be placed into // whatever section its caller is placed into. // -#ifndef ABSL_ATTRIBUTE_SECTION -#define ABSL_ATTRIBUTE_SECTION(name) \ +#ifndef OTABSL_ATTRIBUTE_SECTION +#define OTABSL_ATTRIBUTE_SECTION(name) \ __attribute__((section(#name))) __attribute__((noinline)) #endif -// ABSL_ATTRIBUTE_SECTION_VARIABLE +// OTABSL_ATTRIBUTE_SECTION_VARIABLE // // Tells the compiler/linker to put a given variable into a section and define // `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. // This functionality is supported by GNU linker. -#ifndef ABSL_ATTRIBUTE_SECTION_VARIABLE -#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name))) +#ifndef OTABSL_ATTRIBUTE_SECTION_VARIABLE +#define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name))) #endif -// ABSL_DECLARE_ATTRIBUTE_SECTION_VARS +// OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS // // A weak section declaration to be used as a global declaration -// for ABSL_ATTRIBUTE_SECTION_START|STOP(name) to compile and link -// even without functions with ABSL_ATTRIBUTE_SECTION(name). -// ABSL_DEFINE_ATTRIBUTE_SECTION should be in the exactly one file; it's +// for OTABSL_ATTRIBUTE_SECTION_START|STOP(name) to compile and link +// even without functions with OTABSL_ATTRIBUTE_SECTION(name). +// OTABSL_DEFINE_ATTRIBUTE_SECTION should be in the exactly one file; it's // a no-op on ELF but not on Mach-O. // -#ifndef ABSL_DECLARE_ATTRIBUTE_SECTION_VARS -#define ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) \ - extern char __start_##name[] ABSL_ATTRIBUTE_WEAK; \ - extern char __stop_##name[] ABSL_ATTRIBUTE_WEAK +#ifndef OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS +#define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) \ + extern char __start_##name[] OTABSL_ATTRIBUTE_WEAK; \ + extern char __stop_##name[] OTABSL_ATTRIBUTE_WEAK #endif -#ifndef ABSL_DEFINE_ATTRIBUTE_SECTION_VARS -#define ABSL_INIT_ATTRIBUTE_SECTION_VARS(name) -#define ABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) +#ifndef OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS +#define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) +#define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) #endif -// ABSL_ATTRIBUTE_SECTION_START +// OTABSL_ATTRIBUTE_SECTION_START // // Returns `void*` pointers to start/end of a section of code with -// functions having ABSL_ATTRIBUTE_SECTION(name). +// functions having OTABSL_ATTRIBUTE_SECTION(name). // Returns 0 if no such functions exist. -// One must ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) for this to compile and +// One must OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) for this to compile and // link. // -#define ABSL_ATTRIBUTE_SECTION_START(name) \ +#define OTABSL_ATTRIBUTE_SECTION_START(name) \ (reinterpret_cast(__start_##name)) -#define ABSL_ATTRIBUTE_SECTION_STOP(name) \ +#define OTABSL_ATTRIBUTE_SECTION_STOP(name) \ (reinterpret_cast(__stop_##name)) -#else // !ABSL_HAVE_ATTRIBUTE_SECTION +#else // !OTABSL_HAVE_ATTRIBUTE_SECTION -#define ABSL_HAVE_ATTRIBUTE_SECTION 0 +#define OTABSL_HAVE_ATTRIBUTE_SECTION 0 // provide dummy definitions -#define ABSL_ATTRIBUTE_SECTION(name) -#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name) -#define ABSL_INIT_ATTRIBUTE_SECTION_VARS(name) -#define ABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) -#define ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) -#define ABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast(0)) -#define ABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast(0)) +#define OTABSL_ATTRIBUTE_SECTION(name) +#define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) +#define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) +#define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) +#define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) +#define OTABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast(0)) +#define OTABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast(0)) -#endif // ABSL_ATTRIBUTE_SECTION +#endif // OTABSL_ATTRIBUTE_SECTION -// ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC +// OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC // // Support for aligning the stack on 32-bit x86. -#if ABSL_HAVE_ATTRIBUTE(force_align_arg_pointer) || \ +#if OTABSL_HAVE_ATTRIBUTE(force_align_arg_pointer) || \ (defined(__GNUC__) && !defined(__clang__)) #if defined(__i386__) -#define ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC \ +#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC \ __attribute__((force_align_arg_pointer)) -#define ABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) +#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) #elif defined(__x86_64__) -#define ABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (1) -#define ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC +#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (1) +#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC #else // !__i386__ && !__x86_64 -#define ABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) -#define ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC +#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) +#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC #endif // __i386__ #else -#define ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC -#define ABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) +#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC +#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) #endif -// ABSL_MUST_USE_RESULT +// OTABSL_MUST_USE_RESULT // // Tells the compiler to warn about unused results. // @@ -421,13 +421,13 @@ // declaration or definition. The compiler will warn if the return value from // such a function is unused: // -// ABSL_MUST_USE_RESULT Sprocket* AllocateSprocket(); +// OTABSL_MUST_USE_RESULT Sprocket* AllocateSprocket(); // AllocateSprocket(); // Triggers a warning. // // When annotating a class, it is equivalent to annotating every function which // returns an instance. // -// class ABSL_MUST_USE_RESULT Sprocket {}; +// class OTABSL_MUST_USE_RESULT Sprocket {}; // Sprocket(); // Triggers a warning. // // Sprocket MakeSprocket(); @@ -438,20 +438,20 @@ // Sprocket* SprocketPointer(); // SprocketPointer(); // Does *not* trigger a warning. // -// ABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result +// OTABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result // warning. For that, warn_unused_result is used only for clang but not for gcc. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 // // Note: past advice was to place the macro after the argument list. -#if ABSL_HAVE_ATTRIBUTE(nodiscard) -#define ABSL_MUST_USE_RESULT [[nodiscard]] -#elif defined(__clang__) && ABSL_HAVE_ATTRIBUTE(warn_unused_result) -#define ABSL_MUST_USE_RESULT __attribute__((warn_unused_result)) +#if OTABSL_HAVE_ATTRIBUTE(nodiscard) +#define OTABSL_MUST_USE_RESULT [[nodiscard]] +#elif defined(__clang__) && OTABSL_HAVE_ATTRIBUTE(warn_unused_result) +#define OTABSL_MUST_USE_RESULT __attribute__((warn_unused_result)) #else -#define ABSL_MUST_USE_RESULT +#define OTABSL_MUST_USE_RESULT #endif -// ABSL_ATTRIBUTE_HOT, ABSL_ATTRIBUTE_COLD +// OTABSL_ATTRIBUTE_HOT, OTABSL_ATTRIBUTE_COLD // // Tells GCC that a function is hot or cold. GCC can use this information to // improve static analysis, i.e. a conditional branch to a cold function @@ -460,22 +460,22 @@ // // Example: // -// int foo() ABSL_ATTRIBUTE_HOT; -#if ABSL_HAVE_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_HOT __attribute__((hot)) +// int foo() OTABSL_ATTRIBUTE_HOT; +#if OTABSL_HAVE_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_HOT __attribute__((hot)) #else -#define ABSL_ATTRIBUTE_HOT +#define OTABSL_ATTRIBUTE_HOT #endif -#if ABSL_HAVE_ATTRIBUTE(cold) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_COLD __attribute__((cold)) +#if OTABSL_HAVE_ATTRIBUTE(cold) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_COLD __attribute__((cold)) #else -#define ABSL_ATTRIBUTE_COLD +#define OTABSL_ATTRIBUTE_COLD #endif -// ABSL_XRAY_ALWAYS_INSTRUMENT, ABSL_XRAY_NEVER_INSTRUMENT, ABSL_XRAY_LOG_ARGS +// OTABSL_XRAY_ALWAYS_INSTRUMENT, OTABSL_XRAY_NEVER_INSTRUMENT, OTABSL_XRAY_LOG_ARGS // -// We define the ABSL_XRAY_ALWAYS_INSTRUMENT and ABSL_XRAY_NEVER_INSTRUMENT +// We define the OTABSL_XRAY_ALWAYS_INSTRUMENT and OTABSL_XRAY_NEVER_INSTRUMENT // macro used as an attribute to mark functions that must always or never be // instrumented by XRay. Currently, this is only supported in Clang/LLVM. // @@ -503,27 +503,27 @@ // attributes in source take precedence over these special-case lists. // // To disable the XRay attributes at build-time, users may define -// ABSL_NO_XRAY_ATTRIBUTES. Do NOT define ABSL_NO_XRAY_ATTRIBUTES on specific +// OTABSL_NO_XRAY_ATTRIBUTES. Do NOT define OTABSL_NO_XRAY_ATTRIBUTES on specific // packages/targets, as this may lead to conflicting definitions of functions at // link-time. // -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::xray_always_instrument) && \ - !defined(ABSL_NO_XRAY_ATTRIBUTES) -#define ABSL_XRAY_ALWAYS_INSTRUMENT [[clang::xray_always_instrument]] -#define ABSL_XRAY_NEVER_INSTRUMENT [[clang::xray_never_instrument]] -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::xray_log_args) -#define ABSL_XRAY_LOG_ARGS(N) \ +#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_always_instrument) && \ + !defined(OTABSL_NO_XRAY_ATTRIBUTES) +#define OTABSL_XRAY_ALWAYS_INSTRUMENT [[clang::xray_always_instrument]] +#define OTABSL_XRAY_NEVER_INSTRUMENT [[clang::xray_never_instrument]] +#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_log_args) +#define OTABSL_XRAY_LOG_ARGS(N) \ [[clang::xray_always_instrument, clang::xray_log_args(N)]] #else -#define ABSL_XRAY_LOG_ARGS(N) [[clang::xray_always_instrument]] +#define OTABSL_XRAY_LOG_ARGS(N) [[clang::xray_always_instrument]] #endif #else -#define ABSL_XRAY_ALWAYS_INSTRUMENT -#define ABSL_XRAY_NEVER_INSTRUMENT -#define ABSL_XRAY_LOG_ARGS(N) +#define OTABSL_XRAY_ALWAYS_INSTRUMENT +#define OTABSL_XRAY_NEVER_INSTRUMENT +#define OTABSL_XRAY_LOG_ARGS(N) #endif -// ABSL_ATTRIBUTE_REINITIALIZES +// OTABSL_ATTRIBUTE_REINITIALIZES // // Indicates that a member function reinitializes the entire object to a known // state, independent of the previous state of the object. @@ -531,37 +531,37 @@ // The clang-tidy check bugprone-use-after-move allows member functions marked // with this attribute to be called on objects that have been moved from; // without the attribute, this would result in a use-after-move warning. -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes) -#define ABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] +#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes) +#define OTABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] #else -#define ABSL_ATTRIBUTE_REINITIALIZES +#define OTABSL_ATTRIBUTE_REINITIALIZES #endif // ----------------------------------------------------------------------------- // Variable Attributes // ----------------------------------------------------------------------------- -// ABSL_ATTRIBUTE_UNUSED +// OTABSL_ATTRIBUTE_UNUSED // // Prevents the compiler from complaining about variables that appear unused. -#if ABSL_HAVE_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__)) -#undef ABSL_ATTRIBUTE_UNUSED -#define ABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) +#if OTABSL_HAVE_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__)) +#undef OTABSL_ATTRIBUTE_UNUSED +#define OTABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) #else -#define ABSL_ATTRIBUTE_UNUSED +#define OTABSL_ATTRIBUTE_UNUSED #endif -// ABSL_ATTRIBUTE_INITIAL_EXEC +// OTABSL_ATTRIBUTE_INITIAL_EXEC // // Tells the compiler to use "initial-exec" mode for a thread-local variable. // See http://people.redhat.com/drepper/tls.pdf for the gory details. -#if ABSL_HAVE_ATTRIBUTE(tls_model) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_INITIAL_EXEC __attribute__((tls_model("initial-exec"))) +#if OTABSL_HAVE_ATTRIBUTE(tls_model) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_INITIAL_EXEC __attribute__((tls_model("initial-exec"))) #else -#define ABSL_ATTRIBUTE_INITIAL_EXEC +#define OTABSL_ATTRIBUTE_INITIAL_EXEC #endif -// ABSL_ATTRIBUTE_PACKED +// OTABSL_ATTRIBUTE_PACKED // // Instructs the compiler not to use natural alignment for a tagged data // structure, but instead to reduce its alignment to 1. This attribute can @@ -572,29 +572,29 @@ // purpose is to control the offsets of the members in the structure. Instead, // apply this attribute only to structure members that need it. // -// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the +// When applying OTABSL_ATTRIBUTE_PACKED only to specific structure members the // natural alignment of structure members not annotated is preserved. Aligned // member accesses are faster than non-aligned member accesses even if the // targeted microprocessor supports non-aligned accesses. -#if ABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) +#if OTABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) #else -#define ABSL_ATTRIBUTE_PACKED +#define OTABSL_ATTRIBUTE_PACKED #endif -// ABSL_ATTRIBUTE_FUNC_ALIGN +// OTABSL_ATTRIBUTE_FUNC_ALIGN // // Tells the compiler to align the function start at least to certain // alignment boundary -#if ABSL_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) +#if OTABSL_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__)) +#define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) #else -#define ABSL_ATTRIBUTE_FUNC_ALIGN(bytes) +#define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) #endif -// ABSL_CONST_INIT +// OTABSL_CONST_INIT // -// A variable declaration annotated with the `ABSL_CONST_INIT` attribute will +// A variable declaration annotated with the `OTABSL_CONST_INIT` attribute will // not compile (on supported platforms) unless the variable has a constant // initializer. This is useful for variables with static and thread storage // duration, because it guarantees that they will not suffer from the so-called @@ -606,16 +606,16 @@ // // class MyClass { // public: -// ABSL_CONST_INIT static MyType my_var; +// OTABSL_CONST_INIT static MyType my_var; // }; // // MyType MyClass::my_var = MakeMyType(...); // // Note that this attribute is redundant if the variable is declared constexpr. -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) -#define ABSL_CONST_INIT [[clang::require_constant_initialization]] +#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) +#define OTABSL_CONST_INIT [[clang::require_constant_initialization]] #else -#define ABSL_CONST_INIT -#endif // ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) +#define OTABSL_CONST_INIT +#endif // OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) -#endif // ABSL_BASE_ATTRIBUTES_H_ +#endif // OTABSL_BASE_ATTRIBUTES_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/config.h b/api/include/opentelemetry/nostd/absl/base/config.h index a4761d2141..5eaeb46367 100644 --- a/api/include/opentelemetry/nostd/absl/base/config.h +++ b/api/include/opentelemetry/nostd/absl/base/config.h @@ -29,24 +29,24 @@ // Example: // // Suppose a programmer wants to write a program that uses the 'mmap()' system -// call. The Abseil macro for that feature (`ABSL_HAVE_MMAP`) allows you to +// call. The Abseil macro for that feature (`OTABSL_HAVE_MMAP`) allows you to // selectively include the `mmap.h` header and bracket code using that feature // in the macro: // // #include "absl/base/config.h" // -// #ifdef ABSL_HAVE_MMAP +// #ifdef OTABSL_HAVE_MMAP // #include "sys/mman.h" -// #endif //ABSL_HAVE_MMAP +// #endif //OTABSL_HAVE_MMAP // // ... -// #ifdef ABSL_HAVE_MMAP +// #ifdef OTABSL_HAVE_MMAP // void *ptr = mmap(...); // ... -// #endif // ABSL_HAVE_MMAP +// #endif // OTABSL_HAVE_MMAP -#ifndef ABSL_BASE_CONFIG_H_ -#define ABSL_BASE_CONFIG_H_ +#ifndef OTABSL_BASE_CONFIG_H_ +#define OTABSL_BASE_CONFIG_H_ // Included for the __GLIBC__ macro (or similar macros on other systems). #include @@ -63,18 +63,18 @@ #include #endif -#include "absl/base/options.h" -#include "absl/base/policy_checks.h" +#include "options.h" +#include "policy_checks.h" // Helper macro to convert a CPP variable to a string literal. -#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x -#define ABSL_INTERNAL_TOKEN_STR(x) ABSL_INTERNAL_DO_TOKEN_STR(x) +#define OTABSL_INTERNAL_DO_TOKEN_STR(x) #x +#define OTABSL_INTERNAL_TOKEN_STR(x) OTABSL_INTERNAL_DO_TOKEN_STR(x) // ----------------------------------------------------------------------------- // Abseil namespace annotations // ----------------------------------------------------------------------------- -// ABSL_NAMESPACE_BEGIN/ABSL_NAMESPACE_END +// OTABSL_NAMESPACE_BEGIN/OTABSL_NAMESPACE_END // // An annotation placed at the beginning/end of each `namespace absl` scope. // This is used to inject an inline namespace. @@ -82,11 +82,11 @@ // The proper way to write Abseil code in the `absl` namespace is: // // namespace absl { -// ABSL_NAMESPACE_BEGIN +// OTABSL_NAMESPACE_BEGIN // // void Foo(); // absl::Foo(). // -// ABSL_NAMESPACE_END +// OTABSL_NAMESPACE_END // } // namespace absl // // Users of Abseil should not use these macros, because users of Abseil should @@ -94,37 +94,37 @@ // not support forward declarations of its own types, nor does it support // user-provided specialization of Abseil templates. Code that violates these // rules may be broken without warning.) -#if !defined(ABSL_OPTION_USE_INLINE_NAMESPACE) || \ - !defined(ABSL_OPTION_INLINE_NAMESPACE_NAME) +#if !defined(OTABSL_OPTION_USE_INLINE_NAMESPACE) || \ + !defined(OTABSL_OPTION_INLINE_NAMESPACE_NAME) #error options.h is misconfigured. #endif -// Check that ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" -#if defined(__cplusplus) && ABSL_OPTION_USE_INLINE_NAMESPACE == 1 +// Check that OTABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" +#if defined(__cplusplus) && OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 -#define ABSL_INTERNAL_INLINE_NAMESPACE_STR \ - ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) +#define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \ + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) -static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', - "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " +static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', + "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " "not be empty."); -static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', - "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " +static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || + OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || + OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || + OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || + OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', + "options.h misconfigured: OTABSL_OPTION_INLINE_NAMESPACE_NAME must " "be changed to a new, unique identifier name."); #endif -#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define ABSL_NAMESPACE_BEGIN -#define ABSL_NAMESPACE_END -#elif ABSL_OPTION_USE_INLINE_NAMESPACE == 1 -#define ABSL_NAMESPACE_BEGIN \ - inline namespace ABSL_OPTION_INLINE_NAMESPACE_NAME { -#define ABSL_NAMESPACE_END } +#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define OTABSL_NAMESPACE_BEGIN +#define OTABSL_NAMESPACE_END +#elif OTABSL_OPTION_USE_INLINE_NAMESPACE == 1 +#define OTABSL_NAMESPACE_BEGIN \ + inline namespace OTABSL_OPTION_INLINE_NAMESPACE_NAME { +#define OTABSL_NAMESPACE_END } #else #error options.h is misconfigured. #endif @@ -133,7 +133,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // Compiler Feature Checks // ----------------------------------------------------------------------------- -// ABSL_HAVE_BUILTIN() +// OTABSL_HAVE_BUILTIN() // // Checks whether the compiler supports a Clang Feature Checking Macro, and if // so, checks whether it supports the provided builtin function "x" where x @@ -143,82 +143,82 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. // http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html #ifdef __has_builtin -#define ABSL_HAVE_BUILTIN(x) __has_builtin(x) +#define OTABSL_HAVE_BUILTIN(x) __has_builtin(x) #else -#define ABSL_HAVE_BUILTIN(x) 0 +#define OTABSL_HAVE_BUILTIN(x) 0 #endif #if defined(__is_identifier) -#define ABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x)) +#define OTABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x)) #else -#define ABSL_INTERNAL_HAS_KEYWORD(x) 0 +#define OTABSL_INTERNAL_HAS_KEYWORD(x) 0 #endif -// ABSL_HAVE_TLS is defined to 1 when __thread should be supported. +// OTABSL_HAVE_TLS is defined to 1 when __thread should be supported. // We assume __thread is supported on Linux when compiled with Clang or compiled // against libstdc++ with _GLIBCXX_HAVE_TLS defined. -#ifdef ABSL_HAVE_TLS -#error ABSL_HAVE_TLS cannot be directly set +#ifdef OTABSL_HAVE_TLS +#error OTABSL_HAVE_TLS cannot be directly set #elif defined(__linux__) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS)) -#define ABSL_HAVE_TLS 1 +#define OTABSL_HAVE_TLS 1 #endif -// ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE +// OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE // // Checks whether `std::is_trivially_destructible` is supported. // // Notes: All supported compilers using libc++ support this feature, as does // gcc >= 4.8.1 using libstdc++, and Visual Studio. -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE -#error ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set +#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE +#error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set #elif defined(_LIBCPP_VERSION) || \ (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ defined(_MSC_VER) -#define ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 +#define OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 #endif -// ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +// OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE // // Checks whether `std::is_trivially_default_constructible` and // `std::is_trivially_copy_constructible` are supported. -// ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE +// OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE // // Checks whether `std::is_trivially_copy_assignable` is supported. // Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with // either libc++ or libstdc++, and Visual Studio (but not NVCC). -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) -#error ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set -#elif defined(ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) -#error ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set +#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) +#error OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set +#elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) +#error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ (!defined(__clang__) && defined(__GNUC__) && \ (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \ (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ (defined(_MSC_VER) && !defined(__NVCC__)) -#define ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 -#define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 +#define OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 +#define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 #endif -// ABSL_HAVE_SOURCE_LOCATION_CURRENT +// OTABSL_HAVE_SOURCE_LOCATION_CURRENT // // Indicates whether `absl::SourceLocation::current()` will return useful // information in some contexts. -#ifndef ABSL_HAVE_SOURCE_LOCATION_CURRENT -#if ABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ - ABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE) -#define ABSL_HAVE_SOURCE_LOCATION_CURRENT 1 +#ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT +#if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ + OTABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE) +#define OTABSL_HAVE_SOURCE_LOCATION_CURRENT 1 #endif #endif -// ABSL_HAVE_THREAD_LOCAL +// OTABSL_HAVE_THREAD_LOCAL // // Checks whether C++11's `thread_local` storage duration specifier is // supported. -#ifdef ABSL_HAVE_THREAD_LOCAL -#error ABSL_HAVE_THREAD_LOCAL cannot be directly set +#ifdef OTABSL_HAVE_THREAD_LOCAL +#error OTABSL_HAVE_THREAD_LOCAL cannot be directly set #elif defined(__APPLE__) // Notes: // * Xcode's clang did not support `thread_local` until version 8, and @@ -232,10 +232,10 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // `defined(__APPLE__)` check. #if __has_feature(cxx_thread_local) && \ !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) -#define ABSL_HAVE_THREAD_LOCAL 1 +#define OTABSL_HAVE_THREAD_LOCAL 1 #endif #else // !defined(__APPLE__) -#define ABSL_HAVE_THREAD_LOCAL 1 +#define OTABSL_HAVE_THREAD_LOCAL 1 #endif // There are platforms for which TLS should not be used even though the compiler @@ -257,19 +257,19 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ defined(__NDK_MINOR__) && \ ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) -#undef ABSL_HAVE_TLS -#undef ABSL_HAVE_THREAD_LOCAL +#undef OTABSL_HAVE_TLS +#undef OTABSL_HAVE_THREAD_LOCAL #endif #endif // defined(__ANDROID__) && defined(__clang__) // Emscripten doesn't yet support `thread_local` or `__thread`. // https://github.com/emscripten-core/emscripten/issues/3502 #if defined(__EMSCRIPTEN__) -#undef ABSL_HAVE_TLS -#undef ABSL_HAVE_THREAD_LOCAL +#undef OTABSL_HAVE_TLS +#undef OTABSL_HAVE_THREAD_LOCAL #endif // defined(__EMSCRIPTEN__) -// ABSL_HAVE_INTRINSIC_INT128 +// OTABSL_HAVE_INTRINSIC_INT128 // // Checks whether the __int128 compiler extension for a 128-bit integral type is // supported. @@ -282,51 +282,51 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // * On Nvidia's nvcc: // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions // actually support __int128. -#ifdef ABSL_HAVE_INTRINSIC_INT128 -#error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set +#ifdef OTABSL_HAVE_INTRINSIC_INT128 +#error OTABSL_HAVE_INTRINSIC_INT128 cannot be directly set #elif defined(__SIZEOF_INT128__) #if (defined(__clang__) && !defined(_WIN32)) || \ (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)) -#define ABSL_HAVE_INTRINSIC_INT128 1 +#define OTABSL_HAVE_INTRINSIC_INT128 1 #elif defined(__CUDACC__) // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a // string explaining that it has been removed starting with CUDA 9. We use // nested #ifs because there is no short-circuiting in the preprocessor. // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined. #if __CUDACC_VER__ >= 70000 -#define ABSL_HAVE_INTRINSIC_INT128 1 +#define OTABSL_HAVE_INTRINSIC_INT128 1 #endif // __CUDACC_VER__ >= 70000 #endif // defined(__CUDACC__) -#endif // ABSL_HAVE_INTRINSIC_INT128 +#endif // OTABSL_HAVE_INTRINSIC_INT128 -// ABSL_HAVE_EXCEPTIONS +// OTABSL_HAVE_EXCEPTIONS // // Checks whether the compiler both supports and enables exceptions. Many // compilers support a "no exceptions" mode that disables exceptions. // -// Generally, when ABSL_HAVE_EXCEPTIONS is not defined: +// Generally, when OTABSL_HAVE_EXCEPTIONS is not defined: // // * Code using `throw` and `try` may not compile. // * The `noexcept` specifier will still compile and behave as normal. // * The `noexcept` operator may still return `false`. // // For further details, consult the compiler's documentation. -#ifdef ABSL_HAVE_EXCEPTIONS -#error ABSL_HAVE_EXCEPTIONS cannot be directly set. +#ifdef OTABSL_HAVE_EXCEPTIONS +#error OTABSL_HAVE_EXCEPTIONS cannot be directly set. #elif defined(__clang__) #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) // Clang >= 3.6 #if __has_feature(cxx_exceptions) -#define ABSL_HAVE_EXCEPTIONS 1 +#define OTABSL_HAVE_EXCEPTIONS 1 #endif // __has_feature(cxx_exceptions) #else // Clang < 3.6 // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro #if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) -#define ABSL_HAVE_EXCEPTIONS 1 +#define OTABSL_HAVE_EXCEPTIONS 1 #endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) #endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) @@ -334,7 +334,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \ !(defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__cpp_exceptions)) && \ !(defined(_MSC_VER) && !defined(_CPPUNWIND)) -#define ABSL_HAVE_EXCEPTIONS 1 +#define OTABSL_HAVE_EXCEPTIONS 1 #endif // ----------------------------------------------------------------------------- @@ -358,41 +358,41 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // Note that since Android defines both __ANDROID__ and __linux__, one // may probe for either Linux or Android by simply testing for __linux__. -// ABSL_HAVE_MMAP +// OTABSL_HAVE_MMAP // // Checks whether the platform has an mmap(2) implementation as defined in // POSIX.1-2001. -#ifdef ABSL_HAVE_MMAP -#error ABSL_HAVE_MMAP cannot be directly set +#ifdef OTABSL_HAVE_MMAP +#error OTABSL_HAVE_MMAP cannot be directly set #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \ defined(__ASYLO__) -#define ABSL_HAVE_MMAP 1 +#define OTABSL_HAVE_MMAP 1 #endif -// ABSL_HAVE_PTHREAD_GETSCHEDPARAM +// OTABSL_HAVE_PTHREAD_GETSCHEDPARAM // // Checks whether the platform implements the pthread_(get|set)schedparam(3) // functions as defined in POSIX.1-2001. -#ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM -#error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set +#ifdef OTABSL_HAVE_PTHREAD_GETSCHEDPARAM +#error OTABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__ros__) -#define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1 +#define OTABSL_HAVE_PTHREAD_GETSCHEDPARAM 1 #endif -// ABSL_HAVE_SCHED_YIELD +// OTABSL_HAVE_SCHED_YIELD // // Checks whether the platform implements sched_yield(2) as defined in // POSIX.1-2001. -#ifdef ABSL_HAVE_SCHED_YIELD -#error ABSL_HAVE_SCHED_YIELD cannot be directly set +#ifdef OTABSL_HAVE_SCHED_YIELD +#error OTABSL_HAVE_SCHED_YIELD cannot be directly set #elif defined(__linux__) || defined(__ros__) || defined(__native_client__) -#define ABSL_HAVE_SCHED_YIELD 1 +#define OTABSL_HAVE_SCHED_YIELD 1 #endif -// ABSL_HAVE_SEMAPHORE_H +// OTABSL_HAVE_SEMAPHORE_H // // Checks whether the platform supports the header and sem_init(3) // family of functions as standardized in POSIX.1-2001. @@ -401,24 +401,24 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // explicitly deprecated and will cause build failures if enabled for those // platforms. We side-step the issue by not defining it here for Apple // platforms. -#ifdef ABSL_HAVE_SEMAPHORE_H -#error ABSL_HAVE_SEMAPHORE_H cannot be directly set +#ifdef OTABSL_HAVE_SEMAPHORE_H +#error OTABSL_HAVE_SEMAPHORE_H cannot be directly set #elif defined(__linux__) || defined(__ros__) -#define ABSL_HAVE_SEMAPHORE_H 1 +#define OTABSL_HAVE_SEMAPHORE_H 1 #endif -// ABSL_HAVE_ALARM +// OTABSL_HAVE_ALARM // // Checks whether the platform supports the header and alarm(2) // function as standardized in POSIX.1-2001. -#ifdef ABSL_HAVE_ALARM -#error ABSL_HAVE_ALARM cannot be directly set +#ifdef OTABSL_HAVE_ALARM +#error OTABSL_HAVE_ALARM cannot be directly set #elif defined(__GOOGLE_GRTE_VERSION__) // feature tests for Google's GRTE -#define ABSL_HAVE_ALARM 1 +#define OTABSL_HAVE_ALARM 1 #elif defined(__GLIBC__) // feature test for glibc -#define ABSL_HAVE_ALARM 1 +#define OTABSL_HAVE_ALARM 1 #elif defined(_MSC_VER) // feature tests for Microsoft's library #elif defined(__MINGW32__) @@ -433,11 +433,11 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #elif defined(__native_client__) #else // other standard libraries -#define ABSL_HAVE_ALARM 1 +#define OTABSL_HAVE_ALARM 1 #endif -// ABSL_IS_LITTLE_ENDIAN -// ABSL_IS_BIG_ENDIAN +// OTABSL_IS_LITTLE_ENDIAN +// OTABSL_IS_BIG_ENDIAN // // Checks the endianness of the platform. // @@ -445,21 +445,21 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // Clang (since 3.2); see // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html. // Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error. -#if defined(ABSL_IS_BIG_ENDIAN) -#error "ABSL_IS_BIG_ENDIAN cannot be directly set." +#if defined(OTABSL_IS_BIG_ENDIAN) +#error "OTABSL_IS_BIG_ENDIAN cannot be directly set." #endif -#if defined(ABSL_IS_LITTLE_ENDIAN) -#error "ABSL_IS_LITTLE_ENDIAN cannot be directly set." +#if defined(OTABSL_IS_LITTLE_ENDIAN) +#error "OTABSL_IS_LITTLE_ENDIAN cannot be directly set." #endif #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define ABSL_IS_LITTLE_ENDIAN 1 +#define OTABSL_IS_LITTLE_ENDIAN 1 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define ABSL_IS_BIG_ENDIAN 1 +#define OTABSL_IS_BIG_ENDIAN 1 #elif defined(_WIN32) -#define ABSL_IS_LITTLE_ENDIAN 1 +#define OTABSL_IS_LITTLE_ENDIAN 1 #else #error "absl endian detection needs to be set up for your compiler" #endif @@ -480,63 +480,63 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000)) -#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1 +#define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1 #else -#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0 +#define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0 #endif -// ABSL_HAVE_STD_ANY +// OTABSL_HAVE_STD_ANY // // Checks whether C++17 std::any is available by checking whether exists. -#ifdef ABSL_HAVE_STD_ANY -#error "ABSL_HAVE_STD_ANY cannot be directly set." +#ifdef OTABSL_HAVE_STD_ANY +#error "OTABSL_HAVE_STD_ANY cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ - !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define ABSL_HAVE_STD_ANY 1 + !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE +#define OTABSL_HAVE_STD_ANY 1 #endif #endif -// ABSL_HAVE_STD_OPTIONAL +// OTABSL_HAVE_STD_OPTIONAL // // Checks whether C++17 std::optional is available. -#ifdef ABSL_HAVE_STD_OPTIONAL -#error "ABSL_HAVE_STD_OPTIONAL cannot be directly set." +#ifdef OTABSL_HAVE_STD_OPTIONAL +#error "OTABSL_HAVE_STD_OPTIONAL cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ - !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define ABSL_HAVE_STD_OPTIONAL 1 + !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE +#define OTABSL_HAVE_STD_OPTIONAL 1 #endif #endif -// ABSL_HAVE_STD_VARIANT +// OTABSL_HAVE_STD_VARIANT // // Checks whether C++17 std::variant is available. -#ifdef ABSL_HAVE_STD_VARIANT -#error "ABSL_HAVE_STD_VARIANT cannot be directly set." +#ifdef OTABSL_HAVE_STD_VARIANT +#error "OTABSL_HAVE_STD_VARIANT cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ - !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define ABSL_HAVE_STD_VARIANT 1 + !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE +#define OTABSL_HAVE_STD_VARIANT 1 #endif #endif -// ABSL_HAVE_STD_STRING_VIEW +// OTABSL_HAVE_STD_STRING_VIEW // // Checks whether C++17 std::string_view is available. -#ifdef ABSL_HAVE_STD_STRING_VIEW -#error "ABSL_HAVE_STD_STRING_VIEW cannot be directly set." +#ifdef OTABSL_HAVE_STD_STRING_VIEW +#error "OTABSL_HAVE_STD_STRING_VIEW cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L -#define ABSL_HAVE_STD_STRING_VIEW 1 +#define OTABSL_HAVE_STD_STRING_VIEW 1 #endif #endif @@ -549,70 +549,70 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // TODO(zhangxy): fix tests before enabling aliasing for `std::any`. #if defined(_MSC_VER) && _MSC_VER >= 1910 && \ ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402) -// #define ABSL_HAVE_STD_ANY 1 -#define ABSL_HAVE_STD_OPTIONAL 1 -#define ABSL_HAVE_STD_VARIANT 1 -#define ABSL_HAVE_STD_STRING_VIEW 1 +// #define OTABSL_HAVE_STD_ANY 1 +#define OTABSL_HAVE_STD_OPTIONAL 1 +#define OTABSL_HAVE_STD_VARIANT 1 +#define OTABSL_HAVE_STD_STRING_VIEW 1 #endif -// ABSL_USES_STD_ANY +// OTABSL_USES_STD_ANY // // Indicates whether absl::any is an alias for std::any. -#if !defined(ABSL_OPTION_USE_STD_ANY) +#if !defined(OTABSL_OPTION_USE_STD_ANY) #error options.h is misconfigured. -#elif ABSL_OPTION_USE_STD_ANY == 0 || \ - (ABSL_OPTION_USE_STD_ANY == 2 && !defined(ABSL_HAVE_STD_ANY)) -#undef ABSL_USES_STD_ANY -#elif ABSL_OPTION_USE_STD_ANY == 1 || \ - (ABSL_OPTION_USE_STD_ANY == 2 && defined(ABSL_HAVE_STD_ANY)) -#define ABSL_USES_STD_ANY 1 +#elif OTABSL_OPTION_USE_STD_ANY == 0 || \ + (OTABSL_OPTION_USE_STD_ANY == 2 && !defined(OTABSL_HAVE_STD_ANY)) +#undef OTABSL_USES_STD_ANY +#elif OTABSL_OPTION_USE_STD_ANY == 1 || \ + (OTABSL_OPTION_USE_STD_ANY == 2 && defined(OTABSL_HAVE_STD_ANY)) +#define OTABSL_USES_STD_ANY 1 #else #error options.h is misconfigured. #endif -// ABSL_USES_STD_OPTIONAL +// OTABSL_USES_STD_OPTIONAL // // Indicates whether absl::optional is an alias for std::optional. -#if !defined(ABSL_OPTION_USE_STD_OPTIONAL) +#if !defined(OTABSL_OPTION_USE_STD_OPTIONAL) #error options.h is misconfigured. -#elif ABSL_OPTION_USE_STD_OPTIONAL == 0 || \ - (ABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(ABSL_HAVE_STD_OPTIONAL)) -#undef ABSL_USES_STD_OPTIONAL -#elif ABSL_OPTION_USE_STD_OPTIONAL == 1 || \ - (ABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(ABSL_HAVE_STD_OPTIONAL)) -#define ABSL_USES_STD_OPTIONAL 1 +#elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \ + (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(OTABSL_HAVE_STD_OPTIONAL)) +#undef OTABSL_USES_STD_OPTIONAL +#elif OTABSL_OPTION_USE_STD_OPTIONAL == 1 || \ + (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(OTABSL_HAVE_STD_OPTIONAL)) +#define OTABSL_USES_STD_OPTIONAL 1 #else #error options.h is misconfigured. #endif -// ABSL_USES_STD_VARIANT +// OTABSL_USES_STD_VARIANT // // Indicates whether absl::variant is an alias for std::variant. -#if !defined(ABSL_OPTION_USE_STD_VARIANT) +#if !defined(OTABSL_OPTION_USE_STD_VARIANT) #error options.h is misconfigured. -#elif ABSL_OPTION_USE_STD_VARIANT == 0 || \ - (ABSL_OPTION_USE_STD_VARIANT == 2 && !defined(ABSL_HAVE_STD_VARIANT)) -#undef ABSL_USES_STD_VARIANT -#elif ABSL_OPTION_USE_STD_VARIANT == 1 || \ - (ABSL_OPTION_USE_STD_VARIANT == 2 && defined(ABSL_HAVE_STD_VARIANT)) -#define ABSL_USES_STD_VARIANT 1 +#elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \ + (OTABSL_OPTION_USE_STD_VARIANT == 2 && !defined(OTABSL_HAVE_STD_VARIANT)) +#undef OTABSL_USES_STD_VARIANT +#elif OTABSL_OPTION_USE_STD_VARIANT == 1 || \ + (OTABSL_OPTION_USE_STD_VARIANT == 2 && defined(OTABSL_HAVE_STD_VARIANT)) +#define OTABSL_USES_STD_VARIANT 1 #else #error options.h is misconfigured. #endif -// ABSL_USES_STD_STRING_VIEW +// OTABSL_USES_STD_STRING_VIEW // // Indicates whether absl::string_view is an alias for std::string_view. -#if !defined(ABSL_OPTION_USE_STD_STRING_VIEW) +#if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW) #error options.h is misconfigured. -#elif ABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ - (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ - !defined(ABSL_HAVE_STD_STRING_VIEW)) -#undef ABSL_USES_STD_STRING_VIEW -#elif ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \ - (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ - defined(ABSL_HAVE_STD_STRING_VIEW)) -#define ABSL_USES_STD_STRING_VIEW 1 +#elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ + (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ + !defined(OTABSL_HAVE_STD_STRING_VIEW)) +#undef OTABSL_USES_STD_STRING_VIEW +#elif OTABSL_OPTION_USE_STD_STRING_VIEW == 1 || \ + (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ + defined(OTABSL_HAVE_STD_STRING_VIEW)) +#define OTABSL_USES_STD_STRING_VIEW 1 #else #error options.h is misconfigured. #endif @@ -622,34 +622,34 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // struct can throw. This defeats some of variant_test and // variant_exception_safety_test. #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG) -#define ABSL_INTERNAL_MSVC_2017_DBG_MODE +#define OTABSL_INTERNAL_MSVC_2017_DBG_MODE #endif -// ABSL_INTERNAL_MANGLED_NS -// ABSL_INTERNAL_MANGLED_BACKREFERENCE +// OTABSL_INTERNAL_MANGLED_NS +// OTABSL_INTERNAL_MANGLED_BACKREFERENCE // // Internal macros for building up mangled names in our internal fork of CCTZ. // This implementation detail is only needed and provided for the MSVC build. // -// These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is +// These macros both expand to string literals. OTABSL_INTERNAL_MANGLED_NS is // the mangled spelling of the `absl` namespace, and -// ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing +// OTABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing // the proper count to skip past the CCTZ fork namespace names. (This number // is one larger when there is an inline namespace name to skip.) #if defined(_MSC_VER) -#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define ABSL_INTERNAL_MANGLED_NS "absl" -#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5" +#if OTABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define OTABSL_INTERNAL_MANGLED_NS "absl" +#define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "5" #else -#define ABSL_INTERNAL_MANGLED_NS \ - ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl" -#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6" +#define OTABSL_INTERNAL_MANGLED_NS \ + OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl" +#define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6" #endif #endif -#undef ABSL_INTERNAL_HAS_KEYWORD +#undef OTABSL_INTERNAL_HAS_KEYWORD -// ABSL_DLL +// OTABSL_DLL // // When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` // so we can annotate symbols appropriately as being exported. When used in @@ -657,15 +657,15 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // that consumers know the symbol is defined inside the DLL. In all other cases, // the macro expands to nothing. #if defined(_MSC_VER) -#if defined(ABSL_BUILD_DLL) -#define ABSL_DLL __declspec(dllexport) +#if defined(OTABSL_BUILD_DLL) +#define OTABSL_DLL __declspec(dllexport) #elif 1 -#define ABSL_DLL __declspec(dllimport) +#define OTABSL_DLL __declspec(dllimport) #else -#define ABSL_DLL +#define OTABSL_DLL #endif #else -#define ABSL_DLL +#define OTABSL_DLL #endif // defined(_MSC_VER) -#endif // ABSL_BASE_CONFIG_H_ +#endif // OTABSL_BASE_CONFIG_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/internal/identity.h b/api/include/opentelemetry/nostd/absl/base/internal/identity.h index a3154ed7bc..4afba31796 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/identity.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/identity.h @@ -13,13 +13,13 @@ // limitations under the License. // -#ifndef ABSL_BASE_INTERNAL_IDENTITY_H_ -#define ABSL_BASE_INTERNAL_IDENTITY_H_ +#ifndef OTABSL_BASE_INTERNAL_IDENTITY_H_ +#define OTABSL_BASE_INTERNAL_IDENTITY_H_ -#include "absl/base/config.h" +#include "../config.h" namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN namespace internal { template @@ -31,7 +31,7 @@ template using identity_t = typename identity::type; } // namespace internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_BASE_INTERNAL_IDENTITY_H_ +#endif // OTABSL_BASE_INTERNAL_IDENTITY_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h b/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h index 130d8c2476..9d024a2d91 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ -#define ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ +#ifndef OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ +#define OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ #include -#include "absl/base/internal/identity.h" +#include "identity.h" // File: // This file define a macro that allows the creation of or emulation of C++17 // inline variables based on whether or not the feature is supported. //////////////////////////////////////////////////////////////////////////////// -// Macro: ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) +// Macro: OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) // // Description: // Expands to the equivalent of an inline constexpr instance of the specified @@ -44,7 +44,7 @@ // Usage: // // // Equivalent to: `inline constexpr size_t variant_npos = -1;` -// ABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); +// OTABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); // // Differences in implementation: // For a direct, language-level inline variable, decltype(name) will be the @@ -67,16 +67,16 @@ // appropriate place for pointer types, reference types, function pointer // types, etc.. #if defined(__clang__) -#define ABSL_INTERNAL_EXTERN_DECL(type, name) \ - extern const ::absl::internal::identity_t name; +#define OTABSL_INTERNAL_EXTERN_DECL(type, name) \ + extern const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name; #else // Otherwise, just define the macro to do nothing. -#define ABSL_INTERNAL_EXTERN_DECL(type, name) +#define OTABSL_INTERNAL_EXTERN_DECL(type, name) #endif // defined(__clang__) // See above comment at top of file for details. -#define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ - ABSL_INTERNAL_EXTERN_DECL(type, name) \ - inline constexpr ::absl::internal::identity_t name = init +#define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ + OTABSL_INTERNAL_EXTERN_DECL(type, name) \ + inline constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t name = init #else @@ -86,17 +86,17 @@ // identity_t is used here so that the const and name are in the // appropriate place for pointer types, reference types, function pointer // types, etc.. -#define ABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ +#define OTABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ template \ struct AbslInternalInlineVariableHolder##name { \ - static constexpr ::absl::internal::identity_t kInstance = init; \ + static constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t kInstance = init; \ }; \ \ template \ - constexpr ::absl::internal::identity_t \ + constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t \ AbslInternalInlineVariableHolder##name::kInstance; \ \ - static constexpr const ::absl::internal::identity_t& \ + static constexpr const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t& \ name = /* NOLINT */ \ AbslInternalInlineVariableHolder##name<>::kInstance; \ static_assert(sizeof(void (*)(decltype(name))) != 0, \ @@ -104,4 +104,4 @@ #endif // __cpp_inline_variables -#endif // ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ +#endif // OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/internal/invoke.h b/api/include/opentelemetry/nostd/absl/base/internal/invoke.h index 84f04189b4..99c37ba24a 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/invoke.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/invoke.h @@ -32,20 +32,20 @@ // The implementation is SFINAE-friendly: substitution failure within Invoke() // isn't an error. -#ifndef ABSL_BASE_INTERNAL_INVOKE_H_ -#define ABSL_BASE_INTERNAL_INVOKE_H_ +#ifndef OTABSL_BASE_INTERNAL_INVOKE_H_ +#define OTABSL_BASE_INTERNAL_INVOKE_H_ #include #include #include -#include "absl/meta/type_traits.h" +#include "../../meta/type_traits.h" // The following code is internal implementation detail. See the comment at the // top of this file for the API documentation. namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN namespace base_internal { // The five classes below each implement one of the clauses from the definition @@ -182,7 +182,7 @@ InvokeT Invoke(F&& f, Args&&... args) { } } // namespace base_internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_BASE_INTERNAL_INVOKE_H_ +#endif // OTABSL_BASE_INTERNAL_INVOKE_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/macros.h b/api/include/opentelemetry/nostd/absl/base/macros.h index 547f93bafb..7b4f427d30 100644 --- a/api/include/opentelemetry/nostd/absl/base/macros.h +++ b/api/include/opentelemetry/nostd/absl/base/macros.h @@ -25,33 +25,33 @@ // platforms like Windows, Mac, and embedded systems. Before making // any changes here, make sure that you're not breaking any platforms. -#ifndef ABSL_BASE_MACROS_H_ -#define ABSL_BASE_MACROS_H_ +#ifndef OTABSL_BASE_MACROS_H_ +#define OTABSL_BASE_MACROS_H_ #include #include -#include "absl/base/attributes.h" -#include "absl/base/optimization.h" -#include "absl/base/port.h" +#include "attributes.h" +#include "optimization.h" +#include "port.h" -// ABSL_ARRAYSIZE() +// OTABSL_ARRAYSIZE() // // Returns the number of elements in an array as a compile-time constant, which // can be used in defining new arrays. If you use this macro on a pointer by // mistake, you will get a compile-time error. -#define ABSL_ARRAYSIZE(array) \ +#define OTABSL_ARRAYSIZE(array) \ (sizeof(::absl::macros_internal::ArraySizeHelper(array))) namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN namespace macros_internal { -// Note: this internal template function declaration is used by ABSL_ARRAYSIZE. +// Note: this internal template function declaration is used by OTABSL_ARRAYSIZE. // The function doesn't need a definition, as we only use its type. template auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; } // namespace macros_internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl // kLinkerInitialized @@ -75,20 +75,20 @@ ABSL_NAMESPACE_END // // Invocation // static MyClass my_global(absl::base_internal::kLinkerInitialized); namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN namespace base_internal { enum LinkerInitialized { kLinkerInitialized = 0, }; } // namespace base_internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -// ABSL_FALLTHROUGH_INTENDED +// OTABSL_FALLTHROUGH_INTENDED // // Annotates implicit fall-through between switch labels, allowing a case to // indicate intentional fallthrough and turn off warnings about any lack of a -// `break` statement. The ABSL_FALLTHROUGH_INTENDED macro should be followed by +// `break` statement. The OTABSL_FALLTHROUGH_INTENDED macro should be followed by // a semicolon and can be used in most places where `break` can, provided that // no statements exist between it and the next switch label. // @@ -99,7 +99,7 @@ ABSL_NAMESPACE_END // case 41: // if (truth_is_out_there) { // ++x; -// ABSL_FALLTHROUGH_INTENDED; // Use instead of/along with annotations +// OTABSL_FALLTHROUGH_INTENDED; // Use instead of/along with annotations // // in comments // } else { // return x; @@ -107,36 +107,36 @@ ABSL_NAMESPACE_END // case 42: // ... // -// Notes: when compiled with clang in C++11 mode, the ABSL_FALLTHROUGH_INTENDED +// Notes: when compiled with clang in C++11 mode, the OTABSL_FALLTHROUGH_INTENDED // macro is expanded to the [[clang::fallthrough]] attribute, which is analysed // when performing switch labels fall-through diagnostic // (`-Wimplicit-fallthrough`). See clang documentation on language extensions // for details: // https://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough // -// When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro +// When used with unsupported compilers, the OTABSL_FALLTHROUGH_INTENDED macro // has no effect on diagnostics. In any case this macro has no effect on runtime // behavior and performance of code. -#ifdef ABSL_FALLTHROUGH_INTENDED -#error "ABSL_FALLTHROUGH_INTENDED should not be defined." +#ifdef OTABSL_FALLTHROUGH_INTENDED +#error "OTABSL_FALLTHROUGH_INTENDED should not be defined." #endif // TODO(zhangxy): Use c++17 standard [[fallthrough]] macro, when supported. #if defined(__clang__) && defined(__has_warning) #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") -#define ABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] +#define OTABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] #endif #elif defined(__GNUC__) && __GNUC__ >= 7 -#define ABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] +#define OTABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] #endif -#ifndef ABSL_FALLTHROUGH_INTENDED -#define ABSL_FALLTHROUGH_INTENDED \ +#ifndef OTABSL_FALLTHROUGH_INTENDED +#define OTABSL_FALLTHROUGH_INTENDED \ do { \ } while (0) #endif -// ABSL_DEPRECATED() +// OTABSL_DEPRECATED() // // Marks a deprecated class, struct, enum, function, method and variable // declarations. The macro argument is used as a custom diagnostic message (e.g. @@ -144,26 +144,26 @@ ABSL_NAMESPACE_END // // Examples: // -// class ABSL_DEPRECATED("Use Bar instead") Foo {...}; +// class OTABSL_DEPRECATED("Use Bar instead") Foo {...}; // -// ABSL_DEPRECATED("Use Baz() instead") void Bar() {...} +// OTABSL_DEPRECATED("Use Baz() instead") void Bar() {...} // // template -// ABSL_DEPRECATED("Use DoThat() instead") +// OTABSL_DEPRECATED("Use DoThat() instead") // void DoThis(); // // Every usage of a deprecated entity will trigger a warning when compiled with // clang's `-Wdeprecated-declarations` option. This option is turned off by // default, but the warnings will be reported by clang-tidy. #if defined(__clang__) && __cplusplus >= 201103L -#define ABSL_DEPRECATED(message) __attribute__((deprecated(message))) +#define OTABSL_DEPRECATED(message) __attribute__((deprecated(message))) #endif -#ifndef ABSL_DEPRECATED -#define ABSL_DEPRECATED(message) +#ifndef OTABSL_DEPRECATED +#define OTABSL_DEPRECATED(message) #endif -// ABSL_BAD_CALL_IF() +// OTABSL_BAD_CALL_IF() // // Used on a function overload to trap bad calls: any call that matches the // overload will cause a compile-time error. This macro uses a clang-specific @@ -171,50 +171,50 @@ ABSL_NAMESPACE_END // https://clang.llvm.org/docs/AttributeReference.html#enable-if // // Overloads which use this macro should be bracketed by -// `#ifdef ABSL_BAD_CALL_IF`. +// `#ifdef OTABSL_BAD_CALL_IF`. // // Example: // // int isdigit(int c); -// #ifdef ABSL_BAD_CALL_IF +// #ifdef OTABSL_BAD_CALL_IF // int isdigit(int c) -// ABSL_BAD_CALL_IF(c <= -1 || c > 255, +// OTABSL_BAD_CALL_IF(c <= -1 || c > 255, // "'c' must have the value of an unsigned char or EOF"); -// #endif // ABSL_BAD_CALL_IF -#if ABSL_HAVE_ATTRIBUTE(enable_if) -#define ABSL_BAD_CALL_IF(expr, msg) \ +// #endif // OTABSL_BAD_CALL_IF +#if OTABSL_HAVE_ATTRIBUTE(enable_if) +#define OTABSL_BAD_CALL_IF(expr, msg) \ __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) #endif -// ABSL_ASSERT() +// OTABSL_ASSERT() // // In C++11, `assert` can't be used portably within constexpr functions. -// ABSL_ASSERT functions as a runtime assert but works in C++11 constexpr +// OTABSL_ASSERT functions as a runtime assert but works in C++11 constexpr // functions. Example: // // constexpr double Divide(double a, double b) { -// return ABSL_ASSERT(b != 0), a / b; +// return OTABSL_ASSERT(b != 0), a / b; // } // // This macro is inspired by // https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/ #if defined(NDEBUG) -#define ABSL_ASSERT(expr) \ +#define OTABSL_ASSERT(expr) \ (false ? static_cast(expr) : static_cast(0)) #else -#define ABSL_ASSERT(expr) \ - (ABSL_PREDICT_TRUE((expr)) ? static_cast(0) \ +#define OTABSL_ASSERT(expr) \ + (OTABSL_PREDICT_TRUE((expr)) ? static_cast(0) \ : [] { assert(false && #expr); }()) // NOLINT #endif -#ifdef ABSL_HAVE_EXCEPTIONS -#define ABSL_INTERNAL_TRY try -#define ABSL_INTERNAL_CATCH_ANY catch (...) -#define ABSL_INTERNAL_RETHROW do { throw; } while (false) -#else // ABSL_HAVE_EXCEPTIONS -#define ABSL_INTERNAL_TRY if (true) -#define ABSL_INTERNAL_CATCH_ANY else if (false) -#define ABSL_INTERNAL_RETHROW do {} while (false) -#endif // ABSL_HAVE_EXCEPTIONS +#ifdef OTABSL_HAVE_EXCEPTIONS +#define OTABSL_INTERNAL_TRY try +#define OTABSL_INTERNAL_CATCH_ANY catch (...) +#define OTABSL_INTERNAL_RETHROW do { throw; } while (false) +#else // OTABSL_HAVE_EXCEPTIONS +#define OTABSL_INTERNAL_TRY if (true) +#define OTABSL_INTERNAL_CATCH_ANY else if (false) +#define OTABSL_INTERNAL_RETHROW do {} while (false) +#endif // OTABSL_HAVE_EXCEPTIONS -#endif // ABSL_BASE_MACROS_H_ +#endif // OTABSL_BASE_MACROS_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/optimization.h b/api/include/opentelemetry/nostd/absl/base/optimization.h index 646523b346..69713654a6 100644 --- a/api/include/opentelemetry/nostd/absl/base/optimization.h +++ b/api/include/opentelemetry/nostd/absl/base/optimization.h @@ -19,12 +19,12 @@ // // This header file defines portable macros for performance optimization. -#ifndef ABSL_BASE_OPTIMIZATION_H_ -#define ABSL_BASE_OPTIMIZATION_H_ +#ifndef OTABSL_BASE_OPTIMIZATION_H_ +#define OTABSL_BASE_OPTIMIZATION_H_ -#include "absl/base/config.h" +#include "config.h" -// ABSL_BLOCK_TAIL_CALL_OPTIMIZATION +// OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION // // Instructs the compiler to avoid optimizing tail-call recursion. Use of this // macro is useful when you wish to preserve the existing function order within @@ -34,30 +34,30 @@ // // int f() { // int result = g(); -// ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); +// OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); // return result; // } #if defined(__pnacl__) -#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } +#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } #elif defined(__clang__) // Clang will not tail call given inline volatile assembly. -#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") +#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") #elif defined(__GNUC__) // GCC will not tail call given inline volatile assembly. -#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") +#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") #elif defined(_MSC_VER) #include // The __nop() intrinsic blocks the optimisation. -#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop() +#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop() #else -#define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } +#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } #endif -// ABSL_CACHELINE_SIZE +// OTABSL_CACHELINE_SIZE // // Explicitly defines the size of the L1 cache for purposes of alignment. // Setting the cacheline size allows you to specify that certain objects be -// aligned on a cacheline boundary with `ABSL_CACHELINE_ALIGNED` declarations. +// aligned on a cacheline boundary with `OTABSL_CACHELINE_ALIGNED` declarations. // (See below.) // // NOTE: this macro should be replaced with the following C++17 features, when @@ -71,35 +71,35 @@ #if defined(__GNUC__) // Cache line alignment #if defined(__i386__) || defined(__x86_64__) -#define ABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_SIZE 64 #elif defined(__powerpc64__) -#define ABSL_CACHELINE_SIZE 128 +#define OTABSL_CACHELINE_SIZE 128 #elif defined(__aarch64__) // We would need to read special register ctr_el0 to find out L1 dcache size. // This value is a good estimate based on a real aarch64 machine. -#define ABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_SIZE 64 #elif defined(__arm__) // Cache line sizes for ARM: These values are not strictly correct since // cache line sizes depend on implementations, not architectures. There // are even implementations with cache line sizes configurable at boot // time. #if defined(__ARM_ARCH_5T__) -#define ABSL_CACHELINE_SIZE 32 +#define OTABSL_CACHELINE_SIZE 32 #elif defined(__ARM_ARCH_7A__) -#define ABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_SIZE 64 #endif #endif -#ifndef ABSL_CACHELINE_SIZE +#ifndef OTABSL_CACHELINE_SIZE // A reasonable default guess. Note that overestimates tend to waste more // space, while underestimates tend to waste more time. -#define ABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_SIZE 64 #endif -// ABSL_CACHELINE_ALIGNED +// OTABSL_CACHELINE_ALIGNED // // Indicates that the declared object be cache aligned using -// `ABSL_CACHELINE_SIZE` (see above). Cacheline aligning objects allows you to +// `OTABSL_CACHELINE_SIZE` (see above). Cacheline aligning objects allows you to // load a set of related objects in the L1 cache for performance improvements. // Cacheline aligning objects properly allows constructive memory sharing and // prevents destructive (or "false") memory sharing. @@ -111,7 +111,7 @@ // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html // for more information. // -// On some compilers, `ABSL_CACHELINE_ALIGNED` expands to an `__attribute__` +// On some compilers, `OTABSL_CACHELINE_ALIGNED` expands to an `__attribute__` // or `__declspec` attribute. For compilers where this is not known to work, // the macro expands to nothing. // @@ -126,9 +126,9 @@ // this attribute, so prefer to put it at the beginning of your declaration. // For example, // -// ABSL_CACHELINE_ALIGNED static Foo* foo = ... +// OTABSL_CACHELINE_ALIGNED static Foo* foo = ... // -// class ABSL_CACHELINE_ALIGNED Bar { ... +// class OTABSL_CACHELINE_ALIGNED Bar { ... // // Recommendations: // @@ -138,23 +138,23 @@ // the generated machine code. // 3) Prefer applying this attribute to individual variables. Avoid // applying it to types. This tends to localize the effect. -#define ABSL_CACHELINE_ALIGNED __attribute__((aligned(ABSL_CACHELINE_SIZE))) +#define OTABSL_CACHELINE_ALIGNED __attribute__((aligned(OTABSL_CACHELINE_SIZE))) #elif defined(_MSC_VER) -#define ABSL_CACHELINE_SIZE 64 -#define ABSL_CACHELINE_ALIGNED __declspec(align(ABSL_CACHELINE_SIZE)) +#define OTABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_ALIGNED __declspec(align(OTABSL_CACHELINE_SIZE)) #else -#define ABSL_CACHELINE_SIZE 64 -#define ABSL_CACHELINE_ALIGNED +#define OTABSL_CACHELINE_SIZE 64 +#define OTABSL_CACHELINE_ALIGNED #endif -// ABSL_PREDICT_TRUE, ABSL_PREDICT_FALSE +// OTABSL_PREDICT_TRUE, OTABSL_PREDICT_FALSE // // Enables the compiler to prioritize compilation using static analysis for // likely paths within a boolean branch. // // Example: // -// if (ABSL_PREDICT_TRUE(expression)) { +// if (OTABSL_PREDICT_TRUE(expression)) { // return result; // Faster if more likely // } else { // return 0; @@ -169,13 +169,13 @@ // branch in a codebase is likely counterproductive; however, annotating // specific branches that are both hot and consistently mispredicted is likely // to yield performance improvements. -#if ABSL_HAVE_BUILTIN(__builtin_expect) || \ +#if OTABSL_HAVE_BUILTIN(__builtin_expect) || \ (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#define ABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true)) +#define OTABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0)) +#define OTABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true)) #else -#define ABSL_PREDICT_FALSE(x) (x) -#define ABSL_PREDICT_TRUE(x) (x) +#define OTABSL_PREDICT_FALSE(x) (x) +#define OTABSL_PREDICT_TRUE(x) (x) #endif -#endif // ABSL_BASE_OPTIMIZATION_H_ +#endif // OTABSL_BASE_OPTIMIZATION_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/options.h b/api/include/opentelemetry/nostd/absl/base/options.h index 1fb77e44c4..3632b74f64 100644 --- a/api/include/opentelemetry/nostd/absl/base/options.h +++ b/api/include/opentelemetry/nostd/absl/base/options.h @@ -1,5 +1,5 @@ -#ifndef ABSL_BASE_OPTIONS_H_ -#define ABSL_BASE_OPTIONS_H_ +#ifndef OTABSL_BASE_OPTIONS_H_ +#define OTABSL_BASE_OPTIONS_H_ // Copyright 2019 The Abseil Authors. // @@ -77,7 +77,7 @@ // Type Compatibility Options // ----------------------------------------------------------------------------- // -// ABSL_OPTION_USE_STD_ANY +// OTABSL_OPTION_USE_STD_ANY // // This option controls whether absl::any is implemented as an alias to // std::any, or as an independent implementation. @@ -98,12 +98,12 @@ // For more info, see https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if -// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY. +// absl::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. -#define ABSL_OPTION_USE_STD_ANY 0 +#define OTABSL_OPTION_USE_STD_ANY 0 -// ABSL_OPTION_USE_STD_OPTIONAL +// OTABSL_OPTION_USE_STD_OPTIONAL // // This option controls whether absl::optional is implemented as an alias to // std::optional, or as an independent implementation. @@ -125,12 +125,12 @@ // User code should not inspect this macro. To check in the preprocessor if // absl::optional is a typedef of std::optional, use the feature macro -// ABSL_USES_STD_OPTIONAL. +// OTABSL_USES_STD_OPTIONAL. -#define ABSL_OPTION_USE_STD_OPTIONAL 0 +#define OTABSL_OPTION_USE_STD_OPTIONAL 0 -// ABSL_OPTION_USE_STD_STRING_VIEW +// OTABSL_OPTION_USE_STD_STRING_VIEW // // This option controls whether absl::string_view is implemented as an alias to // std::string_view, or as an independent implementation. @@ -152,11 +152,11 @@ // // User code should not inspect this macro. To check in the preprocessor if // absl::string_view is a typedef of std::string_view, use the feature macro -// ABSL_USES_STD_STRING_VIEW. +// OTABSL_USES_STD_STRING_VIEW. -#define ABSL_OPTION_USE_STD_STRING_VIEW 0 +#define OTABSL_OPTION_USE_STD_STRING_VIEW 0 -// ABSL_OPTION_USE_STD_VARIANT +// OTABSL_OPTION_USE_STD_VARIANT // // This option controls whether absl::variant is implemented as an alias to // std::variant, or as an independent implementation. @@ -178,13 +178,13 @@ // // User code should not inspect this macro. To check in the preprocessor if // absl::variant is a typedef of std::variant, use the feature macro -// ABSL_USES_STD_VARIANT. +// OTABSL_USES_STD_VARIANT. -#define ABSL_OPTION_USE_STD_VARIANT 0 +#define OTABSL_OPTION_USE_STD_VARIANT 0 -// ABSL_OPTION_USE_INLINE_NAMESPACE -// ABSL_OPTION_INLINE_NAMESPACE_NAME +// OTABSL_OPTION_USE_INLINE_NAMESPACE +// OTABSL_OPTION_INLINE_NAMESPACE_NAME // // These options controls whether all entities in the absl namespace are // contained within an inner inline namespace. This does not affect the @@ -201,11 +201,11 @@ // A value of 0 means not to use inline namespaces. // // A value of 1 means to use an inline namespace with the given name inside -// namespace absl. If this is set, ABSL_OPTION_INLINE_NAMESPACE_NAME must also +// namespace absl. If this is set, OTABSL_OPTION_INLINE_NAMESPACE_NAME must also // be changed to a new, unique identifier name. In particular "head" is not // allowed. -#define ABSL_OPTION_USE_INLINE_NAMESPACE 0 -#define ABSL_OPTION_INLINE_NAMESPACE_NAME head +#define OTABSL_OPTION_USE_INLINE_NAMESPACE 1 +#define OTABSL_OPTION_INLINE_NAMESPACE_NAME otel_v1 -#endif // ABSL_BASE_OPTIONS_H_ +#endif // OTABSL_BASE_OPTIONS_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/policy_checks.h b/api/include/opentelemetry/nostd/absl/base/policy_checks.h index 0c6053b1c9..02bdda4b63 100644 --- a/api/include/opentelemetry/nostd/absl/base/policy_checks.h +++ b/api/include/opentelemetry/nostd/absl/base/policy_checks.h @@ -21,8 +21,8 @@ // reported with `#error`. This enforcement is best effort, so successfully // compiling this header does not guarantee a supported configuration. -#ifndef ABSL_BASE_POLICY_CHECKS_H_ -#define ABSL_BASE_POLICY_CHECKS_H_ +#ifndef OTABSL_BASE_POLICY_CHECKS_H_ +#define OTABSL_BASE_POLICY_CHECKS_H_ // Included for the __GLIBC_PREREQ macro used below. #include @@ -110,4 +110,4 @@ #error "Abseil assumes that int is at least 4 bytes. " #endif -#endif // ABSL_BASE_POLICY_CHECKS_H_ +#endif // OTABSL_BASE_POLICY_CHECKS_H_ diff --git a/api/include/opentelemetry/nostd/absl/base/port.h b/api/include/opentelemetry/nostd/absl/base/port.h index 6c28068d4f..aaba551b59 100644 --- a/api/include/opentelemetry/nostd/absl/base/port.h +++ b/api/include/opentelemetry/nostd/absl/base/port.h @@ -16,11 +16,11 @@ // portability macros and functions. // This file is used for both C and C++! -#ifndef ABSL_BASE_PORT_H_ -#define ABSL_BASE_PORT_H_ +#ifndef OTABSL_BASE_PORT_H_ +#define OTABSL_BASE_PORT_H_ -#include "absl/base/attributes.h" -#include "absl/base/config.h" -#include "absl/base/optimization.h" +#include "attributes.h" +#include "config.h" +#include "optimization.h" -#endif // ABSL_BASE_PORT_H_ +#endif // OTABSL_BASE_PORT_H_ diff --git a/api/include/opentelemetry/nostd/absl/meta/type_traits.h b/api/include/opentelemetry/nostd/absl/meta/type_traits.h index ba87d2f0ed..fc69bb5d66 100644 --- a/api/include/opentelemetry/nostd/absl/meta/type_traits.h +++ b/api/include/opentelemetry/nostd/absl/meta/type_traits.h @@ -32,23 +32,23 @@ // features is brittle and not guaranteed. Neither the standard library nor // Abseil provides any guarantee that APIs are stable in the face of template // metaprogramming. Use with caution. -#ifndef ABSL_META_TYPE_TRAITS_H_ -#define ABSL_META_TYPE_TRAITS_H_ +#ifndef OTABSL_META_TYPE_TRAITS_H_ +#define OTABSL_META_TYPE_TRAITS_H_ #include #include #include -#include "absl/base/config.h" +#include "../base/config.h" // MSVC constructibility traits do not detect destructor properties and so our // implementations should not use them as a source-of-truth. #if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) -#define ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 +#define OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 #endif namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN // Defined and documented later on in this file. template @@ -298,7 +298,7 @@ template struct is_trivially_destructible : std::integral_constant::value> { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE +#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE private: static constexpr bool compliant = std::is_trivially_destructible::value == is_trivially_destructible::value; @@ -308,7 +308,7 @@ struct is_trivially_destructible static_assert(compliant || !std::is_trivially_destructible::value, "Not compliant with std::is_trivially_destructible; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE }; // is_trivially_default_constructible() @@ -348,9 +348,9 @@ struct is_trivially_default_constructible : std::integral_constant::value && is_trivially_destructible::value> { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ +#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) + OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_default_constructible::value == @@ -361,7 +361,7 @@ struct is_trivially_default_constructible static_assert(compliant || !std::is_trivially_default_constructible::value, "Not compliant with std::is_trivially_default_constructible; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE }; // is_trivially_move_constructible() @@ -383,9 +383,9 @@ struct is_trivially_move_constructible std::is_object::value && !std::is_array::value, type_traits_internal::IsTriviallyMoveConstructibleObject, std::is_reference>::type::type { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ +#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) + OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_move_constructible::value == @@ -396,7 +396,7 @@ struct is_trivially_move_constructible static_assert(compliant || !std::is_trivially_move_constructible::value, "Not compliant with std::is_trivially_move_constructible; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE }; // is_trivially_copy_constructible() @@ -418,9 +418,9 @@ struct is_trivially_copy_constructible std::is_object::value && !std::is_array::value, type_traits_internal::IsTriviallyCopyConstructibleObject, std::is_lvalue_reference>::type::type { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ +#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) + OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_copy_constructible::value == @@ -431,7 +431,7 @@ struct is_trivially_copy_constructible static_assert(compliant || !std::is_trivially_copy_constructible::value, "Not compliant with std::is_trivially_copy_constructible; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE }; // is_trivially_move_assignable() @@ -457,7 +457,7 @@ struct is_trivially_move_assignable std::is_move_assignable>, type_traits_internal::IsTriviallyMoveAssignableReference>::type:: type { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE +#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE private: static constexpr bool compliant = std::is_trivially_move_assignable::value == @@ -468,7 +468,7 @@ struct is_trivially_move_assignable static_assert(compliant || !std::is_trivially_move_assignable::value, "Not compliant with std::is_trivially_move_assignable; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE }; // is_trivially_copy_assignable() @@ -491,7 +491,7 @@ struct is_trivially_copy_assignable : std::integral_constant< bool, __has_trivial_assign(typename std::remove_reference::type) && absl::is_copy_assignable::value> { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE +#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE private: static constexpr bool compliant = std::is_trivially_copy_assignable::value == @@ -502,7 +502,7 @@ struct is_trivially_copy_assignable static_assert(compliant || !std::is_trivially_copy_assignable::value, "Not compliant with std::is_trivially_copy_assignable; " "Standard: true, Implementation: false"); -#endif // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE +#endif // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE }; namespace type_traits_internal { @@ -626,15 +626,15 @@ namespace type_traits_internal { // #if defined(_MSC_VER) || (defined(_LIBCPP_VERSION) && \ _LIBCPP_VERSION < 4000 && _LIBCPP_STD_VER > 11) -#define ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 0 +#define OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 0 #else -#define ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 1 +#define OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 1 #endif -#if !ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ +#if !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ template struct IsHashable : std::true_type {}; -#else // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ +#else // OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ template struct IsHashable : std::false_type {}; @@ -644,7 +644,7 @@ struct IsHashable< absl::enable_if_t&>()(std::declval())), std::size_t>::value>> : std::true_type {}; -#endif // !ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ +#endif // !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ struct AssertHashEnabledHelper { private: @@ -753,7 +753,7 @@ using swap_internal::Swap; using swap_internal::StdSwapIsUnconstrained; } // namespace type_traits_internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_META_TYPE_TRAITS_H_ +#endif // OTABSL_META_TYPE_TRAITS_H_ diff --git a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h index 095969f91e..9783504d2d 100644 --- a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h @@ -18,27 +18,27 @@ // // This header file defines the `absl::bad_variant_access` type. -#ifndef ABSL_TYPES_BAD_VARIANT_ACCESS_H_ -#define ABSL_TYPES_BAD_VARIANT_ACCESS_H_ +#ifndef OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ +#define OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ #include -#include "absl/base/config.h" +#include "../base/config.h" -#ifdef ABSL_USES_STD_VARIANT +#ifdef OTABSL_USES_STD_VARIANT #include namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN using std::bad_variant_access; -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#else // ABSL_USES_STD_VARIANT +#else // OTABSL_USES_STD_VARIANT namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_variant_access @@ -69,14 +69,26 @@ class bad_variant_access : public std::exception { }; namespace variant_internal { - +#ifdef THROW_BAD_VARIANT_ACCESS +// Header-only implementation with static throw implementation. +// No need to link against Abseil library. +[[noreturn]] static inline void ThrowBadVariantAccess() +{ + THROW_BAD_VARIANT_ACCESS; +}; +//[[noreturn]] static inline void Rethrow() +//{ +// THROW_BAD_VARIANT_ACCESS; // Unused! +//}; +#else +// Original implementation requires linking Abseil library! [[noreturn]] void ThrowBadVariantAccess(); [[noreturn]] void Rethrow(); - +#endif } // namespace variant_internal -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_USES_STD_VARIANT +#endif // OTABSL_USES_STD_VARIANT -#endif // ABSL_TYPES_BAD_VARIANT_ACCESS_H_ +#endif // OTABSL_TYPES_BAD_VARIANT_ACCESS_H_ diff --git a/api/include/opentelemetry/nostd/absl/types/internal/variant.h b/api/include/opentelemetry/nostd/absl/types/internal/variant.h index 71bd3adfc6..ee42da7c93 100644 --- a/api/include/opentelemetry/nostd/absl/types/internal/variant.h +++ b/api/include/opentelemetry/nostd/absl/types/internal/variant.h @@ -16,8 +16,8 @@ // separate file to avoid cluttering the top of the API header with // implementation details. -#ifndef ABSL_TYPES_variant_internal_H_ -#define ABSL_TYPES_variant_internal_H_ +#ifndef OTABSL_TYPES_variant_internal_H_ +#define OTABSL_TYPES_variant_internal_H_ #include #include @@ -27,25 +27,25 @@ #include #include -#include "absl/base/config.h" -#include "absl/base/internal/identity.h" -#include "absl/base/internal/inline_variable.h" -#include "absl/base/internal/invoke.h" -#include "absl/base/macros.h" -#include "absl/base/optimization.h" -#include "absl/meta/type_traits.h" -#include "absl/types/bad_variant_access.h" -#include "absl/utility/utility.h" +#include "../../base/config.h" +#include "../../base/internal/identity.h" +#include "../../base/internal/inline_variable.h" +#include "../../base/internal/invoke.h" +#include "../../base/macros.h" +#include "../../base/optimization.h" +#include "../../meta/type_traits.h" +#include "../../types/bad_variant_access.h" +#include "../../utility/utility.h" -#if !defined(ABSL_USES_STD_VARIANT) +#if !defined(OTABSL_USES_STD_VARIANT) namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN template class variant; -ABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); +OTABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); template struct variant_size; @@ -272,7 +272,7 @@ struct UnreachableSwitchCase { template [[noreturn]] static VisitIndicesResultT Run( Op&& /*ignored*/) { -#if ABSL_HAVE_BUILTIN(__builtin_unreachable) || \ +#if OTABSL_HAVE_BUILTIN(__builtin_unreachable) || \ (defined(__GNUC__) && !defined(__clang__)) __builtin_unreachable(); #elif defined(_MSC_VER) @@ -292,7 +292,7 @@ struct UnreachableSwitchCase { template struct ReachableSwitchCase { static VisitIndicesResultT Run(Op&& op) { - return absl::base_internal::Invoke(absl::forward(op), SizeT()); + return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), SizeT()); } }; @@ -301,7 +301,7 @@ struct ReachableSwitchCase { // power of 2 is because the number was picked to correspond to a power of 2 // amount of "normal" alternatives, plus one for the possibility of the user // providing "monostate" in addition to the more natural alternatives. -ABSL_INTERNAL_INLINE_CONSTEXPR(std::size_t, MaxUnrolledVisitCases, 33); +OTABSL_INTERNAL_INLINE_CONSTEXPR(std::size_t, MaxUnrolledVisitCases, 33); // Note: The default-definition is for unreachable cases. template @@ -423,8 +423,8 @@ struct VisitIndicesSwitch { case 32: return PickCase::Run(absl::forward(op)); default: - ABSL_ASSERT(i == variant_npos); - return absl::base_internal::Invoke(absl::forward(op), NPos()); + OTABSL_ASSERT(i == variant_npos); + return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke(absl::forward(op), NPos()); } } }; @@ -488,7 +488,7 @@ struct VisitIndicesVariadicImpl, EndIndices...> { template VisitIndicesResultT operator()( SizeT /*index*/) && { - return base_internal::Invoke( + return OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( absl::forward(op), SizeT::value - std::size_t{1}>()...); @@ -608,7 +608,7 @@ struct VariantCoreAccess { // Access a variant alternative, throwing if the index is incorrect. template static VariantAccessResult CheckedAccess(Variant&& self) { - if (ABSL_PREDICT_FALSE(self.index_ != I)) { + if (OTABSL_PREDICT_FALSE(self.index_ != I)) { TypedThrowBadVariantAccess>(); } @@ -930,7 +930,7 @@ struct PerformVisitation { absl::result_of_t...)>>::value, "All visitation overloads must have the same return type."); - return absl::base_internal::Invoke( + return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( absl::forward(op), VariantCoreAccess::Access( absl::forward(std::get(variant_tup)))...); @@ -1059,7 +1059,7 @@ class VariantStateBase { std::size_t index_; }; -using absl::internal::identity; +using absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity; // OverloadSet::Overload() is a unary function which is overloaded to // take any of the element types of the variant, by reference-to-const. @@ -1639,8 +1639,8 @@ struct VariantHashBase // IWYU pragma: export namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN using std::bad_variant_access; using std::get; using std::get_if; @@ -63,23 +63,23 @@ using std::variant_npos; using std::variant_size; using std::variant_size_v; using std::visit; -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#else // ABSL_USES_STD_VARIANT +#else // OTABSL_USES_STD_VARIANT #include #include #include #include -#include "absl/base/macros.h" -#include "absl/base/port.h" -#include "absl/meta/type_traits.h" -#include "absl/types/internal/variant.h" +#include "../base/macros.h" +#include "../base/port.h" +#include "../meta/type_traits.h" +#include "../types/internal/variant.h" namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // absl::variant @@ -803,7 +803,7 @@ operator>=(const variant& a, const variant& b) { a.index()); } -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl namespace std { @@ -821,10 +821,10 @@ struct hash> } // namespace std -#endif // ABSL_USES_STD_VARIANT +#endif // OTABSL_USES_STD_VARIANT namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN namespace variant_internal { // Helper visitor for converting a variant` into another type (mostly @@ -860,7 +860,7 @@ To ConvertVariantTo(Variant&& variant) { std::forward(variant)); } -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_TYPES_VARIANT_H_ +#endif // OTABSL_TYPES_VARIANT_H_ diff --git a/api/include/opentelemetry/nostd/absl/utility/utility.h b/api/include/opentelemetry/nostd/absl/utility/utility.h index e6647c7b2e..8c15e2b8c1 100644 --- a/api/include/opentelemetry/nostd/absl/utility/utility.h +++ b/api/include/opentelemetry/nostd/absl/utility/utility.h @@ -37,21 +37,21 @@ // https://en.cppreference.com/w/cpp/utility/apply // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3658.html -#ifndef ABSL_UTILITY_UTILITY_H_ -#define ABSL_UTILITY_UTILITY_H_ +#ifndef OTABSL_UTILITY_UTILITY_H_ +#define OTABSL_UTILITY_UTILITY_H_ #include #include #include #include -#include "absl/base/config.h" -#include "absl/base/internal/inline_variable.h" -#include "absl/base/internal/invoke.h" -#include "absl/meta/type_traits.h" +#include "../base/config.h" +#include "../base/internal/inline_variable.h" +#include "../base/internal/invoke.h" +#include "../meta/type_traits.h" namespace absl { -ABSL_NAMESPACE_BEGIN +OTABSL_NAMESPACE_BEGIN // integer_sequence // @@ -159,12 +159,12 @@ using index_sequence_for = make_index_sequence; // Tag types -#ifdef ABSL_USES_STD_OPTIONAL +#ifdef OTABSL_USES_STD_OPTIONAL using std::in_place_t; using std::in_place; -#else // ABSL_USES_STD_OPTIONAL +#else // OTABSL_USES_STD_OPTIONAL // in_place_t // @@ -173,11 +173,11 @@ using std::in_place; // `std::in_place_t`. struct in_place_t {}; -ABSL_INTERNAL_INLINE_CONSTEXPR(in_place_t, in_place, {}); +OTABSL_INTERNAL_INLINE_CONSTEXPR(in_place_t, in_place, {}); -#endif // ABSL_USES_STD_OPTIONAL +#endif // OTABSL_USES_STD_OPTIONAL -#if defined(ABSL_USES_STD_ANY) || defined(ABSL_USES_STD_VARIANT) +#if defined(OTABSL_USES_STD_ANY) || defined(OTABSL_USES_STD_VARIANT) using std::in_place_type; using std::in_place_type_t; #else @@ -192,9 +192,9 @@ using in_place_type_t = void (*)(utility_internal::InPlaceTypeTag); template void in_place_type(utility_internal::InPlaceTypeTag) {} -#endif // ABSL_USES_STD_ANY || ABSL_USES_STD_VARIANT +#endif // OTABSL_USES_STD_ANY || OTABSL_USES_STD_VARIANT -#ifdef ABSL_USES_STD_VARIANT +#ifdef OTABSL_USES_STD_VARIANT using std::in_place_index; using std::in_place_index_t; #else @@ -209,7 +209,7 @@ using in_place_index_t = void (*)(utility_internal::InPlaceIndexTag); template void in_place_index(utility_internal::InPlaceIndexTag) {} -#endif // ABSL_USES_STD_VARIANT +#endif // OTABSL_USES_STD_VARIANT // Constexpr move and forward @@ -236,10 +236,10 @@ namespace utility_internal { // Helper method for expanding tuple into a called method. template auto apply_helper(Functor&& functor, Tuple&& t, index_sequence) - -> decltype(absl::base_internal::Invoke( + -> decltype(absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( absl::forward(functor), std::get(absl::forward(t))...)) { - return absl::base_internal::Invoke( + return absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::base_internal::Invoke( absl::forward(functor), std::get(absl::forward(t))...); } @@ -344,7 +344,7 @@ constexpr T make_from_tuple(Tuple&& tup) { std::tuple_size>::value>{}); } -ABSL_NAMESPACE_END +OTABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_UTILITY_UTILITY_H_ +#endif // OTABSL_UTILITY_UTILITY_H_ diff --git a/api/include/opentelemetry/nostd/detail/find_index.h b/api/include/opentelemetry/nostd/detail/find_index.h deleted file mode 100644 index 130bc21db4..0000000000 --- a/api/include/opentelemetry/nostd/detail/find_index.h +++ /dev/null @@ -1,61 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// Copyright OpenTelemetry Authors, 2020 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file third_party/boost/LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#pragma once - -#include - -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -constexpr std::size_t not_found = static_cast(-1); -constexpr std::size_t ambiguous = static_cast(-2); - -inline constexpr std::size_t find_index_impl(std::size_t result, std::size_t) -{ - return result; -} - -template -inline constexpr std::size_t find_index_impl(std::size_t result, std::size_t idx, bool b, Bs... bs) -{ - return b ? (result != not_found ? ambiguous : find_index_impl(idx, idx + 1, bs...)) - : find_index_impl(result, idx + 1, bs...); -} - -template -inline constexpr std::size_t find_index() -{ - return find_index_impl(not_found, 0, std::is_same::value...); -} - -template -using find_index_sfinae_impl = - enable_if_t>; - -template -using find_index_sfinae = find_index_sfinae_impl()>; - -template -struct find_index_checked_impl : std::integral_constant -{ - static_assert(I != not_found, "the specified type is not found."); - static_assert(I != ambiguous, "the specified type is ambiguous."); -}; - -template -using find_index_checked = find_index_checked_impl()>; -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/nostd/detail/recursive_union.h b/api/include/opentelemetry/nostd/detail/recursive_union.h deleted file mode 100644 index 8de72592f5..0000000000 --- a/api/include/opentelemetry/nostd/detail/recursive_union.h +++ /dev/null @@ -1,125 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// Copyright OpenTelemetry Authors, 2020 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file third_party/boost/LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#pragma once - -#include -#include - -#include "opentelemetry/nostd/detail/trait.h" -#include "opentelemetry/nostd/detail/valueless.h" -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -#define AUTO_REFREF_RETURN(...) \ - ->decltype((__VA_ARGS__)) \ - { \ - static_assert(std::is_reference::value, ""); \ - return __VA_ARGS__; \ - } - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -namespace access -{ -struct recursive_union -{ - template - struct get_alt_impl - { - template - inline constexpr auto operator()(V &&v) const - AUTO_REFREF_RETURN(get_alt_impl{}(std::forward(v).tail_)) - }; - - template - struct get_alt_impl<0, Dummy> - { - template - inline constexpr auto operator()(V &&v) const AUTO_REFREF_RETURN(std::forward(v).head_) - }; - - template - inline static constexpr auto get_alt(V &&v, in_place_index_t) - AUTO_REFREF_RETURN(get_alt_impl{}(std::forward(v))) -}; -} // namespace access - -template -struct alt -{ - using value_type = T; - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4244) -#endif - template - inline explicit constexpr alt(in_place_t, Args &&... args) : value(std::forward(args)...) - {} -#ifdef _MSC_VER -# pragma warning(pop) -#endif - - T value; -}; - -template -union recursive_union; - -template -union recursive_union -{}; - -#define OPENTELEMETRY_VARIANT_RECURSIVE_UNION(destructible_trait, destructor) \ - template \ - union recursive_union \ - { \ - public: \ - inline explicit constexpr recursive_union(valueless_t) noexcept : dummy_{} {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t<0>, Args &&... args) \ - : head_(in_place_t{}, std::forward(args)...) \ - {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t, Args &&... args) \ - : tail_(in_place_index_t{}, std::forward(args)...) \ - {} \ - \ - recursive_union(const recursive_union &) = default; \ - recursive_union(recursive_union &&) = default; \ - \ - destructor \ - \ - recursive_union & \ - operator=(const recursive_union &) = default; \ - recursive_union &operator=(recursive_union &&) = default; \ - \ - private: \ - char dummy_; \ - alt head_; \ - recursive_union tail_; \ - \ - friend struct access::recursive_union; \ - } - -OPENTELEMETRY_VARIANT_RECURSIVE_UNION(Trait::TriviallyAvailable, ~recursive_union() = default;); -OPENTELEMETRY_VARIANT_RECURSIVE_UNION(Trait::Available, ~recursive_union(){}); -OPENTELEMETRY_VARIANT_RECURSIVE_UNION(Trait::Unavailable, ~recursive_union() = delete;); - -#undef OPENTELEMETRY_VARIANT_RECURSIVE_UNION -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE - -#undef AUTO_REFREF_RETURN diff --git a/api/include/opentelemetry/nostd/mpark/variant.h b/api/include/opentelemetry/nostd/mpark/variant.h deleted file mode 100644 index bf66b5239a..0000000000 --- a/api/include/opentelemetry/nostd/mpark/variant.h +++ /dev/null @@ -1,1282 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// Copyright OpenTelemetry Authors, 2020 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file third_party/boost/LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#pragma once - -#include -#include -#include - -#include "opentelemetry/nostd/detail/all.h" -#include "opentelemetry/nostd/detail/dependent_type.h" -#include "opentelemetry/nostd/detail/find_index.h" -#include "opentelemetry/nostd/detail/functional.h" -#include "opentelemetry/nostd/detail/recursive_union.h" -#include "opentelemetry/nostd/detail/trait.h" -#include "opentelemetry/nostd/detail/type_pack_element.h" -#include "opentelemetry/nostd/detail/variant_alternative.h" -#include "opentelemetry/nostd/detail/variant_fwd.h" -#include "opentelemetry/nostd/detail/variant_size.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -#define AUTO_RETURN(...) \ - ->decay_t { return __VA_ARGS__; } - -#define AUTO_REFREF_RETURN(...) \ - ->decltype((__VA_ARGS__)) \ - { \ - static_assert(std::is_reference::value, ""); \ - return __VA_ARGS__; \ - } - -#define DECLTYPE_AUTO_RETURN(...) \ - ->decltype(__VA_ARGS__) { return __VA_ARGS__; } - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -constexpr std::size_t variant_npos = static_cast(-1); - -class bad_variant_access : public std::exception -{ -public: - virtual const char *what() const noexcept override { return "bad_variant_access"; } -}; - -[[noreturn]] inline void throw_bad_variant_access() -{ -#if __EXCEPTIONS - throw bad_variant_access{}; -#else - std::terminate(); -#endif -} - -namespace detail -{ -namespace access -{ -struct base -{ - template - inline static constexpr auto get_alt(V &&v) -#ifdef _MSC_VER - AUTO_REFREF_RETURN(recursive_union::get_alt(std::forward(v).data_, in_place_index_t{})) -#else - AUTO_REFREF_RETURN(recursive_union::get_alt(data(std::forward(v)), in_place_index_t{})) -#endif -}; - -struct variant -{ - template - inline static constexpr auto get_alt(V &&v) - AUTO_REFREF_RETURN(base::get_alt(std::forward(v).impl_)) -}; -} // namespace access -} // namespace detail - -namespace detail -{ -namespace visitation -{ - -struct base -{ - template - using dispatch_result_t = decltype( - nostd::invoke(std::declval(), access::base::get_alt<0>(std::declval())...)); - - template - struct expected - { - template - inline static constexpr bool but_got() - { - return std::is_same::value; - } - }; - - template - struct visit_return_type_check - { - static_assert(expected::template but_got(), - "`visit` requires the visitor to have a single return type"); - - template - inline static constexpr auto invoke(Visitor &&visitor, Alts &&... alts) - DECLTYPE_AUTO_RETURN(nostd::invoke(std::forward(visitor), - std::forward(alts)...)) - }; - - template - inline static constexpr const T &at(const T &elem) noexcept - { - return elem; - } - - template - inline static constexpr const remove_all_extents_t &at(const std::array &elems, - std::size_t i, - Is... is) noexcept - { - return at(elems[i], is...); - } - - template - inline static constexpr std::array, sizeof...(Fs) + 1> make_farray(F &&f, Fs &&... fs) - { - return {{std::forward(f), std::forward(fs)...}}; - } - - template - struct make_fmatrix_impl - { - - template - inline static constexpr dispatch_result_t dispatch(F &&f, Vs &&... vs) - { - using Expected = dispatch_result_t; - using Actual = decltype( - nostd::invoke(std::forward(f), access::base::get_alt(std::forward(vs))...)); - return visit_return_type_check::invoke( - std::forward(f), access::base::get_alt(std::forward(vs))...); - } - - template - struct impl; - - template - struct impl> - { - inline constexpr auto operator()() const AUTO_RETURN(&dispatch) - }; - - template - struct impl, Ls...> - { - inline constexpr auto operator()() const - AUTO_RETURN(make_farray(impl, Ls...>{}()...)) - }; - }; - - template - inline static constexpr auto make_fmatrix() AUTO_RETURN( - typename make_fmatrix_impl:: - template impl, make_index_sequence::size()>...>{}()) - - template - struct make_fdiagonal_impl - { - template - inline static constexpr dispatch_result_t dispatch(F &&f, Vs &&... vs) - { - using Expected = dispatch_result_t; - using Actual = decltype( - nostd::invoke(std::forward(f), access::base::get_alt(std::forward(vs))...)); - return visit_return_type_check::invoke( - std::forward(f), access::base::get_alt(std::forward(vs))...); - } - - template - inline static constexpr auto impl(index_sequence) - AUTO_RETURN(make_farray(&dispatch...)) - }; - - template - inline static constexpr auto make_fdiagonal() - -> decltype(make_fdiagonal_impl::impl(make_index_sequence::size()>{})) - { - static_assert(all<(decay_t::size() == decay_t::size())...>::value, - "all of the variants must be the same size."); - return make_fdiagonal_impl::impl(make_index_sequence::size()>{}); - } -}; - -#if !defined(_MSC_VER) || _MSC_VER >= 1910 -template -using fmatrix_t = decltype(base::make_fmatrix()); - -template -struct fmatrix -{ - static constexpr fmatrix_t value = base::make_fmatrix(); -}; - -template -constexpr fmatrix_t fmatrix::value; - -template -using fdiagonal_t = decltype(base::make_fdiagonal()); - -template -struct fdiagonal -{ - static constexpr fdiagonal_t value = base::make_fdiagonal(); -}; - -template -constexpr fdiagonal_t fdiagonal::value; -#endif - -struct alt -{ - template - inline static constexpr auto visit_alt(Visitor &&visitor, Vs &&... vs) DECLTYPE_AUTO_RETURN( - base::at(base::make_fmatrix(vs)))...>(), - vs.index()...)(std::forward(visitor), as_base(std::forward(vs))...)) - - template - inline static constexpr auto visit_alt_at(std::size_t index, Visitor &&visitor, Vs &&... vs) - DECLTYPE_AUTO_RETURN(base::at( - base::make_fdiagonal(vs)))...>(), - index)(std::forward(visitor), as_base(std::forward(vs))...)) -}; - -struct variant -{ -private: - template - struct visitor - { - template - inline static constexpr bool does_not_handle() - { - return nostd::is_invocable::value; - } - }; - - template - struct visit_exhaustiveness_check - { - static_assert(visitor::template does_not_handle(), - "`visit` requires the visitor to be exhaustive."); - - inline static constexpr auto invoke(Visitor &&visitor, Values &&... values) - DECLTYPE_AUTO_RETURN(nostd::invoke(std::forward(visitor), - std::forward(values)...)) - }; - - template - struct value_visitor - { - Visitor &&visitor_; - - template - inline constexpr auto operator()(Alts &&... alts) const DECLTYPE_AUTO_RETURN( - visit_exhaustiveness_check(alts).value))...>::invoke( - std::forward(visitor_), - std::forward(alts).value...)) - }; - - template - inline static constexpr auto make_value_visitor(Visitor &&visitor) - AUTO_RETURN(value_visitor{std::forward(visitor)}) - - public - : template - inline static constexpr auto visit_alt(Visitor &&visitor, Vs &&... vs) - DECLTYPE_AUTO_RETURN(alt::visit_alt(std::forward(visitor), - std::forward(vs).impl_...)) - - template - inline static constexpr auto visit_alt_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(alt::visit_alt_at(index, - std::forward(visitor), - std::forward(vs).impl_...)) - - template - inline static constexpr auto visit_value(Visitor &&visitor, Vs &&... vs) - DECLTYPE_AUTO_RETURN( - visit_alt(make_value_visitor(std::forward(visitor)), - std::forward(vs)...)) - - template - inline static constexpr auto visit_value_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(visit_alt_at( - index, - make_value_visitor(std::forward(visitor)), - std::forward(vs)...)) -}; -} // namespace visitation - -template -using index_t = typename std::conditional< - sizeof...(Ts) < (std::numeric_limits::max)(), - unsigned char, - typename std::conditional::max)(), - unsigned short, - unsigned int>::type>::type; - -template -class base -{ -public: - inline explicit constexpr base(valueless_t tag) noexcept - : data_(tag), index_(static_cast>(-1)) - {} - - template - inline explicit constexpr base(in_place_index_t, Args &&... args) - : data_(in_place_index_t{}, std::forward(args)...), index_(I) - {} - - inline constexpr bool valueless_by_exception() const noexcept - { - return index_ == static_cast>(-1); - } - - inline constexpr std::size_t index() const noexcept - { - return valueless_by_exception() ? variant_npos : index_; - } - -protected: - using data_t = recursive_union; - - friend inline constexpr base &as_base(base &b) { return b; } - friend inline constexpr const base &as_base(const base &b) { return b; } - friend inline constexpr base &&as_base(base &&b) { return std::move(b); } - friend inline constexpr const base &&as_base(const base &&b) { return std::move(b); } - - friend inline constexpr data_t &data(base &b) { return b.data_; } - friend inline constexpr const data_t &data(const base &b) { return b.data_; } - friend inline constexpr data_t &&data(base &&b) { return std::move(b).data_; } - friend inline constexpr const data_t &&data(const base &&b) { return std::move(b).data_; } - - inline static constexpr std::size_t size() { return sizeof...(Ts); } - - data_t data_; - index_t index_; - - friend struct access::base; - friend struct visitation::base; -}; - -struct dtor -{ -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4100) -#endif - template - inline void operator()(Alt &alt) const noexcept - { - alt.~Alt(); - } -#ifdef _MSC_VER -# pragma warning(pop) -#endif -}; - -template -class destructor; - -#define OPENTELEMETRY_VARIANT_DESTRUCTOR(destructible_trait, definition, destroy) \ - template \ - class destructor, destructible_trait> : public base \ - { \ - using super = base; \ - \ - public: \ - using super::super; \ - using super::operator=; \ - \ - destructor(const destructor &) = default; \ - destructor(destructor &&) = default; \ - definition destructor &operator=(const destructor &) = default; \ - destructor &operator=(destructor &&) = default; \ - \ - protected: \ - destroy \ - } - -OPENTELEMETRY_VARIANT_DESTRUCTOR( - Trait::TriviallyAvailable, ~destructor() = default; - , inline void destroy() noexcept { this->index_ = static_cast>(-1); }); - -OPENTELEMETRY_VARIANT_DESTRUCTOR( - Trait::Available, - ~destructor() { destroy(); }, - inline void destroy() noexcept { - if (!this->valueless_by_exception()) - { - visitation::alt::visit_alt(dtor{}, *this); - } - this->index_ = static_cast>(-1); - }); - -OPENTELEMETRY_VARIANT_DESTRUCTOR(Trait::Unavailable, ~destructor() = delete; - , inline void destroy() noexcept = delete;); - -#undef OPENTELEMETRY_VARIANT_DESTRUCTOR - -template -class constructor : public destructor -{ - using super = destructor; - -public: - using super::super; - using super::operator=; - -protected: - struct ctor - { - template - inline void operator()(LhsAlt &lhs_alt, RhsAlt &&rhs_alt) const - { - constructor::construct_alt(lhs_alt, std::forward(rhs_alt).value); - } - }; - - template - inline static T &construct_alt(alt &a, Args &&... args) - { - auto *result = ::new (static_cast(std::addressof(a))) - alt(in_place_t{}, std::forward(args)...); - return result->value; - } - - template - inline static void generic_construct(constructor &lhs, Rhs &&rhs) - { - lhs.destroy(); - if (!rhs.valueless_by_exception()) - { - visitation::alt::visit_alt_at(rhs.index(), ctor{}, lhs, std::forward(rhs)); - lhs.index_ = rhs.index_; - } - } -}; - -template -class move_constructor; - -#define OPENTELEMETRY_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, definition) \ - template \ - class move_constructor, move_constructible_trait> \ - : public constructor> \ - { \ - using super = constructor>; \ - \ - public: \ - using super::super; \ - using super::operator=; \ - \ - move_constructor(const move_constructor &) = default; \ - definition ~move_constructor() = default; \ - move_constructor &operator=(const move_constructor &) = default; \ - move_constructor &operator=(move_constructor &&) = default; \ - } - -OPENTELEMETRY_VARIANT_MOVE_CONSTRUCTOR(Trait::TriviallyAvailable, - move_constructor(move_constructor &&that) = default;); - -OPENTELEMETRY_VARIANT_MOVE_CONSTRUCTOR( - Trait::Available, - move_constructor(move_constructor &&that) noexcept( - all::value...>::value) - : move_constructor(valueless_t{}) { this->generic_construct(*this, std::move(that)); }); - -OPENTELEMETRY_VARIANT_MOVE_CONSTRUCTOR(Trait::Unavailable, - move_constructor(move_constructor &&) = delete;); - -#undef OPENTELEMETRY_VARIANT_MOVE_CONSTRUCTOR - -template -class copy_constructor; - -#define OPENTELEMETRY_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, definition) \ - template \ - class copy_constructor, copy_constructible_trait> \ - : public move_constructor> \ - { \ - using super = move_constructor>; \ - \ - public: \ - using super::super; \ - using super::operator=; \ - \ - definition copy_constructor(copy_constructor &&) = default; \ - ~copy_constructor() = default; \ - copy_constructor &operator=(const copy_constructor &) = default; \ - copy_constructor &operator=(copy_constructor &&) = default; \ - } - -OPENTELEMETRY_VARIANT_COPY_CONSTRUCTOR(Trait::TriviallyAvailable, - copy_constructor(const copy_constructor &that) = default;); - -OPENTELEMETRY_VARIANT_COPY_CONSTRUCTOR( - Trait::Available, copy_constructor(const copy_constructor &that) - : copy_constructor(valueless_t{}) { this->generic_construct(*this, that); }); - -OPENTELEMETRY_VARIANT_COPY_CONSTRUCTOR(Trait::Unavailable, - copy_constructor(const copy_constructor &) = delete;); - -#undef OPENTELEMETRY_VARIANT_COPY_CONSTRUCTOR - -template -class assignment : public copy_constructor -{ - using super = copy_constructor; - -public: - using super::super; - using super::operator=; - - template - inline /* auto & */ auto emplace(Args &&... args) - -> decltype(this->construct_alt(access::base::get_alt(*this), std::forward(args)...)) - { - this->destroy(); - auto &result = - this->construct_alt(access::base::get_alt(*this), std::forward(args)...); - this->index_ = I; - return result; - } - -protected: - template - struct assigner - { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &&that_alt) const - { - self->assign_alt(this_alt, std::forward(that_alt).value); - } - assignment *self; - }; - - template - inline void assign_alt(alt &a, Arg &&arg) - { - if (this->index() == I) - { -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4244) -#endif - a.value = std::forward(arg); -#ifdef _MSC_VER -# pragma warning(pop) -#endif - } - else - { - struct - { - void operator()(std::true_type) const { this_->emplace(std::forward(arg_)); } - void operator()(std::false_type) const { this_->emplace(T(std::forward(arg_))); } - assignment *this_; - Arg &&arg_; - } impl{this, std::forward(arg)}; - impl(bool_constant < std::is_nothrow_constructible::value || - !std::is_nothrow_move_constructible::value > {}); - } - } - - template - inline void generic_assign(That &&that) - { - if (this->valueless_by_exception() && that.valueless_by_exception()) - { - // do nothing. - } - else if (that.valueless_by_exception()) - { - this->destroy(); - } - else - { - visitation::alt::visit_alt_at(that.index(), assigner{this}, *this, - std::forward(that)); - } - } -}; - -template -class move_assignment; - -#define OPENTELEMETRY_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, definition) \ - template \ - class move_assignment, move_assignable_trait> : public assignment> \ - { \ - using super = assignment>; \ - \ - public: \ - using super::super; \ - using super::operator=; \ - \ - move_assignment(const move_assignment &) = default; \ - move_assignment(move_assignment &&) = default; \ - ~move_assignment() = default; \ - move_assignment &operator=(const move_assignment &) = default; \ - definition \ - } - -OPENTELEMETRY_VARIANT_MOVE_ASSIGNMENT( - Trait::TriviallyAvailable, move_assignment &operator=(move_assignment &&that) = default;); - -OPENTELEMETRY_VARIANT_MOVE_ASSIGNMENT( - Trait::Available, - move_assignment & - operator=(move_assignment &&that) noexcept( - all<(std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value)...>::value) { - this->generic_assign(std::move(that)); - return *this; - }); - -OPENTELEMETRY_VARIANT_MOVE_ASSIGNMENT(Trait::Unavailable, - move_assignment &operator=(move_assignment &&) = delete;); - -#undef OPENTELEMETRY_VARIANT_MOVE_ASSIGNMENT - -template -class copy_assignment; - -#define OPENTELEMETRY_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, definition) \ - template \ - class copy_assignment, copy_assignable_trait> \ - : public move_assignment> \ - { \ - using super = move_assignment>; \ - \ - public: \ - using super::super; \ - using super::operator=; \ - \ - copy_assignment(const copy_assignment &) = default; \ - copy_assignment(copy_assignment &&) = default; \ - ~copy_assignment() = default; \ - definition copy_assignment &operator=(copy_assignment &&) = default; \ - } - -OPENTELEMETRY_VARIANT_COPY_ASSIGNMENT( - Trait::TriviallyAvailable, copy_assignment &operator=(const copy_assignment &that) = default;); - -OPENTELEMETRY_VARIANT_COPY_ASSIGNMENT( - Trait::Available, - copy_assignment & - operator=(const copy_assignment &that) { - this->generic_assign(that); - return *this; - }); - -OPENTELEMETRY_VARIANT_COPY_ASSIGNMENT( - Trait::Unavailable, copy_assignment &operator=(const copy_assignment &) = delete;); - -#undef OPENTELEMETRY_VARIANT_COPY_ASSIGNMENT -template -class impl : public copy_assignment> -{ - using super = copy_assignment>; - -public: - using super::super; - using super::operator=; - - impl(const impl &) = default; - impl(impl &&) = default; - ~impl() = default; - impl &operator=(const impl &) = default; - impl &operator=(impl &&) = default; - - template - inline void assign(Arg &&arg) - { - this->assign_alt(access::base::get_alt(*this), std::forward(arg)); - } - - inline void swap(impl &that) - { - if (this->valueless_by_exception() && that.valueless_by_exception()) - { - // do nothing. - } - else if (this->index() == that.index()) - { - visitation::alt::visit_alt_at(this->index(), swapper{}, *this, that); - } - else - { - impl *lhs = this; - impl *rhs = std::addressof(that); - if (lhs->move_nothrow() && !rhs->move_nothrow()) - { - std::swap(lhs, rhs); - } - impl tmp(std::move(*rhs)); -#if __EXCEPTIONS - // EXTENSION: When the move construction of `lhs` into `rhs` throws - // and `tmp` is nothrow move constructible then we move `tmp` back - // into `rhs` and provide the strong exception safety guarantee. - try - { - this->generic_construct(*rhs, std::move(*lhs)); - } - catch (...) - { - if (tmp.move_nothrow()) - { - this->generic_construct(*rhs, std::move(tmp)); - } - throw; - } -#else - this->generic_construct(*rhs, std::move(*lhs)); -#endif - this->generic_construct(*lhs, std::move(tmp)); - } - } - -private: - struct swapper - { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &that_alt) const - { - using std::swap; - swap(this_alt.value, that_alt.value); - } - }; - - inline constexpr bool move_nothrow() const - { - return this->valueless_by_exception() || - std::array{ - {std::is_nothrow_move_constructible::value...}}[this->index()]; - } -}; - -template -struct is_non_narrowing_convertible -{ - template - static std::true_type test(T(&&)[1]); - - template - static auto impl(int) -> decltype(test({std::declval()})); - - template - static auto impl(...) -> std::false_type; - - static constexpr bool value = decltype(impl(0))::value; -}; - -template ::value, - typename = void> -struct overload_leaf -{}; - -template -struct overload_leaf -{ - using impl = size_constant (*)(T); - operator impl() const { return nullptr; }; -}; - -template -struct overload_leaf, bool>::value - ? std::is_same, bool>::value - : -#if defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 5 - is_non_narrowing_convertible::value -#else - std::is_convertible::value -#endif - >> -{ - using impl = size_constant (*)(T); - operator impl() const { return nullptr; }; -}; - -template -struct overload_impl -{ -private: - template - struct impl; - - template - struct impl> : overload_leaf... - {}; - -public: - using type = impl>; -}; - -template -using overload = typename overload_impl::type; - -template -using best_match = invoke_result_t, Arg>; - -template -struct is_in_place_index : std::false_type -{}; - -template -struct is_in_place_index> : std::true_type -{}; - -template -struct is_in_place_type : std::false_type -{}; - -template -struct is_in_place_type> : std::true_type -{}; -} // namespace detail - -template -class variant -{ - static_assert(0 < sizeof...(Ts), "variant must consist of at least one alternative."); - - static_assert(detail::all::value...>::value, - "variant can not have an array type as an alternative."); - - static_assert(detail::all::value...>::value, - "variant can not have a reference type as an alternative."); - - static_assert(detail::all::value...>::value, - "variant can not have a void type as an alternative."); - -public: - template , - enable_if_t::value, int> = 0> - inline constexpr variant() noexcept(std::is_nothrow_default_constructible::value) - : impl_(in_place_index_t<0>{}) - {} - - variant(const variant &) = default; - variant(variant &&) = default; - - template , - enable_if_t::value, int> = 0, - enable_if_t::value, int> = 0, - enable_if_t::value, int> = 0, - std::size_t I = detail::best_match::value, - typename T = detail::type_pack_element_t, - enable_if_t::value, int> = 0> - inline constexpr variant(Arg &&arg) noexcept(std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, std::forward(arg)) - {} - - template , - enable_if_t::value, int> = 0> - inline explicit constexpr variant(in_place_index_t, Args &&... args) noexcept( - std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, std::forward(args)...) - {} - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = detail::type_pack_element_t, - enable_if_t &, Args...>::value, int> = 0> - inline explicit constexpr variant( - in_place_index_t, - std::initializer_list il, - Args &&... args) noexcept(std::is_nothrow_constructible &, - Args...>::value) - : impl_(in_place_index_t{}, il, std::forward(args)...) - {} - - template ::value, - enable_if_t::value, int> = 0> - inline explicit constexpr variant(in_place_type_t, Args &&... args) noexcept( - std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, std::forward(args)...) - {} - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - enable_if_t &, Args...>::value, int> = 0> - inline explicit constexpr variant( - in_place_type_t, - std::initializer_list il, - Args &&... args) noexcept(std::is_nothrow_constructible &, - Args...>::value) - : impl_(in_place_index_t{}, il, std::forward(args)...) - {} - - ~variant() = default; - - variant &operator=(const variant &) = default; - variant &operator=(variant &&) = default; - - template < - typename Arg, - enable_if_t, variant>::value, int> = 0, - std::size_t I = detail::best_match::value, - typename T = detail::type_pack_element_t, - enable_if_t<(std::is_assignable::value && std::is_constructible::value), - int> = 0> - inline variant &operator=(Arg &&arg) noexcept((std::is_nothrow_assignable::value && - std::is_nothrow_constructible::value)) - { - impl_.template assign(std::forward(arg)); - return *this; - } - - template , - enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) - { - return impl_.template emplace(std::forward(args)...); - } - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = detail::type_pack_element_t, - enable_if_t &, Args...>::value, int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) - { - return impl_.template emplace(il, std::forward(args)...); - } - - template ::value, - enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) - { - return impl_.template emplace(std::forward(args)...); - } - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - enable_if_t &, Args...>::value, int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) - { - return impl_.template emplace(il, std::forward(args)...); - } - - inline constexpr bool valueless_by_exception() const noexcept - { - return impl_.valueless_by_exception(); - } - - inline constexpr std::size_t index() const noexcept { return impl_.index(); } - - template , Dummy>::value && - detail::dependent_type, Dummy>::value)...>::value, - int> = 0> - inline void swap(variant &that) noexcept( - detail::all<(std::is_nothrow_move_constructible::value && - is_nothrow_swappable::value)...>::value) - { - impl_.swap(that.impl_); - } - -private: - detail::impl impl_; - - friend struct detail::access::variant; - friend struct detail::visitation::variant; -}; - -template -inline constexpr bool holds_alternative(const variant &v) noexcept -{ - return v.index() == I; -} - -template -inline constexpr bool holds_alternative(const variant &v) noexcept -{ - return holds_alternative::value>(v); -} - -namespace detail -{ -template -struct generic_get_impl -{ - constexpr generic_get_impl(int) noexcept {} - - constexpr auto operator()(V &&v) const - AUTO_REFREF_RETURN(access::variant::get_alt(std::forward(v)).value) -}; - -template -inline constexpr auto generic_get(V &&v) AUTO_REFREF_RETURN(generic_get_impl( - holds_alternative(v) ? 0 : (throw_bad_variant_access(), 0))(std::forward(v))) -} // namespace detail - -template -inline constexpr variant_alternative_t> &get(variant &v) -{ - return detail::generic_get(v); -} - -template -inline constexpr variant_alternative_t> &&get(variant &&v) -{ - return detail::generic_get(std::move(v)); -} - -template -inline constexpr const variant_alternative_t> &get(const variant &v) -{ - return detail::generic_get(v); -} - -template -inline constexpr const variant_alternative_t> &&get(const variant &&v) -{ - return detail::generic_get(std::move(v)); -} - -template -inline constexpr T &get(variant &v) -{ - return get::value>(v); -} - -template -inline constexpr T &&get(variant &&v) -{ - return get::value>(std::move(v)); -} - -template -inline constexpr const T &get(const variant &v) -{ - return get::value>(v); -} - -template -inline constexpr const T &&get(const variant &&v) -{ - return get::value>(std::move(v)); -} - -namespace detail -{ - -template -inline constexpr /* auto * */ auto generic_get_if(V *v) noexcept - AUTO_RETURN(v &&holds_alternative(*v) ? std::addressof(access::variant::get_alt(*v).value) - : nullptr) - -} // namespace detail - -template -inline constexpr add_pointer_t>> get_if( - variant *v) noexcept -{ - return detail::generic_get_if(v); -} - -template -inline constexpr add_pointer_t>> get_if( - const variant *v) noexcept -{ - return detail::generic_get_if(v); -} - -template -inline constexpr add_pointer_t get_if(variant *v) noexcept -{ - return get_if::value>(v); -} - -template -inline constexpr add_pointer_t get_if(const variant *v) noexcept -{ - return get_if::value>(v); -} - -namespace detail -{ -template -struct convert_to_bool -{ - template - inline constexpr bool operator()(Lhs &&lhs, Rhs &&rhs) const - { - static_assert(std::is_convertible, bool>::value, - "relational operators must return a type" - " implicitly convertible to bool"); - return nostd::invoke(RelOp{}, std::forward(lhs), std::forward(rhs)); - } -}; -} // namespace detail - -template -inline constexpr bool operator==(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using equal_to = detail::convert_to_bool; - return lhs.index() == rhs.index() && (lhs.valueless_by_exception() || - variant::visit_value_at(lhs.index(), equal_to{}, lhs, rhs)); -} - -template -inline constexpr bool operator!=(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using not_equal_to = detail::convert_to_bool; - return lhs.index() != rhs.index() || - (!lhs.valueless_by_exception() && - variant::visit_value_at(lhs.index(), not_equal_to{}, lhs, rhs)); -} - -template -inline constexpr bool operator<(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using less = detail::convert_to_bool; - return !rhs.valueless_by_exception() && - (lhs.valueless_by_exception() || lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && variant::visit_value_at(lhs.index(), less{}, lhs, rhs))); -} - -template -inline constexpr bool operator>(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using greater = detail::convert_to_bool; - return !lhs.valueless_by_exception() && - (rhs.valueless_by_exception() || lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), greater{}, lhs, rhs))); -} - -template -inline constexpr bool operator<=(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using less_equal = detail::convert_to_bool; - return lhs.valueless_by_exception() || - (!rhs.valueless_by_exception() && - (lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), less_equal{}, lhs, rhs)))); -} - -template -inline constexpr bool operator>=(const variant &lhs, const variant &rhs) -{ - using detail::visitation::variant; - using greater_equal = detail::convert_to_bool; - return rhs.valueless_by_exception() || - (!lhs.valueless_by_exception() && - (lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), greater_equal{}, lhs, rhs)))); -} - -struct monostate -{}; - -inline constexpr bool operator<(monostate, monostate) noexcept -{ - return false; -} - -inline constexpr bool operator>(monostate, monostate) noexcept -{ - return false; -} - -inline constexpr bool operator<=(monostate, monostate) noexcept -{ - return true; -} - -inline constexpr bool operator>=(monostate, monostate) noexcept -{ - return true; -} - -inline constexpr bool operator==(monostate, monostate) noexcept -{ - return true; -} - -inline constexpr bool operator!=(monostate, monostate) noexcept -{ - return false; -} - -namespace detail -{ - -template -inline constexpr bool all_of_impl(const std::array &bs, std::size_t idx) -{ - return idx >= N || (bs[idx] && all_of_impl(bs, idx + 1)); -} - -template -inline constexpr bool all_of(const std::array &bs) -{ - return all_of_impl(bs, 0); -} - -} // namespace detail - -template -inline constexpr auto visit(Visitor &&visitor, Vs &&... vs) DECLTYPE_AUTO_RETURN( - (detail::all_of(std::array{{!vs.valueless_by_exception()...}}) - ? (void)0 - : throw_bad_variant_access()), - detail::visitation::variant::visit_value(std::forward(visitor), - std::forward(vs)...)) template -inline auto swap(variant &lhs, variant &rhs) noexcept(noexcept(lhs.swap(rhs))) - -> decltype(lhs.swap(rhs)) -{ - lhs.swap(rhs); -} -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE - -#undef AUTO_RETURN - -#undef AUTO_REFREF_RETURN - -#undef DECLTYPE_AUTO_RETURN diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index d9c2581975..cab15547fe 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -3,37 +3,23 @@ #pragma once +#include "opentelemetry/version.h" + #ifdef HAVE_CPP_STDLIB # include "opentelemetry/std/variant.h" -#elif defined(HAVE_ABSEIL_VARIANT) -// TODO: we use a LOCAL snapshot of Abseil that is known to compile with Visual Studio 2015, -// header-only, without compiling the actual Abseil binary. As Abseil moves on to new -// toolchains, it may drop support for Visual Studio 2015 in future versions. Perhaps a good -// option would be to determine if Abseil is available, then use the outside implementation, -// but it is not guaranteed to be still compatible with 2015. Thus, the local snapshot here. -# ifdef _MSC_VER -// Abseil variant implementation contains some benign non-impacting warnings -// that should be suppressed if compiling with Visual Studio 2017 and above. -# pragma warning(push) -# pragma warning(disable : 4245) // conversion from int to const unsigned _int64 -# pragma warning(disable : 4127) // conditional expression is constant -# endif -# include "./absl/types/variant.h" -# ifdef _MSC_VER -# pragma warning(pop) -# endif +#else + +# ifndef HAVE_ABSEIL +// We use a LOCAL snapshot of Abseil that is known to compile with Visual Studio 2015. +// Header-only. Without compiling the actual Abseil binary. As Abseil moves on to new +// toolchains, it may drop support for Visual Studio 2015 in future versions. +# if defined(__EXCEPTIONS) +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { -using absl::get; -using absl::holds_alternative; -using absl::monostate; -using absl::variant; -using absl::variant_size; -using absl::visit; -// nostd::bad_variant_access class bad_variant_access : public std::exception { public: @@ -44,40 +30,44 @@ class bad_variant_access : public std::exception { throw bad_variant_access{}; } - -# if __EXCEPTIONS -# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() -# else -# define THROW_BAD_VARIANT_ACCESS std::terminate() -# endif - } // namespace nostd OPENTELEMETRY_END_NAMESPACE +# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() +# else +# define THROW_BAD_VARIANT_ACCESS std::terminate() +# endif +# endif -// TODO: when we compile with Abseil variant we do not have to link the entire Abseil library. -// The only missing funcion is the variant exception handler here, which we statically link -// as-needed. This *should not* clash with the standard handler. However, it would make sense -// to consider a build-time flag that allows to route the handling of ThrowBadVariantAccess to -// the actual Abseil, in case if a product using OpenTelemetry is compiled with Abseil. That -// way the standard Abseil exception handler can be used to catch OpenTelemetry exceptions. -namespace absl -{ -namespace variant_internal -{ # ifdef _MSC_VER +// Abseil variant implementation contains some benign non-impacting warnings +// that should be suppressed if compiling with Visual Studio 2017 and above. # pragma warning(push) -# pragma warning(disable : 4211) // nonstandard extension used: redefined extern to static +# pragma warning(disable : 4245) // conversion from int to const unsigned _int64 +# pragma warning(disable : 4127) // conditional expression is constant # endif -static void ThrowBadVariantAccess() -{ - THROW_BAD_VARIANT_ACCESS; -}; + +# ifdef HAVE_ABSEIL +# include "absl/types/variant.h" +# else +# include "./absl/types/variant.h" +# endif + # ifdef _MSC_VER # pragma warning(pop) # endif -}; // namespace variant_internal -}; // namespace absl -#else -# include "opentelemetry/nostd/mpark/variant.h" +OPENTELEMETRY_BEGIN_NAMESPACE +namespace nostd +{ +using absl::get; +using absl::get_if; +using absl::holds_alternative; +using absl::monostate; +using absl::variant; +using absl::variant_alternative_t; +using absl::variant_size; +using absl::visit; +} // namespace nostd +OPENTELEMETRY_END_NAMESPACE + #endif diff --git a/api/include/opentelemetry/std/span.h b/api/include/opentelemetry/std/span.h index 0291e5aba5..e6de8a6742 100644 --- a/api/include/opentelemetry/std/span.h +++ b/api/include/opentelemetry/std/span.h @@ -26,6 +26,9 @@ # define HAVE_SPAN # endif # endif +# if !__has_include() +# undef HAVE_GSL +# endif #endif #if !defined(HAVE_SPAN) diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index fffe963bac..00cd99cc57 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -14,6 +14,9 @@ OPENTELEMETRY_BEGIN_NAMESPACE // Standard Type aliases in nostd namespace namespace nostd { +using std::get_if; +using std::monostate; +using std::variant_alternative_t; // nostd::variant<...> template diff --git a/api/test/nostd/CMakeLists.txt b/api/test/nostd/CMakeLists.txt index 21c2197ced..a21653200b 100644 --- a/api/test/nostd/CMakeLists.txt +++ b/api/test/nostd/CMakeLists.txt @@ -1,7 +1,14 @@ include(GoogleTest) -foreach(testname function_ref_test string_view_test unique_ptr_test - utility_test span_test shared_ptr_test) +foreach( + testname + function_ref_test + string_view_test + unique_ptr_test + utility_test + span_test + shared_ptr_test + variant_test) add_executable(${testname} "${testname}.cc") target_link_libraries( ${testname} ${GTEST_BOTH_LIBRARIES} ${CORE_RUNTIME_LIBS} diff --git a/api/test/nostd/variant_test.cc b/api/test/nostd/variant_test.cc index 299ef8377e..428d31e624 100644 --- a/api/test/nostd/variant_test.cc +++ b/api/test/nostd/variant_test.cc @@ -20,14 +20,6 @@ class DestroyCounter int *count_; }; -TEST(TypePackElementTest, IndexedType) -{ - using opentelemetry::nostd::detail::type_pack_element_t; - EXPECT_TRUE((std::is_same, int>::value)); - EXPECT_TRUE((std::is_same, double>::value)); - EXPECT_TRUE((std::is_same, char>::value)); -} - TEST(VariantSizeTest, GetVariantSize) { EXPECT_EQ(nostd::variant_size>::value, 0); @@ -120,6 +112,6 @@ TEST(VariantTest, Conversion) TEST(VariantTest, Construction) { - nostd::variant v{"abc"}; + nostd::variant v{"abc"}; EXPECT_EQ(v.index(), 1); } diff --git a/examples/http/server.cc b/examples/http/server.cc index 2906dacae9..8a9c437d60 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -9,8 +9,8 @@ namespace { -uint16_t server_port = 8800; -constexpr char server_name[] = "localhost"; +uint16_t server_port = 8800; +constexpr const char *server_name = "localhost"; class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback { @@ -31,15 +31,17 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback options.parent = opentelemetry::trace::propagation::GetSpan(new_context)->GetContext(); // start span with parent context extracted from http header - auto span = get_tracer("http-server") - ->StartSpan(span_name, - {{"http.server_name", server_name}, - {"net.host.port", server_port}, - {"http.method", request.method}, - {"http.scheme", "http"}, - {"http.request_content_length", request.content.length()}, - {"http.client_ip", request.client}}, - options); + auto span = + get_tracer("http-server") + ->StartSpan( + span_name, + {{"http.server_name", server_name}, + {"net.host.port", server_port}, + {"http.method", request.method}, + {"http.scheme", "http"}, + {"http.request_content_length", static_cast(request.content.length())}, + {"http.client_ip", request.client}}, + options); auto scope = get_tracer("http_server")->WithActiveSpan(span); diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index a2742b1062..8a928d829e 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -55,6 +55,9 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable case common::AttributeType::kTypeDouble: json_[name][key.data()] = opentelemetry::nostd::get(value); return; + case common::AttributeType::kTypeCString: + json_[name][key.data()] = opentelemetry::nostd::get(value); + return; case common::AttributeType::kTypeString: json_[name][key.data()] = opentelemetry::nostd::get(value).data(); diff --git a/exporters/etw/README.md b/exporters/etw/README.md index 9a999fa0e7..675fa6bb47 100644 --- a/exporters/etw/README.md +++ b/exporters/etw/README.md @@ -109,7 +109,6 @@ These options affect how "embedded in application" OpenTelemetry C++ SDK code is |---------------------|------------------------------------------------------------------------------------------------------------------------| | HAVE_CPP_STDLIB | Use STL classes for API surface. This option requires at least C++17. C++20 is recommended. Some customers may benefit from STL library provided with the compiler instead of using custom OpenTelemetry `nostd::` implementation due to security and performance considerations. | | HAVE_GSL | Use [Microsoft GSL](https://github.com/microsoft/GSL) for `gsl::span` implementation. Library must be in include path. Microsoft GSL claims to be the most feature-complete implementation of `std::span`. It may be used instead of `nostd::span` implementation in projects that statically link OpenTelemetry SDK. | -| HAVE_ABSEIL_VARIANT | Use `absl::variant` instead of `nostd::variant`. `nostd::variant` is incompatible with Visual Studio 2015. `absl::variant` should be used instead if targeting Visual Studio 2015. | | HAVE_TLD | Use ETW/TraceLogging Dynamic protocol. This is the default implementation compatible with existing C# "listeners" / "decoders" of ETW events. This option requires an additional optional Microsoft MIT-licensed `TraceLoggingDynamic.h` header. | ## Debugging diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h index 3f7ac3464c..c0f501e866 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h @@ -214,6 +214,10 @@ class PropertyValue : public PropertyVariant case common::AttributeType::kTypeDouble: PropertyVariant::operator=(nostd::get(v)); break; + case common::AttributeType::kTypeCString: { + PropertyVariant::operator=(nostd::get(v)); + break; + }; case common::AttributeType::kTypeString: { PropertyVariant::operator=(nostd::string_view(nostd::get(v)).data()); break; diff --git a/exporters/jaeger/src/recordable.cc b/exporters/jaeger/src/recordable.cc index 10ae117948..8e6cf8d8ff 100644 --- a/exporters/jaeger/src/recordable.cc +++ b/exporters/jaeger/src/recordable.cc @@ -25,6 +25,10 @@ void Recordable::PopulateAttribute(nostd::string_view key, const common::Attribu { AddTag(std::string{key}, nostd::get(value)); } + else if (nostd::holds_alternative(value)) + { + AddTag(std::string{key}, std::string{nostd::get(value)}); + } else if (nostd::holds_alternative(value)) { AddTag(std::string{key}, std::string{nostd::get(value)}); diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 044222e30e..6c5bed5607 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -36,13 +36,18 @@ if(BUILD_TESTING) TEST_PREFIX exporter.otlp. TEST_LIST otlp_recordable_test) if(MSVC) + # Explicitly specify that we consume GTest from shared library. The rest of + # code logic below determines whether we link Release or Debug flavor of the + # library. These flavors have different prefix on Windows, gmock and gmockd + # respectively. add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) - endif() - if(GMOCK_LIB) - # unset GMOCK_LIB to force find_library to redo the lookup, as the cached - # entry could cause linking to incorrect flavor of gmock and leading to - # runtime error. - unset(GMOCK_LIB CACHE) + else() + if(GMOCK_LIB) + # unset GMOCK_LIB to force find_library to redo the lookup, as the cached + # entry could cause linking to incorrect flavor of gmock and leading to + # runtime error. + unset(GMOCK_LIB CACHE) + endif() endif() if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib) diff --git a/exporters/otlp/src/otlp_recordable.cc b/exporters/otlp/src/otlp_recordable.cc index 907ff3bc60..53e92d8d76 100644 --- a/exporters/otlp/src/otlp_recordable.cc +++ b/exporters/otlp/src/otlp_recordable.cc @@ -12,7 +12,7 @@ namespace otlp // // See `attribute_value.h` for details. // -const int kAttributeValueSize = 15; +const int kAttributeValueSize = 16; const int kOwnedAttributeValueSize = 15; void OtlpRecordable::SetIdentity(const opentelemetry::trace::SpanContext &span_context, @@ -63,6 +63,10 @@ void PopulateAttribute(opentelemetry::proto::common::v1::KeyValue *attribute, { attribute->mutable_value()->set_double_value(nostd::get(value)); } + else if (nostd::holds_alternative(value)) + { + attribute->mutable_value()->set_string_value(nostd::get(value)); + } else if (nostd::holds_alternative(value)) { attribute->mutable_value()->set_string_value(nostd::get(value).data(), @@ -134,9 +138,9 @@ void PopulateAttribute(opentelemetry::proto::common::v1::KeyValue *attribute, { // Assert size of variant to ensure that this method gets updated if the variant // definition changes - static_assert( - nostd::variant_size::value == kOwnedAttributeValueSize, - "AttributeValue contains unknown type"); + static_assert(nostd::variant_size::value == + kOwnedAttributeValueSize + 1, + "AttributeValue contains unknown type"); attribute->set_key(key.data(), key.size()); diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index b440b4491f..00d9f63499 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -23,7 +23,7 @@ static const std::map kSpanKindMap // // See `attribute_value.h` for details. // -const int kAttributeValueSize = 15; +const int kAttributeValueSize = 16; void Recordable::SetIdentity(const opentelemetry::trace::SpanContext &span_context, opentelemetry::trace::SpanId parent_span_id) noexcept @@ -73,6 +73,10 @@ void PopulateAttribute(nlohmann::json &attribute, { attribute[key.data()] = nostd::get(value); } + else if (nostd::holds_alternative(value)) + { + attribute[key.data()] = nostd::get(value); + } else if (nostd::holds_alternative(value)) { attribute[key.data()] = nostd::string_view(nostd::get(value).data(), diff --git a/ext/test/w3c_tracecontext_test/CMakeLists.txt b/ext/test/w3c_tracecontext_test/CMakeLists.txt index d8600d3bac..61bfa8f467 100644 --- a/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_test/CMakeLists.txt @@ -1,16 +1,22 @@ include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) find_package(CURL) -find_package(nlohmann_json) - if(NOT CURL_FOUND) message(WARNING "Skipping example_w3c_tracecontext_test: CURL not found") -elseif(NOT nlohmann_json_FOUND) - message( - WARNING "Skipping example_w3c_tracecontext_test: nlohmann_json not found") else() + find_package(nlohmann_json QUIET) + if(NOT nlohmann_json_FOUND) + # Add library from git submodule to include path + include_directories( + ${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/single_include) + else() + # Add header-only library found by CMake + set(NLOHMANN_JSON_LIB nlohmann_json::nlohmann_json) + endif() add_executable(w3c_tracecontext_test main.cc) target_link_libraries( - w3c_tracecontext_test ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace - http_client_curl opentelemetry_exporter_ostream_span ${CURL_LIBRARIES}) + w3c_tracecontext_test + PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace http_client_curl + opentelemetry_exporter_ostream_span ${CURL_LIBRARIES} + ${NLOHMANN_JSON_LIB}) endif() diff --git a/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index c1b390672b..e8935b8f62 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -44,14 +44,14 @@ enum OwnedAttributeType { kTypeBool, kTypeInt, - kTypeInt64, kTypeUInt, + kTypeInt64, kTypeDouble, kTypeString, kTypeSpanBool, kTypeSpanInt, - kTypeSpanInt64, kTypeSpanUInt, + kTypeSpanInt64, kTypeSpanDouble, kTypeSpanString, kTypeUInt64, @@ -74,6 +74,7 @@ struct AttributeConverter { return OwnedAttributeValue(std::string(v)); } + OwnedAttributeValue operator()(std::string v) { return OwnedAttributeValue(v); } OwnedAttributeValue operator()(const char *v) { return OwnedAttributeValue(std::string(v)); } OwnedAttributeValue operator()(nostd::span v) { return convertSpan(v); } OwnedAttributeValue operator()(nostd::span v) { return convertSpan(v); } @@ -98,14 +99,14 @@ struct AttributeConverter /** * Class for storing attributes. */ -class AttributeMap +class AttributeMap : public std::unordered_map { public: // Contruct empty attribute map - AttributeMap(){}; + AttributeMap() : std::unordered_map(){}; // Contruct attribute map and populate with attributes - AttributeMap(const opentelemetry::common::KeyValueIterable &attributes) + AttributeMap(const opentelemetry::common::KeyValueIterable &attributes) : AttributeMap() { attributes.ForEachKeyValue( [&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept { @@ -114,19 +115,32 @@ class AttributeMap }); } + // Construct map from initializer list by applying `SetAttribute` transform for every attribute + AttributeMap( + std::initializer_list> + attributes) + : AttributeMap() + { + for (auto &kv : attributes) + { + SetAttribute(kv.first, kv.second); + } + } + + // Returns a reference to this map const std::unordered_map &GetAttributes() const noexcept { - return attributes_; + return (*this); } + // Convert non-owning key-value to owning std::string(key) and OwnedAttributeValue(value) void SetAttribute(nostd::string_view key, const opentelemetry::common::AttributeValue &value) noexcept { - attributes_[std::string(key)] = nostd::visit(converter_, value); + (*this)[std::string(key)] = nostd::visit(converter_, value); } private: - std::unordered_map attributes_; AttributeConverter converter_; }; } // namespace common diff --git a/sdk/include/opentelemetry/sdk/resource/resource.h b/sdk/include/opentelemetry/sdk/resource/resource.h index f59077bf70..03aebcd84a 100644 --- a/sdk/include/opentelemetry/sdk/resource/resource.h +++ b/sdk/include/opentelemetry/sdk/resource/resource.h @@ -3,6 +3,9 @@ #pragma once +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" + #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/resource/resource_detector.h" #include "opentelemetry/sdk/version/version.h" @@ -18,8 +21,7 @@ namespace sdk namespace resource { -using ResourceAttributes = - std::unordered_map; +using ResourceAttributes = opentelemetry::sdk::common::AttributeMap; class Resource { diff --git a/sdk/src/common/core.cc b/sdk/src/common/core.cc index bebec2585d..2bc6da52a9 100644 --- a/sdk/src/common/core.cc +++ b/sdk/src/common/core.cc @@ -7,8 +7,13 @@ #include "opentelemetry/nostd/variant.h" // clang-format on -#if defined(HAVE_ABSEIL) && !defined(HAVE_ABSEIL_VARIANT) - +#if defined(HAVE_ABSEIL) +/* The option of building and linking with Abseil library implies that Abseil + * may already provide the ThrowBadVariantAccess implementation if its own. + * Reconsider the implementation below: we are potentially introducing + * a function that is already implemented in the Abseil. Most likely the code + * below needs to be removed entirely. + */ # if defined(__GNUC__) || defined(__GNUG__) # ifndef __cdecl // see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html