Compare commits

...

29 Commits

Author SHA1 Message Date
6942dc454b Fix unsupported use of BOOST_SYMBOL_VISIBLE on Sun C++ 2020-01-24 20:59:12 +02:00
7ba160e443 Rename id to id_ to avoid ObjC++ parsing issues. Fixes #52. 2020-01-18 22:15:44 +02:00
d9bfbfc4d4 Disable BUILD_TESTING on the install test 2020-01-18 15:26:21 +02:00
90cb8254df Install Core as well; add EXCLUDE_FROM_ALL to test libraries 2020-01-18 07:12:06 +02:00
4d1486dec9 Update CMakeLists.txt 2020-01-18 05:28:55 +02:00
97665bf539 Remove duplicate clang-3.6 2020-01-02 04:17:38 +02:00
6d82346e0b Fix .travis.yml mistakes 2020-01-02 02:57:24 +02:00
673dd13eaa Switch UBSAN from g++-8 to g++-9 2020-01-01 23:47:39 +02:00
ca525cd7b2 Update Travis to Xenial 2020-01-01 23:32:04 +02:00
9fb5bbd448 Remove 32 bit configuration from clang-win on Appveyor to avoid mspdbcore.dll error 2019-12-09 01:47:54 +02:00
31152834ac Add VS2019 to Appveyor; separate clang-win into its own job 2019-11-24 00:04:25 +02:00
455946faac Merge pull request #49 from Thomas-Barbier-1A/cpp7_redundant_redeclar_constexpr
Fix c++17 warning redundant redeclaration of 'constexpr' static data
2019-10-02 02:55:45 -07:00
08370c9158 Fix c++17 warning redundant redeclaration of 'constexpr' static data
member [-Werror=deprecated]
2019-10-01 18:49:31 +02:00
c556aba559 Remove redundant Travis job 2019-06-18 12:50:59 +03:00
ecc4ddd87c Add gcc9, clang8 to Travis 2019-06-18 12:46:04 +03:00
f67827eee3 Add dist: trusty to .travis.yml 2019-06-18 01:08:17 +03:00
c08b8a94ea Fix sign extension (warning 4826.) Closes #48. 2019-05-24 18:55:27 +03:00
835e5de228 Add clang-win to Appveyor 2019-05-14 04:16:53 +03:00
dc2ad73e30 Merge pull request #47 from KABoissonneault/feature/issue_46
Added boost::winapi::ERROR_CONNECTION_ABORTED_ to handled error codes…
2019-05-13 18:14:54 -07:00
32a6c13533 Added boost::winapi::ERROR_CONNECTION_ABORTED_ to handled error codes in Win32's system_category, making it equivalent to errc::connection_aborted 2019-05-13 18:08:24 -04:00
bfbc5ec42f Remove BOOST_SYSTEM_REQUIRE_CONST_INIT; variables are constexpr, so no longer needed. Closes #45. 2019-05-12 04:15:35 +03:00
9deadda4b4 Merge branch 'feature/system-generic-visible' into feature/std-ec-mismatch 2019-04-25 20:54:01 +03:00
3b6315e4a1 Add BOOST_SYMBOL_VISIBLE to system_category(), generic_category() 2019-04-25 16:55:13 +03:00
1d845408dd Fix thread safety issue in std interop 2019-04-25 01:01:48 +03:00
e08e4253d0 Avoid allocation on interop for system/generic categories; fix DLL interoperability on msvc-14.x by poking into std::system_category::_Addr 2019-04-25 00:31:25 +03:00
afc51937be Mark to_std_category as BOOST_SYMBOL_VISIBLE 2019-04-24 23:18:19 +03:00
907c867cd1 Rename test/std_ec_mismatch to std_single_instance; test also static and shared libraries 2019-04-24 21:15:39 +03:00
9f225112f1 Add std_ec_mismatch_test 2019-04-24 18:19:21 +03:00
48b8a6c41c Switch Appveyor to 2015 image 2019-04-14 18:06:05 +03:00
14 changed files with 451 additions and 161 deletions

View File

@ -6,6 +6,8 @@ language: cpp
sudo: false
dist: xenial
branches:
only:
- master
@ -116,12 +118,22 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
@ -130,6 +142,7 @@ matrix:
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -138,6 +151,7 @@ matrix:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -146,16 +160,15 @@ matrix:
- clang-3.4
- os: linux
dist: trusty
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
@ -166,19 +179,6 @@ matrix:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
@ -189,19 +189,6 @@ matrix:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
@ -212,19 +199,6 @@ matrix:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
@ -235,19 +209,6 @@ matrix:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
@ -258,19 +219,6 @@ matrix:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
@ -281,19 +229,6 @@ matrix:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
@ -304,19 +239,6 @@ matrix:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
@ -327,21 +249,44 @@ matrix:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-8
- os: linux
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-8
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
dist: trusty
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
@ -350,6 +295,7 @@ matrix:
- libc++-dev
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
@ -361,15 +307,51 @@ matrix:
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
env: CMAKE=1
script:
- cd libs/system/test/cmake_subdir_test && mkdir __build__ && cd __build__
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- ctest --output-on-failure -R boost_system
- os: linux
env: CMAKE=1 BUILD_SHARED_LIBS=ON
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- ctest --output-on-failure -R boost_system
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH https://github.com/boostorg/predef.git ../predef
- git clone -b $BOOST_BRANCH https://github.com/boostorg/winapi.git ../winapi
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="system;core" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..

View File

@ -1,12 +1,10 @@
# Copyright 2018 Mike Dev
# Copyright 2018-2020 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
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.5)
project(BoostSystem LANGUAGES CXX)
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_system INTERFACE)
add_library(Boost::system ALIAS boost_system)
@ -14,7 +12,13 @@ add_library(Boost::system ALIAS boost_system)
target_include_directories(boost_system INTERFACE include)
target_link_libraries(boost_system
INTERFACE
Boost::config
Boost::winapi
INTERFACE
Boost::config
Boost::winapi
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -1,4 +1,4 @@
# Copyright 2016-2018 Peter Dimov
# Copyright 2016-2019 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)
@ -14,28 +14,36 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14,17
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z

View File

@ -22,6 +22,11 @@
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
#if defined(BOOST_NO_CXX11_HDR_MUTEX)
// Required for thread-safe map manipulation
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
// BOOST_SYSTEM_NOEXCEPT
// Retained for backward compatibility
@ -43,15 +48,4 @@
# define BOOST_SYSTEM_CONSTEXPR
#endif
// BOOST_SYSTEM_REQUIRE_CONST_INIT
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
#endif
#endif
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED

View File

@ -10,6 +10,7 @@
#include <system_error>
#include <map>
#include <memory>
#include <mutex>
//
@ -30,8 +31,20 @@ private:
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
explicit std_category( boost::system::error_category const * pc, unsigned id ): pc_( pc )
{
if( id != 0 )
{
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
// Poking into the protected _Addr member of std::error_category
// is not a particularly good programming practice, but what can
// you do
_Addr = id;
#endif
}
}
virtual const char * name() const BOOST_NOEXCEPT
@ -53,24 +66,52 @@ public:
virtual bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT;
};
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
#endif
struct cat_ptr_less
{
bool operator()( boost::system::error_category const * p1, boost::system::error_category const * p2 ) const BOOST_NOEXCEPT
{
return *p1 < *p2;
}
};
inline std::error_category const & to_std_category( boost::system::error_category const & cat )
{
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category> > map_type;
static map_type map_;
map_type::iterator i = map_.find( &cat );
if( i == map_.end() )
if( cat == boost::system::system_category() )
{
std::unique_ptr<std_category> p( new std_category( &cat ) );
std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );
i = r.first;
static const std_category system_instance( &cat, 0x1F4D7 );
return system_instance;
}
else if( cat == boost::system::generic_category() )
{
static const std_category generic_instance( &cat, 0x1F4D3 );
return generic_instance;
}
else
{
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category>, cat_ptr_less > map_type;
return *i->second;
static map_type map_;
static std::mutex map_mx_;
std::lock_guard<std::mutex> guard( map_mx_ );
map_type::iterator i = map_.find( &cat );
if( i == map_.end() )
{
std::unique_ptr<std_category> p( new std_category( &cat, 0 ) );
std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );
i = r.first;
}
return *i->second;
}
}
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT

View File

@ -264,6 +264,7 @@ inline error_condition system_category_default_error_condition_win32( int ev ) B
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_CONNECTION_ABORTED_: return make_error_condition( connection_aborted );
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 );

View File

@ -329,14 +329,17 @@ public:
namespace detail
{
template<class T> struct cat_holder
template<class T> struct BOOST_SYMBOL_VISIBLE cat_holder
{
BOOST_SYSTEM_REQUIRE_CONST_INIT static constexpr system_error_category system_category_instance{};
BOOST_SYSTEM_REQUIRE_CONST_INIT static constexpr generic_error_category generic_category_instance{};
static constexpr system_error_category system_category_instance{};
static constexpr generic_error_category generic_category_instance{};
};
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT constexpr system_error_category cat_holder<T>::system_category_instance;
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT constexpr generic_error_category cat_holder<T>::generic_category_instance;
// Before C++17 it was mandatory to redeclare all static constexpr
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class T> constexpr system_error_category cat_holder<T>::system_category_instance;
template<class T> constexpr generic_error_category cat_holder<T>::generic_category_instance;
#endif
} // namespace detail
@ -352,6 +355,11 @@ constexpr error_category const & generic_category() BOOST_NOEXCEPT
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
inline error_category const & generic_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & system_category() BOOST_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
@ -776,11 +784,11 @@ inline std::size_t hash_value( error_code const & ec )
{
error_category const & cat = ec.category();
boost::ulong_long_type id = cat.id_;
boost::ulong_long_type id_ = cat.id_;
if( id == 0 )
if( id_ == 0 )
{
id = reinterpret_cast<boost::ulong_long_type>( &cat );
id_ = reinterpret_cast<boost::uintptr_t>( &cat );
}
boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325;
@ -788,7 +796,7 @@ inline std::size_t hash_value( error_code const & ec )
// id
hv ^= id;
hv ^= id_;
hv *= prime;
// value

71
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,71 @@
# Copyright 2018-2020 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
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()
macro(system_run s1)
string(MAKE_C_IDENTIFIER ${s1} n1)
boost_test(SOURCES ${s1} ${ARGN})
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_NO_ANSI_APIS NAME ${n1}_no_ansi)
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_SYSTEM_USE_UTF8 NAME ${n1}_utf8)
endmacro()
macro(lib name macro)
add_library(${name} EXCLUDE_FROM_ALL ${ARGN})
target_compile_definitions(${name} PRIVATE $<$<BOOL:BUILD_SHARED_LIBS>:${macro}=1>)
target_link_libraries(${name} PRIVATE Boost::system Boost::config)
endmacro()
set(BOOST_TEST_LINK_LIBRARIES Boost::system Boost::core Boost::static_assert)
boost_test(SOURCES quick.cpp)
system_run(error_code_test.cpp)
system_run(error_code_user_test.cpp)
system_run(system_error_test.cpp)
lib(boost_system_throw_test THROW_DYN_LINK throw_test.cpp)
boost_test(SOURCES dynamic_link_test.cpp LINK_LIBRARIES boost_system_throw_test)
system_run(initialization_test.cpp)
system_run(header_only_test.cpp)
boost_test(SOURCES config_test.cpp)
system_run(std_interop_test.cpp)
system_run(std_mismatch_test.cpp)
lib(boost_system_single_instance_lib1 SINGLE_INSTANCE_DYN_LINK single_instance_1.cpp)
lib(boost_system_single_instance_lib2 SINGLE_INSTANCE_DYN_LINK single_instance_2.cpp)
system_run(single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp)
boost_test(SOURCES single_instance_test.cpp NAME single_instance_test_lib LINK_LIBRARIES boost_system_single_instance_lib1 boost_system_single_instance_lib2)
system_run(before_main_test.cpp)
system_run(constexpr_test.cpp)
system_run(win32_hresult_test.cpp)
system_run(error_category_test.cpp)
system_run(generic_category_test.cpp)
system_run(system_category_test.cpp)
system_run(after_main_test.cpp)
system_run(failed_test.cpp)
system_run(failed_constexpr_test.cpp)
boost_test(SOURCES warnings_test.cpp COMPILE_OPTIONS -Wall -Werror)
lib(boost_system_std_single_instance_lib1 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_1.cpp)
lib(boost_system_std_single_instance_lib2 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_2.cpp)
system_run(std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp)
boost_test(SOURCES std_single_instance_test.cpp NAME std_single_instance_test_lib LINK_LIBRARIES boost_system_std_single_instance_lib1 boost_system_std_single_instance_lib2)

View File

@ -10,11 +10,6 @@
import testing ;
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
rule system-run ( sources + )
{
local result ;
@ -32,6 +27,8 @@ system-run error_code_test.cpp ;
system-run error_code_user_test.cpp ;
system-run system_error_test.cpp ;
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
run dynamic_link_test.cpp throw_test : : : <link>shared : throw_test_shared ;
system-run initialization_test.cpp ;
@ -42,6 +39,9 @@ run config_test.cpp : : : <test-info>always_show_run_output ;
system-run std_interop_test.cpp ;
system-run std_mismatch_test.cpp ;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
system-run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp ;
run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>static : single_instance_lib_static ;
run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ;
@ -62,3 +62,10 @@ system-run failed_constexpr_test.cpp ;
run quick.cpp ;
run warnings_test.cpp : : : <warnings>all <warnings-as-errors>on <toolset>gcc:<cxxflags>-Wnon-virtual-dtor <toolset>clang:<cxxflags>-Wnon-virtual-dtor ;
lib std_single_instance_lib1 : std_single_instance_1.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ;
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ;
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ;

View File

@ -0,0 +1,18 @@
# Copyright 2018, 2019 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_system REQUIRED)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::system Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -2,7 +2,7 @@
# 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
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)

View File

@ -0,0 +1,40 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(STD_SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <system_error>
namespace lib1
{
EXPORT std::error_code get_system_code()
{
return boost::system::error_code( 0, boost::system::system_category() );
}
EXPORT std::error_code get_generic_code()
{
return boost::system::error_code( 0, boost::system::generic_category() );
}
} // namespace lib1
#else
EXPORT void lib1_f()
{
}
#endif

View File

@ -0,0 +1,40 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(STD_SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <system_error>
namespace lib2
{
EXPORT std::error_code get_system_code()
{
return boost::system::error_code( 0, boost::system::system_category() );
}
EXPORT std::error_code get_generic_code()
{
return boost::system::error_code( 0, boost::system::generic_category() );
}
} // namespace lib2
#else
EXPORT void lib2_f()
{
}
#endif

View File

@ -0,0 +1,76 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config/helper_macros.hpp>
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(__CYGWIN__)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, __CYGWIN__" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_MSC_VER)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _MSC_VER" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_CPPLIB_VER)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _CPPLIB_VER" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && (_MSC_VER < 1900 || _MSC_VER >= 2000)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, _MSC_VER is " BOOST_STRINGIZE(_MSC_VER) )
int main() {}
#else
#include <boost/core/lightweight_test.hpp>
#include <system_error>
using namespace boost::system;
namespace lib1
{
std::error_code get_system_code();
std::error_code get_generic_code();
} // namespace lib1
namespace lib2
{
std::error_code get_system_code();
std::error_code get_generic_code();
} // namespace lib2
int main()
{
{
std::error_code e1 = lib1::get_system_code();
std::error_code e2 = lib2::get_system_code();
BOOST_TEST_EQ( e1, e2 );
}
{
std::error_code e1 = lib1::get_generic_code();
std::error_code e2 = lib2::get_generic_code();
BOOST_TEST_EQ( e1, e2 );
}
return boost::report_errors();
}
#endif