-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
660 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,24 @@ | ||
// boost/system/api_config.hpp -------------------------------------------------------// | ||
#ifndef BOOST_SYSTEM_API_CONFIG_HPP_INCLUDED | ||
#define BOOST_SYSTEM_API_CONFIG_HPP_INCLUDED | ||
|
||
// Copyright Beman Dawes 2003, 2006, 2010 | ||
|
||
// Distributed under the Boost Software License, Version 1.0. | ||
// See http://www.boost.org/LICENSE_1_0.txt | ||
|
||
// See http://www.boost.org/libs/system for documentation. | ||
|
||
//--------------------------------------------------------------------------------------// | ||
|
||
// Boost.System calls operating system API functions to implement system error category | ||
// functions. Usually there is no question as to which API is to be used. | ||
// Copyright Beman Dawes 2003, 2006, 2010 | ||
// Copyright 2018 Peter Dimov | ||
// | ||
// In the case of MinGW or Cygwin/MinGW, however, both POSIX and Windows API's are | ||
// available. Chaos ensues if other code thinks one is in use when Boost.System was | ||
// actually built with the other. This header centralizes the API choice and prevents | ||
// user definition of API macros, thus elminating the possibility of mismatches and the | ||
// need to test configurations with little or no practical value. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// See http://www.boost.org/LICENSE_1_0.txt | ||
// | ||
// See http://www.boost.org/libs/system for documentation. | ||
|
||
//--------------------------------------------------------------------------------------// | ||
|
||
#ifndef BOOST_SYSTEM_API_CONFIG_HPP | ||
#define BOOST_SYSTEM_API_CONFIG_HPP | ||
|
||
# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API) | ||
# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported | ||
# endif | ||
// This header is no longer used by Boost.System. | ||
// Its use is discouraged and it will be deprecated. | ||
|
||
// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use | ||
// Cygwin/MinGW does not predefine _WIN32. | ||
// Standalone MinGW and all other known Windows compilers do predefine _WIN32 | ||
// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too. | ||
// Definition of BOOST_*_API retained for compatibility. | ||
|
||
# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin | ||
# define BOOST_WINDOWS_API | ||
#if defined(_WIN32) || defined(__CYGWIN__) | ||
// Windows default, including MinGW and Cygwin | ||
# define BOOST_WINDOWS_API | ||
# else | ||
# define BOOST_POSIX_API | ||
# endif | ||
# define BOOST_POSIX_API | ||
#endif | ||
|
||
#endif // BOOST_SYSTEM_API_CONFIG_HPP | ||
#endif // BOOST_SYSTEM_API_CONFIG_HPP_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#ifndef BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED | ||
#define BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED | ||
|
||
// Copyright 2018 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 http://www.boost.org/libs/system for documentation. | ||
|
||
#include <boost/config.hpp> | ||
|
||
// BOOST_SYSTEM_HAS_SYSTEM_ERROR | ||
|
||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) | ||
# define BOOST_SYSTEM_HAS_SYSTEM_ERROR | ||
#endif | ||
|
||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1700 | ||
// msvc-10.0 has no two-argument map::emplace | ||
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR | ||
#endif | ||
|
||
// BOOST_SYSTEM_NOEXCEPT | ||
// Retained for backward compatibility only | ||
|
||
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT | ||
|
||
// BOOST_SYSTEM_HAS_CONSTEXPR | ||
|
||
#if !defined(BOOST_NO_CXX14_CONSTEXPR) | ||
# define BOOST_SYSTEM_HAS_CONSTEXPR | ||
#endif | ||
|
||
#if defined(__GNUC__) && (__GNUC__ == 7 && __GNUC_MINOR__ < 4) && __cplusplus >= 201700L | ||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835 | ||
# undef BOOST_SYSTEM_HAS_CONSTEXPR | ||
#endif | ||
|
||
#if defined(__clang__) && defined(_MSC_VER) && defined(_CPPLIB_VER) | ||
// Clang on Windows with MSVC headers, the constructor of std::error_category | ||
// is not constexpr at least up to VS2017 15.7.x (_MSVC_STL_UPDATE 201803) | ||
# undef BOOST_SYSTEM_HAS_CONSTEXPR | ||
#endif | ||
|
||
#if defined(__clang__) && defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40900 | ||
// The constructor of std::error_category is not constexpr in libstdc++ 4.8 | ||
# undef BOOST_SYSTEM_HAS_CONSTEXPR | ||
#endif | ||
|
||
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR) | ||
# define BOOST_SYSTEM_CONSTEXPR constexpr | ||
#else | ||
# define BOOST_SYSTEM_CONSTEXPR | ||
#endif | ||
|
||
// BOOST_SYSTEM_REQUIRE_CONST_INIT | ||
|
||
#define BOOST_SYSTEM_REQUIRE_CONST_INIT | ||
|
||
#if defined(__has_cpp_attribute) | ||
#if __has_cpp_attribute(clang::require_constant_initialization) | ||
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT | ||
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]] | ||
#endif | ||
#endif | ||
|
||
// BOOST_SYSTEM_WIN32 | ||
|
||
#if defined( _WIN32 ) || defined( __CYGWIN__ ) | ||
# define BOOST_SYSTEM_WIN32 | ||
#endif | ||
|
||
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Support for interoperability between Boost.System and <system_error> | ||
// | ||
// Copyright 2018 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 <system_error> | ||
#include <map> | ||
|
||
// | ||
|
||
namespace boost | ||
{ | ||
|
||
namespace system | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
class std_category: public std::error_category | ||
{ | ||
private: | ||
|
||
boost::system::error_category const * pc_; | ||
|
||
public: | ||
|
||
std_category( boost::system::error_category const * pc ): pc_( pc ) | ||
{ | ||
} | ||
|
||
virtual const char * name() const BOOST_NOEXCEPT | ||
{ | ||
return pc_->name(); | ||
} | ||
|
||
virtual std::string message( int ev ) const | ||
{ | ||
return pc_->message( ev ); | ||
} | ||
|
||
virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT | ||
{ | ||
return pc_->default_error_condition( ev ); | ||
} | ||
|
||
virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT; | ||
virtual bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT; | ||
}; | ||
|
||
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) | ||
{ | ||
typedef std::map<boost::system::error_category const *, std_category> map_type; | ||
|
||
static map_type map_; | ||
|
||
std::pair<map_type::iterator, bool> p = map_.emplace( &cat, &cat ); | ||
|
||
return p.first->second; | ||
} | ||
|
||
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 |
Oops, something went wrong.