diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-24 11:00:15 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-24 11:00:15 +0300 |
commit | fb806af1fc6dd9c94eb05c20fef364d06c83bb34 (patch) | |
tree | ae206e459b625f8229090459a0fd2cc765a204fb /contrib/restricted/boost/system/include | |
parent | 60efd6a481feccd39ce6cc2dd013eb4f28419bc6 (diff) | |
download | ydb-fb806af1fc6dd9c94eb05c20fef364d06c83bb34.tar.gz |
Update contrib/restricted/boost/system to 1.80.0
Diffstat (limited to 'contrib/restricted/boost/system/include')
6 files changed, 215 insertions, 113 deletions
diff --git a/contrib/restricted/boost/system/include/boost/system/detail/config.hpp b/contrib/restricted/boost/system/include/boost/system/detail/config.hpp index 26e0a4cae8..ad958bcabe 100644 --- a/contrib/restricted/boost/system/include/boost/system/detail/config.hpp +++ b/contrib/restricted/boost/system/include/boost/system/detail/config.hpp @@ -13,7 +13,7 @@ // BOOST_SYSTEM_HAS_SYSTEM_ERROR -#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC) +#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC) && !defined(BOOST_NO_CXX11_HDR_MUTEX) # define BOOST_SYSTEM_HAS_SYSTEM_ERROR #endif diff --git a/contrib/restricted/boost/system/include/boost/system/detail/error_category.hpp b/contrib/restricted/boost/system/include/boost/system/detail/error_category.hpp index a205d81cab..6185423eda 100644 --- a/contrib/restricted/boost/system/include/boost/system/detail/error_category.hpp +++ b/contrib/restricted/boost/system/include/boost/system/detail/error_category.hpp @@ -48,6 +48,11 @@ class std_category; #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable: 4351) // new behavior: elements of array will be default initialized +#endif + class BOOST_SYMBOL_VISIBLE error_category { private: @@ -76,13 +81,21 @@ private: boost::ulong_long_type id_; + static std::size_t const stdcat_size_ = 4 * sizeof( void const* ); + + union + { + mutable unsigned char stdcat_[ stdcat_size_ ]; + void const* stdcat_align_; + }; + #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) - mutable std::atomic< boost::system::detail::std_category* > ps_; + mutable std::atomic< unsigned > sc_init_; #else - boost::system::detail::std_category* ps_; + unsigned sc_init_; #endif @@ -103,11 +116,11 @@ protected: #endif - BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), ps_() + BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), stdcat_(), sc_init_() { } - explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), ps_() + explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), stdcat_(), sc_init_() { } @@ -158,14 +171,22 @@ public: } #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + + void init_stdcat() const; + # if defined(__SUNPRO_CC) // trailing __global is not supported operator std::error_category const & () const; # else operator std::error_category const & () const BOOST_SYMBOL_VISIBLE; # endif + #endif }; +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG ) #pragma GCC diagnostic pop #endif diff --git a/contrib/restricted/boost/system/include/boost/system/detail/error_category_impl.hpp b/contrib/restricted/boost/system/include/boost/system/detail/error_category_impl.hpp index e37d4ba6a6..982c667b3f 100644 --- a/contrib/restricted/boost/system/include/boost/system/detail/error_category_impl.hpp +++ b/contrib/restricted/boost/system/include/boost/system/detail/error_category_impl.hpp @@ -97,26 +97,66 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) -#include <boost/system/detail/std_category.hpp> +#include <boost/system/detail/std_category_impl.hpp> +#include <mutex> +#include <new> namespace boost { namespace system { -inline error_category::operator std::error_category const & () const +namespace detail +{ + +template<class = void> struct stdcat_mx_holder +{ + static std::mutex mx_; +}; + +template<class T> std::mutex stdcat_mx_holder<T>::mx_; + +} // namespace detail + +inline void error_category::init_stdcat() const +{ + static_assert( sizeof( stdcat_ ) >= sizeof( boost::system::detail::std_category ), "sizeof(stdcat_) is not enough for std_category" ); + +#if defined(BOOST_MSVC) && BOOST_MSVC < 1900 + // no alignof +#else + + static_assert( alignof( decltype(stdcat_align_) ) >= alignof( boost::system::detail::std_category ), "alignof(stdcat_) is not enough for std_category" ); + +#endif + + std::lock_guard<std::mutex> lk( boost::system::detail::stdcat_mx_holder<>::mx_ ); + + if( sc_init_.load( std::memory_order_acquire ) == 0 ) + { + ::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, 0 ); + sc_init_.store( 1, std::memory_order_release ); + } +} + +#if defined( BOOST_GCC ) && BOOST_GCC >= 40800 && BOOST_GCC < 70000 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif + +inline BOOST_NOINLINE error_category::operator std::error_category const & () const { if( id_ == detail::generic_category_id ) { // This condition must be the same as the one in error_condition.hpp #if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY) - static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 ); - return generic_instance; + static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 ); + return generic_instance; #else - return std::generic_category(); + return std::generic_category(); #endif } @@ -126,36 +166,28 @@ inline error_category::operator std::error_category const & () const // This condition must be the same as the one in error_code.hpp #if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY) - static const boost::system::detail::std_category system_instance( this, 0x1F4D7 ); - return system_instance; + static const boost::system::detail::std_category system_instance( this, 0x1F4D7 ); + return system_instance; #else - return std::system_category(); + return std::system_category(); #endif } - detail::std_category* p = ps_.load( std::memory_order_acquire ); - - if( p != 0 ) + if( sc_init_.load( std::memory_order_acquire ) == 0 ) { - return *p; + init_stdcat(); } - detail::std_category* q = new detail::std_category( this, 0 ); - - if( ps_.compare_exchange_strong( p, q, std::memory_order_release, std::memory_order_acquire ) ) - { - return *q; - } - else - { - delete q; - return *p; - } + return *static_cast<boost::system::detail::std_category const*>( static_cast<void const*>( stdcat_ ) ); } +#if defined( BOOST_GCC ) && BOOST_GCC >= 40800 && BOOST_GCC < 70000 +#pragma GCC diagnostic pop +#endif + } // namespace system } // namespace boost diff --git a/contrib/restricted/boost/system/include/boost/system/detail/error_code.hpp b/contrib/restricted/boost/system/include/boost/system/detail/error_code.hpp index 587b3abddf..584b4b3487 100644 --- a/contrib/restricted/boost/system/include/boost/system/detail/error_code.hpp +++ b/contrib/restricted/boost/system/include/boost/system/detail/error_code.hpp @@ -21,6 +21,11 @@ #include <boost/system/detail/append_int.hpp> #include <boost/system/detail/snprintf.hpp> #include <boost/system/detail/config.hpp> + +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) +# include <boost/system/detail/std_category.hpp> +#endif + #include <boost/assert/source_location.hpp> #include <boost/cstdint.hpp> #include <boost/config.hpp> @@ -139,28 +144,35 @@ public: *this = make_error_code( e ); } - template<class ErrorCodeEnum> error_code( ErrorCodeEnum e, source_location const * loc, - typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT: + error_code( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT: d1_(), lc_flags_( 0 ) { - error_code e2 = make_error_code( e ); + *this = ec; - if( e2.lc_flags_ == 0 || e2.lc_flags_ == 1 ) - { - *this = e2; - } - else + if( ec.lc_flags_ != 0 && ec.lc_flags_ != 1 ) { - *this = error_code( e2.d1_.val_, *e2.d1_.cat_, loc ); + lc_flags_ = ( loc? reinterpret_cast<boost::uintptr_t>( loc ): 2 ) | ( ec.lc_flags_ & 1 ); } } #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) error_code( std::error_code const& ec ) BOOST_NOEXCEPT: - lc_flags_( 1 ) + d1_(), lc_flags_( 0 ) { - ::new( d2_ ) std::error_code( ec ); +#ifndef BOOST_NO_RTTI + + if( detail::std_category const* pc2 = dynamic_cast< detail::std_category const* >( &ec.category() ) ) + { + *this = boost::system::error_code( ec.value(), pc2->original_category() ); + } + else + +#endif + { + ::new( d2_ ) std::error_code( ec ); + lc_flags_ = 1; + } } #endif @@ -177,6 +189,11 @@ public: *this = error_code( val, cat, loc ); } + void assign( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT + { + *this = error_code( ec, loc ); + } + template<typename ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type & operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT @@ -185,13 +202,6 @@ public: return *this; } - template<typename ErrorCodeEnum> - typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, void>::type - assign( ErrorCodeEnum val, source_location const * loc ) BOOST_NOEXCEPT - { - *this = error_code( val, loc ); - } - BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT { *this = error_code(); diff --git a/contrib/restricted/boost/system/include/boost/system/detail/std_category.hpp b/contrib/restricted/boost/system/include/boost/system/detail/std_category.hpp index e8f70e13b2..2b98aa7b20 100644 --- a/contrib/restricted/boost/system/include/boost/system/detail/std_category.hpp +++ b/contrib/restricted/boost/system/include/boost/system/detail/std_category.hpp @@ -11,9 +11,6 @@ // See library home page at http://www.boost.org/libs/system #include <boost/system/detail/error_category.hpp> -#include <boost/system/detail/error_condition.hpp> -#include <boost/system/detail/error_code.hpp> -#include <boost/system/detail/generic_category.hpp> #include <system_error> // @@ -35,6 +32,13 @@ private: public: + boost::system::error_category const & original_category() const BOOST_NOEXCEPT + { + return *pc_; + } + +public: + explicit std_category( boost::system::error_category const * pc, unsigned id ): pc_( pc ) { if( id != 0 ) @@ -66,72 +70,10 @@ public: return pc_->default_error_condition( ev ); } - bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE; - bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE; + inline bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE; + inline bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE; }; -inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT -{ - if( condition.category() == *this ) - { - boost::system::error_condition bn( condition.value(), *pc_ ); - return pc_->equivalent( code, bn ); - } - else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) - { - boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); - return pc_->equivalent( code, bn ); - } - -#ifndef BOOST_NO_RTTI - - else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) ) - { - boost::system::error_condition bn( condition.value(), *pc2->pc_ ); - return pc_->equivalent( code, bn ); - } - -#endif - - else - { - return default_error_condition( code ) == condition; - } -} - -inline bool std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT -{ - if( code.category() == *this ) - { - boost::system::error_code bc( code.value(), *pc_ ); - return pc_->equivalent( bc, condition ); - } - else if( code.category() == std::generic_category() || code.category() == boost::system::generic_category() ) - { - boost::system::error_code bc( code.value(), boost::system::generic_category() ); - return pc_->equivalent( bc, condition ); - } - -#ifndef BOOST_NO_RTTI - - else if( std_category const* pc2 = dynamic_cast< std_category const* >( &code.category() ) ) - { - boost::system::error_code bc( code.value(), *pc2->pc_ ); - return pc_->equivalent( bc, condition ); - } - -#endif - - else if( *pc_ == boost::system::generic_category() ) - { - return std::generic_category().equivalent( code, condition ); - } - else - { - return false; - } -} - } // namespace detail } // namespace system diff --git a/contrib/restricted/boost/system/include/boost/system/detail/std_category_impl.hpp b/contrib/restricted/boost/system/include/boost/system/detail/std_category_impl.hpp new file mode 100644 index 0000000000..9dee5e7980 --- /dev/null +++ b/contrib/restricted/boost/system/include/boost/system/detail/std_category_impl.hpp @@ -0,0 +1,97 @@ +#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED +#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED + +// Support for interoperability between Boost.System and <system_error> +// +// Copyright 2018, 2021 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See library home page at http://www.boost.org/libs/system + +#include <boost/system/detail/std_category.hpp> +#include <boost/system/detail/error_condition.hpp> +#include <boost/system/detail/error_code.hpp> +#include <boost/system/detail/generic_category.hpp> + +// + +namespace boost +{ + +namespace system +{ + +namespace detail +{ + +inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT +{ + if( condition.category() == *this ) + { + boost::system::error_condition bn( condition.value(), *pc_ ); + return pc_->equivalent( code, bn ); + } + else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) + { + boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); + return pc_->equivalent( code, bn ); + } + +#ifndef BOOST_NO_RTTI + + else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) ) + { + boost::system::error_condition bn( condition.value(), *pc2->pc_ ); + return pc_->equivalent( code, bn ); + } + +#endif + + else + { + return default_error_condition( code ) == condition; + } +} + +inline bool std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT +{ + if( code.category() == *this ) + { + boost::system::error_code bc( code.value(), *pc_ ); + return pc_->equivalent( bc, condition ); + } + else if( code.category() == std::generic_category() || code.category() == boost::system::generic_category() ) + { + boost::system::error_code bc( code.value(), boost::system::generic_category() ); + return pc_->equivalent( bc, condition ); + } + +#ifndef BOOST_NO_RTTI + + else if( std_category const* pc2 = dynamic_cast< std_category const* >( &code.category() ) ) + { + boost::system::error_code bc( code.value(), *pc2->pc_ ); + return pc_->equivalent( bc, condition ); + } + +#endif + + else if( *pc_ == boost::system::generic_category() ) + { + return std::generic_category().equivalent( code, condition ); + } + else + { + return false; + } +} + +} // namespace detail + +} // namespace system + +} // namespace boost + +#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED |