Compare commits

...

18 Commits

Author SHA1 Message Date
Peter Dimov 04f0847af4 Add --depth 1 to Appveyor 2018-09-21 20:53:27 +03:00
Glen Fernandes 29a08cdff6 Use BOOST_SYMBOL_VISIBLE with local_counted_base and children 2018-09-19 13:50:13 -04:00
Peter Dimov 6d3af760f6 Generously dispense BOOST_SYMBOL_VISIBLE 2018-09-18 03:18:23 +03:00
Peter Dimov a9f39d2b94 Test make_shared/allocate_shared in dll_test too 2018-09-17 22:04:27 +03:00
Peter Dimov 4e2f236116 Add dll_test (to check for visibility issues) 2018-09-17 21:50:47 +03:00
Peter Dimov 4eb53db537 Use intrin.h under clang-cl 2018-08-12 01:26:59 +03:00
Glen Fernandes a2b6ba85f3 Simplify exception safety in array construct utilities 2018-08-01 08:45:10 -04:00
Peter Dimov e37cd4154f Work around ld: unrecognized option '--push-state--no-as-needed' 2018-05-10 16:16:08 +03:00
Peter Dimov 8563fc5c4e Add tests that include <windows.h> 2018-03-11 23:00:50 +02:00
Peter Dimov 67fab5c9ec Clang x64 warns that __stdcall is ignored, so don't use it there 2018-03-08 06:53:28 +02:00
Peter Dimov f16fbdce26 Fix sp_interlocked on Cygwin 64 2018-03-08 05:15:49 +02:00
Peter Dimov c3b3835a58 Mingw doesn't have _RTL_CRITICAL_SECTION 2018-03-08 03:34:00 +02:00
Peter Dimov d1600b8abc Do not define pthread_* in lightweight_thread.hpp; mingw-w64 includes pthread.h in the standard library headers 2018-03-08 01:19:44 +02:00
Peter Dimov 5885763287 Remove clang from Appveyor; doesn't really work. 2018-03-08 00:39:15 +02:00
Peter Dimov 9bb12692b3 Only test C++14 with clang on Appveyor 2018-03-07 21:23:01 +02:00
Peter Dimov 773ef80f5d Add mingw configurations; move LLVM clang in its own VS2017 job 2018-03-07 20:06:04 +02:00
Peter Dimov 704de2bd67 Add Cygwin to Appveyor 2018-03-07 18:27:45 +02:00
Peter Dimov 1caa233faa Add address-model=32,64 to Appveyor 2018-03-07 17:37:28 +02:00
41 changed files with 357 additions and 184 deletions
+2 -2
View File
@@ -107,7 +107,7 @@ matrix:
- os: linux - os: linux
compiler: g++-7 compiler: g++-7
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons: addons:
apt: apt:
packages: packages:
@@ -273,7 +273,7 @@ install:
script: script:
- |- - |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD ${VARIANT:+variant=$VARIANT} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} - ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD ${VARIANT:+variant=$VARIANT} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications: notifications:
email: email:
+23 -3
View File
@@ -1,4 +1,4 @@
# Copyright 2016, 2017 Peter Dimov # Copyright 2016-2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0. # 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) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@@ -18,15 +18,33 @@ environment:
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0 TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0 TOOLSET: msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1 TOOLSET: msvc-14.1
CXXSTD: 14,17 CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install: install:
- set BOOST_BRANCH=develop - set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd .. - cd ..
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root - cd boost-root
- git submodule init libs/align - git submodule init libs/align
- git submodule init libs/assert - git submodule init libs/assert
@@ -50,5 +68,7 @@ install:
build: off build: off
test_script: test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% - if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% variant=debug,release - if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
+2 -2
View File
@@ -62,7 +62,7 @@ int main()
clock_t t = clock(); clock_t t = clock();
pthread_t a[ m ]; boost::detail::lw_thread_t a[ m ];
for( int i = 0; i < m; ++i ) for( int i = 0; i < m; ++i )
{ {
@@ -71,7 +71,7 @@ int main()
for( int j = 0; j < m; ++j ) for( int j = 0; j < m; ++j )
{ {
pthread_join( a[j], 0 ); boost::detail::lw_thread_join( a[j] );
} }
t = clock() - t; t = clock() - t;
+2 -2
View File
@@ -228,7 +228,7 @@ int main( int ac, char const * av[] )
clock_t t = clock(); clock_t t = clock();
std::vector<pthread_t> a( m ); std::vector<boost::detail::lw_thread_t> a( m );
for( int i = 0; i < m; ++i ) for( int i = 0; i < m; ++i )
{ {
@@ -237,7 +237,7 @@ int main( int ac, char const * av[] )
for( int j = 0; j < m; ++j ) for( int j = 0; j < m; ++j )
{ {
pthread_join( a[ j ], 0 ); boost::detail::lw_thread_join( a[ j ] );
} }
t = clock() - t; t = clock() - t;
+2 -2
View File
@@ -165,7 +165,7 @@ int main()
clock_t t = clock(); clock_t t = clock();
pthread_t a[ mr+mw ]; boost::detail::lw_thread_t a[ mr+mw ];
for( int i = 0; i < mr; ++i ) for( int i = 0; i < mr; ++i )
{ {
@@ -179,7 +179,7 @@ int main()
for( int j = 0; j < mr+mw; ++j ) for( int j = 0; j < mr+mw; ++j )
{ {
pthread_join( a[ j ], 0 ); boost::detail::lw_thread_join( a[ j ] );
} }
t = clock() - t; t = clock() - t;
+2 -2
View File
@@ -100,7 +100,7 @@ int main()
clock_t t = clock(); clock_t t = clock();
pthread_t a[ m ]; boost::detail::lw_thread_t a[ m ];
for( int i = 0; i < m; ++i ) for( int i = 0; i < m; ++i )
{ {
@@ -111,7 +111,7 @@ int main()
for( int j = 0; j < m; ++j ) for( int j = 0; j < m; ++j )
{ {
pthread_join( a[j], 0 ); boost::detail::lw_thread_join( a[j] );
} }
t = clock() - t; t = clock() - t;
+42 -13
View File
@@ -10,30 +10,59 @@
// boost/detail/lightweight_thread.hpp // boost/detail/lightweight_thread.hpp
// //
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008 Peter Dimov // Copyright (c) 2008, 2018 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at // See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
//
//
// typedef /*...*/ lw_thread_t; // as pthread_t
// template<class F> int lw_thread_create( lw_thread_t & th, F f );
// void lw_thread_join( lw_thread_t th );
#include <boost/config.hpp> #include <boost/config.hpp>
#include <memory> #include <memory>
#include <cerrno> #include <cerrno>
// pthread_create, pthread_join
#if defined( BOOST_HAS_PTHREADS ) #if defined( BOOST_HAS_PTHREADS )
#include <pthread.h> #include <pthread.h>
#else namespace boost
{
namespace detail
{
typedef ::pthread_t lw_thread_t;
inline int lw_thread_create_( lw_thread_t* thread, const pthread_attr_t* attr, void* (*start_routine)( void* ), void* arg )
{
return ::pthread_create( thread, attr, start_routine, arg );
}
inline void lw_thread_join( lw_thread_t th )
{
::pthread_join( th, 0 );
}
} // namespace detail
} // namespace boost
#else // defined( BOOST_HAS_PTHREADS )
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
typedef HANDLE pthread_t; namespace boost
{
namespace detail
{
int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg ) typedef HANDLE lw_thread_t;
inline int lw_thread_create_( lw_thread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
{ {
HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 ); HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 );
@@ -48,20 +77,20 @@ int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * star
} }
} }
int pthread_join( pthread_t thread, void ** /*value_ptr*/ ) inline void lw_thread_join( lw_thread_t thread )
{ {
::WaitForSingleObject( thread, INFINITE ); ::WaitForSingleObject( thread, INFINITE );
::CloseHandle( thread ); ::CloseHandle( thread );
return 0;
} }
#endif } // namespace detail
} // namespace boost
#endif // defined( BOOST_HAS_PTHREADS )
// template<class F> int lw_thread_create( pthread_t & pt, F f );
namespace boost namespace boost
{ {
namespace detail namespace detail
{ {
@@ -131,7 +160,7 @@ private:
F f_; F f_;
}; };
template<class F> int lw_thread_create( pthread_t & pt, F f ) template<class F> int lw_thread_create( lw_thread_t & th, F f )
{ {
#if defined(BOOST_NO_CXX11_SMART_PTR) #if defined(BOOST_NO_CXX11_SMART_PTR)
@@ -143,7 +172,7 @@ template<class F> int lw_thread_create( pthread_t & pt, F f )
#endif #endif
int r = pthread_create( &pt, 0, lw_thread_routine, p.get() ); int r = lw_thread_create_( &th, 0, lw_thread_routine, p.get() );
if( r == 0 ) if( r == 0 )
{ {
@@ -30,7 +30,7 @@ struct lsp_if_size_array<T[N]> {
typedef boost::local_shared_ptr<T[N]> type; typedef boost::local_shared_ptr<T[N]> type;
}; };
class lsp_array_base class BOOST_SYMBOL_VISIBLE lsp_array_base
: public local_counted_base { : public local_counted_base {
public: public:
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT { void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
+60 -115
View File
@@ -1,5 +1,5 @@
/* /*
Copyright 2012-2017 Glen Joseph Fernandes Copyright 2012-2018 Glen Joseph Fernandes
(glenjofe@gmail.com) (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0. Distributed under the Boost Software License, Version 1.0.
@@ -154,33 +154,58 @@ sp_array_destroy(A&, T*, std::size_t) BOOST_SP_NOEXCEPT { }
template<bool E, class A, class T> template<bool E, class A, class T>
inline typename sp_enable<!E && inline typename sp_enable<!E &&
!boost::has_trivial_destructor<T>::value>::type !boost::has_trivial_destructor<T>::value>::type
sp_array_destroy(A&, T* start, std::size_t size) sp_array_destroy(A&, T* ptr, std::size_t size)
{ {
while (size > 0) { while (size > 0) {
start[--size].~T(); ptr[--size].~T();
} }
} }
#if !defined(BOOST_NO_CXX11_ALLOCATOR) #if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<bool E, class A, class T> template<bool E, class A, class T>
inline typename sp_enable<E>::type inline typename sp_enable<E>::type
sp_array_destroy(A& allocator, T* start, std::size_t size) sp_array_destroy(A& allocator, T* ptr, std::size_t size)
{ {
while (size > 0) { while (size > 0) {
std::allocator_traits<A>::destroy(allocator, start + --size); std::allocator_traits<A>::destroy(allocator, ptr + --size);
} }
} }
#endif #endif
template<bool E, class A, class T>
class sp_destroyer {
public:
sp_destroyer(A& allocator, T* ptr) BOOST_SP_NOEXCEPT
: allocator_(allocator),
ptr_(ptr),
size_(0) { }
~sp_destroyer() {
sp_array_destroy<E>(allocator_, ptr_, size_);
}
std::size_t& size() BOOST_SP_NOEXCEPT {
return size_;
}
private:
sp_destroyer(const sp_destroyer&);
sp_destroyer& operator=(const sp_destroyer&);
A& allocator_;
T* ptr_;
std::size_t size_;
};
template<bool E, class A, class T> template<bool E, class A, class T>
inline typename sp_enable<!E && inline typename sp_enable<!E &&
boost::has_trivial_constructor<T>::value && boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value && boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value>::type boost::has_trivial_destructor<T>::value>::type
sp_array_construct(A&, T* start, std::size_t size) sp_array_construct(A&, T* ptr, std::size_t size)
{ {
for (std::size_t i = 0; i < size; ++i) { for (std::size_t i = 0; i < size; ++i) {
start[i] = T(); ptr[i] = T();
} }
} }
@@ -189,30 +214,11 @@ inline typename sp_enable<!E &&
boost::has_trivial_constructor<T>::value && boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value && boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value>::type boost::has_trivial_destructor<T>::value>::type
sp_array_construct(A&, T* start, std::size_t size, const T* list, sp_array_construct(A&, T* ptr, std::size_t size, const T* list,
std::size_t count) std::size_t count)
{ {
for (std::size_t i = 0; i < size; ++i) { for (std::size_t i = 0; i < size; ++i) {
start[i] = list[i % count]; ptr[i] = list[i % count];
}
}
#if !defined(BOOST_NO_EXCEPTIONS)
template<bool E, class A, class T>
inline typename sp_enable<!E &&
!(boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value)>::type
sp_array_construct(A& none, T* start, std::size_t size)
{
std::size_t i = 0;
try {
for (; i < size; ++i) {
::new(static_cast<void*>(start + i)) T();
}
} catch (...) {
sp_array_destroy<E>(none, start, i);
throw;
} }
} }
@@ -221,30 +227,13 @@ inline typename sp_enable<!E &&
!(boost::has_trivial_constructor<T>::value && !(boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value && boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value)>::type boost::has_trivial_destructor<T>::value)>::type
sp_array_construct(A& none, T* start, std::size_t size, const T* list, sp_array_construct(A& none, T* ptr, std::size_t size)
std::size_t count)
{ {
std::size_t i = 0; sp_destroyer<E, A, T> hold(none, ptr);
try { for (std::size_t& i = hold.size(); i < size; ++i) {
for (; i < size; ++i) { ::new(static_cast<void*>(ptr + i)) T();
::new(static_cast<void*>(start + i)) T(list[i % count]);
}
} catch (...) {
sp_array_destroy<E>(none, start, i);
throw;
}
}
#else
template<bool E, class A, class T>
inline typename sp_enable<!E &&
!(boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value)>::type
sp_array_construct(A&, T* start, std::size_t size)
{
for (std::size_t i = 0; i < size; ++i) {
::new(static_cast<void*>(start + i)) T();
} }
hold.size() = 0;
} }
template<bool E, class A, class T> template<bool E, class A, class T>
@@ -252,100 +241,56 @@ inline typename sp_enable<!E &&
!(boost::has_trivial_constructor<T>::value && !(boost::has_trivial_constructor<T>::value &&
boost::has_trivial_assign<T>::value && boost::has_trivial_assign<T>::value &&
boost::has_trivial_destructor<T>::value)>::type boost::has_trivial_destructor<T>::value)>::type
sp_array_construct(A&, T* start, std::size_t size, const T* list, sp_array_construct(A& none, T* ptr, std::size_t size, const T* list,
std::size_t count) std::size_t count)
{ {
for (std::size_t i = 0; i < size; ++i) { sp_destroyer<E, A, T> hold(none, ptr);
::new(static_cast<void*>(start + i)) T(list[i % count]); for (std::size_t& i = hold.size(); i < size; ++i) {
::new(static_cast<void*>(ptr + i)) T(list[i % count]);
} }
hold.size() = 0;
} }
#endif
#if !defined(BOOST_NO_CXX11_ALLOCATOR) #if !defined(BOOST_NO_CXX11_ALLOCATOR)
#if !defined(BOOST_NO_EXCEPTIONS)
template<bool E, class A, class T> template<bool E, class A, class T>
inline typename sp_enable<E>::type inline typename sp_enable<E>::type
sp_array_construct(A& allocator, T* start, std::size_t size) sp_array_construct(A& allocator, T* ptr, std::size_t size)
{ {
std::size_t i = 0; sp_destroyer<E, A, T> hold(allocator, ptr);
try { for (std::size_t& i = hold.size(); i < size; ++i) {
for (i = 0; i < size; ++i) { std::allocator_traits<A>::construct(allocator, ptr + i);
std::allocator_traits<A>::construct(allocator, start + i);
}
} catch (...) {
sp_array_destroy<E>(allocator, start, i);
throw;
} }
hold.size() = 0;
} }
template<bool E, class A, class T> template<bool E, class A, class T>
inline typename sp_enable<E>::type inline typename sp_enable<E>::type
sp_array_construct(A& allocator, T* start, std::size_t size, const T* list, sp_array_construct(A& allocator, T* ptr, std::size_t size, const T* list,
std::size_t count) std::size_t count)
{ {
std::size_t i = 0; sp_destroyer<E, A, T> hold(allocator, ptr);
try { for (std::size_t& i = hold.size(); i < size; ++i) {
for (i = 0; i < size; ++i) { std::allocator_traits<A>::construct(allocator, ptr + i,
std::allocator_traits<A>::construct(allocator, start + i,
list[i % count]);
}
} catch (...) {
sp_array_destroy<E>(allocator, start, i);
throw;
}
}
#else
template<bool E, class A, class T>
inline typename sp_enable<E>::type
sp_array_construct(A& allocator, T* start, std::size_t size)
{
for (std::size_t i = 0; i < size; ++i) {
std::allocator_traits<A>::construct(allocator, start + i);
}
}
template<bool E, class A, class T>
inline typename sp_enable<E>::type
sp_array_construct(A& allocator, T* start, std::size_t size, const T* list,
std::size_t count)
{
for (std::size_t i = 0; i < size; ++i) {
std::allocator_traits<A>::construct(allocator, start + i,
list[i % count]); list[i % count]);
} }
hold.size() = 0;
} }
#endif #endif
#endif
template<class A, class T> template<class A, class T>
inline typename sp_enable<boost::has_trivial_constructor<T>::value>::type inline typename sp_enable<boost::has_trivial_constructor<T>::value>::type
sp_array_default(A&, T*, std::size_t) BOOST_SP_NOEXCEPT { } sp_array_default(A&, T*, std::size_t) BOOST_SP_NOEXCEPT { }
#if !defined(BOOST_NO_EXCEPTIONS)
template<class A, class T> template<class A, class T>
inline typename sp_enable<!boost::has_trivial_constructor<T>::value>::type inline typename sp_enable<!boost::has_trivial_constructor<T>::value>::type
sp_array_default(A& none, T* start, std::size_t size) sp_array_default(A& none, T* ptr, std::size_t size)
{ {
std::size_t i = 0; sp_destroyer<false, A, T> hold(none, ptr);
try { for (std::size_t& i = hold.size(); i < size; ++i) {
for (; i < size; ++i) { ::new(static_cast<void*>(ptr + i)) T;
::new(static_cast<void*>(start + i)) T;
}
} catch (...) {
sp_array_destroy<false>(none, start, i);
throw;
} }
hold.size() = 0;
} }
#else
template<bool E, class A, class T>
inline typename sp_enable<!boost::has_trivial_constructor<T>::value>::type
sp_array_default(A&, T* start, std::size_t size)
{
for (std::size_t i = 0; i < size; ++i) {
::new(static_cast<void*>(start + i)) T;
}
}
#endif
template<class A> template<class A>
class sp_array_state { class sp_array_state {
@@ -479,7 +424,7 @@ private:
struct sp_default { }; struct sp_default { };
template<class T, bool E = sp_use_construct<T>::value> template<class T, bool E = sp_use_construct<T>::value>
class sp_array_base class BOOST_SYMBOL_VISIBLE sp_array_base
: public sp_counted_base { : public sp_counted_base {
typedef typename T::type allocator; typedef typename T::type allocator;
@@ -27,7 +27,7 @@ namespace boost
namespace detail namespace detail
{ {
class local_counted_base class BOOST_SYMBOL_VISIBLE local_counted_base
{ {
private: private:
@@ -89,7 +89,7 @@ public:
} }
}; };
class local_counted_impl: public local_counted_base class BOOST_SYMBOL_VISIBLE local_counted_impl: public local_counted_base
{ {
private: private:
@@ -124,7 +124,7 @@ public:
} }
}; };
class local_counted_impl_em: public local_counted_base class BOOST_SYMBOL_VISIBLE local_counted_impl_em: public local_counted_base
{ {
public: public:
@@ -61,7 +61,9 @@ extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRIT
extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *); extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *); extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
#else typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
#else // #ifndef BOOST_USE_WINDOWS_H
typedef ::CRITICAL_SECTION critical_section; typedef ::CRITICAL_SECTION critical_section;
@@ -74,6 +76,8 @@ using ::EnterCriticalSection;
using ::LeaveCriticalSection; using ::LeaveCriticalSection;
using ::DeleteCriticalSection; using ::DeleteCriticalSection;
typedef ::CRITICAL_SECTION rtl_critical_section;
#endif // #ifndef BOOST_USE_WINDOWS_H #endif // #ifndef BOOST_USE_WINDOWS_H
class lightweight_mutex class lightweight_mutex
@@ -90,15 +94,15 @@ public:
lightweight_mutex() lightweight_mutex()
{ {
#if BOOST_PLAT_WINDOWS_RUNTIME #if BOOST_PLAT_WINDOWS_RUNTIME
boost::detail::InitializeCriticalSectionEx(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_), 4000, 0); boost::detail::InitializeCriticalSectionEx(reinterpret_cast< rtl_critical_section* >(&cs_), 4000, 0);
#else #else
boost::detail::InitializeCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
#endif #endif
} }
~lightweight_mutex() ~lightweight_mutex()
{ {
boost::detail::DeleteCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_)); boost::detail::DeleteCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
} }
class scoped_lock; class scoped_lock;
@@ -117,12 +121,12 @@ public:
explicit scoped_lock(lightweight_mutex & m): m_(m) explicit scoped_lock(lightweight_mutex & m): m_(m)
{ {
boost::detail::EnterCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); boost::detail::EnterCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
} }
~scoped_lock() ~scoped_lock()
{ {
boost::detail::LeaveCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_)); boost::detail::LeaveCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
} }
}; };
}; };
@@ -16,6 +16,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <machine/sys/inline.h> #include <machine/sys/inline.h>
namespace boost namespace boost
@@ -71,7 +72,7 @@ inline int atomic_conditional_increment( int * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -21,6 +21,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <builtins.h> #include <builtins.h>
#include <sys/atomic_op.h> #include <sys/atomic_op.h>
@@ -63,7 +64,7 @@ inline int32_t atomic_conditional_increment( int32_t * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -16,6 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
namespace boost namespace boost
@@ -63,7 +64,7 @@ inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t *
# pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wweak-vtables"
#endif #endif
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -25,6 +25,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -91,7 +92,7 @@ store:
return a; return a;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -26,6 +26,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -79,7 +80,7 @@ inline int atomic_conditional_increment( int * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -17,6 +17,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -78,7 +79,7 @@ inline int atomic_conditional_increment( int * pw )
return rv; return rv;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -21,6 +21,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -108,7 +109,7 @@ inline int atomic_conditional_increment( int * pw )
return rv; return rv;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -25,6 +25,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -102,7 +103,7 @@ inline int atomic_conditional_increment( int * pw )
return rv; return rv;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -20,6 +20,7 @@
// Thanks to Michael van der Westhuizen // Thanks to Michael van der Westhuizen
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <inttypes.h> // int32_t #include <inttypes.h> // int32_t
namespace boost namespace boost
@@ -87,7 +88,7 @@ inline int32_t atomic_conditional_increment( int32_t * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -25,6 +25,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -94,7 +95,7 @@ inline int atomic_conditional_increment( int * pw )
return rv; return rv;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -19,6 +19,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -26,7 +27,7 @@ namespace boost
namespace detail namespace detail
{ {
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -20,6 +20,7 @@
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/config.hpp>
#include <pthread.h> #include <pthread.h>
namespace boost namespace boost
@@ -28,7 +29,7 @@ namespace boost
namespace detail namespace detail
{ {
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -20,6 +20,7 @@
// Thanks to Michael van der Westhuizen // Thanks to Michael van der Westhuizen
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <inttypes.h> // uint32_t #include <inttypes.h> // uint32_t
namespace boost namespace boost
@@ -82,7 +83,7 @@ inline uint32_t atomic_conditional_increment( uint32_t * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -21,6 +21,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <atomic.h> #include <atomic.h>
namespace boost namespace boost
@@ -29,7 +30,7 @@ namespace boost
namespace detail namespace detail
{ {
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -20,6 +20,7 @@
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/smart_ptr/detail/spinlock_pool.hpp> #include <boost/smart_ptr/detail/spinlock_pool.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -51,7 +52,7 @@ inline int atomic_conditional_increment( int * pw )
return rv; return rv;
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -16,6 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <atomic> #include <atomic>
#include <cstdint> #include <cstdint>
@@ -57,7 +58,7 @@ inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -16,6 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
#include <limits.h> #include <limits.h>
#if defined( __ia64__ ) && defined( __INTEL_COMPILER ) #if defined( __ia64__ ) && defined( __INTEL_COMPILER )
@@ -76,7 +77,7 @@ inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -22,6 +22,7 @@
// //
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
extern "builtin" void __lwsync(void); extern "builtin" void __lwsync(void);
extern "builtin" void __isync(void); extern "builtin" void __isync(void);
@@ -70,7 +71,7 @@ inline int atomic_conditional_increment( int *pw )
} }
} }
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -27,6 +27,7 @@
#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/smart_ptr/detail/sp_interlocked.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/detail/sp_typeinfo.hpp> #include <boost/detail/sp_typeinfo.hpp>
#include <boost/config.hpp>
namespace boost namespace boost
{ {
@@ -34,7 +35,7 @@ namespace boost
namespace detail namespace detail
{ {
class sp_counted_base class BOOST_SYMBOL_VISIBLE sp_counted_base
{ {
private: private:
@@ -64,7 +64,7 @@ template<class D> D * get_local_deleter( local_sp_deleter<D> * p );
// //
template<class X> class sp_counted_impl_p: public sp_counted_base template<class X> class BOOST_SYMBOL_VISIBLE sp_counted_impl_p: public sp_counted_base
{ {
private: private:
@@ -143,7 +143,7 @@ public:
# pragma option push -Vx- # pragma option push -Vx-
#endif #endif
template<class P, class D> class sp_counted_impl_pd: public sp_counted_base template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public sp_counted_base
{ {
private: private:
@@ -216,7 +216,7 @@ public:
#endif #endif
}; };
template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base template<class P, class D, class A> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pda: public sp_counted_base
{ {
private: private:
@@ -32,11 +32,21 @@
// MinGW-w64 provides intrin.h for both 32 and 64-bit targets. // MinGW-w64 provides intrin.h for both 32 and 64-bit targets.
# define BOOST_SP_HAS_INTRIN_H # define BOOST_SP_HAS_INTRIN_H
#elif defined( __LP64__ )
// We have to use intrin.h on Cygwin 64
# define BOOST_SP_HAS_INTRIN_H
// Intel C++ on Windows on VC10+ stdlib // Intel C++ on Windows on VC10+ stdlib
#elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520 #elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
# define BOOST_SP_HAS_INTRIN_H # define BOOST_SP_HAS_INTRIN_H
// clang-cl on Windows on VC10+ stdlib
#elif defined( __clang__ ) && defined( _MSC_VER ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
# define BOOST_SP_HAS_INTRIN_H
#endif #endif
#if defined( BOOST_USE_WINDOWS_H ) #if defined( BOOST_USE_WINDOWS_H )
+14 -8
View File
@@ -60,18 +60,24 @@ namespace detail
{ {
#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME #if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
#if !BOOST_COMP_CLANG || !defined __MINGW32__
extern "C" void __stdcall Sleep( unsigned long ms ); #if defined(__clang__) && defined(__x86_64__)
// clang x64 warns that __stdcall is ignored
# define BOOST_SP_STDCALL
#else #else
#include <_mingw.h> # define BOOST_SP_STDCALL __stdcall
#if !defined __MINGW64_VERSION_MAJOR #endif
extern "C" void __stdcall Sleep( unsigned long ms );
#if defined(__LP64__) // Cygwin 64
extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned int ms );
#else #else
extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long ms ); extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned long ms );
#endif
#endif
#endif #endif
#undef BOOST_SP_STDCALL
#endif // !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
inline void yield( unsigned k ) inline void yield( unsigned k )
{ {
if( k < 4 ) if( k < 4 )
+9
View File
@@ -272,3 +272,12 @@ run lsp_convertible_test2.cpp ;
run make_shared_array_tmp_test.cpp ; run make_shared_array_tmp_test.cpp ;
run lw_thread_test.cpp : : : <threading>multi ; run lw_thread_test.cpp : : : <threading>multi ;
compile sp_windows_h_test.cpp ;
compile spinlock_windows_h_test.cpp ;
compile yield_k_windows_h_test.cpp ;
lib dll_test : dll_test_lib.cpp : <link>shared:<define>DLL_TEST_DYN_LINK=1 ;
run dll_test_main.cpp dll_test : : : <link>static : dll_test_static ;
run dll_test_main.cpp dll_test : : : <link>shared : dll_test_shared ;
+42
View File
@@ -0,0 +1,42 @@
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/config.hpp>
#include <memory>
#if defined(DLL_TEST_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT boost::shared_ptr<int> dll_test_41()
{
return boost::shared_ptr<int>( new int( 41 ) );
}
EXPORT boost::shared_ptr<int> dll_test_42()
{
return boost::make_shared<int>( 42 );
}
EXPORT boost::shared_ptr<int> dll_test_43()
{
return boost::allocate_shared<int>( std::allocator<int>(), 43 );
}
EXPORT boost::shared_ptr<int[]> dll_test_44()
{
return boost::make_shared<int[1]>( 44 );
}
EXPORT boost::shared_ptr<int[]> dll_test_45()
{
return boost::allocate_shared<int[1]>( std::allocator<int>(), 45 );
}
+45
View File
@@ -0,0 +1,45 @@
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_ptr<int> dll_test_41();
boost::shared_ptr<int> dll_test_42();
boost::shared_ptr<int> dll_test_43();
boost::shared_ptr<int[]> dll_test_44();
boost::shared_ptr<int[]> dll_test_45();
int main()
{
{
boost::shared_ptr<int> p = dll_test_41();
BOOST_TEST_EQ( *p, 41 );
}
{
boost::shared_ptr<int> p = dll_test_42();
BOOST_TEST_EQ( *p, 42 );
}
{
boost::shared_ptr<int> p = dll_test_43();
BOOST_TEST_EQ( *p, 43 );
}
{
boost::shared_ptr<int[]> p = dll_test_44();
BOOST_TEST_EQ( p[0], 44 );
}
{
boost::shared_ptr<int[]> p = dll_test_45();
BOOST_TEST_EQ( p[0], 45 );
}
return boost::report_errors();
}
+2 -2
View File
@@ -18,7 +18,7 @@ void f()
int main() int main()
{ {
int const N = 4; int const N = 4;
pthread_t th[ N ] = {}; boost::detail::lw_thread_t th[ N ] = {};
for( int i = 0; i < N; ++i ) for( int i = 0; i < N; ++i )
{ {
@@ -27,7 +27,7 @@ int main()
for( int i = 0; i < N; ++i ) for( int i = 0; i < N; ++i )
{ {
pthread_join( th[ i ], 0 ); boost::detail::lw_thread_join( th[ i ] );
} }
BOOST_TEST_EQ( count, N ); BOOST_TEST_EQ( count, N );
+12 -1
View File
@@ -13,9 +13,20 @@
#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/smart_ptr/detail/sp_interlocked.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#ifndef __LP64__
typedef long long_type;
#else
// On Cygwin 64, long is 64 bit
typedef int long_type;
#endif
int main() int main()
{ {
long x = 0, r; long_type x = 0, r;
r = BOOST_SP_INTERLOCKED_INCREMENT( &x ); r = BOOST_SP_INTERLOCKED_INCREMENT( &x );
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <windows.h>
# include <boost/shared_ptr.hpp>
#endif
int main()
{
}
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <windows.h>
# include <boost/smart_ptr/detail/spinlock.hpp>
#endif
int main()
{
}
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <windows.h>
# include <boost/smart_ptr/detail/yield_k.hpp>
#endif
int main()
{
}