From 1f67456bcfd10a6a17c87f5626787291ad717652 Mon Sep 17 00:00:00 2001 From: Marek Kurdej Date: Fri, 23 Oct 2015 11:54:17 +0200 Subject: [PATCH 01/30] Use `BOOST_NOEXCEPT_OR_NOTHROW` instead of `throw()` to avoid -Wdeprecated warning on clang (3.5+). --- include/boost/system/system_error.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/system/system_error.hpp b/include/boost/system/system_error.hpp index b306aae..797bea5 100644 --- a/include/boost/system/system_error.hpp +++ b/include/boost/system/system_error.hpp @@ -44,10 +44,10 @@ namespace boost const char * what_arg ) : std::runtime_error(what_arg), m_error_code(ev,ecat) {} - virtual ~system_error() throw() {} + virtual ~system_error() BOOST_NOEXCEPT_OR_NOTHROW {} - const error_code & code() const throw() { return m_error_code; } - const char * what() const throw(); + const error_code & code() const BOOST_NOEXCEPT_OR_NOTHROW { return m_error_code; } + const char * what() const BOOST_NOEXCEPT_OR_NOTHROW; private: error_code m_error_code; @@ -56,7 +56,7 @@ namespace boost // implementation ------------------------------------------------------// - inline const char * system_error::what() const throw() + inline const char * system_error::what() const BOOST_NOEXCEPT_OR_NOTHROW // see http://www.boost.org/more/error_handling.html for lazy build rationale { if ( m_what.empty() ) From a4120cdf1d36333c4ec9e043eec1dda7aa406629 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 2 Apr 2017 08:01:19 -0400 Subject: [PATCH 02/30] Upgrade to Visual Studio 2017 --- test/msvc/config_test/config_test.vcxproj | 6 ++--- .../error_code_test/error_code_test.vcxproj | 6 ++--- .../header_only_test/header_only_test.vcxproj | 6 ++--- test/msvc/system-dll/system-dll.vcxproj | 7 +++--- test/msvc/system.sln | 24 +++++++++++++++++-- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/test/msvc/config_test/config_test.vcxproj b/test/msvc/config_test/config_test.vcxproj index 396f312..484ad8d 100644 --- a/test/msvc/config_test/config_test.vcxproj +++ b/test/msvc/config_test/config_test.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode diff --git a/test/msvc/error_code_test/error_code_test.vcxproj b/test/msvc/error_code_test/error_code_test.vcxproj index 12c91cd..2edf1bf 100644 --- a/test/msvc/error_code_test/error_code_test.vcxproj +++ b/test/msvc/error_code_test/error_code_test.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode diff --git a/test/msvc/header_only_test/header_only_test.vcxproj b/test/msvc/header_only_test/header_only_test.vcxproj index 199b23e..5dd9e29 100644 --- a/test/msvc/header_only_test/header_only_test.vcxproj +++ b/test/msvc/header_only_test/header_only_test.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode diff --git a/test/msvc/system-dll/system-dll.vcxproj b/test/msvc/system-dll/system-dll.vcxproj index aca6f00..cd7174d 100644 --- a/test/msvc/system-dll/system-dll.vcxproj +++ b/test/msvc/system-dll/system-dll.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ DynamicLibrary true - v140 + v141 Unicode DynamicLibrary false - v140 + v141 true Unicode @@ -54,6 +54,7 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEMDLL_EXPORTS;%(PreprocessorDefinitions) + stdcpplatest Windows diff --git a/test/msvc/system.sln b/test/msvc/system.sln index b544fb0..f5b0094 100644 --- a/test/msvc/system.sln +++ b/test/msvc/system.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.30626.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system-dll", "system-dll\system-dll.vcxproj", "{419402D4-F990-4B05-A459-655E2DC33DC2}" EndProject @@ -11,28 +11,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "header_only_test", "header_ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config_test", "config_test\config_test.vcxproj", "{E18C2B56-DCEC-438F-9C38-3C8B08B65247}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clang-system-dll", "clang-system-dll\clang-system-dll.vcxproj", "{30993F97-5E77-4B5A-B25F-B545C276077A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|Win32.ActiveCfg = Debug|Win32 {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|Win32.Build.0 = Debug|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|x64.ActiveCfg = Debug|Win32 {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|Win32.ActiveCfg = Release|Win32 {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|Win32.Build.0 = Release|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|x64.ActiveCfg = Release|Win32 {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|Win32.ActiveCfg = Debug|Win32 {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|Win32.Build.0 = Debug|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|x64.ActiveCfg = Debug|Win32 {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|Win32.ActiveCfg = Release|Win32 {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|Win32.Build.0 = Release|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|x64.ActiveCfg = Release|Win32 {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|Win32.ActiveCfg = Debug|Win32 {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|Win32.Build.0 = Debug|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|x64.ActiveCfg = Debug|Win32 {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|Win32.ActiveCfg = Release|Win32 {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|Win32.Build.0 = Release|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|x64.ActiveCfg = Release|Win32 {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|Win32.ActiveCfg = Debug|Win32 {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|Win32.Build.0 = Debug|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|x64.ActiveCfg = Debug|Win32 {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|Win32.ActiveCfg = Release|Win32 {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|Win32.Build.0 = Release|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|x64.ActiveCfg = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|Win32.ActiveCfg = Debug|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|Win32.Build.0 = Debug|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|x64.ActiveCfg = Debug|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|x64.Build.0 = Debug|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|Win32.ActiveCfg = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|Win32.Build.0 = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.ActiveCfg = Release|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From ebda81008e32aad8ec48dc31ad9bd70df6c669f8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 05:45:24 +0300 Subject: [PATCH 03/30] Add .travis.yml --- .travis.yml | 307 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b7165c0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,307 @@ +# Copyright 2016 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +os: + - linux + - osx + +branches: + only: + - master + - develop + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++03 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 + + - os: linux + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.6 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.6 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z + +install: + - cd .. + - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/system + - python tools/boostdep/depinst/depinst.py system + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + - ./b2 libs/system/test toolset=$TOOLSET + +notifications: + email: + on_success: always From 6010be4144ce126e79a7eee56f5b40eef8085b87 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 06:05:39 +0300 Subject: [PATCH 04/30] Add conversions to std:: counterparts when is available --- include/boost/system/error_code.hpp | 120 +++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 20 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 6ec444f..ed60c52 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -28,6 +28,10 @@ # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined #endif +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR +#include +#endif + #include // must be the last #include #ifndef BOOST_SYSTEM_NOEXCEPT @@ -181,10 +185,79 @@ namespace boost // ----------------------------------------------------------------------// + class error_category; + + // predefined error categories -----------------------------------------// + +#ifdef BOOST_ERROR_CODE_HEADER_ONLY + inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#else + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#endif + // deprecated synonyms --------------------------------------------------// + +#ifndef BOOST_SYSTEM_NO_DEPRECATED + inline const error_category & get_system_category() { return system_category(); } + inline const error_category & get_generic_category() { return generic_category(); } + inline const error_category & get_posix_category() { return generic_category(); } + static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category(); + static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category(); + static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category(); +#endif + // class error_category ------------------------------------------------// class error_category : public noncopyable { +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR + + private: + + class std_category: public std::error_category + { + private: + + boost::system::error_category const * pc_; + + public: + + explicit 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; + }; + + std_category std_cat_; + + public: + + error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {} + + operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT + { + if( this == &generic_category() ) + { + return std::generic_category(); + } + + return std_cat_; + } + +#endif + public: virtual ~error_category(){} @@ -204,26 +277,6 @@ namespace boost } }; - // predefined error categories -----------------------------------------// - -# ifdef BOOST_ERROR_CODE_HEADER_ONLY - inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; - inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; -#else - BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; - BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; -#endif - // deprecated synonyms --------------------------------------------------// - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - inline const error_category & get_system_category() { return system_category(); } - inline const error_category & get_generic_category() { return generic_category(); } - inline const error_category & get_posix_category() { return generic_category(); } - static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category(); -# endif - // class error_condition -----------------------------------------------// // error_conditions are portable, error_codes are system or library specific @@ -308,12 +361,30 @@ namespace boost || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); } +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR + + operator std::error_condition () const BOOST_SYSTEM_NOEXCEPT + { + return std::error_condition( value(), category() ); + } + +#endif + private: int m_val; const error_category * m_cat; }; +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR + + inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT + { + return pc_->default_error_condition( ev ); + } + +#endif + // class error_code ----------------------------------------------------// // We want error_code to be a value type that can be copied without slicing @@ -402,6 +473,15 @@ namespace boost || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); } +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR + + operator std::error_code () const BOOST_SYSTEM_NOEXCEPT + { + return std::error_code( value(), category() ); + } + +#endif + private: int m_val; const error_category * m_cat; From 044c0565b98e0ee7780e9e7588c66e672f6ef8ae Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 14:33:54 +0300 Subject: [PATCH 05/30] Add test for std interop; implement equivalent --- include/boost/system/error_code.hpp | 33 +++-- test/Jamfile.v2 | 6 + test/std_interop_test.cpp | 188 ++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 10 deletions(-) create mode 100644 test/std_interop_test.cpp diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index ed60c52..24404ba 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -238,6 +238,7 @@ namespace boost } virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT; + virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT; }; std_category std_cat_; @@ -248,7 +249,7 @@ namespace boost operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT { - if( this == &generic_category() ) + if( *this == generic_category() ) { return std::generic_category(); } @@ -376,15 +377,6 @@ namespace boost }; -#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR - - inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT - { - return pc_->default_error_condition( ev ); - } - -#endif - // class error_code ----------------------------------------------------// // We want error_code to be a value type that can be copied without slicing @@ -601,6 +593,27 @@ namespace boost return *this == code.category() && code.value() == condition; } +#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR + + inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT + { + return pc_->default_error_condition( ev ); + } + + inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT + { + if( condition.category() == std::generic_category() ) + { + return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) ); + } + else + { + return default_error_condition( code ) == condition; + } + } + +#endif + } // namespace system } // namespace boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c6008fc..4195bc8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -55,4 +55,10 @@ project [ run config_test.cpp : : : always_show_run_output ] + [ run std_interop_test.cpp + : : : static + ] + [ run std_interop_test.cpp + : : : shared : std_interop_test_shared + ] ; diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp new file mode 100644 index 0000000..3b7c637 --- /dev/null +++ b/test/std_interop_test.cpp @@ -0,0 +1,188 @@ + +// Copyright 2017 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 + +#if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) + +int main() {} + +#else + +#include +#include +#include +#include +#include + +static void test_generic_category() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + std::error_category const & st = bt; + + BOOST_TEST_EQ( &st, &std::generic_category() ); + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + int ev = ENOENT; + // BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); +} + +static void test_system_category() +{ + boost::system::error_category const & bt = boost::system::system_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + { + int ev = 5; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + int ev = 4; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } +} + +class user_category_impl: public boost::system::error_category +{ +public: + + virtual const char * name() const BOOST_NOEXCEPT + { + return "user"; + } + + virtual std::string message( int ev ) const + { + char buffer[ 256 ]; + sprintf( buffer, "user message %d", ev ); + + return buffer; + } + + virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT + { + if( ev == 4 ) + { + return boost::system::error_condition( EMFILE, boost::system::generic_category() ); + } + else if( ev == 5 ) + { + return boost::system::error_condition( EACCES, boost::system::generic_category() ); + } + else + { + return boost::system::error_condition( ev, *this ); + } + } + + virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT + { + if( code == 4 && condition == make_error_condition( boost::system::errc::too_many_files_open_in_system ) ) + { + return true; + } + + if( code == 4 && condition == make_error_condition( boost::system::errc::too_many_files_open ) ) + { + return true; + } + + return default_error_condition( code ) == condition; + } + + // virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT; +}; + +boost::system::error_category const & user_category() +{ + static user_category_impl cat_; + return cat_; +} + +static void test_user_category() +{ + boost::system::error_category const & bt = user_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + { + int ev = 5; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + int ev = 4; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + boost::system::error_condition bn = make_error_condition( boost::system::errc::too_many_files_open_in_system ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + boost::system::error_condition bn = make_error_condition( boost::system::errc::too_many_files_open ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + } +} + +int main() +{ + test_generic_category(); + test_system_category(); + test_user_category(); + + return boost::report_errors(); +} + +#endif From 96db439aef03e6db5c49911fe162d38377ea3c35 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 15:07:48 +0300 Subject: [PATCH 06/30] Test exact generic condition values --- test/std_interop_test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 3b7c637..961b320 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -37,8 +37,14 @@ static void test_generic_category() boost::system::error_condition bn = bt.default_error_condition( ev ); BOOST_TEST( bt.equivalent( ev, bn ) ); + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + std::error_condition sn( bn ); BOOST_TEST( st.equivalent( ev, sn ) ); + + BOOST_TEST_EQ( sn.value(), ev ); + BOOST_TEST_EQ( &sn.category(), &st ); } static void test_system_category() From b722a1ebdab5ccf8ce8d40346991f27060fa43a5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 15:53:02 +0300 Subject: [PATCH 07/30] Add a few more std interop tests --- test/std_interop_test.cpp | 117 +++++++++++++++++++++++++++++++------- 1 file changed, 97 insertions(+), 20 deletions(-) diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 961b320..e51b8be 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -34,17 +34,40 @@ static void test_generic_category() int ev = ENOENT; // BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); - boost::system::error_condition bn = bt.default_error_condition( ev ); - BOOST_TEST( bt.equivalent( ev, bn ) ); + { + boost::system::error_code bc( ev, bt ); - BOOST_TEST_EQ( bn.value(), ev ); - BOOST_TEST_EQ( &bn.category(), &bt ); + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); - std::error_condition sn( bn ); - BOOST_TEST( st.equivalent( ev, sn ) ); + std::error_code sc( bc ); - BOOST_TEST_EQ( sn.value(), ev ); - BOOST_TEST_EQ( &sn.category(), &st ); + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + + BOOST_TEST_EQ( sn.value(), ev ); + BOOST_TEST_EQ( &sn.category(), &st ); + + BOOST_TEST( st.equivalent( ev, sn ) ); + + std::error_condition sn2 = st.default_error_condition( ev ); + + BOOST_TEST_EQ( sn2.value(), ev ); + BOOST_TEST_EQ( &sn2.category(), &st ); + + BOOST_TEST( st.equivalent( ev, sn2 ) ); + } } static void test_system_category() @@ -58,22 +81,50 @@ static void test_system_category() int ev = 5; BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); - boost::system::error_condition bn = bt.default_error_condition( ev ); - BOOST_TEST( bt.equivalent( ev, bn ) ); + { + boost::system::error_code bc( ev, bt ); - std::error_condition sn( bn ); - BOOST_TEST( st.equivalent( ev, sn ) ); + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } } { int ev = 4; BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); - boost::system::error_condition bn = bt.default_error_condition( ev ); - BOOST_TEST( bt.equivalent( ev, bn ) ); + { + boost::system::error_code bc( ev, bt ); - std::error_condition sn( bn ); - BOOST_TEST( st.equivalent( ev, sn ) ); + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } } } @@ -145,17 +196,43 @@ static void test_user_category() int ev = 5; BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); - boost::system::error_condition bn = bt.default_error_condition( ev ); - BOOST_TEST( bt.equivalent( ev, bn ) ); + { + boost::system::error_code bc( ev, bt ); - std::error_condition sn( bn ); - BOOST_TEST( st.equivalent( ev, sn ) ); + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } } { int ev = 4; BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + { boost::system::error_condition bn = bt.default_error_condition( ev ); BOOST_TEST( bt.equivalent( ev, bn ) ); From 2d18f6680027a8be1a3ebca12e4dc107c91609af Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 18:43:31 +0300 Subject: [PATCH 08/30] Try to fix g++ 4.x issue with generic_category --- include/boost/system/error_code.hpp | 13 ++++++++++++- test/std_interop_test.cpp | 28 +++++++++++++++++----------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 24404ba..94ef8e2 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -251,7 +251,18 @@ namespace boost { if( *this == generic_category() ) { - return std::generic_category(); + std::error_category const & st = std::generic_category(); + + int ev = ENOENT; + + // if the standard generic category works, use it; else not + if( st.equivalent( ev, st.default_error_condition( ev ) ) ) + { + // g++ 4.x with libstdc++ 5 installed fails, because the two + // generic categories, v1 and v2, get mixed up + + return st; + } } return std_cat_; diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index e51b8be..4820ee6 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -24,15 +24,28 @@ int main() {} static void test_generic_category() { + int ev = ENOENT; + + // check whether the standard generic category works + + std::error_category const & st0 = std::generic_category(); + bool has_roundtrip = st0.equivalent( ev, st0.default_error_condition( ev ) ); + + // + boost::system::error_category const & bt = boost::system::generic_category(); std::error_category const & st = bt; - BOOST_TEST_EQ( &st, &std::generic_category() ); - BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); - int ev = ENOENT; - // BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + if( has_roundtrip ) + { + BOOST_TEST_EQ( &st, &std::generic_category() ); + } + else + { + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + } { boost::system::error_code bc( ev, bt ); @@ -60,13 +73,6 @@ static void test_generic_category() BOOST_TEST_EQ( &sn.category(), &st ); BOOST_TEST( st.equivalent( ev, sn ) ); - - std::error_condition sn2 = st.default_error_condition( ev ); - - BOOST_TEST_EQ( sn2.value(), ev ); - BOOST_TEST_EQ( &sn2.category(), &st ); - - BOOST_TEST( st.equivalent( ev, sn2 ) ); } } From c4238c745c215d0f59bd8ae699321ec31cd56ab7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 18:59:15 +0300 Subject: [PATCH 09/30] Add second overload of equivalent, improve first --- include/boost/system/error_code.hpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 94ef8e2..544dcbf 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -239,6 +239,7 @@ namespace boost virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT; 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; }; std_category std_cat_; @@ -613,13 +614,34 @@ namespace boost inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT { - if( condition.category() == std::generic_category() ) + if( default_error_condition( code ) == condition ) + { + return true; + } + else if( condition.category() == std::generic_category() ) { return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) ); } else { - return default_error_condition( code ) == condition; + return false; + } + } + + inline bool error_category::std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT + { + if( *this == code.category() && code.value() == condition ) + { + return true; + } + else if( *pc_ == boost::system::generic_category() ) + { + std::error_category const & st = std::generic_category(); + return st.equivalent( code, condition ); + } + else + { + return false; } } From bdd1613898d64a3d7a7d3e804253760cb4b13d7f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 May 2017 19:33:03 +0300 Subject: [PATCH 10/30] Do not map system::generic to std::generic directly --- include/boost/system/error_code.hpp | 21 ++++----------------- test/std_interop_test.cpp | 20 +++----------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 544dcbf..81c979b 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -250,22 +250,9 @@ namespace boost operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT { - if( *this == generic_category() ) - { - std::error_category const & st = std::generic_category(); - - int ev = ENOENT; - - // if the standard generic category works, use it; else not - if( st.equivalent( ev, st.default_error_condition( ev ) ) ) - { - // g++ 4.x with libstdc++ 5 installed fails, because the two - // generic categories, v1 and v2, get mixed up - - return st; - } - } - + // do not map generic to std::generic on purpose; occasionally, + // there are two std::generic categories in a program, which leads + // to error codes/conditions mysteriously not being equal to themselves return std_cat_; } @@ -618,7 +605,7 @@ namespace boost { return true; } - else if( condition.category() == std::generic_category() ) + else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) { return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) ); } diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 4820ee6..5ee69a8 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -24,28 +24,14 @@ int main() {} static void test_generic_category() { - int ev = ENOENT; - - // check whether the standard generic category works - - std::error_category const & st0 = std::generic_category(); - bool has_roundtrip = st0.equivalent( ev, st0.default_error_condition( ev ) ); - - // - boost::system::error_category const & bt = boost::system::generic_category(); std::error_category const & st = bt; BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); - if( has_roundtrip ) - { - BOOST_TEST_EQ( &st, &std::generic_category() ); - } - else - { - BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); - } + int ev = ENOENT; + + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); { boost::system::error_code bc( ev, bt ); From 02262a40484e209801ad5fe4d7f517649d9de690 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 May 2017 01:25:09 +0300 Subject: [PATCH 11/30] Test a user-defined error condition category; improve equivalent --- include/boost/system/error_code.hpp | 19 ++++-- test/std_interop_test.cpp | 94 +++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 81c979b..70a41cd 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -607,8 +607,20 @@ namespace boost } else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) { - return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) ); + boost::system::error_code bc( code, *pc_ ); + boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); + + return bc == bn; } +#ifndef BOOST_NO_RTTI + else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) ) + { + boost::system::error_code bc( code, *pc_ ); + boost::system::error_condition bn( condition.value(), *pc2->pc_ ); + + return bc == bn; + } +#endif else { return false; @@ -623,8 +635,7 @@ namespace boost } else if( *pc_ == boost::system::generic_category() ) { - std::error_category const & st = std::generic_category(); - return st.equivalent( code, condition ); + return code == std::error_condition( condition, std::generic_category() ); } else { @@ -644,5 +655,3 @@ namespace boost # endif #endif // BOOST_SYSTEM_ERROR_CODE_HPP - - diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 5ee69a8..6b9c77d 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -120,6 +120,8 @@ static void test_system_category() } } +// test_user_category + class user_category_impl: public boost::system::error_category { public: @@ -251,11 +253,103 @@ static void test_user_category() } } +// test_user2_category + +enum user2_errc +{ + my_enoent = 1, + my_einval, + my_other +}; + +class user2_category_impl: public boost::system::error_category +{ +public: + + virtual const char * name() const BOOST_NOEXCEPT + { + return "user2"; + } + + virtual std::string message( int ev ) const + { + char buffer[ 256 ]; + sprintf( buffer, "user2 message %d", ev ); + + return buffer; + } + + virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT + { + return boost::system::error_condition( ev, *this ); + } + + virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT + { + return default_error_condition( code ) == condition; + } + + virtual bool equivalent( const boost::system::error_code & code, int condition ) const BOOST_NOEXCEPT + { + if( code.category() == *this ) + { + return condition == code.value(); + } + else if( condition == my_enoent ) + { + return code == boost::system::errc::no_such_file_or_directory; + } + else if( condition == my_einval ) + { + return code == boost::system::errc::invalid_argument; + } + else + { + return false; + } + } +}; + +boost::system::error_category const & user2_category() +{ + static user2_category_impl cat_; + return cat_; +} + +static void test_user2_category() +{ + boost::system::error_category const & bt = user2_category(); + std::error_category const & st = bt; + + int ev = my_enoent; + + boost::system::error_condition bn( ev, bt ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + boost::system::error_code bc = make_error_code( boost::system::errc::no_such_file_or_directory ); + + BOOST_TEST( bc == bn ); + + std::error_condition sn( bn ); + + BOOST_TEST_EQ( sn.value(), ev ); + BOOST_TEST_EQ( &sn.category(), &st ); + + std::error_code sc( bc ); + + BOOST_TEST( sc == sn ); +} + +// + int main() { test_generic_category(); test_system_category(); test_user_category(); + test_user2_category(); return boost::report_errors(); } From 4626b887be4234f12b656d4c9ce6fba16048abc7 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 28 May 2017 16:34:24 -0400 Subject: [PATCH 12/30] #define _CRT_SECURE_NO_WARNINGS to avoid spurious VC++ warning --- test/std_interop_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 6b9c77d..4527137 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -8,6 +8,9 @@ // See library home page at http://www.boost.org/libs/system +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + #include #if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) From 67ae4c2aa7270d435a58cb5b45a13586e16075e7 Mon Sep 17 00:00:00 2001 From: Jorge Lodos Date: Tue, 23 Feb 2016 19:06:33 -0600 Subject: [PATCH 13/30] Do not include windows.h in header only mode --- include/boost/system/detail/error_code.ipp | 33 ++++++++++--------- .../detail/local_free_on_destruction.hpp | 4 ++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index 71c60f6..7c29076 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -21,7 +21,8 @@ #include // for strerror/strerror_r # if defined( BOOST_WINDOWS_API ) -# include +# include +# include # if !BOOST_PLAT_WINDOWS_RUNTIME # include # endif @@ -372,12 +373,12 @@ namespace std::wstring buf(128, wchar_t()); for (;;) { - DWORD retval = ::FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + boost::detail::winapi::DWORD_ retval = boost::detail::winapi::FormatMessageW( + boost::detail::winapi::FORMAT_MESSAGE_FROM_SYSTEM_ | + boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language &buf[0], buf.size(), NULL @@ -388,7 +389,7 @@ namespace buf.resize(retval); break; } - else if ( ::GetLastError() != ERROR_INSUFFICIENT_BUFFER ) + else if (boost::detail::winapi::GetLastError() != ERROR_INSUFFICIENT_BUFFER) { return std::string("Unknown error"); } @@ -399,23 +400,23 @@ namespace } int num_chars = (buf.size() + 1) * 2; - LPSTR narrow_buffer = (LPSTR)_alloca( num_chars ); - if (::WideCharToMultiByte(CP_ACP, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) + boost::detail::winapi::LPSTR_ narrow_buffer = (boost::detail::winapi::LPSTR_)_alloca(num_chars); + if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) { return std::string("Unknown error"); } std::string str( narrow_buffer ); #else - LPVOID lpMsgBuf = 0; - DWORD retval = ::FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + boost::detail::winapi::LPVOID_ lpMsgBuf = 0; + boost::detail::winapi::DWORD_ retval = boost::detail::winapi::FormatMessageA( + boost::detail::winapi::FORMAT_MESSAGE_ALLOCATE_BUFFER_ | + boost::detail::winapi::FORMAT_MESSAGE_FROM_SYSTEM_ | + boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPSTR) &lpMsgBuf, + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language + (boost::detail::winapi::LPSTR_) &lpMsgBuf, 0, NULL ); @@ -423,7 +424,7 @@ namespace if (retval == 0) return std::string("Unknown error"); - std::string str( static_cast(lpMsgBuf) ); + std::string str(static_cast(lpMsgBuf)); # endif while ( str.size() && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) diff --git a/include/boost/system/detail/local_free_on_destruction.hpp b/include/boost/system/detail/local_free_on_destruction.hpp index 110024f..25f879b 100644 --- a/include/boost/system/detail/local_free_on_destruction.hpp +++ b/include/boost/system/detail/local_free_on_destruction.hpp @@ -12,6 +12,8 @@ #ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP #define BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP +#include + namespace boost { namespace system { namespace detail { @@ -24,7 +26,7 @@ public: ~local_free_on_destruction() { - ::LocalFree(p_); + boost::detail::winapi::LocalFree(p_); } private: From 9087c92cc79760d757c467ed3d9e9a7adb14a1e5 Mon Sep 17 00:00:00 2001 From: Beman Date: Sat, 3 Jun 2017 08:22:04 -0400 Subject: [PATCH 14/30] Add std_interop_test to msvc solution. Add cout message indicating whether or not inter-operation will be tested. --- .../std_interop_test/std_interop_test.vcxproj | 156 ++++++++++++++++++ test/msvc/system.sln | 15 +- test/std_interop_test.cpp | 10 +- 3 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 test/msvc/std_interop_test/std_interop_test.vcxproj diff --git a/test/msvc/std_interop_test/std_interop_test.vcxproj b/test/msvc/std_interop_test/std_interop_test.vcxproj new file mode 100644 index 0000000..39fe49c --- /dev/null +++ b/test/msvc/std_interop_test/std_interop_test.vcxproj @@ -0,0 +1,156 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313} + Win32Proj + std_interop_test + 10.0.14393.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + + + + {419402d4-f990-4b05-a459-655e2dc33dc2} + + + + + + \ No newline at end of file diff --git a/test/msvc/system.sln b/test/msvc/system.sln index f5b0094..186bdc3 100644 --- a/test/msvc/system.sln +++ b/test/msvc/system.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26430.6 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system-dll", "system-dll\system-dll.vcxproj", "{419402D4-F990-4B05-A459-655E2DC33DC2}" EndProject @@ -13,6 +13,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config_test", "config_test\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clang-system-dll", "clang-system-dll\clang-system-dll.vcxproj", "{30993F97-5E77-4B5A-B25F-B545C276077A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "std_interop_test", "std_interop_test\std_interop_test.vcxproj", "{47B0A041-1EB5-4842-BD17-BA0DCC5E0313}" + ProjectSection(ProjectDependencies) = postProject + {419402D4-F990-4B05-A459-655E2DC33DC2} = {419402D4-F990-4B05-A459-655E2DC33DC2} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -53,6 +58,14 @@ Global {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|Win32.Build.0 = Release|Win32 {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.ActiveCfg = Release|x64 {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.Build.0 = Release|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|Win32.ActiveCfg = Debug|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|Win32.Build.0 = Debug|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|x64.ActiveCfg = Debug|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|x64.Build.0 = Debug|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|Win32.ActiveCfg = Release|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|Win32.Build.0 = Release|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.ActiveCfg = Release|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 4527137..8264a69 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -15,7 +15,12 @@ #if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) -int main() {} +int main() +{ + std::cout + << "The version of the C++ standard library being used does not" + " support header so interoperation will not be tested.\n"; +} #else @@ -349,6 +354,9 @@ static void test_user2_category() int main() { + std::cout + << "The version of the C++ standard library being used" + " supports header so interoperation will be tested.\n"; test_generic_category(); test_system_category(); test_user_category(); From 4736079b2e57124e9ffeea007d183db4973f5697 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 4 Jun 2017 11:01:08 -0400 Subject: [PATCH 15/30] Fix boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_ in error_code.ipp (Thanks to Lastique). Use in windows_error.hpp. Add msvc project to build header-only version of error_code_test. --- include/boost/system/detail/error_code.ipp | 2 +- include/boost/system/windows_error.hpp | 116 +++++++------- .../header_only_error_code_test.vcxproj | 151 ++++++++++++++++++ test/msvc/system.sln | 10 ++ 4 files changed, 221 insertions(+), 58 deletions(-) create mode 100644 test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index 7c29076..e686fd3 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -389,7 +389,7 @@ namespace buf.resize(retval); break; } - else if (boost::detail::winapi::GetLastError() != ERROR_INSUFFICIENT_BUFFER) + else if (boost::detail::winapi::GetLastError() != boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_) { return std::string("Unknown error"); } diff --git a/include/boost/system/windows_error.hpp b/include/boost/system/windows_error.hpp index 38d6284..0fb7ea6 100644 --- a/include/boost/system/windows_error.hpp +++ b/include/boost/system/windows_error.hpp @@ -19,14 +19,16 @@ #include -// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on -// either of those platforms include the full windows.h +//// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on +//// either of those platforms include the full windows.h +// +//#if defined(__MINGW32__) || defined(__CYGWIN__) +//#include +//#else +//#include +//#endif -#if defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -#include -#endif +#include namespace boost { @@ -45,59 +47,59 @@ namespace boost { success = 0, // These names and values are based on Windows winerror.h - invalid_function = ERROR_INVALID_FUNCTION, - file_not_found = ERROR_FILE_NOT_FOUND, - path_not_found = ERROR_PATH_NOT_FOUND, - too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, - access_denied = ERROR_ACCESS_DENIED, - invalid_handle = ERROR_INVALID_HANDLE, - arena_trashed = ERROR_ARENA_TRASHED, - not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, - invalid_block = ERROR_INVALID_BLOCK, - bad_environment = ERROR_BAD_ENVIRONMENT, - bad_format = ERROR_BAD_FORMAT, - invalid_access = ERROR_INVALID_ACCESS, - outofmemory = ERROR_OUTOFMEMORY, - invalid_drive = ERROR_INVALID_DRIVE, - current_directory = ERROR_CURRENT_DIRECTORY, - not_same_device = ERROR_NOT_SAME_DEVICE, - no_more_files = ERROR_NO_MORE_FILES, - write_protect = ERROR_WRITE_PROTECT, - bad_unit = ERROR_BAD_UNIT, - not_ready = ERROR_NOT_READY, - bad_command = ERROR_BAD_COMMAND, - crc = ERROR_CRC, - bad_length = ERROR_BAD_LENGTH, - seek = ERROR_SEEK, - not_dos_disk = ERROR_NOT_DOS_DISK, - sector_not_found = ERROR_SECTOR_NOT_FOUND, - out_of_paper = ERROR_OUT_OF_PAPER, - write_fault = ERROR_WRITE_FAULT, - read_fault = ERROR_READ_FAULT, - gen_failure = ERROR_GEN_FAILURE, - sharing_violation = ERROR_SHARING_VIOLATION, - lock_violation = ERROR_LOCK_VIOLATION, - wrong_disk = ERROR_WRONG_DISK, - sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, - handle_eof = ERROR_HANDLE_EOF, - handle_disk_full= ERROR_HANDLE_DISK_FULL, - rem_not_list = ERROR_REM_NOT_LIST, - dup_name = ERROR_DUP_NAME, - bad_net_path = ERROR_BAD_NETPATH, - network_busy = ERROR_NETWORK_BUSY, + invalid_function = boost::detail::winapi::ERROR_INVALID_FUNCTION_, + file_not_found = boost::detail::winapi::ERROR_FILE_NOT_FOUND_, + path_not_found = boost::detail::winapi::ERROR_PATH_NOT_FOUND_, + too_many_open_files = boost::detail::winapi::ERROR_TOO_MANY_OPEN_FILES_, + access_denied = boost::detail::winapi::ERROR_ACCESS_DENIED_, + invalid_handle = boost::detail::winapi::ERROR_INVALID_HANDLE_, + arena_trashed = boost::detail::winapi::ERROR_ARENA_TRASHED_, + not_enough_memory = boost::detail::winapi::ERROR_NOT_ENOUGH_MEMORY_, + invalid_block = boost::detail::winapi::ERROR_INVALID_BLOCK_, + bad_environment = boost::detail::winapi::ERROR_BAD_ENVIRONMENT_, + bad_format = boost::detail::winapi::ERROR_BAD_FORMAT_, + invalid_access = boost::detail::winapi::ERROR_INVALID_ACCESS_, + outofmemory = boost::detail::winapi::ERROR_OUTOFMEMORY_, + invalid_drive = boost::detail::winapi::ERROR_INVALID_DRIVE_, + current_directory = boost::detail::winapi::ERROR_CURRENT_DIRECTORY_, + not_same_device = boost::detail::winapi::ERROR_NOT_SAME_DEVICE_, + no_more_files = boost::detail::winapi::ERROR_NO_MORE_FILES_, + write_protect = boost::detail::winapi::ERROR_WRITE_PROTECT_, + bad_unit = boost::detail::winapi::ERROR_BAD_UNIT_, + not_ready = boost::detail::winapi::ERROR_NOT_READY_, + bad_command = boost::detail::winapi::ERROR_BAD_COMMAND_, + crc = boost::detail::winapi::ERROR_CRC_, + bad_length = boost::detail::winapi::ERROR_BAD_LENGTH_, + seek = boost::detail::winapi::ERROR_SEEK_, + not_dos_disk = boost::detail::winapi::ERROR_NOT_DOS_DISK_, + sector_not_found = boost::detail::winapi::ERROR_SECTOR_NOT_FOUND_, + out_of_paper = boost::detail::winapi::ERROR_OUT_OF_PAPER_, + write_fault = boost::detail::winapi::ERROR_WRITE_FAULT_, + read_fault = boost::detail::winapi::ERROR_READ_FAULT_, + gen_failure = boost::detail::winapi::ERROR_GEN_FAILURE_, + sharing_violation = boost::detail::winapi::ERROR_SHARING_VIOLATION_, + lock_violation = boost::detail::winapi::ERROR_LOCK_VIOLATION_, + wrong_disk = boost::detail::winapi::ERROR_WRONG_DISK_, + sharing_buffer_exceeded = boost::detail::winapi::ERROR_SHARING_BUFFER_EXCEEDED_, + handle_eof = boost::detail::winapi::ERROR_HANDLE_EOF_, + handle_disk_full= boost::detail::winapi::ERROR_HANDLE_DISK_FULL_, + rem_not_list = boost::detail::winapi::ERROR_REM_NOT_LIST_, + dup_name = boost::detail::winapi::ERROR_DUP_NAME_, + bad_net_path = boost::detail::winapi::ERROR_BAD_NETPATH_, + network_busy = boost::detail::winapi::ERROR_NETWORK_BUSY_, // ... - file_exists = ERROR_FILE_EXISTS, - cannot_make = ERROR_CANNOT_MAKE, + file_exists = boost::detail::winapi::ERROR_FILE_EXISTS_, + cannot_make = boost::detail::winapi::ERROR_CANNOT_MAKE_, // ... - broken_pipe = ERROR_BROKEN_PIPE, - open_failed = ERROR_OPEN_FAILED, - buffer_overflow = ERROR_BUFFER_OVERFLOW, - disk_full= ERROR_DISK_FULL, + broken_pipe = boost::detail::winapi::ERROR_BROKEN_PIPE_, + open_failed = boost::detail::winapi::ERROR_OPEN_FAILED_, + buffer_overflow = boost::detail::winapi::ERROR_BUFFER_OVERFLOW_, + disk_full= boost::detail::winapi::ERROR_DISK_FULL_, // ... - lock_failed = ERROR_LOCK_FAILED, - busy = ERROR_BUSY, - cancel_violation = ERROR_CANCEL_VIOLATION, - already_exists = ERROR_ALREADY_EXISTS + lock_failed = boost::detail::winapi::ERROR_LOCK_FAILED_, + busy = boost::detail::winapi::ERROR_BUSY_, + cancel_violation = boost::detail::winapi::ERROR_CANCEL_VIOLATION_, + already_exists = boost::detail::winapi::ERROR_ALREADY_EXISTS_ // ... // TODO: add more Windows errors diff --git a/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj b/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj new file mode 100644 index 0000000..2649e3a --- /dev/null +++ b/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7} + Win32Proj + header_only_error_code_test + 10.0.14393.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY + + + Console + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY + + + Console + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY + + + Console + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY + + + Console + true + true + + + + + + + + + \ No newline at end of file diff --git a/test/msvc/system.sln b/test/msvc/system.sln index 186bdc3..25b44db 100644 --- a/test/msvc/system.sln +++ b/test/msvc/system.sln @@ -18,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "std_interop_test", "std_int {419402D4-F990-4B05-A459-655E2DC33DC2} = {419402D4-F990-4B05-A459-655E2DC33DC2} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "header_only_error_code_test", "header_only_error_code_test\header_only_error_code_test.vcxproj", "{C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -66,6 +68,14 @@ Global {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|Win32.Build.0 = Release|Win32 {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.ActiveCfg = Release|x64 {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.Build.0 = Release|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|Win32.ActiveCfg = Debug|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|Win32.Build.0 = Debug|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|x64.ActiveCfg = Debug|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|x64.Build.0 = Debug|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|Win32.ActiveCfg = Release|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|Win32.Build.0 = Release|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|x64.ActiveCfg = Release|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From bd37d3b619f492cb7e7ce6ed2de12ea9d9a1a291 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 4 Jun 2017 11:17:39 -0400 Subject: [PATCH 16/30] Reformat overly long lines of code. --- include/boost/system/detail/error_code.ipp | 36 ++++---- include/boost/system/error_code.hpp | 97 +++++++++++++--------- 2 files changed, 81 insertions(+), 52 deletions(-) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index e686fd3..f5fed6a 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -1,4 +1,4 @@ -// error_code support implementation file ----------------------------------// +// error_code support implementation file --------------------------------------------// // Copyright Beman Dawes 2002, 2006 // Copyright (c) Microsoft Corporation 2014 @@ -7,7 +7,7 @@ // See library home page at http://www.boost.org/libs/system -//----------------------------------------------------------------------------// +//--------------------------------------------------------------------------------------// #include @@ -31,7 +31,7 @@ # endif # endif -//----------------------------------------------------------------------------// +//--------------------------------------------------------------------------------------// namespace boost { namespace system @@ -40,7 +40,7 @@ namespace boost namespace { - // standard error categories ---------------------------------------------// + // standard error categories -------------------------------------------------------// class generic_error_category : public error_category { @@ -85,7 +85,8 @@ namespace // -- VMS doesn't provide strerror_r, but on this platform, strerror is // thread safe. # if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ - || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\ + || (defined(__linux) && (!defined(__USE_XOPEN2K)\ + || defined(BOOST_SYSTEM_USE_STRERROR)))\ || (defined(__osf__) && !defined(_REENTRANT))\ || (defined(__INTEGRITY))\ || (defined(__vms))\ @@ -157,14 +158,15 @@ namespace # endif // else POSIX version of strerror_r # endif // else use strerror_r } - // system_error_category implementation --------------------------------// + // system_error_category implementation --------------------------------------------// const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + error_condition system_error_category::default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT { using namespace boost::system::errc; #if defined(__PGI) @@ -186,7 +188,7 @@ namespace { case 0: return make_error_condition( success ); # if defined(BOOST_POSIX_API) - // POSIX-like O/S -> posix_errno decode table ---------------------------// + // POSIX-like O/S -> posix_errno decode table -------------------------------------// case E2BIG: return make_error_condition( argument_list_too_long ); case EACCES: return make_error_condition( permission_denied ); case EADDRINUSE: return make_error_condition( address_in_use ); @@ -294,7 +296,8 @@ namespace case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); - case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid" + case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: + "The directory name is invalid" case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); @@ -378,7 +381,8 @@ namespace boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, + boost::detail::winapi::SUBLANG_DEFAULT_), // Default language &buf[0], buf.size(), NULL @@ -389,7 +393,8 @@ namespace buf.resize(retval); break; } - else if (boost::detail::winapi::GetLastError() != boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_) + else if (boost::detail::winapi::GetLastError() != + boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_) { return std::string("Unknown error"); } @@ -400,8 +405,10 @@ namespace } int num_chars = (buf.size() + 1) * 2; - boost::detail::winapi::LPSTR_ narrow_buffer = (boost::detail::winapi::LPSTR_)_alloca(num_chars); - if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) + boost::detail::winapi::LPSTR_ narrow_buffer = + (boost::detail::winapi::LPSTR_)_alloca(num_chars); + if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, + buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) { return std::string("Unknown error"); } @@ -415,7 +422,8 @@ namespace boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, + boost::detail::winapi::SUBLANG_DEFAULT_), // Default language (boost::detail::winapi::LPSTR_) &lpMsgBuf, 0, NULL diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 70a41cd..dd585d7 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -1,4 +1,4 @@ -// boost/system/error_code.hpp ---------------------------------------------// +// boost/system/error_code.hpp -------------------------------------------------------// // Copyright Beman Dawes 2006, 2007 // Copyright Christoper Kohlhoff 2007 @@ -47,7 +47,7 @@ namespace boost class error_condition; // portable generic values defined below, but ultimately // based on the POSIX standard - // "Concept" helpers ---------------------------------------------------// + // "Concept" helpers -------------------------------------------------------------// template< class T > struct is_error_code_enum { static const bool value = false; }; @@ -55,7 +55,7 @@ namespace boost template< class T > struct is_error_condition_enum { static const bool value = false; }; - // generic error_conditions --------------------------------------------// + // generic error_conditions ------------------------------------------------------// namespace errc { @@ -153,9 +153,9 @@ namespace boost { static const bool value = true; }; - // ----------------------------------------------------------------------// + // --------------------------------------------------------------------------------// - // Operating system specific interfaces --------------------------------// + // Operating system specific interfaces ------------------------------------------// // The interface is divided into general and system-specific portions to @@ -183,11 +183,11 @@ namespace boost // These headers are effectively empty for compiles on operating systems // where they are not applicable. - // ----------------------------------------------------------------------// + // --------------------------------------------------------------------------------// class error_category; - // predefined error categories -----------------------------------------// + // predefined error categories ---------------------------------------------------// #ifdef BOOST_ERROR_CODE_HEADER_ONLY inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; @@ -196,15 +196,18 @@ namespace boost BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; #endif - // deprecated synonyms --------------------------------------------------// + // deprecated synonyms ------------------------------------------------------------// #ifndef BOOST_SYSTEM_NO_DEPRECATED inline const error_category & get_system_category() { return system_category(); } inline const error_category & get_generic_category() { return generic_category(); } inline const error_category & get_posix_category() { return generic_category(); } - static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category(); + static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED + = generic_category(); + static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED + = generic_category(); + static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED + = system_category(); #endif // class error_category ------------------------------------------------// @@ -237,9 +240,12 @@ namespace boost return pc_->message( ev ); } - virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT; - 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; + virtual std::error_condition default_error_condition( int ev ) const + BOOST_NOEXCEPT; + 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; }; std_category std_cat_; @@ -263,21 +269,23 @@ namespace boost virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; virtual std::string message( int ev ) const = 0; - inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual error_condition default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT; inline virtual bool equivalent( int code, - const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; + const error_condition & condition ) const + BOOST_SYSTEM_NOEXCEPT; inline virtual bool equivalent( const error_code & code, int condition ) const BOOST_SYSTEM_NOEXCEPT; - bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } - bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } + bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT + { return this == &rhs; } + bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT + { return this != &rhs; } bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT - { - return std::less()( this, &rhs ); - } + { return std::less()( this, &rhs ); } }; - // class error_condition -----------------------------------------------// + // class error_condition ---------------------------------------------------------// // error_conditions are portable, error_codes are system or library specific @@ -287,11 +295,13 @@ namespace boost // constructors: error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} - error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} + error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + : m_val(val), m_cat(&cat) {} template error_condition(ErrorConditionEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT + typename boost::enable_if >::type* + = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(e); } @@ -305,7 +315,8 @@ namespace boost } template - typename boost::enable_if, error_condition>::type & + typename boost::enable_if, + error_condition>::type & operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(val); @@ -376,7 +387,7 @@ namespace boost }; - // class error_code ----------------------------------------------------// + // class error_code --------------------------------------------------------------// // We want error_code to be a value type that can be copied without slicing // and without requiring heap allocation, but we also want it to have @@ -390,11 +401,13 @@ namespace boost // constructors: error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} - error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} + error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + : m_val(val), m_cat(&cat) {} template error_code(ErrorCodeEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT + typename boost::enable_if >::type* = 0) + BOOST_SYSTEM_NOEXCEPT { *this = make_error_code(e); } @@ -423,7 +436,8 @@ namespace boost // observers: int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } - error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } + error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT + { return m_cat->default_error_condition(value()); } std::string message() const { return m_cat->message(value()); } # ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS @@ -560,7 +574,7 @@ namespace boost + reinterpret_cast(&ec.category()); } - // make_* functions for errc::errc_t -----------------------------// + // make_* functions for errc::errc_t ---------------------------------------------// namespace errc { @@ -573,9 +587,10 @@ namespace boost { return error_condition( e, generic_category() ); } } - // error_category default implementation -------------------------------// + // error_category default implementation -----------------------------------------// - error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + error_condition error_category::default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT { return error_condition( ev, *this ); } @@ -594,26 +609,31 @@ namespace boost #ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR - inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT + inline std::error_condition error_category::std_category::default_error_condition( + int ev ) const BOOST_NOEXCEPT { return pc_->default_error_condition( ev ); } - inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT + inline bool error_category::std_category::equivalent( int code, + const std::error_condition & condition ) const BOOST_NOEXCEPT { if( default_error_condition( code ) == condition ) { return true; } - else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) + else if( condition.category() == std::generic_category() + || condition.category() == boost::system::generic_category() ) { boost::system::error_code bc( code, *pc_ ); - boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); + boost::system::error_condition bn( condition.value(), + boost::system::generic_category() ); return bc == bn; } #ifndef BOOST_NO_RTTI - else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) ) + else if( std_category const* pc2 = dynamic_cast< std_category const* >( + &condition.category() ) ) { boost::system::error_code bc( code, *pc_ ); boost::system::error_condition bn( condition.value(), *pc2->pc_ ); @@ -627,7 +647,8 @@ namespace boost } } - inline bool error_category::std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT + inline bool error_category::std_category::equivalent( const std::error_code & code, + int condition ) const BOOST_NOEXCEPT { if( *this == code.category() && code.value() == condition ) { From f26bfc87aa07cdb596527daa381e05fcc09bfe29 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 4 Jun 2017 11:28:14 -0400 Subject: [PATCH 17/30] Fix typo --- include/boost/system/detail/error_code.ipp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index f5fed6a..ec9fbb4 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -296,8 +296,8 @@ namespace case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); - case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: - "The directory name is invalid" + case ERROR_DIRECTORY: return make_error_condition( invalid_argument );\ + // WinError.h: "The directory name is invalid" case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); From 1ad099291d7142b0fb0b7d08713d188b6d97d2a8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 19:22:48 +0300 Subject: [PATCH 18/30] Add required #include --- test/std_interop_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 8264a69..44a97b9 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -12,6 +12,7 @@ # define _CRT_SECURE_NO_WARNINGS #include +#include #if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) From ef2b755d77b88a122c6cb9a7928fb5c8f879392a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 19:34:28 +0300 Subject: [PATCH 19/30] Fix include in error_code_test on cygwin/mingw --- test/error_code_test.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index a9a928e..3cad994 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -30,14 +30,20 @@ // with a boost::system using directive increases use scenario coverage. using namespace boost::system; -# if defined( BOOST_WINDOWS_API ) -# include "winerror.h" -# define BOOST_ACCESS_ERROR_MACRO ERROR_ACCESS_DENIED -# elif defined( BOOST_POSIX_API ) -# define BOOST_ACCESS_ERROR_MACRO EACCES -# else -# error "Only supported for POSIX and Windows" -# endif +#if defined( BOOST_WINDOWS_API ) +// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on +// either of those platforms include the full windows.h +# if defined(__MINGW32__) || defined(__CYGWIN__) +# include +# else +# include +# endif +# define BOOST_ACCESS_ERROR_MACRO ERROR_ACCESS_DENIED +#elif defined( BOOST_POSIX_API ) +# define BOOST_ACCESS_ERROR_MACRO EACCES +#else +# error "Only supported for POSIX and Windows" +#endif namespace { From cc26feabef7b55341298df4aba006f9c12d14175 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 19:50:36 +0300 Subject: [PATCH 20/30] Fix error_code.ipp on Cygwin --- include/boost/system/detail/error_code.ipp | 155 +++++++++++---------- 1 file changed, 81 insertions(+), 74 deletions(-) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index ec9fbb4..51ba3f4 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -21,6 +21,7 @@ #include // for strerror/strerror_r # if defined( BOOST_WINDOWS_API ) +# include # include # include # if !BOOST_PLAT_WINDOWS_RUNTIME @@ -182,6 +183,12 @@ namespace if ( HRESULT_FACILITY( ev ) == FACILITY_WIN32 ) ev = HRESULT_CODE( ev ); # endif +# endif + +# if defined(BOOST_WINDOWS_API) + + using namespace boost::detail::winapi; // for error codes + # endif switch ( ev ) @@ -282,81 +289,81 @@ namespace #else // Windows system -> posix_errno decode table ---------------------------// // see WinError.h comments for descriptions of errors - case ERROR_ACCESS_DENIED: return make_error_condition( permission_denied ); - case ERROR_ALREADY_EXISTS: return make_error_condition( file_exists ); - case ERROR_BAD_UNIT: return make_error_condition( no_such_device ); - case ERROR_BUFFER_OVERFLOW: return make_error_condition( filename_too_long ); - case ERROR_BUSY: return make_error_condition( device_or_resource_busy ); - case ERROR_BUSY_DRIVE: return make_error_condition( device_or_resource_busy ); - case ERROR_CANNOT_MAKE: return make_error_condition( permission_denied ); - case ERROR_CANTOPEN: return make_error_condition( io_error ); - case ERROR_CANTREAD: return make_error_condition( io_error ); - case ERROR_CANTWRITE: return make_error_condition( io_error ); - case ERROR_CURRENT_DIRECTORY: return make_error_condition( permission_denied ); - case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); - case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); - case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); - case ERROR_DIRECTORY: return make_error_condition( invalid_argument );\ + case ERROR_ACCESS_DENIED_: return make_error_condition( permission_denied ); + case ERROR_ALREADY_EXISTS_: return make_error_condition( file_exists ); + case ERROR_BAD_UNIT_: return make_error_condition( no_such_device ); + case ERROR_BUFFER_OVERFLOW_: return make_error_condition( filename_too_long ); + case ERROR_BUSY_: return make_error_condition( device_or_resource_busy ); + case ERROR_BUSY_DRIVE_: return make_error_condition( device_or_resource_busy ); + case ERROR_CANNOT_MAKE_: return make_error_condition( permission_denied ); + case ERROR_CANTOPEN_: return make_error_condition( io_error ); + case ERROR_CANTREAD_: return make_error_condition( io_error ); + case ERROR_CANTWRITE_: return make_error_condition( io_error ); + case ERROR_CURRENT_DIRECTORY_: return make_error_condition( permission_denied ); + case ERROR_DEV_NOT_EXIST_: return make_error_condition( no_such_device ); + case ERROR_DEVICE_IN_USE_: return make_error_condition( device_or_resource_busy ); + case ERROR_DIR_NOT_EMPTY_: return make_error_condition( directory_not_empty ); + case ERROR_DIRECTORY_: return make_error_condition( invalid_argument );\ // WinError.h: "The directory name is invalid" - case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); - case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); - case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); - case ERROR_HANDLE_DISK_FULL: return make_error_condition( no_space_on_device ); - case ERROR_INVALID_ACCESS: return make_error_condition( permission_denied ); - case ERROR_INVALID_DRIVE: return make_error_condition( no_such_device ); - case ERROR_INVALID_FUNCTION: return make_error_condition( function_not_supported ); - case ERROR_INVALID_HANDLE: return make_error_condition( invalid_argument ); - case ERROR_INVALID_NAME: return make_error_condition( invalid_argument ); - case ERROR_LOCK_VIOLATION: return make_error_condition( no_lock_available ); - case ERROR_LOCKED: return make_error_condition( no_lock_available ); - case ERROR_NEGATIVE_SEEK: return make_error_condition( invalid_argument ); - case ERROR_NOACCESS: return make_error_condition( permission_denied ); - case ERROR_NOT_ENOUGH_MEMORY: return make_error_condition( not_enough_memory ); - case ERROR_NOT_READY: return make_error_condition( resource_unavailable_try_again ); - case ERROR_NOT_SAME_DEVICE: return make_error_condition( cross_device_link ); - case ERROR_OPEN_FAILED: return make_error_condition( io_error ); - case ERROR_OPEN_FILES: return make_error_condition( device_or_resource_busy ); - case ERROR_OPERATION_ABORTED: return make_error_condition( operation_canceled ); - case ERROR_OUTOFMEMORY: return make_error_condition( not_enough_memory ); - case ERROR_PATH_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); - case ERROR_READ_FAULT: return make_error_condition( io_error ); - case ERROR_RETRY: return make_error_condition( resource_unavailable_try_again ); - case ERROR_SEEK: return make_error_condition( io_error ); - case ERROR_SHARING_VIOLATION: return make_error_condition( permission_denied ); - case ERROR_TOO_MANY_OPEN_FILES: return make_error_condition( too_many_files_open ); - case ERROR_WRITE_FAULT: return make_error_condition( io_error ); - case ERROR_WRITE_PROTECT: return make_error_condition( permission_denied ); - case WSAEACCES: return make_error_condition( permission_denied ); - case WSAEADDRINUSE: return make_error_condition( address_in_use ); - case WSAEADDRNOTAVAIL: return make_error_condition( address_not_available ); - case WSAEAFNOSUPPORT: return make_error_condition( address_family_not_supported ); - case WSAEALREADY: return make_error_condition( connection_already_in_progress ); - case WSAEBADF: return make_error_condition( bad_file_descriptor ); - case WSAECONNABORTED: return make_error_condition( connection_aborted ); - case WSAECONNREFUSED: return make_error_condition( connection_refused ); - case WSAECONNRESET: return make_error_condition( connection_reset ); - case WSAEDESTADDRREQ: return make_error_condition( destination_address_required ); - case WSAEFAULT: return make_error_condition( bad_address ); - case WSAEHOSTUNREACH: return make_error_condition( host_unreachable ); - case WSAEINPROGRESS: return make_error_condition( operation_in_progress ); - case WSAEINTR: return make_error_condition( interrupted ); - case WSAEINVAL: return make_error_condition( invalid_argument ); - case WSAEISCONN: return make_error_condition( already_connected ); - case WSAEMFILE: return make_error_condition( too_many_files_open ); - case WSAEMSGSIZE: return make_error_condition( message_size ); - case WSAENAMETOOLONG: return make_error_condition( filename_too_long ); - case WSAENETDOWN: return make_error_condition( network_down ); - case WSAENETRESET: return make_error_condition( network_reset ); - case WSAENETUNREACH: return make_error_condition( network_unreachable ); - case WSAENOBUFS: return make_error_condition( no_buffer_space ); - case WSAENOPROTOOPT: return make_error_condition( no_protocol_option ); - case WSAENOTCONN: return make_error_condition( not_connected ); - case WSAENOTSOCK: return make_error_condition( not_a_socket ); - case WSAEOPNOTSUPP: return make_error_condition( operation_not_supported ); - case WSAEPROTONOSUPPORT: return make_error_condition( protocol_not_supported ); - case WSAEPROTOTYPE: return make_error_condition( wrong_protocol_type ); - case WSAETIMEDOUT: return make_error_condition( timed_out ); - case WSAEWOULDBLOCK: return make_error_condition( operation_would_block ); + case ERROR_DISK_FULL_: return make_error_condition( no_space_on_device ); + case ERROR_FILE_EXISTS_: return make_error_condition( file_exists ); + case ERROR_FILE_NOT_FOUND_: return make_error_condition( no_such_file_or_directory ); + case ERROR_HANDLE_DISK_FULL_: return make_error_condition( no_space_on_device ); + case ERROR_INVALID_ACCESS_: return make_error_condition( permission_denied ); + case ERROR_INVALID_DRIVE_: return make_error_condition( no_such_device ); + case ERROR_INVALID_FUNCTION_: return make_error_condition( function_not_supported ); + case ERROR_INVALID_HANDLE_: return make_error_condition( invalid_argument ); + case ERROR_INVALID_NAME_: return make_error_condition( invalid_argument ); + case ERROR_LOCK_VIOLATION_: return make_error_condition( no_lock_available ); + case ERROR_LOCKED_: return make_error_condition( no_lock_available ); + case ERROR_NEGATIVE_SEEK_: return make_error_condition( invalid_argument ); + case ERROR_NOACCESS_: return make_error_condition( permission_denied ); + case ERROR_NOT_ENOUGH_MEMORY_: return make_error_condition( not_enough_memory ); + case ERROR_NOT_READY_: return make_error_condition( resource_unavailable_try_again ); + case ERROR_NOT_SAME_DEVICE_: return make_error_condition( cross_device_link ); + case ERROR_OPEN_FAILED_: return make_error_condition( io_error ); + case ERROR_OPEN_FILES_: return make_error_condition( device_or_resource_busy ); + case ERROR_OPERATION_ABORTED_: return make_error_condition( operation_canceled ); + case ERROR_OUTOFMEMORY_: return make_error_condition( not_enough_memory ); + case ERROR_PATH_NOT_FOUND_: return make_error_condition( no_such_file_or_directory ); + case ERROR_READ_FAULT_: return make_error_condition( io_error ); + case ERROR_RETRY_: return make_error_condition( resource_unavailable_try_again ); + case ERROR_SEEK_: return make_error_condition( io_error ); + case ERROR_SHARING_VIOLATION_: return make_error_condition( permission_denied ); + case ERROR_TOO_MANY_OPEN_FILES_: return make_error_condition( too_many_files_open ); + case ERROR_WRITE_FAULT_: return make_error_condition( io_error ); + case ERROR_WRITE_PROTECT_: return make_error_condition( permission_denied ); + case WSAEACCES_: return make_error_condition( permission_denied ); + case WSAEADDRINUSE_: return make_error_condition( address_in_use ); + case WSAEADDRNOTAVAIL_: return make_error_condition( address_not_available ); + case WSAEAFNOSUPPORT_: return make_error_condition( address_family_not_supported ); + case WSAEALREADY_: return make_error_condition( connection_already_in_progress ); + case WSAEBADF_: return make_error_condition( bad_file_descriptor ); + case WSAECONNABORTED_: return make_error_condition( connection_aborted ); + case WSAECONNREFUSED_: return make_error_condition( connection_refused ); + case WSAECONNRESET_: return make_error_condition( connection_reset ); + case WSAEDESTADDRREQ_: return make_error_condition( destination_address_required ); + case WSAEFAULT_: return make_error_condition( bad_address ); + case WSAEHOSTUNREACH_: return make_error_condition( host_unreachable ); + case WSAEINPROGRESS_: return make_error_condition( operation_in_progress ); + case WSAEINTR_: return make_error_condition( interrupted ); + case WSAEINVAL_: return make_error_condition( invalid_argument ); + case WSAEISCONN_: return make_error_condition( already_connected ); + case WSAEMFILE_: return make_error_condition( too_many_files_open ); + case WSAEMSGSIZE_: return make_error_condition( message_size ); + case WSAENAMETOOLONG_: return make_error_condition( filename_too_long ); + case WSAENETDOWN_: return make_error_condition( network_down ); + case WSAENETRESET_: return make_error_condition( network_reset ); + case WSAENETUNREACH_: return make_error_condition( network_unreachable ); + case WSAENOBUFS_: return make_error_condition( no_buffer_space ); + case WSAENOPROTOOPT_: return make_error_condition( no_protocol_option ); + case WSAENOTCONN_: return make_error_condition( not_connected ); + case WSAENOTSOCK_: return make_error_condition( not_a_socket ); + case WSAEOPNOTSUPP_: return make_error_condition( operation_not_supported ); + case WSAEPROTONOSUPPORT_: return make_error_condition( protocol_not_supported ); + case WSAEPROTOTYPE_: return make_error_condition( wrong_protocol_type ); + case WSAETIMEDOUT_: return make_error_condition( timed_out ); + case WSAEWOULDBLOCK_: return make_error_condition( operation_would_block ); #endif default: return error_condition( ev, system_category() ); } From 62ecf74717e5f80ad0418cbc7c0747fd6824c655 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 19:58:16 +0300 Subject: [PATCH 21/30] Add appveyor.yml --- appveyor.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..2a88ee1 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,53 @@ +# Copyright 2016, 2017 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +version: 1.0.{build}-{branch} + +shallow_clone: true + +branches: + only: + - master + - develop + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-9.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-10.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-11.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-12.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\cygwin; + TOOLSET: gcc + CXXFLAGS: -std=c++03 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\cygwin; + TOOLSET: gcc + CXXFLAGS: -std=c++11 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + TOOLSET: msvc-14.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + TOOLSET: msvc-14.1 + +install: + - cd .. + - git clone -b %APPVEYOR_REPO_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\system + - python tools/boostdep/depinst/depinst.py system + - bootstrap + - b2 headers + +build: off + +test_script: + - PATH=%ADDPATH%%PATH% + - b2 libs/system/test toolset=%TOOLSET% cxxflags=%CXXFLAGS% From 473cf5ef91d5c9d7cea4c49cf1140da6a405149a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 20:12:21 +0300 Subject: [PATCH 22/30] Add `import testing` to test/Jamfile --- test/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4195bc8..a421a25 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,6 +7,7 @@ # See library home page at http://www.boost.org/libs/system +import testing ; project : requirements From 138a7c0d27833a6885ec8e30981e8e199b95a4ad Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 20:17:40 +0300 Subject: [PATCH 23/30] Fix CXXFLAGS in appveyor.yml --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2a88ee1..7851a36 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,11 +24,11 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 ADDPATH: C:\cygwin; TOOLSET: gcc - CXXFLAGS: -std=c++03 + CXXFLAGS: cxxflags=-std=c++03 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 ADDPATH: C:\cygwin; TOOLSET: gcc - CXXFLAGS: -std=c++11 + CXXFLAGS: cxxflags=-std=c++11 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 TOOLSET: msvc-14.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 @@ -50,4 +50,4 @@ build: off test_script: - PATH=%ADDPATH%%PATH% - - b2 libs/system/test toolset=%TOOLSET% cxxflags=%CXXFLAGS% + - b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS% From 23e7c5d13335c6f6b677b18fea73931ee243fccb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 15:23:48 +0300 Subject: [PATCH 24/30] Add MinGW to Appveyor --- appveyor.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 7851a36..3ccc21b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,6 +29,22 @@ environment: ADDPATH: C:\cygwin; TOOLSET: gcc CXXFLAGS: cxxflags=-std=c++11 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw\bin; + TOOLSET: gcc + CXXFLAGS: cxxflags=-std=c++03 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw\bin; + TOOLSET: gcc + CXXFLAGS: cxxflags=-std=c++11 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; + TOOLSET: gcc + CXXFLAGS: cxxflags=-std=c++03 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; + TOOLSET: gcc + CXXFLAGS: cxxflags=-std=c++11 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 TOOLSET: msvc-14.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 From 483f3769e6671afa577224b7fff7d1513b7bde6c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 16:21:08 +0300 Subject: [PATCH 25/30] Add --debug-configuration to appveyor.yml --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3ccc21b..304c460 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,4 +66,6 @@ build: off test_script: - PATH=%ADDPATH%%PATH% - - b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS% + - PATH + - ECHO b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS% + - b2 --debug-configuration libs/system/test toolset=%TOOLSET% %CXXFLAGS% From 81880ba5ffca65eb4959a14d36dfa8ba1d7f65ca Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 17:28:25 +0300 Subject: [PATCH 26/30] Execute bootstrap in a subshell in Appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 304c460..d8184b5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,7 +59,7 @@ install: - git submodule update --init tools/boostdep - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\system - python tools/boostdep/depinst/depinst.py system - - bootstrap + - cmd /c bootstrap - b2 headers build: off From d6c950f534f6c98f00553b5d91d4cafe27a81455 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 18:09:33 +0300 Subject: [PATCH 27/30] Add missing #include --- test/std_interop_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/std_interop_test.cpp b/test/std_interop_test.cpp index 44a97b9..5e52c50 100644 --- a/test/std_interop_test.cpp +++ b/test/std_interop_test.cpp @@ -30,6 +30,7 @@ int main() #include #include #include +#include static void test_generic_category() { @@ -143,7 +144,7 @@ public: virtual std::string message( int ev ) const { char buffer[ 256 ]; - sprintf( buffer, "user message %d", ev ); + std::sprintf( buffer, "user message %d", ev ); return buffer; } @@ -283,7 +284,7 @@ public: virtual std::string message( int ev ) const { char buffer[ 256 ]; - sprintf( buffer, "user2 message %d", ev ); + std::sprintf( buffer, "user2 message %d", ev ); return buffer; } From 5eda96dcbce5ebf1f5a17685c5dcc933c65178bc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 18:10:55 +0300 Subject: [PATCH 28/30] Fix Cygwin path --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d8184b5..96878e3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,11 +22,11 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 TOOLSET: msvc-12.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - ADDPATH: C:\cygwin; + ADDPATH: C:\cygwin\bin; TOOLSET: gcc CXXFLAGS: cxxflags=-std=c++03 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - ADDPATH: C:\cygwin; + ADDPATH: C:\cygwin\bin; TOOLSET: gcc CXXFLAGS: cxxflags=-std=c++11 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 From 87c427b5dfdcf8c84a81d07e454bf78b431489ee Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 19:27:55 +0300 Subject: [PATCH 29/30] Rework the equivalence logic in terms of the corresponding downstream `equivalent` --- include/boost/system/error_code.hpp | 37 ++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index dd585d7..5d98301 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -618,45 +618,60 @@ namespace boost inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT { - if( default_error_condition( code ) == condition ) + if( condition.category() == *this ) { - return true; + 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_code bc( code, *pc_ ); boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); - return bc == bn; + 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_code bc( code, *pc_ ); boost::system::error_condition bn( condition.value(), *pc2->pc_ ); - - return bc == bn; + return pc_->equivalent( code, bn ); } #endif else { - return false; + return default_error_condition( code ) == condition; } } inline bool error_category::std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT { - if( *this == code.category() && code.value() == condition ) + if( code.category() == *this ) { - return true; + 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 code == std::error_condition( condition, std::generic_category() ); + return std::generic_category().equivalent( code, condition ); } else { From 29fda3272c2f5b17ce042db7d82b984d8a79f8e0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2017 20:01:32 +0300 Subject: [PATCH 30/30] Remove diagnostic options from appveyor.yml --- appveyor.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 96878e3..829bc5a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,6 +66,4 @@ build: off test_script: - PATH=%ADDPATH%%PATH% - - PATH - - ECHO b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS% - - b2 --debug-configuration libs/system/test toolset=%TOOLSET% %CXXFLAGS% + - b2 libs/system/test toolset=%TOOLSET% %CXXFLAGS%