From d2c1ed0ed58db1c87f24ee9f3db4acca32bfb820 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 16 Apr 2017 00:18:24 +0300 Subject: [PATCH 1/4] Add clang-3.9/linux, c++1z/osx to Travis --- .travis.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7b5505b..84089a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -231,6 +231,46 @@ matrix: - 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 @@ -240,6 +280,9 @@ matrix: - 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 https://github.com/boostorg/boost.git boost-root From acb29ad6f327b6b1be22cdbd1d913d5eae6fdd2b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 16 Apr 2017 21:02:07 +0300 Subject: [PATCH 2/4] Add lwm_win32_cs_test --- test/Jamfile.v2 | 2 ++ test/lwm_win32_cs_test.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/lwm_win32_cs_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 528fe06..2c82726 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -208,5 +208,7 @@ import testing ; [ run sp_nothrow_test.cpp ] [ compile make_shared_msvc_test.cpp ] + + [ compile lwm_win32_cs_test.cpp ] ; } diff --git a/test/lwm_win32_cs_test.cpp b/test/lwm_win32_cs_test.cpp new file mode 100644 index 0000000..cd8be86 --- /dev/null +++ b/test/lwm_win32_cs_test.cpp @@ -0,0 +1,18 @@ +// +// lwm_win32_cs_test.cpp +// +// 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) +// + +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# include +# include +#endif + +int main() +{ +} From 3568e093bb42da2dcf050c659bb5cbb86acdfbd3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 16 Apr 2017 21:38:29 +0300 Subject: [PATCH 3/4] Fix lwm_win32_cs.hpp for Clang --- .../boost/smart_ptr/detail/lwm_win32_cs.hpp | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/include/boost/smart_ptr/detail/lwm_win32_cs.hpp b/include/boost/smart_ptr/detail/lwm_win32_cs.hpp index a93cf09..7d3e156 100644 --- a/include/boost/smart_ptr/detail/lwm_win32_cs.hpp +++ b/include/boost/smart_ptr/detail/lwm_win32_cs.hpp @@ -21,7 +21,13 @@ #include #ifdef BOOST_USE_WINDOWS_H -# include + +#include + +#else + +struct _RTL_CRITICAL_SECTION; + #endif namespace boost @@ -47,13 +53,13 @@ struct critical_section }; #if BOOST_PLAT_WINDOWS_RUNTIME -extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(critical_section *, unsigned long, unsigned long); +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(::_RTL_CRITICAL_SECTION *, unsigned long, unsigned long); #else -extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *); +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *); #endif -extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *); -extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *); -extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *); +extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *); +extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *); +extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *); #else @@ -75,15 +81,15 @@ public: lightweight_mutex() { #if BOOST_PLAT_WINDOWS_RUNTIME - InitializeCriticalSectionEx(&cs_, 4000, 0); + boost::detail::InitializeCriticalSectionEx(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_), 4000, 0); #else - InitializeCriticalSection(&cs_); + boost::detail::InitializeCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); #endif } ~lightweight_mutex() { - DeleteCriticalSection(&cs_); + boost::detail::DeleteCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); } class scoped_lock; @@ -102,12 +108,12 @@ public: explicit scoped_lock(lightweight_mutex & m): m_(m) { - EnterCriticalSection(&m_.cs_); + boost::detail::EnterCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); } ~scoped_lock() { - LeaveCriticalSection(&m_.cs_); + boost::detail::LeaveCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); } }; }; From 6bdd3fde65654926332ec249c940eca275433de0 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sat, 22 Apr 2017 22:39:57 -0400 Subject: [PATCH 4/4] Add alternative sp_array_construct for trivially destructible case --- .../boost/smart_ptr/allocate_shared_array.hpp | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp index b43b43d..c063a35 100644 --- a/include/boost/smart_ptr/allocate_shared_array.hpp +++ b/include/boost/smart_ptr/allocate_shared_array.hpp @@ -9,9 +9,10 @@ Distributed under the Boost Software License, Version 1.0. #define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP #include -#include -#include #include +#include +#include +#include #include namespace boost { @@ -173,7 +174,7 @@ inline void sp_array_destroy(A& allocator, T* storage, std::size_t size) { while (size > 0) { - std::allocator_traits::destroy(allocator, &storage[--size]); + std::allocator_traits::destroy(allocator, storage + --size); } } #endif @@ -202,15 +203,27 @@ sp_array_construct(T* storage, std::size_t size) ::new(static_cast(storage + i)) T(); } } catch (...) { - while (i > 0) { - storage[--i].~T(); - } + sp_array_destroy(storage, i); throw; } } template -inline void +inline +typename sp_enable::value || + boost::has_trivial_destructor::value>::type +sp_array_construct(T* storage, std::size_t size, const T* list, + std::size_t count) +{ + for (std::size_t i = 0; i < size; ++i) { + ::new(static_cast(storage + i)) T(list[i % count]); + } +} + +template +inline +typename sp_enable::value && + !boost::has_trivial_destructor::value>::type sp_array_construct(T* storage, std::size_t size, const T* list, std::size_t count) { @@ -220,9 +233,7 @@ sp_array_construct(T* storage, std::size_t size, const T* list, ::new(static_cast(storage + i)) T(list[i % count]); } } catch (...) { - while (i > 0) { - storage[--i].~T(); - } + sp_array_destroy(storage, i); throw; } } @@ -332,9 +343,7 @@ sp_array_default(T* storage, std::size_t size) ::new(static_cast(storage + i)) T; } } catch (...) { - while (i > 0) { - storage[--i].~T(); - } + sp_array_destroy(storage, i); throw; } }