Skip to content

Commit

Permalink
Update contrib/restricted/boost/system to 1.82.0
Browse files Browse the repository at this point in the history
  • Loading branch information
georgthegreat committed May 10, 2023
1 parent 2a79bc7 commit 0bd2968
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//
// See http://www.boost.org/libs/system for documentation.

#include <boost/system/detail/requires_cxx11.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>

Expand Down Expand Up @@ -64,7 +65,9 @@

// BOOST_SYSTEM_CLANG_6

#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11))
// Android NDK r18b has Clang 7.0.2 that still needs the workaround
// https://github.com/boostorg/system/issues/100
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11) || (defined(__ANDROID__) && __clang_major__ == 7))
# define BOOST_SYSTEM_CLANG_6
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/system/detail/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <string>
#include <functional>
#include <cstddef>
Expand Down Expand Up @@ -116,11 +117,18 @@ class BOOST_SYMBOL_VISIBLE error_category

#endif

BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), stdcat_(), sc_init_()
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
BOOST_CONSTEXPR
#endif
error_category() BOOST_NOEXCEPT: id_( 0 ), stdcat_(), sc_init_()
{
}

explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), stdcat_(), sc_init_()
explicit
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
BOOST_CONSTEXPR
#endif
error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), stdcat_(), sc_init_()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,14 @@ 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_impl.hpp>
#include <boost/system/detail/mutex.hpp>
#include <new>

#if !defined(BOOST_SYSTEM_DISABLE_THREADS)
# include <mutex>
#endif

namespace boost
{
namespace system
{

#if !defined(BOOST_SYSTEM_DISABLE_THREADS)

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

#endif

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" );
Expand All @@ -137,13 +118,17 @@ inline void error_category::init_stdcat() const

#endif

#if !defined(BOOST_SYSTEM_DISABLE_THREADS)
std::lock_guard<std::mutex> lk( boost::system::detail::stdcat_mx_holder<>::mx_ );
#endif
// detail::mutex has a constexpr default constructor,
// and therefore guarantees static initialization, on
// everything except VS 2013 (msvc-12.0)

static system::detail::mutex mx_;

system::detail::lock_guard<system::detail::mutex> lk( mx_ );

if( sc_init_.load( std::memory_order_acquire ) == 0 )
{
::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, 0 );
::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, system::detail::id_wrapper<0>() );
sc_init_.store( 1, std::memory_order_release );
}
}
Expand All @@ -160,7 +145,7 @@ inline BOOST_NOINLINE error_category::operator std::error_category const & () co
// 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 );
static const boost::system::detail::std_category generic_instance( this, system::detail::id_wrapper<0x1F4D3>() );
return generic_instance;

#else
Expand All @@ -175,7 +160,7 @@ inline BOOST_NOINLINE error_category::operator std::error_category const & () co
// 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 );
static const boost::system::detail::std_category system_instance( this, system::detail::id_wrapper<0x1F4D7>() );
return system_instance;

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,12 @@ class error_code
{
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)

if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
bool s1 = lhs.lc_flags_ == 1;
bool s2 = rhs.lc_flags_ == 1;

if( s1 != s2 ) return false;

if( s1 && s2 )
{
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
Expand All @@ -421,7 +426,13 @@ class error_code
{
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)

if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
bool s1 = lhs.lc_flags_ == 1;
bool s2 = rhs.lc_flags_ == 1;

if( s1 < s2 ) return true;
if( s2 < s1 ) return false;

if( s1 && s2 )
{
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
Expand Down
110 changes: 110 additions & 0 deletions contrib/restricted/boost/system/include/boost/system/detail/mutex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED

// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)

#include <boost/config.hpp>

#if defined(BOOST_SYSTEM_DISABLE_THREADS)

namespace boost
{
namespace system
{
namespace detail
{

struct mutex
{
void lock()
{
}

void unlock()
{
}
};

} // namespace detail
} // namespace system
} // namespace boost

#elif defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140

// Under the MS STL, std::mutex::mutex() is not constexpr, as is
// required by the standard, which leads to initialization order
// issues. However, shared_mutex is based on SRWLock and its
// default constructor is constexpr, so we use that instead.

#include <shared_mutex>

namespace boost
{
namespace system
{
namespace detail
{

typedef std::shared_mutex mutex;

} // namespace detail
} // namespace system
} // namespace boost

#else

#include <mutex>

namespace boost
{
namespace system
{
namespace detail
{

using std::mutex;

} // namespace detail
} // namespace system
} // namespace boost

#endif

namespace boost
{
namespace system
{
namespace detail
{

template<class Mtx> class lock_guard
{
private:

Mtx& mtx_;

private:

lock_guard( lock_guard const& );
lock_guard& operator=( lock_guard const& );

public:

explicit lock_guard( Mtx& mtx ): mtx_( mtx )
{
mtx_.lock();
}

~lock_guard()
{
mtx_.unlock();
}
};

} // namespace detail
} // namespace system
} // namespace boost

#endif // #ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED

// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>

#if defined(BOOST_NO_CXX11_CONSTEXPR) || \
defined(BOOST_NO_CXX11_NOEXCEPT) || \
defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || \
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)

BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.System 1.82 and will be removed in Boost.System 1.84.")

#endif

#endif // #ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See library home page at http://www.boost.org/libs/system

#include <boost/system/detail/error_category.hpp>
#include <boost/config.hpp>
#include <system_error>

//
Expand All @@ -24,6 +25,8 @@ namespace system
namespace detail
{

template<unsigned Id> struct id_wrapper {};

class BOOST_SYMBOL_VISIBLE std_category: public std::error_category
{
private:
Expand All @@ -39,20 +42,22 @@ class BOOST_SYMBOL_VISIBLE std_category: public std::error_category

public:

explicit std_category( boost::system::error_category const * pc, unsigned id ): pc_( pc )
template<unsigned Id>
explicit std_category( boost::system::error_category const * pc, id_wrapper<Id> ): pc_( pc )
{
if( id != 0 )
{
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000 && !defined(_LIBCPP_VERSION)
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000

// We used to assign to the protected _Addr member of std::error_category
// here when Id != 0, but this should never happen now because this code
// path is no longer used

// Poking into the protected _Addr member of std::error_category
// is not a particularly good programming practice, but what can
// you do
#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)

_Addr = id;
static_assert( Id == 0, "This constructor should only be called with Id == 0 under MS STL 14.0+" );

#endif

#endif
}
}

const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
case ERROR_ACCESS_DENIED_: return permission_denied;
case ERROR_ALREADY_EXISTS_: return file_exists;
case ERROR_BAD_NETPATH_: return no_such_file_or_directory;
case ERROR_BAD_NET_NAME_: return no_such_file_or_directory;
case ERROR_BAD_UNIT_: return no_such_device;
case ERROR_BROKEN_PIPE_: return broken_pipe;
case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
Expand All @@ -75,6 +76,7 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
case ERROR_DIR_NOT_EMPTY_: return directory_not_empty;
case ERROR_DIRECTORY_: return invalid_argument; // WinError.h: "The directory name is invalid"
case ERROR_DISK_FULL_: return no_space_on_device;
case ERROR_FILENAME_EXCED_RANGE_: return filename_too_long;
case ERROR_FILE_EXISTS_: return file_exists;
case ERROR_FILE_NOT_FOUND_: return no_such_file_or_directory;
case ERROR_HANDLE_DISK_FULL_: return no_space_on_device;
Expand All @@ -100,12 +102,16 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
case ERROR_REPARSE_TAG_INVALID_: return invalid_argument;
case ERROR_RETRY_: return resource_unavailable_try_again;
case ERROR_SEEK_: return io_error;
case ERROR_SEM_TIMEOUT_: return timed_out;
case ERROR_SHARING_VIOLATION_: return permission_denied;
case ERROR_NOT_SUPPORTED_: return not_supported; // WinError.h: "The request is not supported."
case ERROR_TIMEOUT_: return timed_out;
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
case ERROR_WRITE_FAULT_: return io_error;
case ERROR_WRITE_PROTECT_: return permission_denied;

case 258: return timed_out; // WAIT_TIMEOUT

case WSAEACCES_: return permission_denied;
case WSAEADDRINUSE_: return address_in_use;
case WSAEADDRNOTAVAIL_: return address_not_available;
Expand Down

0 comments on commit 0bd2968

Please sign in to comment.