mirror of
https://github.com/boostorg/system.git
synced 2026-06-16 17:02:39 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9c26b9fa0 | |||
| 2e2430c4fa | |||
| 4b1caad727 | |||
| 5b96abbaa8 | |||
| 2e1c800d82 | |||
| 04a79d710f | |||
| 5700936367 | |||
| 86b031cab9 | |||
| 204e65f725 |
@@ -144,6 +144,10 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- toolset: msvc-14.0
|
||||||
|
cxxstd: "14"
|
||||||
|
addrmd: 32,64
|
||||||
|
os: windows-2019
|
||||||
- toolset: msvc-14.1
|
- toolset: msvc-14.1
|
||||||
cxxstd: "14,17,latest"
|
cxxstd: "14,17,latest"
|
||||||
addrmd: 32,64
|
addrmd: 32,64
|
||||||
|
|||||||
+1
-9
@@ -22,20 +22,12 @@ environment:
|
|||||||
ADDRMD: 32,64
|
ADDRMD: 32,64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
TOOLSET: msvc-14.1
|
TOOLSET: msvc-14.1
|
||||||
CXXSTD: 14,17
|
|
||||||
ADDRMD: 32,64
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
TOOLSET: clang-win
|
|
||||||
CXXSTD: 14,17
|
|
||||||
ADDRMD: 64
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
TOOLSET: msvc-14.2
|
|
||||||
CXXSTD: 14,17,latest
|
CXXSTD: 14,17,latest
|
||||||
ADDRMD: 32,64
|
ADDRMD: 32,64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
TOOLSET: clang-win
|
TOOLSET: clang-win
|
||||||
CXXSTD: 14,17,latest
|
CXXSTD: 14,17,latest
|
||||||
ADDRMD: 64
|
ADDRMD: 32,64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
ADDPATH: C:\cygwin\bin;
|
ADDPATH: C:\cygwin\bin;
|
||||||
TOOLSET: gcc
|
TOOLSET: gcc
|
||||||
|
|||||||
@@ -83,6 +83,28 @@ private:
|
|||||||
// >3: pointer to source_location, failed_ in lsb
|
// >3: pointer to source_location, failed_ in lsb
|
||||||
boost::uintptr_t lc_flags_;
|
boost::uintptr_t lc_flags_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
char const* category_name() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
// return category().name();
|
||||||
|
|
||||||
|
if( lc_flags_ == 0 )
|
||||||
|
{
|
||||||
|
// must match detail::system_error_category::name()
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
else if( lc_flags_ == 1 )
|
||||||
|
{
|
||||||
|
// must match detail::interop_error_category::name()
|
||||||
|
return "std:unknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return d1_.cat_->name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// constructors:
|
// constructors:
|
||||||
@@ -188,7 +210,11 @@ public:
|
|||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||||
return ec.value() + 1000 * static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
|
||||||
|
unsigned cv = static_cast<unsigned>( ec.value() );
|
||||||
|
unsigned ch = static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
||||||
|
|
||||||
|
return static_cast<int>( cv + 1000 * ch );
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@@ -230,7 +256,14 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return category().message( value() );
|
if( lc_flags_ == 0 )
|
||||||
|
{
|
||||||
|
return detail::system_error_category_message( value() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return category().message( value() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
@@ -238,23 +271,33 @@ public:
|
|||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
if( lc_flags_ == 1 )
|
if( lc_flags_ == 1 )
|
||||||
{
|
{
|
||||||
|
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||||
|
|
||||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||||
try
|
try
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
|
||||||
detail::snprintf( buffer, len, "%s", ec.message().c_str() );
|
detail::snprintf( buffer, len, "%s", ec.message().c_str() );
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
|
detail::snprintf( buffer, len, "No message text available for error std:%s:%d", ec.category().name(), ec.value() );
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return category().message( value(), buffer, len );
|
if( lc_flags_ == 0 )
|
||||||
|
{
|
||||||
|
return detail::system_error_category_message( value(), buffer, len );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return category().message( value(), buffer, len );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||||
@@ -594,7 +637,7 @@ public:
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::string r = category().name();
|
std::string r = category_name();
|
||||||
detail::append_int( r, value() );
|
detail::append_int( r, value() );
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -604,7 +647,7 @@ public:
|
|||||||
inline friend std::basic_ostream<Ch, Tr>&
|
inline friend std::basic_ostream<Ch, Tr>&
|
||||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||||
{
|
{
|
||||||
return os << ec.to_string();
|
return os << ec.to_string().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string what() const
|
std::string what() const
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
#include <boost/system/detail/system_category.hpp>
|
#include <boost/system/detail/system_category.hpp>
|
||||||
|
#include <boost/system/detail/system_category_message.hpp>
|
||||||
#include <boost/system/detail/error_condition.hpp>
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
#include <boost/system/api_config.hpp>
|
#include <boost/system/api_config.hpp>
|
||||||
|
|
||||||
@@ -22,7 +23,6 @@
|
|||||||
|
|
||||||
#if defined(BOOST_WINDOWS_API)
|
#if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
#include <boost/system/detail/system_category_message_win32.hpp>
|
|
||||||
#include <boost/system/detail/system_category_condition_win32.hpp>
|
#include <boost/system/detail/system_category_condition_win32.hpp>
|
||||||
|
|
||||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
@@ -39,35 +39,23 @@ inline boost::system::error_condition boost::system::detail::system_error_catego
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
|
||||||
{
|
|
||||||
return system_category_message_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return system_category_message_win32( ev, buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // #if defined(BOOST_WINDOWS_API)
|
#else // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
#include <boost/system/detail/generic_category_message.hpp>
|
|
||||||
|
|
||||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return error_condition( boost::system::detail::generic_value_tag( ev ) );
|
return error_condition( boost::system::detail::generic_value_tag( ev ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||||
{
|
{
|
||||||
return generic_error_category_message( ev );
|
return system_error_category_message( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return generic_error_category_message( ev, buffer, len );
|
return system_error_category_message( ev, buffer, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(BOOST_WINDOWS_API)
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Implementation of system_error_category_message
|
||||||
|
//
|
||||||
|
// Copyright 2018, 2022 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/api_config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
||||||
|
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#include <boost/system/detail/system_category_message_win32.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
inline std::string system_error_category_message( int ev )
|
||||||
|
{
|
||||||
|
return system_category_message_win32( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return system_category_message_win32( ev, buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace system
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#else // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#include <boost/system/detail/generic_category_message.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
inline std::string system_error_category_message( int ev )
|
||||||
|
{
|
||||||
|
return generic_error_category_message( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return generic_error_category_message( ev, buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace system
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
@@ -10,13 +10,6 @@
|
|||||||
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||||
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||||
|
|
||||||
#include <boost/config/pragma_message.hpp>
|
|
||||||
|
|
||||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
|
||||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
|
||||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This header is effectively empty for compiles on operating systems where
|
// This header is effectively empty for compiles on operating systems where
|
||||||
// it is not applicable.
|
// it is not applicable.
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ boost_test(TYPE run SOURCES system_error_test3.cpp)
|
|||||||
|
|
||||||
boost_test(TYPE run SOURCES std_interop_test11.cpp)
|
boost_test(TYPE run SOURCES std_interop_test11.cpp)
|
||||||
|
|
||||||
|
boost_test(TYPE run SOURCES ec_wstream_test.cpp)
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ run system_error_test3.cpp ;
|
|||||||
|
|
||||||
run std_interop_test11.cpp ;
|
run std_interop_test11.cpp ;
|
||||||
|
|
||||||
|
run ec_wstream_test.cpp ;
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
import ../../config/checks/config : requires ;
|
import ../../config/checks/config : requires ;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2022 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::wostringstream os;
|
||||||
|
os << sys::error_code();
|
||||||
|
|
||||||
|
BOOST_TEST( os.str() == L"system:0" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user