forked from boostorg/smart_ptr
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04f0847af4 | |||
| 29a08cdff6 | |||
| 6d3af760f6 | |||
| a9f39d2b94 | |||
| 4e2f236116 | |||
| 4eb53db537 | |||
| a2b6ba85f3 | |||
| e37cd4154f | |||
| 8563fc5c4e | |||
| 67fab5c9ec | |||
| f16fbdce26 | |||
| c3b3835a58 | |||
| d1600b8abc | |||
| 5885763287 | |||
| 9bb12692b3 | |||
| 773ef80f5d | |||
| 704de2bd67 | |||
| 1caa233faa |
+2
-2
@@ -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
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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 )
|
||||||
|
|||||||
@@ -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 )
|
||||||
|
|||||||
@@ -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 ;
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -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 );
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user