From 076effa650d4cc2130c1b4ff9ed261188ae57aeb Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 11 May 2021 13:31:03 -0700 Subject: [PATCH 01/60] Add curl via vcpkg to WIndows builds --- tools/setup-buildtools.cmd | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index 2c0912ca2e..39270b9c7c 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -54,5 +54,6 @@ vcpkg install abseil:x64-windows vcpkg install protobuf:x64-windows vcpkg install gRPC:x64-windows vcpkg install prometheus-cpp:x64-windows +vcpkg install curl:x64-windows popd exit /b 0 From 54903e823064162973d06078148affc98ec2188c Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 20:21:59 -0700 Subject: [PATCH 02/60] Attempt to gracefully switch over from MPark variant to absl::variant --- CMakeLists.txt | 2 - .../opentelemetry/nostd/absl/README.md | 9 - .../opentelemetry/nostd/detail/find_index.h | 61 - .../nostd/detail/recursive_union.h | 125 -- .../opentelemetry/nostd/mpark/variant.h | 1282 ----------------- api/include/opentelemetry/nostd/variant.h | 4 +- exporters/etw/README.md | 1 - 7 files changed, 1 insertion(+), 1483 deletions(-) delete mode 100644 api/include/opentelemetry/nostd/detail/find_index.h delete mode 100644 api/include/opentelemetry/nostd/detail/recursive_union.h delete mode 100644 api/include/opentelemetry/nostd/mpark/variant.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 515c48895e..8d6b448ada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,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 diff --git a/api/include/opentelemetry/nostd/absl/README.md b/api/include/opentelemetry/nostd/absl/README.md index 1c03ceaaf5..937b7e060d 100644 --- a/api/include/opentelemetry/nostd/absl/README.md +++ b/api/include/opentelemetry/nostd/absl/README.md @@ -3,12 +3,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/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 923af09ba8..ac35d60df1 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -16,7 +16,7 @@ #ifdef HAVE_CPP_STDLIB # include "opentelemetry/std/variant.h" -#elif defined(HAVE_ABSEIL_VARIANT) +#else // 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 @@ -89,6 +89,4 @@ static void ThrowBadVariantAccess() }; // namespace variant_internal }; // namespace absl -#else -# include "opentelemetry/nostd/mpark/variant.h" #endif 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 From 5c7c70c1c42baf627e632f7e3f5d11bd1d796674 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 20:26:17 -0700 Subject: [PATCH 03/60] Fixing markdownlint warning (sigh) --- api/include/opentelemetry/nostd/absl/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/api/include/opentelemetry/nostd/absl/README.md b/api/include/opentelemetry/nostd/absl/README.md index 937b7e060d..6a40855704 100644 --- a/api/include/opentelemetry/nostd/absl/README.md +++ b/api/include/opentelemetry/nostd/absl/README.md @@ -2,4 +2,3 @@ This is a snapshot of Abseil Variant `absl::variant` from Abseil `v2020-03-03#8`. - From 24ff212ac96b139ab32563da3023a980e92b6fc1 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 20:28:46 -0700 Subject: [PATCH 04/60] Add CHANGELOG.md entry about variant implementation switch --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a45feac7c5..374a20c57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Increment the: ## [Unreleased] * [EXPORTER] Populate resource to OTLP proto data ([#758](https://github.com/open-telemetry/opentelemetry-cpp/pull/758)) +* [API] Switch from MPark variant to `absl::variant` ([#771](https://github.com/open-telemetry/opentelemetry-cpp/pull/771)) ## [0.6.0] 2021-05-11 From 8ed894308c56e083648631c8d4e9c00cfb0bc0f9 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 21:52:48 -0700 Subject: [PATCH 05/60] Fix static vs extern issue in Abseil. Add Abseil Variant to include directory path. --- CMakeLists.txt | 3 + .../nostd/absl/types/bad_variant_access.h | 16 ++++- api/include/opentelemetry/nostd/variant.h | 72 ++++++++----------- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d6b448ada..fd912222c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,9 @@ if(WITH_ABSEIL) # target_link_libraries(main PRIVATE absl::any absl::base absl::bits # absl::city) +else() + # Use local snapshot of Abseil Variant implementation. + include_directories(api/include/opentelemetry/nostd) endif() if(WITH_STL) 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..a322f479b0 100644 --- a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h @@ -69,10 +69,22 @@ 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 void ThrowBadVariantAccess() +{ + THROW_BAD_VARIANT_ACCESS; +}; +[[noreturn]] static 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 } // namespace absl diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index ac35d60df1..791c713948 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -17,34 +17,17 @@ #ifdef HAVE_CPP_STDLIB # include "opentelemetry/std/variant.h" #else -// 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 + +#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. +# 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: @@ -55,38 +38,39 @@ class bad_variant_access : public std::exception { throw bad_variant_access{}; } +} +OPENTELEMETRY_END_NAMESPACE -# if __EXCEPTIONS +# if defined(__EXCEPTIONS) || defined(__cpp_exceptions) # define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() # else # define THROW_BAD_VARIANT_ACCESS std::terminate() # endif +#endif -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE - -// 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; -}; +# include "absl/types/variant.h" # ifdef _MSC_VER # pragma warning(pop) # endif -}; // namespace variant_internal -}; // namespace absl + +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; + +} // namespace nostd +OPENTELEMETRY_END_NAMESPACE #endif From 645136f4979fe046b87804177a43a7637e2cdcee Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:28:06 -0700 Subject: [PATCH 06/60] Isolate to local abseil paths to avoid picking up external Abseil library --- .../opentelemetry/nostd/absl/base/config.h | 4 ++-- .../nostd/absl/base/internal/identity.h | 2 +- .../absl/base/internal/inline_variable.h | 2 +- .../nostd/absl/base/internal/invoke.h | 2 +- .../opentelemetry/nostd/absl/base/macros.h | 6 ++--- .../nostd/absl/base/optimization.h | 2 +- .../opentelemetry/nostd/absl/base/port.h | 6 ++--- .../nostd/absl/meta/type_traits.h | 2 +- .../nostd/absl/types/bad_variant_access.h | 2 +- .../nostd/absl/types/internal/variant.h | 18 +++++++------- .../opentelemetry/nostd/absl/types/variant.h | 12 +++++----- .../nostd/absl/utility/utility.h | 8 +++---- api/include/opentelemetry/nostd/variant.h | 24 ++++++++++++------- 13 files changed, 48 insertions(+), 42 deletions(-) diff --git a/api/include/opentelemetry/nostd/absl/base/config.h b/api/include/opentelemetry/nostd/absl/base/config.h index a4761d2141..1119d8f8db 100644 --- a/api/include/opentelemetry/nostd/absl/base/config.h +++ b/api/include/opentelemetry/nostd/absl/base/config.h @@ -63,8 +63,8 @@ #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 diff --git a/api/include/opentelemetry/nostd/absl/base/internal/identity.h b/api/include/opentelemetry/nostd/absl/base/internal/identity.h index a3154ed7bc..2147e4f37c 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/identity.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/identity.h @@ -16,7 +16,7 @@ #ifndef ABSL_BASE_INTERNAL_IDENTITY_H_ #define ABSL_BASE_INTERNAL_IDENTITY_H_ -#include "absl/base/config.h" +#include "../config.h" namespace absl { ABSL_NAMESPACE_BEGIN 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..42d156e2e1 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/inline_variable.h @@ -17,7 +17,7 @@ #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 diff --git a/api/include/opentelemetry/nostd/absl/base/internal/invoke.h b/api/include/opentelemetry/nostd/absl/base/internal/invoke.h index 84f04189b4..609d9fccc2 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/invoke.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/invoke.h @@ -39,7 +39,7 @@ #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. diff --git a/api/include/opentelemetry/nostd/absl/base/macros.h b/api/include/opentelemetry/nostd/absl/base/macros.h index 547f93bafb..83919739bc 100644 --- a/api/include/opentelemetry/nostd/absl/base/macros.h +++ b/api/include/opentelemetry/nostd/absl/base/macros.h @@ -31,9 +31,9 @@ #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() // diff --git a/api/include/opentelemetry/nostd/absl/base/optimization.h b/api/include/opentelemetry/nostd/absl/base/optimization.h index 646523b346..a9e2afcd52 100644 --- a/api/include/opentelemetry/nostd/absl/base/optimization.h +++ b/api/include/opentelemetry/nostd/absl/base/optimization.h @@ -22,7 +22,7 @@ #ifndef ABSL_BASE_OPTIMIZATION_H_ #define ABSL_BASE_OPTIMIZATION_H_ -#include "absl/base/config.h" +#include "config.h" // ABSL_BLOCK_TAIL_CALL_OPTIMIZATION // diff --git a/api/include/opentelemetry/nostd/absl/base/port.h b/api/include/opentelemetry/nostd/absl/base/port.h index 6c28068d4f..4350d0e470 100644 --- a/api/include/opentelemetry/nostd/absl/base/port.h +++ b/api/include/opentelemetry/nostd/absl/base/port.h @@ -19,8 +19,8 @@ #ifndef ABSL_BASE_PORT_H_ #define ABSL_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_ diff --git a/api/include/opentelemetry/nostd/absl/meta/type_traits.h b/api/include/opentelemetry/nostd/absl/meta/type_traits.h index ba87d2f0ed..16ad9d2c4e 100644 --- a/api/include/opentelemetry/nostd/absl/meta/type_traits.h +++ b/api/include/opentelemetry/nostd/absl/meta/type_traits.h @@ -39,7 +39,7 @@ #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. 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 a322f479b0..f79c5426e1 100644 --- a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h @@ -23,7 +23,7 @@ #include -#include "absl/base/config.h" +#include "../base/config.h" #ifdef ABSL_USES_STD_VARIANT diff --git a/api/include/opentelemetry/nostd/absl/types/internal/variant.h b/api/include/opentelemetry/nostd/absl/types/internal/variant.h index 71bd3adfc6..ac3f58db5d 100644 --- a/api/include/opentelemetry/nostd/absl/types/internal/variant.h +++ b/api/include/opentelemetry/nostd/absl/types/internal/variant.h @@ -27,15 +27,15 @@ #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) diff --git a/api/include/opentelemetry/nostd/absl/types/variant.h b/api/include/opentelemetry/nostd/absl/types/variant.h index ac93464bf8..6eda2d7ac4 100644 --- a/api/include/opentelemetry/nostd/absl/types/variant.h +++ b/api/include/opentelemetry/nostd/absl/types/variant.h @@ -42,8 +42,8 @@ #ifndef ABSL_TYPES_VARIANT_H_ #define ABSL_TYPES_VARIANT_H_ -#include "absl/base/config.h" -#include "absl/utility/utility.h" +#include "../base/config.h" +#include "../utility/utility.h" #ifdef ABSL_USES_STD_VARIANT @@ -73,10 +73,10 @@ ABSL_NAMESPACE_END #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 diff --git a/api/include/opentelemetry/nostd/absl/utility/utility.h b/api/include/opentelemetry/nostd/absl/utility/utility.h index e6647c7b2e..1bcfb0161c 100644 --- a/api/include/opentelemetry/nostd/absl/utility/utility.h +++ b/api/include/opentelemetry/nostd/absl/utility/utility.h @@ -45,10 +45,10 @@ #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 diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index 791c713948..78a05dea4c 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -18,11 +18,11 @@ # include "opentelemetry/std/variant.h" #else -#ifndef HAVE_ABSEIL +# 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. -# include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd @@ -38,15 +38,15 @@ class bad_variant_access : public std::exception { throw bad_variant_access{}; } -} +} // namespace nostd OPENTELEMETRY_END_NAMESPACE -# if defined(__EXCEPTIONS) || defined(__cpp_exceptions) -# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() -# else -# define THROW_BAD_VARIANT_ACCESS std::terminate() +# if defined(__EXCEPTIONS) || defined(__cpp_exceptions) +# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() +# else +# define THROW_BAD_VARIANT_ACCESS std::terminate() +# endif # endif -#endif # ifdef _MSC_VER // Abseil variant implementation contains some benign non-impacting warnings @@ -55,7 +55,13 @@ OPENTELEMETRY_END_NAMESPACE # 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 HAVE_ABSEIL +# include "absl/types/variant.h" +# else +# include "./absl/types/variant.h" +# endif + # ifdef _MSC_VER # pragma warning(pop) # endif From 8a0b7f4bd2c92e06d26aee9a8352397ff3ddfe71 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:28:44 -0700 Subject: [PATCH 07/60] No need to specify include path to nostd since now local Abseil would lookup itself using relative paths --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd912222c6..8d6b448ada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,9 +43,6 @@ if(WITH_ABSEIL) # target_link_libraries(main PRIVATE absl::any absl::base absl::bits # absl::city) -else() - # Use local snapshot of Abseil Variant implementation. - include_directories(api/include/opentelemetry/nostd) endif() if(WITH_STL) From bdb22c6ed18f5386a10e65a3b8910d15e88e5589 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:29:21 -0700 Subject: [PATCH 08/60] HAVE_ABSEIL_VARIANT option is gone because by default we know build API with Abseil Variant, but without entire Abseil Library --- sdk/src/common/core.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/common/core.cc b/sdk/src/common/core.cc index c5025c2c95..a3b57d670b 100644 --- a/sdk/src/common/core.cc +++ b/sdk/src/common/core.cc @@ -4,7 +4,7 @@ #include "opentelemetry/nostd/variant.h" // clang-format on -#if defined(HAVE_ABSEIL) && !defined(HAVE_ABSEIL_VARIANT) +#if defined(HAVE_ABSEIL) # if defined(__GNUC__) || defined(__GNUG__) # ifndef __cdecl From dfae1ba6823c47d9b34bce73a39b00f177fee683 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:30:44 -0700 Subject: [PATCH 09/60] Issue with GMOCK on Windows --- exporters/otlp/CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 044222e30e..1f493af2c5 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -37,12 +37,13 @@ if(BUILD_TESTING) TEST_LIST otlp_recordable_test) if(MSVC) 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) From 963ccf1b6a1f9a30155ac3736c4912afc94d8d83 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:31:35 -0700 Subject: [PATCH 10/60] Reinstate the magic of C-string (both std and abseil variant want this explicitly be defined, no implicit conversion to string_view) --- api/include/opentelemetry/common/attribute_value.h | 2 ++ .../exporters/elasticsearch/es_log_recordable.h | 3 +++ .../opentelemetry/exporters/etw/etw_properties.h | 4 ++++ exporters/jaeger/src/recordable.cc | 4 ++++ exporters/otlp/src/otlp_recordable.cc | 12 ++++++++---- exporters/zipkin/src/recordable.cc | 4 ++++ .../opentelemetry/sdk/common/attribute_utils.h | 2 ++ 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/api/include/opentelemetry/common/attribute_value.h b/api/include/opentelemetry/common/attribute_value.h index a83133f13e..08f4447db9 100644 --- a/api/include/opentelemetry/common/attribute_value.h +++ b/api/include/opentelemetry/common/attribute_value.h @@ -37,6 +37,7 @@ using AttributeValue = int64_t, uint32_t, double, + const char *, nostd::string_view, nostd::span, nostd::span, @@ -61,6 +62,7 @@ enum AttributeType kTypeInt64, kTypeUInt, kTypeDouble, + kTypeCString, kTypeString, kTypeSpanBool, kTypeSpanInt, 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 aa4836335e..994aa9eac8 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -67,6 +67,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/include/opentelemetry/exporters/etw/etw_properties.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h index 387fcd7a61..27b2520b0b 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h @@ -225,6 +225,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 3a493e4ef1..cdfd670e54 100644 --- a/exporters/jaeger/src/recordable.cc +++ b/exporters/jaeger/src/recordable.cc @@ -36,6 +36,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/src/otlp_recordable.cc b/exporters/otlp/src/otlp_recordable.cc index b3b26246d2..0f4aadfdf0 100644 --- a/exporters/otlp/src/otlp_recordable.cc +++ b/exporters/otlp/src/otlp_recordable.cc @@ -9,7 +9,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, @@ -60,6 +60,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(), @@ -131,9 +135,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 6999bb21e3..df6e3469aa 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -86,6 +86,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/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index 98521b707b..9242a5a9bc 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -42,6 +42,7 @@ using OwnedAttributeValue = nostd::variant, std::vector, @@ -66,6 +67,7 @@ enum OwnedAttributeType kTypeSpanInt64, kTypeSpanUInt, kTypeSpanDouble, + kTypeSpanCString, kTypeSpanString, kTypeUInt64, kTypeSpanUInt64, From fd5e04100911c557a91ad2a18846f75a8d7cf139 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 May 2021 23:46:28 -0700 Subject: [PATCH 11/60] Fix Zipkin exporter to support const char * AttributeValue --- exporters/zipkin/src/recordable.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index df6e3469aa..e3c1c8cfef 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -36,7 +36,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 From e235db28e9eda1eb444c9503c2ec720ba0d9cce4 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:22:38 -0700 Subject: [PATCH 12/60] Make sure that our local snapshot of Abseil Variant on API surface does not clash with gRPC Abseil --- .../nostd/absl/base/attributes.h | 370 ++++++++--------- .../opentelemetry/nostd/absl/base/config.h | 380 +++++++++--------- .../nostd/absl/base/internal/identity.h | 10 +- .../absl/base/internal/inline_variable.h | 30 +- .../nostd/absl/base/internal/invoke.h | 10 +- .../opentelemetry/nostd/absl/base/macros.h | 100 ++--- .../nostd/absl/base/optimization.h | 72 ++-- .../opentelemetry/nostd/absl/base/options.h | 40 +- .../nostd/absl/base/policy_checks.h | 6 +- .../opentelemetry/nostd/absl/base/port.h | 6 +- .../nostd/absl/meta/type_traits.h | 52 +-- .../nostd/absl/types/bad_variant_access.h | 20 +- .../nostd/absl/types/internal/variant.h | 34 +- .../opentelemetry/nostd/absl/types/variant.h | 24 +- .../nostd/absl/utility/utility.h | 30 +- 15 files changed, 592 insertions(+), 592 deletions(-) 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 1119d8f8db..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 @@ -67,14 +67,14 @@ #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 2147e4f37c..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 "../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 42d156e2e1..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,8 +12,8 @@ // 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 @@ -24,7 +24,7 @@ // 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 609d9fccc2..99c37ba24a 100644 --- a/api/include/opentelemetry/nostd/absl/base/internal/invoke.h +++ b/api/include/opentelemetry/nostd/absl/base/internal/invoke.h @@ -32,8 +32,8 @@ // 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 @@ -45,7 +45,7 @@ // 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 83919739bc..7b4f427d30 100644 --- a/api/include/opentelemetry/nostd/absl/base/macros.h +++ b/api/include/opentelemetry/nostd/absl/base/macros.h @@ -25,8 +25,8 @@ // 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 @@ -35,23 +35,23 @@ #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 a9e2afcd52..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 "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 4350d0e470..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 "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 16ad9d2c4e..fc69bb5d66 100644 --- a/api/include/opentelemetry/nostd/absl/meta/type_traits.h +++ b/api/include/opentelemetry/nostd/absl/meta/type_traits.h @@ -32,8 +32,8 @@ // 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 @@ -44,11 +44,11 @@ // 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 f79c5426e1..ea01eaf36a 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 "../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 @@ -86,9 +86,9 @@ namespace variant_internal { [[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 ac3f58db5d..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 @@ -37,15 +37,15 @@ #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,10 +63,10 @@ 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 @@ -79,7 +79,7 @@ ABSL_NAMESPACE_END #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 1bcfb0161c..8c15e2b8c1 100644 --- a/api/include/opentelemetry/nostd/absl/utility/utility.h +++ b/api/include/opentelemetry/nostd/absl/utility/utility.h @@ -37,8 +37,8 @@ // 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 @@ -51,7 +51,7 @@ #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_ From 41293fd8a9a635e2391fa45f0e16d002239d8314 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:23:12 -0700 Subject: [PATCH 13/60] attribute_utils.h had wrong order for the enum and missing initializer from std::string --- sdk/include/opentelemetry/sdk/common/attribute_utils.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index 9242a5a9bc..2395ce3a09 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -58,16 +58,16 @@ enum OwnedAttributeType { kTypeBool, kTypeInt, - kTypeInt64, kTypeUInt, + kTypeInt64, kTypeDouble, + kTypeCString, kTypeString, kTypeSpanBool, kTypeSpanInt, - kTypeSpanInt64, kTypeSpanUInt, + kTypeSpanInt64, kTypeSpanDouble, - kTypeSpanCString, kTypeSpanString, kTypeUInt64, kTypeSpanUInt64, @@ -89,6 +89,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); } From 4accbbeb6859027a681fc8dbd95d8631288691f5 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:23:29 -0700 Subject: [PATCH 14/60] Adjust Resource to store const char * as std::string --- sdk/src/resource/resource.cc | 13 ++++++++++++- sdk/test/resource/resource_test.cc | 15 +++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/sdk/src/resource/resource.cc b/sdk/src/resource/resource.cc index 40354b5b5d..a1940899e9 100644 --- a/sdk/src/resource/resource.cc +++ b/sdk/src/resource/resource.cc @@ -15,7 +15,18 @@ const std::string kTelemetrySdkVersion = "telemetry.sdk.version"; const std::string kServiceName = "service.name"; const std::string kProcessExecutableName = "process.executable.name"; -Resource::Resource(const ResourceAttributes &attributes) noexcept : attributes_(attributes) {} +Resource::Resource(const ResourceAttributes &attributes) noexcept : attributes_(attributes) +{ + for (auto &kv : attributes_) + { + // replace all const char * objects by owning std::string objects + if (kv.second.index() == opentelemetry::sdk::common::kTypeCString) + { + std::string vStr = nostd::get(kv.second); + kv.second = vStr; + } + } +} Resource Resource::Merge(const Resource &other) noexcept { diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index 1f58ee2f9c..bba66de921 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -50,8 +50,9 @@ TEST(ResourceTest, create_without_servicename) EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), opentelemetry::nostd::get(e.second)); else - EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second)); + EXPECT_STREQ( + opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second).c_str()); } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name } @@ -82,8 +83,9 @@ TEST(ResourceTest, create_with_servicename) EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), opentelemetry::nostd::get(e.second)); else - EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second)); + EXPECT_STREQ( + opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second).c_str()); } } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name @@ -104,8 +106,9 @@ TEST(ResourceTest, create_with_emptyatrributes) { EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end()); if (expected_attributes.find(e.first) != expected_attributes.end()) - EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second)); + EXPECT_STREQ( + opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second).c_str()); } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name } From 63f0b639fd4186dabd3bb27ad6e9ececb17762b9 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:33:14 -0700 Subject: [PATCH 15/60] Fix build warning that turns an error in Bazel build --- .../opentelemetry/nostd/absl/types/bad_variant_access.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 ea01eaf36a..201a06d901 100644 --- a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h @@ -76,10 +76,10 @@ namespace variant_internal { { THROW_BAD_VARIANT_ACCESS; }; -[[noreturn]] static void Rethrow() -{ - THROW_BAD_VARIANT_ACCESS; // Unused! -}; +//[[noreturn]] static void Rethrow() +//{ +// THROW_BAD_VARIANT_ACCESS; // Unused! +//}; #else // Original implementation requires linking Abseil library! [[noreturn]] void ThrowBadVariantAccess(); From 8047102f0ca2bd1e1f09166161ce27b306918c0f Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:39:51 -0700 Subject: [PATCH 16/60] Fix for Bazel error with no-exceptions build --- api/include/opentelemetry/nostd/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index 78a05dea4c..771b7590b5 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -41,7 +41,7 @@ class bad_variant_access : public std::exception } // namespace nostd OPENTELEMETRY_END_NAMESPACE -# if defined(__EXCEPTIONS) || defined(__cpp_exceptions) +# if defined(__EXCEPTIONS) # define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() # else # define THROW_BAD_VARIANT_ACCESS std::terminate() From 206c63c61a46f296dd5c306a0dce1af49e44164d Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:50:11 -0700 Subject: [PATCH 17/60] Fix Bazel tsan build --- api/include/opentelemetry/nostd/variant.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index 771b7590b5..f2040e66fb 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -14,6 +14,8 @@ #pragma once +#include "opentelemetry/version.h" + #ifdef HAVE_CPP_STDLIB # include "opentelemetry/std/variant.h" #else From 4f0910ea66cbe63c7d809b108dca60666fbf0152 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 03:56:30 -0700 Subject: [PATCH 18/60] Can't declare a class using exceptions in a build with no-exceptions --- api/include/opentelemetry/nostd/variant.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index f2040e66fb..f8eb220c49 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -24,8 +24,9 @@ // 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. -# include +# if defined(__EXCEPTIONS) +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { @@ -42,8 +43,6 @@ class bad_variant_access : public std::exception } } // namespace nostd OPENTELEMETRY_END_NAMESPACE - -# if defined(__EXCEPTIONS) # define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() # else # define THROW_BAD_VARIANT_ACCESS std::terminate() From e9e2e857d33c3fece5722a229a8271900f7cfacf Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 04:21:00 -0700 Subject: [PATCH 19/60] Add full set of features to nostd::variant --- api/include/opentelemetry/nostd/variant.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index f8eb220c49..03ac89bf56 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -71,12 +71,13 @@ 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 From a8dfb7d12a3b2033897f9247b2f6752865dc2dc9 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 04:21:41 -0700 Subject: [PATCH 20/60] Variant test SHOULD NOT make assumptions about how compilers work, when both `std::` and `absl::` work differently! --- api/test/nostd/variant_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/test/nostd/variant_test.cc b/api/test/nostd/variant_test.cc index 9362b7794b..9c1246b70f 100644 --- a/api/test/nostd/variant_test.cc +++ b/api/test/nostd/variant_test.cc @@ -17,6 +17,8 @@ class DestroyCounter int *count_; }; +#if 0 +/* I am not sure what this test is validating */ TEST(TypePackElementTest, IndexedType) { using opentelemetry::nostd::detail::type_pack_element_t; @@ -24,6 +26,7 @@ TEST(TypePackElementTest, IndexedType) EXPECT_TRUE((std::is_same, double>::value)); EXPECT_TRUE((std::is_same, char>::value)); } +#endif TEST(VariantSizeTest, GetVariantSize) { @@ -117,6 +120,6 @@ TEST(VariantTest, Conversion) TEST(VariantTest, Construction) { - nostd::variant v{"abc"}; + nostd::variant v{"abc"}; EXPECT_EQ(v.index(), 1); } From 9785f16e811914d170f20f951424e1fb0c4411a3 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 20 May 2021 04:22:10 -0700 Subject: [PATCH 21/60] Re-enable Variant Test that was disabled in CMake build for some reason --- api/test/nostd/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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} From 2abdc1a92271b309dbec0fc4e5819d51511cdbf9 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 17:38:31 -0700 Subject: [PATCH 22/60] Can't use GSL if it's not found --- api/include/opentelemetry/std/span.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/include/opentelemetry/std/span.h b/api/include/opentelemetry/std/span.h index 9a95b449f5..df713ee222 100644 --- a/api/include/opentelemetry/std/span.h +++ b/api/include/opentelemetry/std/span.h @@ -37,6 +37,9 @@ # define HAVE_SPAN # endif # endif +# if !__has_include() +# undef HAVE_GSL +# endif #endif #if !defined(HAVE_SPAN) From 1ea289f47fc5b72eb7130ce6ccff50eb286d900a Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 17:39:18 -0700 Subject: [PATCH 23/60] Add those definitions back globally since we are still building projects that do not link to opentelemetry_api target --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4febb958c7..2d056a3e03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,8 @@ if(WITH_ABSEIL) endif() if(WITH_STL) + 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 From 9d8754ddf6b6549ad0d8b9a921b8e6f03f485511 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 17:39:40 -0700 Subject: [PATCH 24/60] Clan on Mac requires this to be inline --- .../opentelemetry/nostd/absl/types/bad_variant_access.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 201a06d901..9783504d2d 100644 --- a/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/absl/types/bad_variant_access.h @@ -72,11 +72,11 @@ namespace variant_internal { #ifdef THROW_BAD_VARIANT_ACCESS // Header-only implementation with static throw implementation. // No need to link against Abseil library. -[[noreturn]] static void ThrowBadVariantAccess() +[[noreturn]] static inline void ThrowBadVariantAccess() { THROW_BAD_VARIANT_ACCESS; }; -//[[noreturn]] static void Rethrow() +//[[noreturn]] static inline void Rethrow() //{ // THROW_BAD_VARIANT_ACCESS; // Unused! //}; From a6c41bd2ff74adea15e002a1bf20fc212041a1e0 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 17:40:06 -0700 Subject: [PATCH 25/60] Add missing classes to STDLIB build --- api/include/opentelemetry/std/variant.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index a6f5cbac43..c68fa8f826 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -25,6 +25,9 @@ OPENTELEMETRY_BEGIN_NAMESPACE // Standard Type aliases in nostd namespace namespace nostd { +using std::variant_alternative_t; +using std::get_if; +using std::monostate; // nostd::variant<...> template From 12231f67443e174e5762d61aa479d45023f2ad4a Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 18:53:02 -0700 Subject: [PATCH 26/60] Code formatting --- api/include/opentelemetry/std/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index c68fa8f826..d9f999e6a5 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -25,9 +25,9 @@ OPENTELEMETRY_BEGIN_NAMESPACE // Standard Type aliases in nostd namespace namespace nostd { -using std::variant_alternative_t; using std::get_if; using std::monostate; +using std::variant_alternative_t; // nostd::variant<...> template From 8037c8a007b76a7a552f1df3dfb2326653bdfe17 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 18:53:43 -0700 Subject: [PATCH 27/60] Add proper dependency on json.hpp --- ext/test/w3c_tracecontext_test/CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/test/w3c_tracecontext_test/CMakeLists.txt b/ext/test/w3c_tracecontext_test/CMakeLists.txt index d8600d3bac..d415ebf9d4 100644 --- a/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_test/CMakeLists.txt @@ -1,16 +1,17 @@ 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) + if(NOT nlohmann_json_FOUND) + add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/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::nlohmann_json) endif() From 8e2a4819d8f4c0de920153685b7d8c79c34c01ee Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 21:36:28 -0700 Subject: [PATCH 28/60] Fix an issue with not finding json.hpp --- ext/test/w3c_tracecontext_test/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/test/w3c_tracecontext_test/CMakeLists.txt b/ext/test/w3c_tracecontext_test/CMakeLists.txt index d415ebf9d4..78850fdd93 100644 --- a/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_test/CMakeLists.txt @@ -6,12 +6,17 @@ if(NOT CURL_FOUND) else() find_package(nlohmann_json) if(NOT nlohmann_json_FOUND) - add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/nlohmann-json) + # 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 PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace http_client_curl opentelemetry_exporter_ostream_span ${CURL_LIBRARIES} - nlohmann_json::nlohmann_json) + ${NLOHMANN_JSON_LIB}) endif() From c9b56d55d57aa905001ea86c3ca4630893415733 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 22:02:41 -0700 Subject: [PATCH 29/60] Add overload with attributes as initializer list + options, no links --- api/include/opentelemetry/trace/tracer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index 168cf5e583..6d358239c6 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -82,6 +82,20 @@ class Tracer return this->StartSpan(name, attributes, {}, options); } + template ::value> * = nullptr> + nostd::shared_ptr StartSpan( + nostd::string_view name, + std::initializer_list> attributes, + const StartSpanOptions &options = {}) noexcept + { + return this->StartSpan(name, + nostd::span>{ + attributes.begin(), attributes.end()}, + {}, options); + } + + template ::value> * = nullptr> nostd::shared_ptr StartSpan( From 2dc6ccea0fd93e546f64c463723962f4514c9692 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 22:03:15 -0700 Subject: [PATCH 30/60] Make finding json.hpp quiet --- ext/test/w3c_tracecontext_test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/test/w3c_tracecontext_test/CMakeLists.txt b/ext/test/w3c_tracecontext_test/CMakeLists.txt index 78850fdd93..61bfa8f467 100644 --- a/ext/test/w3c_tracecontext_test/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_test/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(CURL) if(NOT CURL_FOUND) message(WARNING "Skipping example_w3c_tracecontext_test: CURL not found") else() - find_package(nlohmann_json) + find_package(nlohmann_json QUIET) if(NOT nlohmann_json_FOUND) # Add library from git submodule to include path include_directories( From 1d487fd4817cf0f6009f53ef5827bd35c4ba85a4 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 21 May 2021 22:06:43 -0700 Subject: [PATCH 31/60] Minor formatting --- api/include/opentelemetry/trace/tracer.h | 1 - 1 file changed, 1 deletion(-) diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index 6d358239c6..78e99d0605 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -95,7 +95,6 @@ class Tracer {}, options); } - template ::value> * = nullptr> nostd::shared_ptr StartSpan( From ec6b88df105ce156f4b4f5aeaba9326b23dcb858 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Mon, 24 May 2021 14:12:24 -0700 Subject: [PATCH 32/60] Update server.cc Resolve an issue with implicit variant conversion --- examples/http/server.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/http/server.cc b/examples/http/server.cc index a9f1a81e08..711733d763 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -7,7 +7,7 @@ namespace { uint16_t server_port = 8800; -constexpr char server_name[] = "localhost"; +constexpr const char* server_name = "localhost"; class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback { @@ -30,13 +30,14 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback // 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); + { + {"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); From c0677837115c0dc7010421bffdc2b47950cd0e5c Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Mon, 24 May 2021 14:14:54 -0700 Subject: [PATCH 33/60] Code formatting --- examples/http/server.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/http/server.cc b/examples/http/server.cc index 711733d763..1472dacf38 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -6,8 +6,8 @@ namespace { -uint16_t server_port = 8800; -constexpr const char* server_name = "localhost"; +uint16_t server_port = 8800; +constexpr const char *server_name = "localhost"; class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback { @@ -28,16 +28,17 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback options.parent = GetSpanFromContext(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", static_cast(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); From c478c17864ff4b114a9aeefc8ccbbbb4c6bcd6ab Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 28 May 2021 12:28:26 -0700 Subject: [PATCH 34/60] Code formatting change --- CMakeLists.txt | 8 ++++---- exporters/otlp/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a846e8c9e0..0da0cd2d11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,10 @@ 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. + # 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 diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 1f5783b092..6c5bed5607 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -36,10 +36,10 @@ 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. + # 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) else() if(GMOCK_LIB) From ab2c5a9edd89925808a4b39f3689f596507cd43a Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 28 May 2021 14:27:17 -0700 Subject: [PATCH 35/60] Update .codecov.yaml Make our codecov more forgiving --- .github/.codecov.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/.codecov.yaml b/.github/.codecov.yaml index c97b4e92dd..e2c304a9b4 100644 --- a/.github/.codecov.yaml +++ b/.github/.codecov.yaml @@ -1,13 +1,22 @@ codecov: - require_ci_to_pass: yes + require_ci_to_pass: false max_report_age: off coverage: precision: 2 - round: down + round: up range: "80...100" status: - patch: off + project: + default: + informational: true + target: auto + threshold: 10% + patch: + default: + informational: true + target: auto + threshold: 10% parsers: gcov: @@ -20,7 +29,7 @@ parsers: comment: layout: "reach,diff,flags,tree" behavior: default - require_changes: no + require_changes: false # Relative file path fixing. # CI file paths must match Git file paths. From ebdf93468ca8a25eb51218bba050b32b30865ed2 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 2 Jun 2021 13:04:19 -0700 Subject: [PATCH 36/60] Keep logs preview building --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2ace0e9e1..8078eaca86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ if(WITH_METRICS_PREVIEW) add_definitions(-DENABLE_METRICS_PREVIEW) endif() -option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF) +option(WITH_LOGS_PREVIEW "Whether to build logs preview" ON) if(WITH_LOGS_PREVIEW) add_definitions(-DENABLE_LOGS_PREVIEW) From 692259c97218cdf960d7f7c2451a6f44c700647d Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 2 Jun 2021 13:04:53 -0700 Subject: [PATCH 37/60] Allow Resource Attributes initialized from common::AttributeValue --- .../sdk/common/attribute_utils.h | 24 ++++++++++++------- .../opentelemetry/sdk/resource/resource.h | 6 +++-- sdk/src/resource/resource.cc | 13 +--------- sdk/test/resource/resource_test.cc | 21 ++++++---------- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index d9f85632da..d640d96e60 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -29,7 +29,6 @@ using OwnedAttributeValue = nostd::variant, std::vector, @@ -48,7 +47,6 @@ enum OwnedAttributeType kTypeUInt, kTypeInt64, kTypeDouble, - kTypeCString, kTypeString, kTypeSpanBool, kTypeSpanInt, @@ -101,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 { @@ -117,19 +115,29 @@ 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/resource/resource.cc b/sdk/src/resource/resource.cc index 5e0321e743..e7f055b101 100644 --- a/sdk/src/resource/resource.cc +++ b/sdk/src/resource/resource.cc @@ -18,18 +18,7 @@ const std::string kTelemetrySdkVersion = "telemetry.sdk.version"; const std::string kServiceName = "service.name"; const std::string kProcessExecutableName = "process.executable.name"; -Resource::Resource(const ResourceAttributes &attributes) noexcept : attributes_(attributes) -{ - for (auto &kv : attributes_) - { - // replace all const char * objects by owning std::string objects - if (kv.second.index() == opentelemetry::sdk::common::kTypeCString) - { - std::string vStr = nostd::get(kv.second); - kv.second = vStr; - } - } -} +Resource::Resource(const ResourceAttributes &attributes) noexcept : attributes_(attributes) {} Resource Resource::Merge(const Resource &other) noexcept { diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index 9b380ae39d..f938c0abdf 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -28,11 +28,7 @@ class TestResource : public opentelemetry::sdk::resource::Resource TEST(ResourceTest, create_without_servicename) { - // Note that we pass resource attributes as `const char *`. But SDK - // sees all resource attribute values copied into owning object that - // contains only `std::string` values. That is why the test below - // verifies that values that we retrieve back are all `std::string` - // and not `const char *`. + opentelemetry::sdk::resource::ResourceAttributes expected_attributes = { {"service", "backend"}, {"version", (uint32_t)1}, @@ -57,9 +53,8 @@ TEST(ResourceTest, create_without_servicename) EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), opentelemetry::nostd::get(e.second)); else - EXPECT_STREQ( - opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second).c_str()); + EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second)); } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name } @@ -90,9 +85,8 @@ TEST(ResourceTest, create_with_servicename) EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), opentelemetry::nostd::get(e.second)); else - EXPECT_STREQ( - opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second).c_str()); + EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second)); } } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name @@ -113,9 +107,8 @@ TEST(ResourceTest, create_with_emptyatrributes) { EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end()); if (expected_attributes.find(e.first) != expected_attributes.end()) - EXPECT_STREQ( - opentelemetry::nostd::get(expected_attributes.find(e.first)->second), - opentelemetry::nostd::get(e.second).c_str()); + EXPECT_EQ(opentelemetry::nostd::get(expected_attributes.find(e.first)->second), + opentelemetry::nostd::get(e.second)); } EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name } From 553628b81014a25d6d7b8b8c51ba6d635601274e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 2 Jun 2021 13:10:46 -0700 Subject: [PATCH 38/60] Apply code formatting --- sdk/include/opentelemetry/sdk/common/attribute_utils.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/attribute_utils.h b/sdk/include/opentelemetry/sdk/common/attribute_utils.h index d640d96e60..e8935b8f62 100644 --- a/sdk/include/opentelemetry/sdk/common/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/common/attribute_utils.h @@ -103,7 +103,7 @@ class AttributeMap : public std::unordered_map { public: // Contruct empty attribute map - AttributeMap() : std::unordered_map() {}; + AttributeMap() : std::unordered_map(){}; // Contruct attribute map and populate with attributes AttributeMap(const opentelemetry::common::KeyValueIterable &attributes) : AttributeMap() @@ -116,9 +116,12 @@ class AttributeMap : public std::unordered_map } // Construct map from initializer list by applying `SetAttribute` transform for every attribute - AttributeMap(std::initializer_list > attributes) : AttributeMap() + AttributeMap( + std::initializer_list> + attributes) + : AttributeMap() { - for (auto& kv : attributes) + for (auto &kv : attributes) { SetAttribute(kv.first, kv.second); } From 55b1f0092a5e415950aa845a9162c47c57b7d3c3 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 2 Jun 2021 17:41:00 -0700 Subject: [PATCH 39/60] Visual Studio 2019 Update 16.10 fixes --- tools/ports/benchmark/portfile.cmake | 2 +- .../fix-default-proto-file-path.patch | 20 +++ tools/ports/protobuf/fix-static-build.patch | 13 ++ tools/ports/protobuf/port_def.patch | 14 ++ tools/ports/protobuf/portfile.cmake | 127 ++++++++++++++++++ .../protobuf-targets-vcpkg-protoc.cmake | 8 ++ .../ports/protobuf/vcpkg-cmake-wrapper.cmake | 16 +++ tools/ports/protobuf/vcpkg.json | 21 +++ tools/setup-buildtools.cmd | 4 +- tools/vcpkg | 2 +- 10 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 tools/ports/protobuf/fix-default-proto-file-path.patch create mode 100644 tools/ports/protobuf/fix-static-build.patch create mode 100644 tools/ports/protobuf/port_def.patch create mode 100644 tools/ports/protobuf/portfile.cmake create mode 100644 tools/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake create mode 100644 tools/ports/protobuf/vcpkg-cmake-wrapper.cmake create mode 100644 tools/ports/protobuf/vcpkg.json diff --git a/tools/ports/benchmark/portfile.cmake b/tools/ports/benchmark/portfile.cmake index 5a2779c493..dba57ab53d 100644 --- a/tools/ports/benchmark/portfile.cmake +++ b/tools/ports/benchmark/portfile.cmake @@ -22,7 +22,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO google/benchmark REF c05843a9f622db08ad59804c190f98879b76beba # v1.5.3 - SHA512 1 + SHA512 4e4b793ff6d7a4b12ce4b98cf5faa6d5d27a0a1d7be630c0c4a2a4bca5168fd94585e5e3e1a9c43603e42145ddcded8e5a3688528bf073a068f53054b86ce774 HEAD_REF master PATCHES "version.patch" ) diff --git a/tools/ports/protobuf/fix-default-proto-file-path.patch b/tools/ports/protobuf/fix-default-proto-file-path.patch new file mode 100644 index 0000000000..a5af918b32 --- /dev/null +++ b/tools/ports/protobuf/fix-default-proto-file-path.patch @@ -0,0 +1,20 @@ +diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc +index f192ae6..22900ed 100644 +--- a/src/google/protobuf/compiler/command_line_interface.cc ++++ b/src/google/protobuf/compiler/command_line_interface.cc +@@ -260,11 +260,15 @@ void AddDefaultProtoPaths( + return; + } + // Check if the upper level directory has an "include" subdirectory. ++ // change "'$/bin' is next to 'include'" assumption to "'$/bin/tools' is next to 'include'" ++ for (int i = 0; i < 2; i++) ++ { + pos = path.find_last_of("/\\"); + if (pos == std::string::npos || pos == 0) { + return; + } + path = path.substr(0, pos); ++ } + if (IsInstalledProtoPath(path + "/include")) { + paths->push_back( + std::pair("", path + "/include")); diff --git a/tools/ports/protobuf/fix-static-build.patch b/tools/ports/protobuf/fix-static-build.patch new file mode 100644 index 0000000000..0ba4982fe6 --- /dev/null +++ b/tools/ports/protobuf/fix-static-build.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/install.cmake b/cmake/install.cmake +index 4091bc8..9850018 100644 +--- a/cmake/install.cmake ++++ b/cmake/install.cmake +@@ -31,7 +31,7 @@ endforeach() + if (protobuf_BUILD_PROTOC_BINARIES) + install(TARGETS protoc EXPORT protobuf-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) +- if (UNIX AND NOT APPLE) ++ if (UNIX AND NOT APPLE AND NOT protobuf_MSVC_STATIC_RUNTIME) + set_property(TARGET protoc + PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + elseif (APPLE) diff --git a/tools/ports/protobuf/port_def.patch b/tools/ports/protobuf/port_def.patch new file mode 100644 index 0000000000..31d71531d0 --- /dev/null +++ b/tools/ports/protobuf/port_def.patch @@ -0,0 +1,14 @@ +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc +index f7b64a080..3493d9082 100644 +--- a/src/google/protobuf/port_def.inc ++++ b/src/google/protobuf/port_def.inc +@@ -564,7 +564,8 @@ + + // Our use of constinit does not yet work with GCC: + // https://github.com/protocolbuffers/protobuf/issues/8310 +-#if defined(__cpp_constinit) && !defined(__GNUC__) ++// Does not work yet with Visual Studio 2019 Update 16.10 ++#if defined(__cpp_constinit) && !defined(__GNUC__) && !defined(_MSC_VER) + #define PROTOBUF_CONSTINIT constinit + #elif defined(__has_cpp_attribute) + #if __has_cpp_attribute(clang::require_constant_initialization) diff --git a/tools/ports/protobuf/portfile.cmake b/tools/ports/protobuf/portfile.cmake new file mode 100644 index 0000000000..8f7c3b119d --- /dev/null +++ b/tools/ports/protobuf/portfile.cmake @@ -0,0 +1,127 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO protocolbuffers/protobuf + REF 436bd7880e458532901c58f4d9d1ea23fa7edd52 #v3.15.8 + SHA512 88bb9a965bccfe11a07aee2c0c16eb9cc1845ea2d7500ef6def3e1c0a8155ac4eadd0ceef4b12552960dffe95a0fc82549d1abba71ca073ab86ec5de57d9cafb + HEAD_REF master + PATCHES + fix-static-build.patch + fix-default-proto-file-path.patch + port_def.patch +) + +string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" protobuf_BUILD_SHARED_LIBS) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" protobuf_MSVC_STATIC_RUNTIME) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + zlib protobuf_WITH_ZLIB +) + +if(VCPKG_TARGET_IS_UWP) + set(protobuf_BUILD_LIBPROTOC OFF) +else() + set(protobuf_BUILD_LIBPROTOC ON) +endif() + +if (VCPKG_DOWNLOAD_MODE) + # download PKGCONFIG in download mode which is used in `vcpkg_fixup_pkgconfig()` at the end of this script. + # download it here because `vcpkg_configure_cmake()` halts execution in download mode when running configure process. + vcpkg_find_acquire_program(PKGCONFIG) +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/cmake + PREFER_NINJA + OPTIONS + -Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS} + -Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME} + -Dprotobuf_BUILD_TESTS=OFF + -DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf + -Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES} + -Dprotobuf_BUILD_LIBPROTOC=${protobuf_BUILD_LIBPROTOC} + ${FEATURE_OPTIONS} +) + +vcpkg_install_cmake() + +# It appears that at this point the build hasn't actually finished. There is probably +# a process spawned by the build, therefore we need to wait a bit. + +function(protobuf_try_remove_recurse_wait PATH_TO_REMOVE) + file(REMOVE_RECURSE ${PATH_TO_REMOVE}) + if (EXISTS "${PATH_TO_REMOVE}") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5) + file(REMOVE_RECURSE ${PATH_TO_REMOVE}) + endif() +endfunction() + +protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/include) + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-release.cmake + "\${_IMPORT_PREFIX}/bin/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}" + "\${_IMPORT_PREFIX}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}" + ) +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(READ ${CURRENT_PACKAGES_DIR}/debug/share/protobuf/protobuf-targets-debug.cmake DEBUG_MODULE) + string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" DEBUG_MODULE "${DEBUG_MODULE}") + string(REPLACE "\${_IMPORT_PREFIX}/debug/bin/protoc${EXECUTABLE_SUFFIX}" "\${_IMPORT_PREFIX}/tools/protobuf/protoc${EXECUTABLE_SUFFIX}" DEBUG_MODULE "${DEBUG_MODULE}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/protobuf/protobuf-targets-debug.cmake "${DEBUG_MODULE}") +endif() + +protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share) + +if(protobuf_BUILD_PROTOC_BINARIES) + if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME) + vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN) + else() + vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.15.8.0 AUTO_CLEAN) + endif() +else() + file(COPY ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) +endif() + +vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-config.cmake + "if(protobuf_MODULE_COMPATIBLE)" + "if(ON)" +) +if(NOT protobuf_BUILD_LIBPROTOC) + vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-module.cmake + "_protobuf_find_libraries(Protobuf_PROTOC protoc)" + "" + ) +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/bin) + protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/bin) +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/google/protobuf/stubs/platform_macros.h + "\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_" + "\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_" + ) +endif() + +vcpkg_copy_pdbs() +set(packages protobuf protobuf-lite) +foreach(_package IN LISTS packages) + set(_file ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${_package}.pc) + if(EXISTS "${_file}") + vcpkg_replace_string(${_file} "-l${_package}" "-l${_package}d") + endif() +endforeach() + +vcpkg_fixup_pkgconfig() + +if(NOT protobuf_BUILD_PROTOC_BINARIES) + configure_file(${CMAKE_CURRENT_LIST_DIR}/protobuf-targets-vcpkg-protoc.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-targets-vcpkg-protoc.cmake COPYONLY) +endif() + +configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY) +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/tools/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake b/tools/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake new file mode 100644 index 0000000000..245adf5608 --- /dev/null +++ b/tools/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake @@ -0,0 +1,8 @@ +# Create imported target protobuf::protoc +add_executable(protobuf::protoc IMPORTED) + +# Import target "protobuf::protoc" for configuration "Release" +set_property(TARGET protobuf::protoc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LOCATION_RELEASE "${Protobuf_PROTOC_EXECUTABLE}" +) diff --git a/tools/ports/protobuf/vcpkg-cmake-wrapper.cmake b/tools/ports/protobuf/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000000..542a16c2b8 --- /dev/null +++ b/tools/ports/protobuf/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,16 @@ +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.3) + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + if(NOT "CONFIG" IN_LIST ARGS AND NOT "NO_MODULE" IN_LIST ARGS) + if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + set(Protobuf_USE_STATIC_LIBS ON) + else() + set(Protobuf_USE_STATIC_LIBS OFF) + endif() + endif() + cmake_policy(POP) +endif() + +find_program(Protobuf_PROTOC_EXECUTABLE NAMES protoc PATHS "${CMAKE_CURRENT_LIST_DIR}/../../../@HOST_TRIPLET@/tools/protobuf" NO_DEFAULT_PATH) + +_find_package(${ARGS}) diff --git a/tools/ports/protobuf/vcpkg.json b/tools/ports/protobuf/vcpkg.json new file mode 100644 index 0000000000..5f1926a088 --- /dev/null +++ b/tools/ports/protobuf/vcpkg.json @@ -0,0 +1,21 @@ +{ + "name": "protobuf", + "version-semver": "3.15.8", + "port-version": 2, + "description": "Protocol Buffers - Google's data interchange format", + "homepage": "https://github.com/protocolbuffers/protobuf", + "dependencies": [ + { + "name": "protobuf", + "host": true + } + ], + "features": { + "zlib": { + "description": "ZLib based features like Gzip streams", + "dependencies": [ + "zlib" + ] + } + } +} diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index 7819aaf792..fd31eb21fd 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -56,11 +56,11 @@ if %ERRORLEVEL% == 1 ( REM Install dependencies vcpkg install gtest:%ARCH%-windows -vcpkg install --head --overlay-ports=%~dp0ports benchmark:%ARCH%-windows +vcpkg install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows +vcpkg install --overlay-ports=%~dp0ports protobuf:%ARCH%-windows vcpkg install ms-gsl:%ARCH%-windows vcpkg install nlohmann-json:%ARCH%-windows vcpkg install abseil:%ARCH%-windows -vcpkg install protobuf:%ARCH%-windows vcpkg install gRPC:%ARCH%-windows vcpkg install prometheus-cpp:%ARCH%-windows vcpkg install curl:%ARCH%-windows diff --git a/tools/vcpkg b/tools/vcpkg index e9f8cc67a5..5568f110b5 160000 --- a/tools/vcpkg +++ b/tools/vcpkg @@ -1 +1 @@ -Subproject commit e9f8cc67a5e5541973e53ac03f88adb45cc1b21b +Subproject commit 5568f110b509a9fd90711978a7cb76bae75bb092 From 3a35d0501456dd517c7411fb8ae423470369e77e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 2 Jun 2021 18:24:49 -0700 Subject: [PATCH 40/60] CMake version check was not properly populating CMAKE_CXX_STANDARD --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c04d83175..3955494fdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ endif() if(WITH_STL) # Require at least C++17. C++20 is needed to avoid gsl::span - if(CMAKE_MINOR_VERSION VERSION_GREATER "3.18") + if(CMAKE_VERSION VERSION_GREATER "3.18.0") # Ask for 20, may get anything below set(CMAKE_CXX_STANDARD 20) else() From e2c98583f69551c409bc50920a8c926a80fbfde0 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 4 Jun 2021 14:29:27 -0700 Subject: [PATCH 41/60] Fix for C++20 flag detection --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78fe7ddf57..74a6267139 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(WITH_STL) 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") + if(CMAKE_VERSION VERSION_GREATER 3.18.0) # Ask for 20, may get anything below set(CMAKE_CXX_STANDARD 20) else() From 3452f4855fbdf75a259e3af22d88009eb897a25e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Fri, 4 Jun 2021 14:34:57 -0700 Subject: [PATCH 42/60] Add support for clang compilers --- tools/build.cmd | 70 +++++++++++++++++++++++++++--------------------- tools/vcvars.cmd | 18 +++++++++++-- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/tools/build.cmd b/tools/build.cmd index 14da784661..2f05f877c3 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -1,6 +1,6 @@ @echo off REM ########################################################################################## -REM # Build SDK with Visual Studio + CMake + MSBUild or Ninja. # +REM # Build SDK with (msvc or clang) + CMake + (MSBuild or Ninja). # REM # # REM # CMake arguments may be passed as parameters to this script. # REM # If Visual Studio is not installed, then this script falls back to LLVM-CLang, # @@ -10,7 +10,7 @@ REM ############################################################################ REM # # REM # Options passed as environment variables: # REM # # -REM # VS_TOOLS_VERSION - specify visual studio version. See `vcvars.cmd` for details. # +REM # BUILDTOOLS_VERSION - specify build tools version. See `vcvars.cmd` for details. # REM # CMAKE_GEN - specify CMake generator. # REM # VCPKG_ROOT - path to vcpkg root # REM # ARCH - architecture to build for (default: x64) # @@ -20,36 +20,43 @@ set "PATH=%PATH%;%ProgramFiles%\CMake\bin" pushd %~dp0 setlocal enableextensions setlocal enabledelayedexpansion -if not defined VS_TOOLS_VERSION ( - set VS_TOOLS_VERSION=vs2019 +if not defined BUILDTOOLS_VERSION ( + set BUILDTOOLS_VERSION=vs2019 ) REM ########################################################################################## REM Set up CMake generator. Use Ninja if available. REM ########################################################################################## -if not defined CMAKE_GEN ( - set CMAKE_GEN=Visual Studio 16 2019 - for /f "tokens=*" %%F in ('where ninja') do ( - set NINJA=%%F - ) - if defined VCPKG_ROOT ( - if not defined NINJA ( - for /f "tokens=*" %%F in ('where /R %VCPKG_ROOT%\vcpkg\downloads\tools ninja') do ( - set NINJA=%%F - ) - popd - ) - ) +for /f "tokens=*" %%F in ('where ninja') do ( + set NINJA=%%F +) + +if defined VCPKG_ROOT ( if not defined NINJA ( - for /f "tokens=*" %%F in ('where /R %CD%\vcpkg\downloads\tools ninja') do ( + for /f "tokens=*" %%F in ('where /R %VCPKG_ROOT%\vcpkg\downloads\tools ninja') do ( set NINJA=%%F ) + popd ) - if defined NINJA ( - echo Using ninja at !NINJA! +) + +if not defined NINJA ( + for /f "tokens=*" %%F in ('where /R %CD%\vcpkg\downloads\tools ninja') do ( + set NINJA=%%F + ) +) + +if defined NINJA ( + echo Found ninja: !NINJA! + if not defined CMAKE_GEN ( set CMAKE_GEN=Ninja ) ) + +if not defined CMAKE_GEN ( + set CMAKE_GEN=Visual Studio 16 2019 +) + set "ROOT=%~dp0\.." if not defined ARCH ( set ARCH=x64 @@ -80,23 +87,23 @@ REM The following two configurations are built below: REM - nostd - build with OpenTelemetry C++ Template library REM - stl - build with Standard Template Library REM ########################################################################################## -REM Build with nostd implementation. Supported VS_TOOLS_VERSION: +REM Build with nostd implementation. Supported BUILDTOOLS_VERSION: REM - vs2015 (C++11) REM - vs2017 (C++14) REM - vs2019 (C++20) REM ########################################################################################## set CONFIG=-DWITH_STL:BOOL=OFF %* -set "OUTDIR=%ROOT%\out\%VS_TOOLS_VERSION%\nostd" +set "OUTDIR=%ROOT%\out\%BUILDTOOLS_VERSION%\nostd" call :build_config REM ########################################################################################## -REM Build with STL implementation (only for vs2017+). Supported VS_TOOLS_VERSION: +REM Build with STL implementation (only for vs2017+). Supported BUILDTOOLS_VERSION: REM - vs2017 (C++14) REM - vs2019 (C++20) - optimal config with all OpenTelemetry API classes using STL only. REM ########################################################################################## -if "%VS_TOOLS_VERSION%" neq "vs2015" ( +if "%BUILDTOOLS_VERSION%" neq "vs2015" ( set CONFIG=-DWITH_STL:BOOL=ON %* - set "OUTDIR=%ROOT%\out\%VS_TOOLS_VERSION%\stl" + set "OUTDIR=%ROOT%\out\%BUILDTOOLS_VERSION%\stl" call :build_config ) @@ -110,12 +117,13 @@ REM TODO: consider rmdir for clean builds if not exist "%OUTDIR%" mkdir "%OUTDIR%" cd "%OUTDIR%" -if "!VS_TOOLS_VERSION!" == "vs2019" ( - REM Prefer ninja if available - if "!CMAKE_GEN!" == "Ninja" ( - call :build_config_ninja - exit /b - ) +REM Prefer ninja if available +if "!CMAKE_GEN!" == "Ninja" ( + call :build_config_ninja + exit /b +) + +if "!BUILDTOOLS_VERSION!" == "vs2019" ( REM Only latest vs2019 generator supports and requires -A parameter cmake -G "!CMAKE_GEN!" -A !ARCH! -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" ) else ( diff --git a/tools/vcvars.cmd b/tools/vcvars.cmd index 69308778a7..14e65c8c42 100644 --- a/tools/vcvars.cmd +++ b/tools/vcvars.cmd @@ -29,8 +29,8 @@ if "%1" neq "" ( goto %1 ) -if defined VS_TOOLS_VERSION ( - goto %VS_TOOLS_VERSION% +if defined BUILDTOOLS_VERSION ( + goto %BUILDTOOLS_VERSION% ) :vs2019 @@ -115,4 +115,18 @@ REM is not set up by checking TOOLS_VS_NOTFOUND set TOOLS_VS_NOTFOUND=1 exit /b 0 +REM Auto-detection bypass logic for LLVM-Clang. There is no auto-detection +REM because by default LLVM Clang of any version is installed in the same +REM directory at %ProgramFiles%\LLVM\bin. +REM +REM Path to LLVM bin must be configured manually: +REM +REM set BUILDTOOLS_VERSION=clang-10 +REM set "PATH=%ProgramFiles%\LLVM\bin;%PATH%" +REM +:clang-9 +:clang-10 +:clang-11 +:clang-12 + :tools_configured From 8daf5c80e7b2b9ad69cef396d508ffd5257acf62 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 12:00:50 -0700 Subject: [PATCH 43/60] Support vs2015 and clang --- api/test/nostd/variant_test.cc | 2 ++ tools/build-benchmark.cmd | 2 +- tools/build-clang.cmd | 7 +++++++ tools/build-vs2015.cmd | 18 +++++++++++++----- tools/build-vs2017.cmd | 2 +- tools/build-vs2019.cmd | 2 +- tools/build.cmd | 10 ++-------- tools/setup-buildtools.cmd | 24 ++++++++++++++++-------- tools/vcvars.cmd | 4 ++-- 9 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 tools/build-clang.cmd diff --git a/api/test/nostd/variant_test.cc b/api/test/nostd/variant_test.cc index 428d31e624..347e250115 100644 --- a/api/test/nostd/variant_test.cc +++ b/api/test/nostd/variant_test.cc @@ -27,6 +27,7 @@ TEST(VariantSizeTest, GetVariantSize) EXPECT_EQ((nostd::variant_size>::value), 2); } +#if 0 TEST(VariantAlternativeTest, GetVariantSize) { EXPECT_TRUE((std::is_same>, int>::value)); @@ -35,6 +36,7 @@ TEST(VariantAlternativeTest, GetVariantSize) EXPECT_TRUE((std::is_same>, const double>::value)); } +#endif TEST(VariantTest, Get) { diff --git a/tools/build-benchmark.cmd b/tools/build-benchmark.cmd index 39b9f180d9..379cb1313a 100644 --- a/tools/build-benchmark.cmd +++ b/tools/build-benchmark.cmd @@ -1,5 +1,5 @@ @echo off -set VS_TOOLS_VERSION=vs2019 +set BUILDTOOLS_VERSION=vs2019 set CMAKE_GEN="Visual Studio 16 2019" echo Building Google Benchmark (test only dependency)... @setlocal ENABLEEXTENSIONS diff --git a/tools/build-clang.cmd b/tools/build-clang.cmd new file mode 100644 index 0000000000..a41c5bb6c1 --- /dev/null +++ b/tools/build-clang.cmd @@ -0,0 +1,7 @@ +@echo off +pushd %~dp0 +set "PATH=%ProgramFiles%\LLVM-12\bin;%PATH%" +set BUILDTOOLS_VERSION=clang-12 +set CMAKE_GEN=Ninja +call build.cmd %* +popd diff --git a/tools/build-vs2015.cmd b/tools/build-vs2015.cmd index 30bb41c3c9..5323b83460 100644 --- a/tools/build-vs2015.cmd +++ b/tools/build-vs2015.cmd @@ -1,11 +1,19 @@ REM Build with Visual Studio 2015 -set "VS_TOOLS_VERSION=vs2015" -set ARCH=Win64 +set "PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\bin;%PATH%" +set BUILDTOOLS_VERSION=vs2015 +set ARCH=x64 if NOT "%1"=="" ( set ARCH=%1 ) -set "CMAKE_GEN=Visual Studio 14 2015 %ARCH%" +set "CMAKE_GEN=Ninja" +set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\" +set CMAKE_SYSTEM_VERSION=8.1 +set "PATH=%ProgramFiles(x86)%\Windows Kits\8.1\bin\%ARCH%;%PATH%" +REM set WINSDK_VERSION=10.0.19041.0 +set WINSDK_VERSION=8.1 +REM set "PATH=%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.19041.0\%ARCH%\;%PATH%" +set VCPKG_ROOT=C:\work\vcpkg.vs2015 +REM set VCPKG_FORCE_SYSTEM_BINARIES=1 cd %~dp0 call setup-buildtools.cmd -REM TODO: currently we cannot build without Abseil variant for Visual Studio 2015 -call build.cmd -DWITH_ABSEIL:BOOL=ON +call build.cmd -DMSVC_TOOLSET_VERSION=140 diff --git a/tools/build-vs2017.cmd b/tools/build-vs2017.cmd index de84593123..9515d82a6e 100644 --- a/tools/build-vs2017.cmd +++ b/tools/build-vs2017.cmd @@ -1,5 +1,5 @@ REM Build with Visual Studio 2017 -set "VS_TOOLS_VERSION=vs2017" +set "BUILDTOOLS_VERSION=vs2017" set ARCH=Win64 if NOT "%1"=="" ( set ARCH=%1 diff --git a/tools/build-vs2019.cmd b/tools/build-vs2019.cmd index b4a39938a3..e59bdada29 100644 --- a/tools/build-vs2019.cmd +++ b/tools/build-vs2019.cmd @@ -1,5 +1,5 @@ REM Build with Visual Studio 2017 -set "VS_TOOLS_VERSION=vs2019" +set "BUILDTOOLS_VERSION=vs2019" set ARCH=Win64 if NOT "%1"=="" ( set ARCH=%1 diff --git a/tools/build.cmd b/tools/build.cmd index 2f05f877c3..16112d40d6 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -87,19 +87,14 @@ REM The following two configurations are built below: REM - nostd - build with OpenTelemetry C++ Template library REM - stl - build with Standard Template Library REM ########################################################################################## -REM Build with nostd implementation. Supported BUILDTOOLS_VERSION: -REM - vs2015 (C++11) -REM - vs2017 (C++14) -REM - vs2019 (C++20) +REM Build with nostd implementation. REM ########################################################################################## set CONFIG=-DWITH_STL:BOOL=OFF %* set "OUTDIR=%ROOT%\out\%BUILDTOOLS_VERSION%\nostd" call :build_config REM ########################################################################################## -REM Build with STL implementation (only for vs2017+). Supported BUILDTOOLS_VERSION: -REM - vs2017 (C++14) -REM - vs2019 (C++20) - optimal config with all OpenTelemetry API classes using STL only. +REM Build with STL implementation. This option does not yield benefits for vs2015 build. REM ########################################################################################## if "%BUILDTOOLS_VERSION%" neq "vs2015" ( set CONFIG=-DWITH_STL:BOOL=ON %* @@ -127,7 +122,6 @@ if "!BUILDTOOLS_VERSION!" == "vs2019" ( REM Only latest vs2019 generator supports and requires -A parameter cmake -G "!CMAKE_GEN!" -A !ARCH! -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" ) else ( - REM Old vs2017 generator does not support -A parameter cmake -G "!CMAKE_GEN!" -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" ) set "SOLUTION=%OUTDIR%\opentelemetry-cpp.sln" diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index 7819aaf792..f6c46af85e 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -1,8 +1,12 @@ @echo off setlocal enableextensions setlocal enabledelayedexpansion -set "PATH=%ProgramFiles%\CMake\bin;%~dp0;%~dp0vcpkg;%ProgramData%\chocolatey\bin;%PATH%" -if "%VCPKG_ROOT%" NEQ "" set "PATH=%VCPKG_ROOT%;%PATH%" +set "PATH=%ProgramFiles%\CMake\bin;%~dp0;%ProgramData%\chocolatey\bin;%PATH%" +if "%VCPKG_ROOT%" NEQ "" ( + set "PATH=%VCPKG_ROOT%;%PATH%" +) else ( + set "PATH=%~dp0vcpkg;%PATH%" +) pushd %~dp0 net session >nul 2>&1 @@ -22,11 +26,13 @@ if %errorLevel% == 0 ( echo Running without Administrative privilege... ) -REM Print current Visual Studio installations detected -where /Q vswhere -if %ERRORLEVEL% == 0 ( - echo Visual Studio installations detected: - vswhere -property installationPath +if not defined BUILDTOOLS_VERSION ( + REM Print current Visual Studio installations detected + where /Q vswhere + if %ERRORLEVEL% == 0 ( + echo Visual Studio installations detected: + vswhere -property installationPath + ) ) REM This script allows to pass architecture in ARCH env var @@ -56,7 +62,9 @@ if %ERRORLEVEL% == 1 ( REM Install dependencies vcpkg install gtest:%ARCH%-windows -vcpkg install --head --overlay-ports=%~dp0ports benchmark:%ARCH%-windows +REM vcpkg install --head --overlay-ports=%~dp0ports benchmark:%ARCH%-windows +REM vcpkg install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows +vcpkg install benchmark:%ARCH%-windows vcpkg install ms-gsl:%ARCH%-windows vcpkg install nlohmann-json:%ARCH%-windows vcpkg install abseil:%ARCH%-windows diff --git a/tools/vcvars.cmd b/tools/vcvars.cmd index 14e65c8c42..9904a5e2a7 100644 --- a/tools/vcvars.cmd +++ b/tools/vcvars.cmd @@ -100,10 +100,10 @@ if exist %TOOLS_VS2017% ( ) :vs2015 -set TOOLS_VS2015="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\bin\vcvarsall.bat" +set TOOLS_VS2015="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" if exist %TOOLS_VS2015% ( echo Building with vs2015 BuildTools... - call %TOOLS_VS2015% %ARCH% + call %TOOLS_VS2015% %ARCH% %WINSDK_VERSION% set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0" set VCPKG_PLATFORM_TOOLSET=v140 goto tools_configured From 8efad2831a805a9b033ef0bcee36d2d5bc656e96 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:44:32 -0700 Subject: [PATCH 44/60] Remove unused method from Tracer API --- api/include/opentelemetry/trace/tracer.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index fccf65b960..57761e5f90 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -85,19 +85,6 @@ class Tracer return this->StartSpan(name, attributes, {}, options); } - template ::value> * = nullptr> - nostd::shared_ptr StartSpan( - nostd::string_view name, - std::initializer_list> attributes, - const StartSpanOptions &options = {}) noexcept - { - return this->StartSpan(name, - nostd::span>{ - attributes.begin(), attributes.end()}, - {}, options); - } - template ::value> * = nullptr> nostd::shared_ptr StartSpan( From 5ff530f6daee5e32f8e5b8055b38e0878dc10574 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:45:46 -0700 Subject: [PATCH 45/60] Turn all optional components off and fix an issue with __cplusplus --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c1439d743..e311401e7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,7 @@ if(WITH_STL) set(MSVC_CXX_OPT_FLAG "/O2") endif() endif() - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} /Zc:__cplusplus ${MSVC_CXX_OPT_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_OPT_FLAG}") endif() endif() @@ -129,7 +128,7 @@ option( OFF) option(WITH_EXAMPLES "Whether to build examples" ON) -option(WITH_METRICS_PREVIEW "Whether to build metrics preview" ON) +option(WITH_METRICS_PREVIEW "Whether to build metrics preview" OFF) if(WITH_METRICS_PREVIEW) add_definitions(-DENABLE_METRICS_PREVIEW) @@ -168,8 +167,10 @@ if(MSVC) # Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value # for recent C++ language standards. Without this option MSVC returns the # value of __cplusplus="199711L" - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") - + if(MSVC_VERSION GREATER 1900) + # __cplusplus flag is not supported by Visual Studio 2015 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") + endif() # When using vcpkg, all targets build with the same runtime if(VCPKG_TOOLCHAIN) set(CMAKE_MSVC_RUNTIME_LIBRARY From 430cc6ad92de6944e25684fe9eb913ca3049f423 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:46:05 -0700 Subject: [PATCH 46/60] Rename script to mention clang-12 since it assumes the path to clang-12 --- tools/{build-clang.cmd => build-clang-12.cmd} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{build-clang.cmd => build-clang-12.cmd} (100%) diff --git a/tools/build-clang.cmd b/tools/build-clang-12.cmd similarity index 100% rename from tools/build-clang.cmd rename to tools/build-clang-12.cmd From 86a1f3b288104c3cdd3574afabf83eed99149b13 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:46:33 -0700 Subject: [PATCH 47/60] Benchmark should specify proper sha or latest vcpkg is gonna fail --- tools/ports/benchmark/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ports/benchmark/portfile.cmake b/tools/ports/benchmark/portfile.cmake index 5a2779c493..dba57ab53d 100644 --- a/tools/ports/benchmark/portfile.cmake +++ b/tools/ports/benchmark/portfile.cmake @@ -22,7 +22,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO google/benchmark REF c05843a9f622db08ad59804c190f98879b76beba # v1.5.3 - SHA512 1 + SHA512 4e4b793ff6d7a4b12ce4b98cf5faa6d5d27a0a1d7be630c0c4a2a4bca5168fd94585e5e3e1a9c43603e42145ddcded8e5a3688528bf073a068f53054b86ce774 HEAD_REF master PATCHES "version.patch" ) From 26b8866836cf34cfd2ab77c5dc22f5dd7eb009e9 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:47:13 -0700 Subject: [PATCH 48/60] Latest visual studio 2019 would like arch to be x64 instead of Win64 --- tools/build-vs2019.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build-vs2019.cmd b/tools/build-vs2019.cmd index e59bdada29..d03dcd9d2a 100644 --- a/tools/build-vs2019.cmd +++ b/tools/build-vs2019.cmd @@ -1,10 +1,10 @@ REM Build with Visual Studio 2017 set "BUILDTOOLS_VERSION=vs2019" -set ARCH=Win64 +set ARCH=x64 if NOT "%1"=="" ( set ARCH=%1 ) -if "%ARCH%"=="Win64" ( +if "%ARCH%"=="x64" ( REM Parameter needed for CMake Visual Studio 2019 generator set CMAKE_ARCH=x64 ) From e2264895005e712a894f351a07250991c9c3b25c Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:47:58 -0700 Subject: [PATCH 49/60] Merge source code fixes for vs2015 --- api/include/opentelemetry/trace/propagation/b3_propagator.h | 6 +++--- .../opentelemetry/exporters/etw/etw_traceloggingdynamic.h | 5 +++-- exporters/etw/test/etw_perf_test.cc | 4 +--- exporters/etw/test/etw_tracer_test.cc | 4 +--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/api/include/opentelemetry/trace/propagation/b3_propagator.h b/api/include/opentelemetry/trace/propagation/b3_propagator.h index 77d736bedc..9aac90f03e 100644 --- a/api/include/opentelemetry/trace/propagation/b3_propagator.h +++ b/api/include/opentelemetry/trace/propagation/b3_propagator.h @@ -139,11 +139,11 @@ class B3Propagator : public B3PropagatorExtractor char trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 3]; static_assert(sizeof(trace_identity) == 51, "b3 trace identity buffer size mismatch"); - span_context.trace_id().ToLowerBase16( - nostd::span{&trace_identity[0], kTraceIdHexStrLength}); + span_context.trace_id().ToLowerBase16(nostd::span{ + &trace_identity[0], static_cast(kTraceIdHexStrLength)}); trace_identity[kTraceIdHexStrLength] = '-'; span_context.span_id().ToLowerBase16(nostd::span{ - &trace_identity[kTraceIdHexStrLength + 1], kSpanIdHexStrLength}); + &trace_identity[kTraceIdHexStrLength + 1], static_cast(kSpanIdHexStrLength)}); trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 1] = '-'; trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 2] = span_context.trace_flags().IsSampled() ? '1' : '0'; diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h index 9fe479b7eb..a6243c46db 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h @@ -8,7 +8,8 @@ # endif # endif #else -# ifdef HAVE_TLD -# include "TraceLoggingDynamic.h" +# ifndef HAVE_TLD +# define HAVE_TLD # endif +# include "TraceLoggingDynamic.h" #endif diff --git a/exporters/etw/test/etw_perf_test.cc b/exporters/etw/test/etw_perf_test.cc index f2d28c094b..d25ea73957 100644 --- a/exporters/etw/test/etw_perf_test.cc +++ b/exporters/etw/test/etw_perf_test.cc @@ -14,9 +14,7 @@ using namespace OPENTELEMETRY_NAMESPACE; -using Properties = opentelemetry::exporter::etw::Properties; -using PropertyValue = opentelemetry::exporter::etw::PropertyValue; -using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap; +using namespace opentelemetry::exporter::etw; namespace { diff --git a/exporters/etw/test/etw_tracer_test.cc b/exporters/etw/test/etw_tracer_test.cc index 5d741d5b75..45d49356c8 100644 --- a/exporters/etw/test/etw_tracer_test.cc +++ b/exporters/etw/test/etw_tracer_test.cc @@ -12,9 +12,7 @@ using namespace OPENTELEMETRY_NAMESPACE; -using Properties = opentelemetry::exporter::etw::Properties; -using PropertyValue = opentelemetry::exporter::etw::PropertyValue; -using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap; +using namespace opentelemetry::exporter::etw; std::string getTemporaryValue() { From 5d0453d2fbfeed908c0e9ceb048e9620e1666f9c Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:48:29 -0700 Subject: [PATCH 50/60] vcpkg head parameter was incorrect --- tools/setup-buildtools.cmd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index f6c46af85e..cf57d05a6e 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -62,9 +62,7 @@ if %ERRORLEVEL% == 1 ( REM Install dependencies vcpkg install gtest:%ARCH%-windows -REM vcpkg install --head --overlay-ports=%~dp0ports benchmark:%ARCH%-windows -REM vcpkg install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows -vcpkg install benchmark:%ARCH%-windows +vcpkg install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows vcpkg install ms-gsl:%ARCH%-windows vcpkg install nlohmann-json:%ARCH%-windows vcpkg install abseil:%ARCH%-windows From d20e97ec54f96defc8521a262b514c7ea7a8af98 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:48:44 -0700 Subject: [PATCH 51/60] Merge code fix for vs2015 --- examples/grpc/client.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/grpc/client.cpp b/examples/grpc/client.cpp index 5ebdbf617d..719a62225b 100644 --- a/examples/grpc/client.cpp +++ b/examples/grpc/client.cpp @@ -1,12 +1,14 @@ +// Make sure to include GRPC headers first because otherwise Abseil may create +// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other +// modern compilers are unaffected. +#include +#include "messages.grpc.pb.h" + #include "tracer_common.h" #include #include #include -#include - -#include "messages.grpc.pb.h" - using grpc::Channel; using grpc::ClientContext; using grpc::ClientReader; From 5f0218abb3f11da4c3f660982e22a9d4f690f26f Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 8 Jun 2021 14:49:37 -0700 Subject: [PATCH 52/60] Use Windows 8.1 SDK and clarify how to use Win 10 SDK in a comment --- tools/build-vs2015.cmd | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/build-vs2015.cmd b/tools/build-vs2015.cmd index 5323b83460..f21f3a2ec2 100644 --- a/tools/build-vs2015.cmd +++ b/tools/build-vs2015.cmd @@ -7,13 +7,17 @@ if NOT "%1"=="" ( ) set "CMAKE_GEN=Ninja" set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\" -set CMAKE_SYSTEM_VERSION=8.1 + +REM Building with Windows SDK 8.1 set "PATH=%ProgramFiles(x86)%\Windows Kits\8.1\bin\%ARCH%;%PATH%" -REM set WINSDK_VERSION=10.0.19041.0 set WINSDK_VERSION=8.1 +set CMAKE_SYSTEM_VERSION=8.1 + +REM Replace above Windows SDK 8.1 by Windows 10 SDK if necessary. +REM Resulting binaries may not be compatible with Windows 8. +REM set WINSDK_VERSION=10.0.19041.0 REM set "PATH=%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.19041.0\%ARCH%\;%PATH%" -set VCPKG_ROOT=C:\work\vcpkg.vs2015 -REM set VCPKG_FORCE_SYSTEM_BINARIES=1 + cd %~dp0 call setup-buildtools.cmd call build.cmd -DMSVC_TOOLSET_VERSION=140 From a3b3eb32292716b25746fbeca318dcee7bfe0eaf Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 9 Jun 2021 14:10:46 -0700 Subject: [PATCH 53/60] Update tracer.h Remove unused template --- api/include/opentelemetry/trace/tracer.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index fccf65b960..57761e5f90 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -85,19 +85,6 @@ class Tracer return this->StartSpan(name, attributes, {}, options); } - template ::value> * = nullptr> - nostd::shared_ptr StartSpan( - nostd::string_view name, - std::initializer_list> attributes, - const StartSpanOptions &options = {}) noexcept - { - return this->StartSpan(name, - nostd::span>{ - attributes.begin(), attributes.end()}, - {}, options); - } - template ::value> * = nullptr> nostd::shared_ptr StartSpan( From a23d26a6057dbdb09812dd48f9f64850d505e320 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 9 Jun 2021 14:41:53 -0700 Subject: [PATCH 54/60] Re-add ability to auto-parent --- .../opentelemetry/exporters/etw/etw_tracer.h | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 7cf6edea24..346be01309 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -291,8 +291,12 @@ static inline bool CopySpanIdToActivityId(const trace::SpanContext &spanContext, { return false; } - auto spanId = spanContext.span_id().Id().data(); - std::copy(spanId, spanId + 8, reinterpret_cast(&outGuid)); + auto spanId = spanContext.span_id().Id().data(); + uint8_t *guidPtr = reinterpret_cast(&outGuid); + for (size_t i = 0; i < 8; i++) + { + guidPtr[i] = spanId[i]; + } return true; }; @@ -477,12 +481,22 @@ class Tracer : public trace::Tracer UpdateStatus(currentSpan, evt); etwProvider().write(provHandle, evt, ActivityIdPtr, RelatedActivityIdPtr, 0, encoding); } + + { + // Atomically remove the span from list of spans + const std::lock_guard lock(scopes_mutex_); + auto spanId = ToLowerBase16(spanBase.GetContext().span_id()); + scopes_.erase(spanId); + } }; const trace::TraceId &trace_id() { return traceId_; }; friend class Span; + std::mutex scopes_mutex_; // protects scopes_ + std::map> scopes_; + /** * @brief Init a reference to etw::ProviderHandle * @return Provider Handle @@ -638,6 +652,12 @@ class Tracer : public trace::Tracer etwProvider().write(provHandle, evt, ActivityIdPtr, RelatedActivityIdPtr, 1, encoding); }; + { + const std::lock_guard lock(scopes_mutex_); + // Use span_id as index + scopes_[ToLowerBase16(result->GetContext().span_id())] = WithActiveSpan(result); + } + return result; }; From 73b7fc5b8248fc70709714120d0a26b5a5819a1e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 9 Jun 2021 14:53:49 -0700 Subject: [PATCH 55/60] Update vcpkg to tag: 2021.05.12 --- tools/vcpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vcpkg b/tools/vcpkg index e9f8cc67a5..5568f110b5 160000 --- a/tools/vcpkg +++ b/tools/vcpkg @@ -1 +1 @@ -Subproject commit e9f8cc67a5e5541973e53ac03f88adb45cc1b21b +Subproject commit 5568f110b509a9fd90711978a7cb76bae75bb092 From cfb1779ecedbcc2e87133190a38bdfa99a90a313 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 10 Jun 2021 11:49:47 -0700 Subject: [PATCH 56/60] Turn logs off --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58dea20131..c29a5e9912 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ if(WITH_METRICS_PREVIEW) add_definitions(-DENABLE_METRICS_PREVIEW) endif() -option(WITH_LOGS_PREVIEW "Whether to build logs preview" ON) +option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF) if(WITH_LOGS_PREVIEW) add_definitions(-DENABLE_LOGS_PREVIEW) From 95bbaf58c9cc4c2e791b46757ca84e9e11cbec91 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 10 Jun 2021 11:51:19 -0700 Subject: [PATCH 57/60] Use 'defined' - it is more readable --- tools/setup-buildtools.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index 3999e9cee0..956c8ddfe4 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -2,7 +2,7 @@ setlocal enableextensions setlocal enabledelayedexpansion set "PATH=%ProgramFiles%\CMake\bin;%~dp0;%ProgramData%\chocolatey\bin;%PATH%" -if "%VCPKG_ROOT%" NEQ "" ( +if defined VCPKG_ROOT ( set "PATH=%VCPKG_ROOT%;%PATH%" ) else ( set "PATH=%~dp0vcpkg;%PATH%" From 10fd8458c4b4ac5114bb6ae7020ec6774e6d2990 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 10 Jun 2021 11:54:27 -0700 Subject: [PATCH 58/60] Revert etw/etw_tracer.h changes --- .../opentelemetry/exporters/etw/etw_tracer.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 346be01309..2806bfa593 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -481,22 +481,12 @@ class Tracer : public trace::Tracer UpdateStatus(currentSpan, evt); etwProvider().write(provHandle, evt, ActivityIdPtr, RelatedActivityIdPtr, 0, encoding); } - - { - // Atomically remove the span from list of spans - const std::lock_guard lock(scopes_mutex_); - auto spanId = ToLowerBase16(spanBase.GetContext().span_id()); - scopes_.erase(spanId); - } }; const trace::TraceId &trace_id() { return traceId_; }; friend class Span; - std::mutex scopes_mutex_; // protects scopes_ - std::map> scopes_; - /** * @brief Init a reference to etw::ProviderHandle * @return Provider Handle @@ -652,12 +642,6 @@ class Tracer : public trace::Tracer etwProvider().write(provHandle, evt, ActivityIdPtr, RelatedActivityIdPtr, 1, encoding); }; - { - const std::lock_guard lock(scopes_mutex_); - // Use span_id as index - scopes_[ToLowerBase16(result->GetContext().span_id())] = WithActiveSpan(result); - } - return result; }; From 26bc34b255f1c92ebbd410f75c4785cdbc8cf9eb Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 10 Jun 2021 15:08:25 -0700 Subject: [PATCH 59/60] Fix Visual Studio 2017 issue --- api/include/opentelemetry/std/span.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/include/opentelemetry/std/span.h b/api/include/opentelemetry/std/span.h index e6de8a6742..ae614a9425 100644 --- a/api/include/opentelemetry/std/span.h +++ b/api/include/opentelemetry/std/span.h @@ -39,9 +39,10 @@ OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { +using gsl::dynamic_extent; template using span = gsl::span; -} +} // namespace nostd OPENTELEMETRY_END_NAMESPACE # define HAVE_SPAN # else From 2c05aeeff1d9c65925ca07bc995d90fbdc2dfa10 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Thu, 10 Jun 2021 15:11:09 -0700 Subject: [PATCH 60/60] Build farm for Windows --- tools/build-clang.cmd | 7 +++++ tools/build-vs2015.cmd | 16 +++++++++-- tools/build-vs2017.cmd | 11 ++++++-- tools/build-vs2019.cmd | 2 -- tools/build.cmd | 24 ++++++++++++++-- tools/ports/benchmark/portfile.cmake | 4 --- tools/vcvars.cmd | 42 ++++++++++++++++++++++------ 7 files changed, 84 insertions(+), 22 deletions(-) create mode 100644 tools/build-clang.cmd diff --git a/tools/build-clang.cmd b/tools/build-clang.cmd new file mode 100644 index 0000000000..c160fd661b --- /dev/null +++ b/tools/build-clang.cmd @@ -0,0 +1,7 @@ +@echo off +pushd %~dp0 +set "PATH=%ProgramFiles%\LLVM\bin;%PATH%" +set BUILDTOOLS_VERSION=clang +set CMAKE_GEN=Ninja +call build.cmd %* +popd diff --git a/tools/build-vs2015.cmd b/tools/build-vs2015.cmd index f21f3a2ec2..ed230d1559 100644 --- a/tools/build-vs2015.cmd +++ b/tools/build-vs2015.cmd @@ -1,22 +1,32 @@ REM Build with Visual Studio 2015 set "PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\bin;%PATH%" + +REM ### Note that vcpkg built with 2019/2017 can't be used with 2015! +REM ### Consider to specify custom VCPKG_ROOT for 2015 as follows: +REM +REM set VCPKG_ROOT=C:\vcpkg.2015 +REM + set BUILDTOOLS_VERSION=vs2015 set ARCH=x64 if NOT "%1"=="" ( set ARCH=%1 ) set "CMAKE_GEN=Ninja" -set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\" +set "VCPKG_VISUAL_STUDIO_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0" REM Building with Windows SDK 8.1 set "PATH=%ProgramFiles(x86)%\Windows Kits\8.1\bin\%ARCH%;%PATH%" set WINSDK_VERSION=8.1 set CMAKE_SYSTEM_VERSION=8.1 +set VCPKG_PLATFORM_TOOLSET=v140 -REM Replace above Windows SDK 8.1 by Windows 10 SDK if necessary. -REM Resulting binaries may not be compatible with Windows 8. +REM ### Replace above Windows SDK 8.1 by Windows 10 SDK if necessary. +REM ### Resulting binaries may not be compatible with Windows 8 +REM REM set WINSDK_VERSION=10.0.19041.0 REM set "PATH=%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.19041.0\%ARCH%\;%PATH%" +REM cd %~dp0 call setup-buildtools.cmd diff --git a/tools/build-vs2017.cmd b/tools/build-vs2017.cmd index 9515d82a6e..3a95d9b110 100644 --- a/tools/build-vs2017.cmd +++ b/tools/build-vs2017.cmd @@ -1,10 +1,17 @@ REM Build with Visual Studio 2017 set "BUILDTOOLS_VERSION=vs2017" -set ARCH=Win64 +set ARCH=x64 if NOT "%1"=="" ( set ARCH=%1 ) -set "CMAKE_GEN=Visual Studio 15 2017 %ARCH%" + +REM ### Uncomment below to use Visual Studio MSBuild solution. +REM ### Ninja generator produces much faster builds. But it is +REM ### easier to debug MSBuild solution in vs2017 IDE : +REM +REM set "CMAKE_GEN=Visual Studio 15 2017" +REM + cd %~dp0 call setup-buildtools.cmd call build.cmd diff --git a/tools/build-vs2019.cmd b/tools/build-vs2019.cmd index d03dcd9d2a..2fd6dbc59e 100644 --- a/tools/build-vs2019.cmd +++ b/tools/build-vs2019.cmd @@ -8,8 +8,6 @@ if "%ARCH%"=="x64" ( REM Parameter needed for CMake Visual Studio 2019 generator set CMAKE_ARCH=x64 ) - -set "CMAKE_GEN=Visual Studio 16 2019" cd %~dp0 call setup-buildtools.cmd call build.cmd diff --git a/tools/build.cmd b/tools/build.cmd index 16112d40d6..7558f4efff 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -118,12 +118,30 @@ if "!CMAKE_GEN!" == "Ninja" ( exit /b ) +if "!BUILDTOOLS_VERSION!" == "vs2015" ( + cmake -G "!CMAKE_GEN!" -A !ARCH! -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" + call :build_msbuild + exit /b +) + +if "!BUILDTOOLS_VERSION!" == "vs2017" ( + cmake -G "!CMAKE_GEN!" -A !ARCH! -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" + call :build_msbuild + exit /b +) + if "!BUILDTOOLS_VERSION!" == "vs2019" ( - REM Only latest vs2019 generator supports and requires -A parameter cmake -G "!CMAKE_GEN!" -A !ARCH! -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" -) else ( - cmake -G "!CMAKE_GEN!" -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" + call :build_msbuild + exit /b ) + +REM ########################################################################################## +REM Exotic CMake generators, like MSYS and MinGW MAY work, but untested +REM ########################################################################################## +cmake -G "!CMAKE_GEN!" -DCMAKE_TOOLCHAIN_FILE="!VCPKG_CMAKE!" !CONFIG! "!ROOT!" + +:build_msbuild set "SOLUTION=%OUTDIR%\opentelemetry-cpp.sln" msbuild "%SOLUTION%" /p:Configuration=Release /p:VcpkgEnabled=true exit /b diff --git a/tools/ports/benchmark/portfile.cmake b/tools/ports/benchmark/portfile.cmake index dba57ab53d..fdb988c538 100644 --- a/tools/ports/benchmark/portfile.cmake +++ b/tools/ports/benchmark/portfile.cmake @@ -1,11 +1,7 @@ if (VCPKG_PLATFORM_TOOLSET STREQUAL "v140") - # set(CMAKE_C_COMPILER_WORKS 1) - # set(CMAKE_CXX_COMPILER_WORKS 1) set(CMAKE_C_COMPILER cl.exe) set(CMAKE_CXX_COMPILER cl.exe) set(MSVC_TOOLSET_VERSION 140) - # set(VCPKG_VISUAL_STUDIO_PATH "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0") - # set(VCPKG_PLATFORM_TOOLSET v140) else() # Make sure vs2019 compiled binaries are compat with vs2017 set(VCPKG_CXX_FLAGS "/Zc:__cplusplus /d2FH4-") diff --git a/tools/vcvars.cmd b/tools/vcvars.cmd index 9904a5e2a7..94f5cca95a 100644 --- a/tools/vcvars.cmd +++ b/tools/vcvars.cmd @@ -1,7 +1,7 @@ @echo off REM +-------------------------------------------------------------------+ -REM | Autodetect and set up the build environment for Visual Studio. | -REM | Visual Studio version may be specified as 1st argument. | +REM | Autodetect and set up the build environment. | +REM | Build Tools version may be specified as 1st argument. | REM +-------------------------------------------------------------------+ REM | Description | Argument value | REM +-----------------------------------------+-------------------------+ @@ -18,6 +18,12 @@ REM | Visual Studio 2017 Community | vs2017_community | REM | Visual Studio 2017 Build Tools (no IDE) | vs2017_buildtools | REM | | | REM | Visual Studio 2015 Build Tools (no IDE) | vs2015 | +REM | | | +REM | LLVM Clang (any version) | clang | +REM | LLVM Clang 9 | clang-9 | +REM | LLVM Clang 10 | clang-10 | +REM | LLVM Clang 11 | clang-11 | +REM | LLVM Clang 11 | clang-12 | REM +-----------------------------------------+-------------------------+ set "VSCMD_START_DIR=%CD%" @@ -115,15 +121,35 @@ REM is not set up by checking TOOLS_VS_NOTFOUND set TOOLS_VS_NOTFOUND=1 exit /b 0 -REM Auto-detection bypass logic for LLVM-Clang. There is no auto-detection -REM because by default LLVM Clang of any version is installed in the same -REM directory at %ProgramFiles%\LLVM\bin. -REM -REM Path to LLVM bin must be configured manually: +REM +-------------------------------------------------------------------+ +REM | There is no auto-detection of LLVM Clang version. | +REM | LLVM Clang of any version is installed in the same directory | +REM | at %ProgramFiles%\LLVM\bin . Developers choose their own custom | +REM | layout for installing multiple clang toolchains side-by-side. | +REM | | +REM | Example layout (merely a guideline, layout could differ): | +REM | | +REM | %ProgramFiles%\LLVM-9\bin | +REM | %ProgramFiles%\LLVM-10\bin | +REM | %ProgramFiles%\LLVM-11\bin | +REM | %ProgramFiles%\LLVM-12\bin | +REM +-------------------------------------------------------------------+ REM +REM ## Example 1: use clang-10 located in LLVM-10 directory: REM set BUILDTOOLS_VERSION=clang-10 +REM set "PATH=%ProgramFiles%\LLVM-10\bin;%PATH%" +REM tools\build.cmd +REM +REM ## Example 2: use whatever clang located in LLVM directory: +REM set BUILDTOOLS_VERSION=clang REM set "PATH=%ProgramFiles%\LLVM\bin;%PATH%" -REM +REM tools\build.cmd +REM +REM BUILDTOOLS_VERSION determines the output directory location. +REM Store build artifacts produced by different toolchains - +REM side-by-side, each in its own separate output directory. +REM +:clang :clang-9 :clang-10 :clang-11