diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-19 20:22:58 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2014-10-20 13:49:33 (GMT) |
commit | 6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch) | |
tree | 2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/smart_ptr/detail | |
parent | 38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff) | |
download | swift-contrib-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip swift-contrib-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2 |
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0.
Updated our update.sh script to stop on error.
Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to
missing include of <iostream> with newer Boost.
Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/smart_ptr/detail')
44 files changed, 2011 insertions, 469 deletions
diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp new file mode 100644 index 0000000..4f9dc2b --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * 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) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP + +#include <boost/align/align.hpp> +#include <boost/smart_ptr/detail/array_traits.hpp> +#include <boost/smart_ptr/detail/array_utility.hpp> +#include <boost/type_traits/alignment_of.hpp> + +namespace boost { + namespace detail { + struct ms_init_tag { }; + struct ms_noinit_tag { }; + + template<class T> + struct ms_allocator_state; + + template<class T> + struct ms_allocator_state<T[]> { + typedef typename array_base<T>::type type; + + ms_allocator_state(std::size_t size_, + type** result_) + : size(size_ * array_total<T>::size), + result(result_) { + } + + std::size_t size; + + union { + type** result; + type* object; + }; + }; + + template<class T, std::size_t N> + struct ms_allocator_state<T[N]> { + typedef typename array_base<T>::type type; + + ms_allocator_state(type** result_) + : result(result_) { + } + + enum { + size = array_total<T[N]>::size + }; + + union { + type** result; + type* object; + }; + }; + + template<class A, class T, class R> + class as_allocator + : public A { + template<class A_, class T_, class R_> + friend class as_allocator; + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef std::allocator_traits<A> AT; + typedef typename AT::template rebind_alloc<char> CA; + typedef typename AT::template rebind_traits<char> CT; +#else + typedef typename A::template rebind<char>::other CA; +#endif + + public: + typedef A allocator_type; + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef typename AT::value_type value_type; + typedef typename AT::pointer pointer; + typedef typename AT::const_pointer const_pointer; + typedef typename AT::void_pointer void_pointer; + typedef typename AT::const_void_pointer const_void_pointer; + typedef typename AT::size_type size_type; + typedef typename AT::difference_type difference_type; +#else + typedef typename A::value_type value_type; + typedef typename A::pointer pointer; + typedef typename A::const_pointer const_pointer; + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + typedef typename A::reference reference; + typedef typename A::const_reference const_reference; + typedef void* void_pointer; + typedef const void* const_void_pointer; +#endif + + template<class U> + struct rebind { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef as_allocator<typename AT:: + template rebind_alloc<U>, T, R> other; +#else + typedef as_allocator<typename A:: + template rebind<U>::other, T, R> other; +#endif + }; + + typedef typename array_base<T>::type type; + + as_allocator(const A& allocator_, type** result) + : A(allocator_), + data(result) { + } + + as_allocator(const A& allocator_, std::size_t size, + type** result) + : A(allocator_), + data(size, result) { + } + + template<class U> + as_allocator(const as_allocator<U, T, R>& other) + : A(other.allocator()), + data(other.data) { + } + + pointer allocate(size_type count, const_void_pointer = 0) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(value_type); + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; + CA ca(allocator()); + void* p1 = ca.allocate(n1 + n3); + void* p2 = static_cast<char*>(p1) + n1; + (void)boost::alignment::align(M, n2, p2, n3); + *data.result = static_cast<type*>(p2); + return static_cast<value_type*>(p1); + } + + void deallocate(pointer memory, size_type count) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(value_type); + std::size_t n2 = data.size * sizeof(type) + M; + char* p1 = reinterpret_cast<char*>(memory); + CA ca(allocator()); + ca.deallocate(p1, n1 + n2); + } + + const A& allocator() const { + return static_cast<const A&>(*this); + } + + A& allocator() { + return static_cast<A&>(*this); + } + + void set(type* memory) { + data.object = memory; + } + + void operator()() { + if (data.object) { + R tag; + release(tag); + } + } + + private: + void release(ms_init_tag) { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + as_destroy(allocator(), data.object, data.size); +#else + ms_destroy(data.object, data.size); +#endif + } + + void release(ms_noinit_tag) { + ms_destroy(data.object, data.size); + } + + ms_allocator_state<T> data; + }; + + template<class A1, class A2, class T, class R> + bool operator==(const as_allocator<A1, T, R>& a1, + const as_allocator<A2, T, R>& a2) { + return a1.allocator() == a2.allocator(); + } + + template<class A1, class A2, class T, class R> + bool operator!=(const as_allocator<A1, T, R>& a1, + const as_allocator<A2, T, R>& a2) { + return a1.allocator() != a2.allocator(); + } + + template<class T, class Y = char> + class ms_allocator; + + template<class T, class Y> + class ms_allocator { + template<class T_, class Y_> + friend class ms_allocator; + + public: + typedef typename array_base<T>::type type; + + typedef Y value_type; + typedef Y* pointer; + typedef const Y* const_pointer; + typedef std::size_t size_type; + typedef ptrdiff_t difference_type; + typedef Y& reference; + typedef const Y& const_reference; + + template<class U> + struct rebind { + typedef ms_allocator<T, U> other; + }; + + ms_allocator(type** result) + : data(result) { + } + + ms_allocator(std::size_t size, type** result) + : data(size, result) { + } + + template<class U> + ms_allocator(const ms_allocator<T, U>& other) + : data(other.data) { + } + + pointer allocate(size_type count, const void* = 0) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(Y); + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; + void* p1 = ::operator new(n1 + n3); + void* p2 = static_cast<char*>(p1) + n1; + (void)boost::alignment::align(M, n2, p2, n3); + *data.result = static_cast<type*>(p2); + return static_cast<Y*>(p1); + } + + void deallocate(pointer memory, size_type) { + void* p1 = memory; + ::operator delete(p1); + } + +#if defined(BOOST_NO_CXX11_ALLOCATOR) + pointer address(reference value) const { + return &value; + } + + const_pointer address(const_reference value) const { + return &value; + } + + size_type max_size() const { + enum { + N = static_cast<std::size_t>(-1) / sizeof(Y) + }; + return N; + } + + void construct(pointer memory, const_reference value) { + void* p1 = memory; + ::new(p1) Y(value); + } + + void destroy(pointer memory) { + (void)memory; + memory->~Y(); + } +#endif + + void set(type* memory) { + data.object = memory; + } + + void operator()() { + if (data.object) { + ms_destroy(data.object, data.size); + } + } + + private: + ms_allocator_state<T> data; + }; + + template<class T, class Y1, class Y2> + bool operator==(const ms_allocator<T, Y1>&, + const ms_allocator<T, Y2>&) { + return true; + } + + template<class T, class Y1, class Y2> + bool operator!=(const ms_allocator<T, Y1>&, + const ms_allocator<T, Y2>&) { + return false; + } + + class ms_in_allocator_tag { + public: + void operator()(const void*) { + } + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp new file mode 100644 index 0000000..b7c9617 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * 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) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP + +#include <boost/smart_ptr/detail/array_allocator.hpp> +#include <boost/smart_ptr/detail/sp_counted_impl.hpp> + +namespace boost { + namespace detail { + template<class P, class A> + class sp_counted_impl_pda<P, ms_in_allocator_tag, A> + : public sp_counted_base { + typedef ms_in_allocator_tag D; + typedef sp_counted_impl_pda<P, D, A> Y; + public: + sp_counted_impl_pda(P, D, const A& allocator_) + : allocator(allocator_) { + } + + virtual void dispose() { + allocator(); + } + + virtual void destroy() { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef typename std::allocator_traits<A>:: + template rebind_alloc<Y> YA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<Y> YT; +#else + typedef typename A::template rebind<Y>::other YA; +#endif + YA a1(allocator); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + YT::destroy(a1, this); + YT::deallocate(a1, this, 1); +#else + this->~Y(); + a1.deallocate(this, 1); +#endif + } + + virtual void* get_deleter(const sp_typeinfo&) { + return &reinterpret_cast<char&>(allocator); + } + + virtual void* get_untyped_deleter() { + return &reinterpret_cast<char&>(allocator); + } + + private: + sp_counted_impl_pda(const sp_counted_impl_pda&); + sp_counted_impl_pda& operator=(const sp_counted_impl_pda&); + + A allocator; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp new file mode 100644 index 0000000..819c5ba --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * 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) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP + +#include <boost/type_traits/remove_cv.hpp> + +namespace boost { + namespace detail { + template<class T> + struct array_base { + typedef typename boost::remove_cv<T>::type type; + }; + + template<class T> + struct array_base<T[]> { + typedef typename array_base<T>::type type; + }; + + template<class T, std::size_t N> + struct array_base<T[N]> { + typedef typename array_base<T>::type type; + }; + + template<class T> + struct array_total { + enum { + size = 1 + }; + }; + + template<class T, std::size_t N> + struct array_total<T[N]> { + enum { + size = N * array_total<T>::size + }; + }; + + template<class T> + struct array_inner; + + template<class T> + struct array_inner<T[]> { + typedef T type; + }; + + template<class T, std::size_t N> + struct array_inner<T[N]> { + typedef T type; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp new file mode 100644 index 0000000..84029a1 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * 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) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_UTILITY_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_UTILITY_HPP + +#include <boost/config.hpp> +#include <boost/type_traits/has_trivial_constructor.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#if !defined(BOOST_NO_CXX11_ALLOCATOR) +#include <memory> +#endif + +namespace boost { + namespace detail { + typedef boost::true_type ms_is_trivial; + typedef boost::false_type ms_no_trivial; + + template<class T> + inline void ms_destroy(T*, std::size_t, ms_is_trivial) { + } + + template<class T> + inline void ms_destroy(T* memory, std::size_t size, ms_no_trivial) { + for (std::size_t i = size; i > 0;) { + memory[--i].~T(); + } + } + + template<class T> + inline void ms_destroy(T* memory, std::size_t size) { + boost::has_trivial_destructor<T> trivial; + ms_destroy(memory, size, trivial); + } + + template<class T> + inline void ms_init(T* memory, std::size_t size, ms_is_trivial) { + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } + } + + template<class T> + inline void ms_init(T* memory, std::size_t size, ms_no_trivial) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } +#endif + } + + template<class T> + inline void ms_init(T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + ms_init(memory, size, trivial); + } + + template<class T, std::size_t N> + inline void ms_init(T* memory, std::size_t size, const T* list) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(list[i % N]); + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(list[i % N]); + } +#endif + } + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + template<class T, class A> + inline void as_destroy(const A& allocator, T* memory, + std::size_t size) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); + for (std::size_t i = size; i > 0;) { + TT::destroy(a2, &memory[--i]); + } + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size, + ms_is_trivial) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i); + } + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size, + ms_no_trivial) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + TT::construct(a2, memory + i); + } + } catch (...) { + as_destroy(a2, memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i); + } +#endif + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + as_init(allocator, memory, size, trivial); + } + + template<class T, class A, std::size_t N> + inline void as_init(const A& allocator, T* memory, std::size_t size, + const T* list) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + TT::construct(a2, memory + i, list[i % N]); + } + } catch (...) { + as_destroy(a2, memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i, list[i % N]); + } +#endif + } +#endif + + template<class T> + inline void ms_noinit(T*, std::size_t, ms_is_trivial) { + } + + template<class T> + inline void ms_noinit(T* memory, std::size_t size, ms_no_trivial) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T; + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T; + } +#endif + } + + template<class T> + inline void ms_noinit(T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + ms_noinit(memory, size, trivial); + } + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp index cc44ac2..8aefd44 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp @@ -11,10 +11,11 @@ // boost/detail/atomic_count.hpp - thread/SMP safe reference counter // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2013 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) +// 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 // // typedef <implementation-defined> boost::detail::atomic_count; // @@ -27,92 +28,68 @@ // a; // // Returns: (long) the current value of a +// Memory Ordering: acquire // // ++a; // // Effects: Atomically increments the value of a // Returns: (long) the new value of a +// Memory Ordering: acquire/release // // --a; // // Effects: Atomically decrements the value of a // Returns: (long) the new value of a -// -// Important note: when --a returns zero, it must act as a -// read memory barrier (RMB); i.e. the calling thread must -// have a synchronized view of the memory -// -// On Intel IA-32 (x86) memory is always synchronized, so this -// is not a problem. -// -// On many architectures the atomic instructions already act as -// a memory barrier. -// -// This property is necessary for proper reference counting, since -// a thread can update the contents of a shared object, then -// release its reference, and another thread may immediately -// release the last reference causing object destruction. -// -// The destructor needs to have a synchronized view of the -// object to perform proper cleanup. -// -// Original example by Alexander Terekhov: -// -// Given: -// -// - a mutable shared object OBJ; -// - two threads THREAD1 and THREAD2 each holding -// a private smart_ptr object pointing to that OBJ. -// -// t1: THREAD1 updates OBJ (thread-safe via some synchronization) -// and a few cycles later (after "unlock") destroys smart_ptr; -// -// t2: THREAD2 destroys smart_ptr WITHOUT doing any synchronization -// with respect to shared mutable object OBJ; OBJ destructors -// are called driven by smart_ptr interface... +// Memory Ordering: acquire/release // #include <boost/config.hpp> #include <boost/smart_ptr/detail/sp_has_sync.hpp> -#ifndef BOOST_HAS_THREADS +#if defined( BOOST_AC_DISABLE_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> -namespace boost -{ +#elif defined( BOOST_AC_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> -namespace detail -{ +#elif defined( BOOST_AC_USE_SPINLOCK ) +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> -typedef long atomic_count; +#elif defined( BOOST_AC_USE_PTHREADS ) +# include <boost/smart_ptr/detail/atomic_count_pt.hpp> -} +#elif defined( BOOST_SP_DISABLE_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> -} +#elif defined( BOOST_SP_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> -#elif defined(BOOST_AC_USE_PTHREADS) -# include <boost/smart_ptr/detail/atomic_count_pthreads.hpp> +#elif defined( BOOST_SP_USE_SPINLOCK ) +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> -#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) -# include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> +#elif defined( BOOST_SP_USE_PTHREADS ) +# include <boost/smart_ptr/detail/atomic_count_pt.hpp> -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# include <boost/smart_ptr/detail/atomic_count_win32.hpp> +#elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> + +#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ ) +# include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> #elif defined( BOOST_SP_HAS_SYNC ) -# include <boost/smart_ptr/detail/atomic_count_sync.hpp> +# include <boost/smart_ptr/detail/atomic_count_sync.hpp> -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) -# include <boost/smart_ptr/detail/atomic_count_gcc.hpp> +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# include <boost/smart_ptr/detail/atomic_count_win32.hpp> -#elif defined(BOOST_HAS_PTHREADS) +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +# include <boost/smart_ptr/detail/atomic_count_gcc.hpp> -# define BOOST_AC_USE_PTHREADS -# include <boost/smart_ptr/detail/atomic_count_pthreads.hpp> +#elif !defined( BOOST_HAS_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> #else - -// Use #define BOOST_DISABLE_THREADS to avoid the error -#error Unrecognized threading platform +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> #endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp new file mode 100644 index 0000000..3bbf138 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp @@ -0,0 +1,59 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED + +// +// boost/detail/atomic_count_nt.hpp +// +// Trivial atomic_count for the single-threaded case +// +// http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html +// +// Copyright 2013 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 +// + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + return ++value_; + } + + long operator--() + { + return --value_; + } + + operator long() const + { + return value_; + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + long value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pthreads.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pt.hpp index 05f7867..f99b910 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pthreads.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pt.hpp @@ -11,6 +11,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // +#include <boost/assert.hpp> #include <pthread.h> // @@ -37,12 +38,12 @@ private: scoped_lock(pthread_mutex_t & m): m_(m) { - pthread_mutex_lock(&m_); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); } ~scoped_lock() { - pthread_mutex_unlock(&m_); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } private: @@ -54,12 +55,12 @@ public: explicit atomic_count(long v): value_(v) { - pthread_mutex_init(&mutex_, 0); + BOOST_VERIFY( pthread_mutex_init( &mutex_, 0 ) == 0 ); } ~atomic_count() { - pthread_mutex_destroy(&mutex_); + BOOST_VERIFY( pthread_mutex_destroy( &mutex_ ) == 0 ); } long operator++() diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp new file mode 100644 index 0000000..8e62349 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp @@ -0,0 +1,62 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED + +// +// boost/detail/atomic_count_spin.hpp +// +// Copyright (c) 2013 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/smart_ptr/detail/spinlock_pool.hpp> + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +private: + +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return ++value_; + } + + long operator--() + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return --value_; + } + + operator long() const + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return value_; + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + long value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp new file mode 100644 index 0000000..55b9998 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp @@ -0,0 +1,60 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED + +// +// boost/detail/atomic_count_std_atomic.hpp +// +// atomic_count for std::atomic +// +// Copyright 2013 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 <atomic> +#include <cstdint> + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + return value_.fetch_add( 1, std::memory_order_acq_rel ) + 1; + } + + long operator--() + { + return value_.fetch_sub( 1, std::memory_order_acq_rel ) - 1; + } + + operator long() const + { + return value_.load( std::memory_order_acquire ); + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + std::atomic_int_least32_t value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp index 60a0569..633e73c 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp @@ -17,7 +17,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> namespace boost { @@ -35,12 +35,12 @@ public: long operator++() { - return BOOST_INTERLOCKED_INCREMENT( &value_ ); + return BOOST_SP_INTERLOCKED_INCREMENT( &value_ ); } long operator--() { - return BOOST_INTERLOCKED_DECREMENT( &value_ ); + return BOOST_SP_INTERLOCKED_DECREMENT( &value_ ); } operator long() const diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp index 00477e4..a93cf09 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp @@ -11,12 +11,15 @@ // boost/detail/lwm_win32_cs.hpp // // Copyright (c) 2002, 2003 Peter Dimov +// Copyright (c) Microsoft Corporation 2014 // // 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/predef.h> + #ifdef BOOST_USE_WINDOWS_H # include <windows.h> #endif @@ -43,7 +46,11 @@ struct critical_section #endif }; +#if BOOST_PLAT_WINDOWS_RUNTIME +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(critical_section *, unsigned long, unsigned long); +#else extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(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 *); @@ -67,7 +74,11 @@ public: lightweight_mutex() { +#if BOOST_PLAT_WINDOWS_RUNTIME + InitializeCriticalSectionEx(&cs_, 4000, 0); +#else InitializeCriticalSection(&cs_); +#endif } ~lightweight_mutex() diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp index 842a05d..8ae1527 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp @@ -1,14 +1,21 @@ // This header intentionally has no include guards. // -// Copyright (c) 2001-2009 Peter Dimov +// Copyright (c) 2001-2009, 2012 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(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) +#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR ) - operator bool () const + explicit operator bool () const BOOST_NOEXCEPT + { + return px != 0; + } + +#elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) + + operator bool () const BOOST_NOEXCEPT { return px != 0; } @@ -21,7 +28,7 @@ typedef void (*unspecified_bool_type)( this_type*** ); - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: unspecified_bool; } @@ -31,18 +38,18 @@ ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \ ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) ) - typedef T * (this_type::*unspecified_bool_type)() const; + typedef element_type * (this_type::*unspecified_bool_type)() const; - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: &this_type::get; } #else - typedef T * this_type::*unspecified_bool_type; + typedef element_type * this_type::*unspecified_bool_type; - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: &this_type::px; } @@ -50,7 +57,7 @@ #endif // operator! is redundant, but some compilers need it - bool operator! () const // never throws + bool operator! () const BOOST_NOEXCEPT { return px == 0; } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp deleted file mode 100644 index 450c9bc..0000000 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED -#define BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED - -// -// detail/shared_array_nmt.hpp - shared_array.hpp without member templates -// -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/shared_array.htm for documentation. -// - -#include <boost/assert.hpp> -#include <boost/checked_delete.hpp> -#include <boost/throw_exception.hpp> -#include <boost/smart_ptr/detail/atomic_count.hpp> - -#include <cstddef> // for std::ptrdiff_t -#include <algorithm> // for std::swap -#include <functional> // for std::less -#include <new> // for std::bad_alloc - -namespace boost -{ - -template<class T> class shared_array -{ -private: - - typedef detail::atomic_count count_type; - -public: - - typedef T element_type; - - explicit shared_array(T * p = 0): px(p) - { -#ifndef BOOST_NO_EXCEPTIONS - - try // prevent leak if new throws - { - pn = new count_type(1); - } - catch(...) - { - boost::checked_array_delete(p); - throw; - } - -#else - - pn = new count_type(1); - - if(pn == 0) - { - boost::checked_array_delete(p); - boost::throw_exception(std::bad_alloc()); - } - -#endif - } - - ~shared_array() - { - if(--*pn == 0) - { - boost::checked_array_delete(px); - delete pn; - } - } - - shared_array(shared_array const & r) : px(r.px) // never throws - { - pn = r.pn; - ++*pn; - } - - shared_array & operator=(shared_array const & r) - { - shared_array(r).swap(*this); - return *this; - } - - void reset(T * p = 0) - { - BOOST_ASSERT(p == 0 || p != px); - shared_array(p).swap(*this); - } - - T * get() const // never throws - { - return px; - } - - T & operator[](std::ptrdiff_t i) const // never throws - { - BOOST_ASSERT(px != 0); - BOOST_ASSERT(i >= 0); - return px[i]; - } - - long use_count() const // never throws - { - return *pn; - } - - bool unique() const // never throws - { - return *pn == 1; - } - - void swap(shared_array<T> & other) // never throws - { - std::swap(px, other.px); - std::swap(pn, other.pn); - } - -private: - - T * px; // contained pointer - count_type * pn; // ptr to reference counter - -}; // shared_array - -template<class T, class U> inline bool operator==(shared_array<T> const & a, shared_array<U> const & b) -{ - return a.get() == b.get(); -} - -template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b) -{ - return a.get() != b.get(); -} - -template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) -{ - return std::less<T*>()(a.get(), b.get()); -} - -template<class T> void swap(shared_array<T> & a, shared_array<T> & b) -{ - a.swap(b); -} - -} // namespace boost - -#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp index f96a220..1e7d688 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp @@ -35,7 +35,14 @@ // rather than including <memory> directly: #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr #include <functional> // std::less -#include <new> // std::bad_alloc + +#ifdef BOOST_NO_EXCEPTIONS +# include <new> // std::bad_alloc +#endif + +#if !defined( BOOST_NO_CXX11_SMART_PTR ) +# include <boost/utility/addressof.hpp> +#endif namespace boost { @@ -56,6 +63,38 @@ template< class D > struct sp_inplace_tag { }; +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + +template< class T > class sp_reference_wrapper +{ +public: + + explicit sp_reference_wrapper( T & t): t_( boost::addressof( t ) ) + { + } + + template< class Y > void operator()( Y * p ) const + { + (*t_)( p ); + } + +private: + + T * t_; +}; + +template< class D > struct sp_convert_reference +{ + typedef D type; +}; + +template< class D > struct sp_convert_reference< D& > +{ + typedef sp_reference_wrapper< D > type; +}; + +#endif + class weak_count; class shared_count @@ -161,7 +200,7 @@ public: } catch( ... ) { - D()( p ); // delete p + D::operator_fn( p ); // delete p throw; } @@ -171,7 +210,7 @@ public: if( pi_ == 0 ) { - D()( p ); // delete p + D::operator_fn( p ); // delete p boost::throw_exception( std::bad_alloc() ); } @@ -186,16 +225,35 @@ public: #endif { typedef sp_counted_impl_pda<P, D, A> impl_type; + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2; + +#else + typedef typename A::template rebind< impl_type >::other A2; +#endif + A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS try { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + std::allocator_traits<A2>::construct( a2, pi, p, d, a ); + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); - new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + +#endif } catch(...) { @@ -211,11 +269,28 @@ public: #else +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); +#endif + if( pi_ != 0 ) { - new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::construct( a2, pi, p, d, a ); + +#else + + ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + +#endif } else { @@ -234,20 +309,39 @@ public: #endif { typedef sp_counted_impl_pda< P, D, A > impl_type; + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2; + +#else + typedef typename A::template rebind< impl_type >::other A2; +#endif + A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS try { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + std::allocator_traits<A2>::construct( a2, pi, p, a ); + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); - new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + ::new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + +#endif } catch(...) { - D()( p ); + D::operator_fn( p ); if( pi_ != 0 ) { @@ -259,15 +353,32 @@ public: #else +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); +#endif + if( pi_ != 0 ) { - new( static_cast< void* >( pi_ ) ) impl_type( p, a ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::construct( a2, pi, p, a ); + +#else + + ::new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + +#endif } else { - D()( p ); + D::operator_fn( p ); boost::throw_exception( std::bad_alloc() ); } @@ -300,6 +411,33 @@ public: #endif +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + + template<class Y, class D> + explicit shared_count( std::unique_ptr<Y, D> & r ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + typedef typename sp_convert_reference<D>::type D2; + + D2 d2( r.get_deleter() ); + pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 ); + +#ifdef BOOST_NO_EXCEPTIONS + + if( pi_ == 0 ) + { + boost::throw_exception( std::bad_alloc() ); + } + +#endif + + r.release(); + } + +#endif + ~shared_count() // nothrow { if( pi_ != 0 ) pi_->release(); @@ -316,7 +454,7 @@ public: if( pi_ != 0 ) pi_->add_ref_copy(); } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) shared_count(shared_count && r): pi_(r.pi_) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) @@ -381,6 +519,11 @@ public: { return pi_? pi_->get_deleter( ti ): 0; } + + void * get_untyped_deleter() const + { + return pi_? pi_->get_untyped_deleter(): 0; + } }; @@ -423,7 +566,7 @@ public: // Move support -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) weak_count(weak_count && r): pi_(r.pi_) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp deleted file mode 100644 index afc1ec0..0000000 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED -#define BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED - -// -// detail/shared_ptr_nmt.hpp - shared_ptr.hpp without member templates -// -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. -// - -#include <boost/assert.hpp> -#include <boost/checked_delete.hpp> -#include <boost/throw_exception.hpp> -#include <boost/smart_ptr/detail/atomic_count.hpp> - -#ifndef BOOST_NO_AUTO_PTR -# include <memory> // for std::auto_ptr -#endif - -#include <algorithm> // for std::swap -#include <functional> // for std::less -#include <new> // for std::bad_alloc - -namespace boost -{ - -template<class T> class shared_ptr -{ -private: - - typedef detail::atomic_count count_type; - -public: - - typedef T element_type; - typedef T value_type; - - explicit shared_ptr(T * p = 0): px(p) - { -#ifndef BOOST_NO_EXCEPTIONS - - try // prevent leak if new throws - { - pn = new count_type(1); - } - catch(...) - { - boost::checked_delete(p); - throw; - } - -#else - - pn = new count_type(1); - - if(pn == 0) - { - boost::checked_delete(p); - boost::throw_exception(std::bad_alloc()); - } - -#endif - } - - ~shared_ptr() - { - if(--*pn == 0) - { - boost::checked_delete(px); - delete pn; - } - } - - shared_ptr(shared_ptr const & r): px(r.px) // never throws - { - pn = r.pn; - ++*pn; - } - - shared_ptr & operator=(shared_ptr const & r) - { - shared_ptr(r).swap(*this); - return *this; - } - -#ifndef BOOST_NO_AUTO_PTR - - explicit shared_ptr(std::auto_ptr<T> & r) - { - pn = new count_type(1); // may throw - px = r.release(); // fix: moved here to stop leak if new throws - } - - shared_ptr & operator=(std::auto_ptr<T> & r) - { - shared_ptr(r).swap(*this); - return *this; - } - -#endif - - void reset(T * p = 0) - { - BOOST_ASSERT(p == 0 || p != px); - shared_ptr(p).swap(*this); - } - - T & operator*() const // never throws - { - BOOST_ASSERT(px != 0); - return *px; - } - - T * operator->() const // never throws - { - BOOST_ASSERT(px != 0); - return px; - } - - T * get() const // never throws - { - return px; - } - - long use_count() const // never throws - { - return *pn; - } - - bool unique() const // never throws - { - return *pn == 1; - } - - void swap(shared_ptr<T> & other) // never throws - { - std::swap(px, other.px); - std::swap(pn, other.pn); - } - -private: - - T * px; // contained pointer - count_type * pn; // ptr to reference counter -}; - -template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) -{ - return a.get() == b.get(); -} - -template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) -{ - return a.get() != b.get(); -} - -template<class T> inline bool operator<(shared_ptr<T> const & a, shared_ptr<T> const & b) -{ - return std::less<T*>()(a.get(), b.get()); -} - -template<class T> void swap(shared_ptr<T> & a, shared_ptr<T> & b) -{ - a.swap(b); -} - -// get_pointer() enables boost::mem_fn to recognize shared_ptr - -template<class T> inline T * get_pointer(shared_ptr<T> const & p) -{ - return p.get(); -} - -} // namespace boost - -#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp index eb39797..31b2627 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp @@ -48,6 +48,21 @@ template< class Y, class T > struct sp_convertible enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) }; }; +template< class Y, class T > struct sp_convertible< Y, T[] > +{ + enum _vt { value = false }; +}; + +template< class Y, class T > struct sp_convertible< Y[], T[] > +{ + enum _vt { value = sp_convertible< Y[1], T[1] >::value }; +}; + +template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] > +{ + enum _vt { value = sp_convertible< Y[1], T[1] >::value }; +}; + struct sp_empty { }; diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp index 24adfcc..c415892 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp @@ -10,7 +10,7 @@ // // detail/sp_counted_base.hpp // -// Copyright 2005, 2006 Peter Dimov +// Copyright 2005-2013 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,9 @@ #if defined( BOOST_SP_DISABLE_THREADS ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> +#elif defined( BOOST_SP_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp> + #elif defined( BOOST_SP_USE_SPINLOCK ) # include <boost/smart_ptr/detail/sp_counted_base_spin.hpp> @@ -32,25 +35,28 @@ #elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> -#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) -# include <boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp> +#elif defined( __SNC__ ) +# include <boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp> -#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) -# include <boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp> +#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined(__PATHSCALE__) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp> #elif defined(__HP_aCC) && defined(__ia64) # include <boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp> +#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) && !defined(__PATHSCALE__) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp> + #elif defined( __IBMCPP__ ) && defined( __powerpc ) # include <boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp> #elif defined( __MWERKS__ ) && defined( __POWERPC__ ) # include <boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp> -#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc ) ) +#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc ) ) && !defined(__PATHSCALE__) && !defined( _AIX ) # include <boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp> -#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) +#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) && !defined(__PATHSCALE__) # include <boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp> #elif defined( BOOST_SP_HAS_SYNC ) @@ -62,6 +68,9 @@ #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__) # include <boost/smart_ptr/detail/sp_counted_base_w32.hpp> +#elif defined( _AIX ) +# include <boost/smart_ptr/detail/sp_counted_base_aix.hpp> + #elif !defined( BOOST_HAS_THREADS ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp index dffd995..cebc243 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp new file mode 100644 index 0000000..fe6c727 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp @@ -0,0 +1,143 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED + +// +// detail/sp_counted_base_aix.hpp +// based on: detail/sp_counted_base_w32.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// Copyright 2006 Michael van der Westhuizen +// +// 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/detail/sp_typeinfo.hpp> +#include <builtins.h> +#include <sys/atomic_op.h> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int32_t* pw ) +{ + // ++*pw; + + fetch_and_add( pw, 1 ); +} + +inline int32_t atomic_decrement( int32_t * pw ) +{ + // return --*pw; + + int32_t originalValue; + + __lwsync(); + originalValue = fetch_and_add( pw, -1 ); + __isync(); + + return (originalValue - 1); +} + +inline int32_t atomic_conditional_increment( int32_t * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int32_t tmp = fetch_and_add( pw, 0 ); + for( ;; ) + { + if( tmp == 0 ) return 0; + if( compare_and_swap( pw, &tmp, tmp + 1 ) ) return (tmp + 1); + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int32_t use_count_; // #shared + int32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return fetch_and_add( const_cast<int32_t*>(&use_count_), 0 ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp index 51ac56a..6c268e8 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp @@ -124,6 +124,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp index d122a49..f6e3904 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp @@ -111,6 +111,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp index 3f1f449..545c8ae 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp index 7f5c414..2e5bc0e 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp index 21fa59d..c6d20ce 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp @@ -120,6 +120,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp index 4d7fa8d..173dce5 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp @@ -127,6 +127,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp index dfd70e7..5c901f9 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp @@ -59,6 +59,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp index 3c56fec..a16d2d8 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp @@ -19,6 +19,7 @@ // #include <boost/detail/sp_typeinfo.hpp> +#include <boost/assert.hpp> #include <pthread.h> namespace boost @@ -46,15 +47,15 @@ public: // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init #if defined(__hpux) && defined(_DECTHREADS_) - pthread_mutex_init( &m_, pthread_mutexattr_default ); + BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); #else - pthread_mutex_init( &m_, 0 ); + BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); #endif } virtual ~sp_counted_base() // nothrow { - pthread_mutex_destroy( &m_ ); + BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); } // dispose() is called when use_count_ drops to zero, to release @@ -70,27 +71,28 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } bool add_ref_lock() // true on success { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); bool r = use_count_ == 0? false: ( ++use_count_, true ); - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; } void release() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_use_count = --use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_use_count == 0 ) { @@ -101,16 +103,16 @@ public: void weak_add_ref() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++weak_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } void weak_release() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_weak_count = --weak_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_weak_count == 0 ) { @@ -120,9 +122,9 @@ public: long use_count() const // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long r = use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp new file mode 100644 index 0000000..56ed79f --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp @@ -0,0 +1,162 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_gcc_sparc.hpp - g++ on Sparc V8+ +// +// Copyright (c) 2006 Piotr Wyderski +// Copyright (c) 2006 Tomas Puverle +// Copyright (c) 2006 Peter Dimov +// Copyright (c) 2011 Emil Dotchevski +// +// 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 +// +// Thanks to Michael van der Westhuizen + +#include <boost/detail/sp_typeinfo.hpp> +#include <inttypes.h> // uint32_t + +namespace boost +{ + +namespace detail +{ + +inline uint32_t compare_and_swap( uint32_t * dest_, uint32_t compare_, uint32_t swap_ ) +{ + return __builtin_cellAtomicCompareAndSwap32(dest_,compare_,swap_); +} + +inline uint32_t atomic_fetch_and_add( uint32_t * pw, uint32_t dv ) +{ + // long r = *pw; + // *pw += dv; + // return r; + + for( ;; ) + { + uint32_t r = *pw; + + if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) ) + { + return r; + } + } +} + +inline void atomic_increment( uint32_t * pw ) +{ + (void) __builtin_cellAtomicIncr32( pw ); +} + +inline uint32_t atomic_decrement( uint32_t * pw ) +{ + return __builtin_cellAtomicDecr32( pw ); +} + +inline uint32_t atomic_conditional_increment( uint32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + for( ;; ) + { + uint32_t r = *pw; + + if( r == 0 ) + { + return r; + } + + if( __builtin_expect( ( compare_and_swap( pw, r, r + 1 ) == r ), 1 ) ) + { + return r; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + uint32_t use_count_; // #shared + uint32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return const_cast< uint32_t const volatile & >( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp index bbd11e6..77734e7 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp @@ -84,6 +84,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp new file mode 100644 index 0000000..cab8453 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp @@ -0,0 +1,137 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_std_atomic.hpp - C++11 std::atomic +// +// Copyright (c) 2007, 2013 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/detail/sp_typeinfo.hpp> +#include <atomic> +#include <cstdint> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( std::atomic_int_least32_t * pw ) +{ + pw->fetch_add( 1, std::memory_order_relaxed ); +} + +inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw ) +{ + return pw->fetch_sub( 1, std::memory_order_acq_rel ); +} + +inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + std::int_least32_t r = pw->load( std::memory_order_relaxed ); + + for( ;; ) + { + if( r == 0 ) + { + return r; + } + + if( pw->compare_exchange_weak( r, r + 1, std::memory_order_relaxed, std::memory_order_relaxed ) ) + { + return r; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + std::atomic_int_least32_t use_count_; // #shared + std::atomic_int_least32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return use_count_.load( std::memory_order_acquire ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp index 41f654e..fafed0e 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp @@ -109,6 +109,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp index 842f58f..162f309 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp index 06aa456..4ba509c 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp @@ -24,7 +24,7 @@ // formulation // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/detail/workaround.hpp> #include <boost/detail/sp_typeinfo.hpp> @@ -67,10 +67,11 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { - BOOST_INTERLOCKED_INCREMENT( &use_count_ ); + BOOST_SP_INTERLOCKED_INCREMENT( &use_count_ ); } bool add_ref_lock() // true on success @@ -85,11 +86,11 @@ public: // work around a code generation bug long tmp2 = tmp + 1; - if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; #else - if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; #endif } @@ -97,7 +98,7 @@ public: void release() // nothrow { - if( BOOST_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) + if( BOOST_SP_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) { dispose(); weak_release(); @@ -106,12 +107,12 @@ public: void weak_add_ref() // nothrow { - BOOST_INTERLOCKED_INCREMENT( &weak_count_ ); + BOOST_SP_INTERLOCKED_INCREMENT( &weak_count_ ); } void weak_release() // nothrow { - if( BOOST_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) + if( BOOST_SP_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) { destroy(); } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp index aab39bd..a7b43ae 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp @@ -83,6 +83,11 @@ public: return 0; } + virtual void * get_untyped_deleter() + { + return 0; + } + #if defined(BOOST_SP_USE_STD_ALLOCATOR) void * operator new( std::size_t ) @@ -153,6 +158,11 @@ public: return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0; } + virtual void * get_untyped_deleter() + { + return &reinterpret_cast<char&>( del ); + } + #if defined(BOOST_SP_USE_STD_ALLOCATOR) void * operator new( std::size_t ) @@ -203,7 +213,7 @@ public: { } - sp_counted_impl_pda( P p, A a ): p_( p ), d_(), a_( a ) + sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a ) { } @@ -214,11 +224,28 @@ public: virtual void destroy() // nothrow { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< this_type > A2; + +#else + typedef typename A::template rebind< this_type >::other A2; +#endif + A2 a2( a_ ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::destroy( a2, this ); + +#else + this->~this_type(); + +#endif + a2.deallocate( this, 1 ); } @@ -226,6 +253,11 @@ public: { return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0; } + + virtual void * get_untyped_deleter() + { + return &reinterpret_cast<char&>( d_ ); + } }; #ifdef __CODEGUARD__ diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp new file mode 100644 index 0000000..5f1d190 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_forward.hpp +// +// Copyright 2008,2012 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/config.hpp> + +namespace boost +{ + +namespace detail +{ + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +template< class T > T&& sp_forward( T & t ) BOOST_NOEXCEPT +{ + return static_cast< T&& >( t ); +} + +#endif + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp index 12acea8..16de21d 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp @@ -20,7 +20,17 @@ // are available. // -#if defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) && !defined( BOOST_SP_NO_SYNC ) +#ifndef BOOST_SP_NO_SYNC + +#if defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 ) + +# define BOOST_SP_HAS_SYNC + +#elif defined( __IBMCPP__ ) && ( __IBMCPP__ >= 1210 ) + +# define BOOST_SP_HAS_SYNC + +#elif defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) #define BOOST_SP_HAS_SYNC @@ -44,10 +54,16 @@ #undef BOOST_SP_HAS_SYNC #endif -#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1100 ) +#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1110 ) #undef BOOST_SP_HAS_SYNC #endif -#endif // __GNUC__ * 100 + __GNUC_MINOR__ >= 401 +#if defined(__PATHSCALE__) && ((__PATHCC__ == 4) && (__PATHCC_MINOR__ < 9)) +#undef BOOST_SP_HAS_SYNC +#endif + +#endif + +#endif // #ifndef BOOST_SP_NO_SYNC #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp new file mode 100644 index 0000000..9a2c1e0 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * 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) + */ +#ifndef BOOST_SMART_PTR_DETAIL_SP_IF_ARRAY_HPP +#define BOOST_SMART_PTR_DETAIL_SP_IF_ARRAY_HPP + +#include <boost/smart_ptr/shared_ptr.hpp> + +namespace boost { + namespace detail { + template<class T> + struct sp_if_array; + + template<class T> + struct sp_if_array<T[]> { + typedef boost::shared_ptr<T[]> type; + }; + + template<class T> + struct sp_if_size_array; + + template<class T, std::size_t N> + struct sp_if_size_array<T[N]> { + typedef boost::shared_ptr<T[N]> type; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp new file mode 100644 index 0000000..814b0c2 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp @@ -0,0 +1,152 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/sp_interlocked.hpp +// +// Copyright 2005, 2014 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/config.hpp> + +// BOOST_SP_HAS_INTRIN_H + +// VC9 has intrin.h, but it collides with <utility> +#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1600 + +# define BOOST_SP_HAS_INTRIN_H + +// Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. +#elif defined( __MINGW64_VERSION_MAJOR ) + +// MinGW-w64 provides intrin.h for both 32 and 64-bit targets. +# define BOOST_SP_HAS_INTRIN_H + +// Intel C++ on Windows on VC10+ stdlib +#elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520 + +# define BOOST_SP_HAS_INTRIN_H + +#endif + +#if defined( BOOST_USE_WINDOWS_H ) + +# include <windows.h> + +# define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd + +#elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H ) + +#include <intrin.h> + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#elif defined( _WIN32_WCE ) + +#if _WIN32_WCE >= 0x600 + +extern "C" long __cdecl _InterlockedIncrement( long volatile * ); +extern "C" long __cdecl _InterlockedDecrement( long volatile * ); +extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#else + +// under Windows CE we still have old-style Interlocked* functions + +extern "C" long __cdecl InterlockedIncrement( long* ); +extern "C" long __cdecl InterlockedDecrement( long* ); +extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); +extern "C" long __cdecl InterlockedExchange( long*, long ); +extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); + +# define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd + +#endif + +#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) + +#if defined( __CLRCALL_PURE_OR_CDECL ) + +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); + +#else + +extern "C" long __cdecl _InterlockedIncrement( long volatile * ); +extern "C" long __cdecl _InterlockedDecrement( long volatile * ); +extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +#endif + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) + +namespace boost +{ + +namespace detail +{ + +extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * ); +extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * ); +extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long ); +extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long ); +extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long ); + +} // namespace detail + +} // namespace boost + +# define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd + +#else + +# error "Interlocked intrinsics not available" + +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp new file mode 100644 index 0000000..ccbb123 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp @@ -0,0 +1,45 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_nullptr_t.hpp +// +// Copyright 2013 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/config.hpp> +#include <cstddef> + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +namespace boost +{ + +namespace detail +{ + +#if defined( __clang__ ) && !defined( _LIBCPP_VERSION ) && !defined( BOOST_NO_CXX11_DECLTYPE ) + + typedef decltype(nullptr) sp_nullptr_t; + +#else + + typedef std::nullptr_t sp_nullptr_t; + +#endif + +} // namespace detail + +} // namespace boost + +#endif // !defined( BOOST_NO_CXX11_NULLPTR ) + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp index 88d7ad6..19f93d7 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp @@ -31,7 +31,16 @@ #include <boost/config.hpp> #include <boost/smart_ptr/detail/sp_has_sync.hpp> -#if defined( BOOST_SP_USE_PTHREADS ) +#if defined( BOOST_SP_USE_STD_ATOMIC ) +# if !defined( __clang__ ) +# include <boost/smart_ptr/detail/spinlock_std_atomic.hpp> +# else +// Clang (at least up to 3.4) can't compile spinlock_pool when +// using std::atomic, so substitute the __sync implementation instead. +# include <boost/smart_ptr/detail/spinlock_sync.hpp> +# endif + +#elif defined( BOOST_SP_USE_PTHREADS ) # include <boost/smart_ptr/detail/spinlock_pt.hpp> #elif defined(__GNUC__) && defined( __arm__ ) && !defined( __thumb__ ) diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp index f1bbaf6..016796a 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp @@ -11,13 +11,15 @@ #include <boost/smart_ptr/detail/yield_k.hpp> -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__) # define BOOST_SP_ARM_BARRIER "dmb" +# define BOOST_SP_ARM_HAS_LDREX #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) # define BOOST_SP_ARM_BARRIER "mcr p15, 0, r0, c7, c10, 5" +# define BOOST_SP_ARM_HAS_LDREX #else @@ -43,17 +45,7 @@ public: { int r; -#if defined(__ARM_ARCH_6__) \ - || defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) \ - || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) \ - || defined(__ARM_ARCH_6T2__) \ - || defined(__ARM_ARCH_7__) \ - || defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) \ - || defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) +#ifdef BOOST_SP_ARM_HAS_LDREX __asm__ __volatile__( "ldrex %0, [%2]; \n" @@ -123,5 +115,6 @@ public: #define BOOST_DETAIL_SPINLOCK_INIT {0} #undef BOOST_SP_ARM_BARRIER +#undef BOOST_SP_ARM_HAS_LDREX #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp new file mode 100644 index 0000000..a61c1cd --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp @@ -0,0 +1,83 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2014 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/smart_ptr/detail/yield_k.hpp> +#include <atomic> + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + std::atomic_flag v_; + +public: + + bool try_lock() + { + return !v_.test_and_set( std::memory_order_acquire ); + } + + void lock() + { + for( unsigned k = 0; !try_lock(); ++k ) + { + boost::detail::yield( k ); + } + } + + void unlock() + { + v_ .clear( std::memory_order_release ); + } + +public: + + class scoped_lock + { + private: + + spinlock & sp_; + + scoped_lock( scoped_lock const & ); + scoped_lock & operator=( scoped_lock const & ); + + public: + + explicit scoped_lock( spinlock & sp ): sp_( sp ) + { + sp.lock(); + } + + ~scoped_lock() + { + sp_.unlock(); + } + }; +}; + +} // namespace detail +} // namespace boost + +#define BOOST_DETAIL_SPINLOCK_INIT { ATOMIC_FLAG_INIT } + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp index fb97629..d34e4fc 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp @@ -15,7 +15,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/smart_ptr/detail/yield_k.hpp> // BOOST_COMPILER_FENCE @@ -59,7 +59,7 @@ public: bool try_lock() { - long r = BOOST_INTERLOCKED_EXCHANGE( &v_, 1 ); + long r = BOOST_SP_INTERLOCKED_EXCHANGE( &v_, 1 ); BOOST_COMPILER_FENCE diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp index 23eadd8..9f4496b 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp @@ -11,6 +11,7 @@ // yield_k.hpp // // Copyright (c) 2008 Peter Dimov +// Copyright (c) Microsoft Corporation 2014 // // void yield( unsigned k ); // @@ -24,13 +25,17 @@ // #include <boost/config.hpp> +#include <boost/predef.h> + +#if BOOST_PLAT_WINDOWS_RUNTIME +#include <thread> +#endif // BOOST_SMT_PAUSE #if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) extern "C" void _mm_pause(); -#pragma intrinsic( _mm_pause ) #define BOOST_SMT_PAUSE _mm_pause(); @@ -54,7 +59,7 @@ namespace boost namespace detail { -#if !defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME extern "C" void __stdcall Sleep( unsigned long ms ); #endif @@ -69,6 +74,7 @@ inline void yield( unsigned k ) BOOST_SMT_PAUSE } #endif +#if !BOOST_PLAT_WINDOWS_RUNTIME else if( k < 32 ) { Sleep( 0 ); @@ -77,6 +83,13 @@ inline void yield( unsigned k ) { Sleep( 1 ); } +#else + else + { + // Sleep isn't supported on the Windows Runtime. + std::this_thread::yield(); + } +#endif } } // namespace detail |