diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-06-27 11:11:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-27 11:11:13 (GMT) |
commit | e24393f41834f116038faf6c6d5012575a67136a (patch) | |
tree | a1e83679e55781bc92849a07c5acda7b5c09908c /contrib/src/boost/smart_ptr | |
parent | b3a2d91805feb81f79ee52c30a077521912b0bf9 (diff) | |
parent | 3a5692f40663282640775f8ff497c4860d265a2a (diff) | |
download | uscxml-e24393f41834f116038faf6c6d5012575a67136a.zip uscxml-e24393f41834f116038faf6c6d5012575a67136a.tar.gz uscxml-e24393f41834f116038faf6c6d5012575a67136a.tar.bz2 |
Merge pull request #149 from tklab-tud/sradomski
remerge
Diffstat (limited to 'contrib/src/boost/smart_ptr')
42 files changed, 6653 insertions, 6677 deletions
diff --git a/contrib/src/boost/smart_ptr/bad_weak_ptr.hpp b/contrib/src/boost/smart_ptr/bad_weak_ptr.hpp index 845db90..3e0a1b7 100644 --- a/contrib/src/boost/smart_ptr/bad_weak_ptr.hpp +++ b/contrib/src/boost/smart_ptr/bad_weak_ptr.hpp @@ -1,68 +1,59 @@ -#ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
-#define BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/smart_ptr/bad_weak_ptr.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-//
-// 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 <exception>
-
-#ifdef __BORLANDC__
-# pragma warn -8026 // Functions with excep. spec. are not expanded inline
-#endif
-
-namespace boost
-{
-
-// The standard library that comes with Borland C++ 5.5.1, 5.6.4
-// defines std::exception and its members as having C calling
-// convention (-pc). When the definition of bad_weak_ptr
-// is compiled with -ps, the compiler issues an error.
-// Hence, the temporary #pragma option -pc below.
-
-#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564
-# pragma option push -pc
-#endif
-
-#if defined(__clang__)
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wweak-vtables"
-#endif
-
-class bad_weak_ptr: public std::exception
-{
-public:
-
- virtual char const * what() const throw()
- {
- return "tr1::bad_weak_ptr";
- }
-};
-
-#if defined(__clang__)
-# pragma clang diagnostic pop
-#endif
-
-#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564
-# pragma option pop
-#endif
-
-} // namespace boost
-
-#ifdef __BORLANDC__
-# pragma warn .8026 // Functions with excep. spec. are not expanded inline
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED +#define BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/smart_ptr/bad_weak_ptr.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// +// 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 <exception> + +#ifdef __BORLANDC__ +# pragma warn -8026 // Functions with excep. spec. are not expanded inline +#endif + +namespace boost +{ + +// The standard library that comes with Borland C++ 5.5.1, 5.6.4 +// defines std::exception and its members as having C calling +// convention (-pc). When the definition of bad_weak_ptr +// is compiled with -ps, the compiler issues an error. +// Hence, the temporary #pragma option -pc below. + +#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564 +# pragma option push -pc +#endif + +class bad_weak_ptr: public std::exception +{ +public: + + virtual char const * what() const throw() + { + return "tr1::bad_weak_ptr"; + } +}; + +#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564 +# pragma option pop +#endif + +} // namespace boost + +#ifdef __BORLANDC__ +# pragma warn .8026 // Functions with excep. spec. are not expanded inline +#endif + +#endif // #ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/lightweight_mutex.hpp b/contrib/src/boost/smart_ptr/detail/lightweight_mutex.hpp index f6c159e..d46b193 100644 --- a/contrib/src/boost/smart_ptr/detail/lightweight_mutex.hpp +++ b/contrib/src/boost/smart_ptr/detail/lightweight_mutex.hpp @@ -1,42 +1,42 @@ -#ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/detail/lightweight_mutex.hpp - lightweight mutex
-//
-// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
-//
-// 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 <unspecified> boost::detail::lightweight_mutex;
-//
-// boost::detail::lightweight_mutex is a header-only implementation of
-// a subset of the Mutex concept requirements:
-//
-// http://www.boost.org/doc/html/threads/concepts.html#threads.concepts.Mutex
-//
-// It maps to a CRITICAL_SECTION on Windows or a pthread_mutex on POSIX.
-//
-
-#include <boost/config.hpp>
-
-#if !defined(BOOST_HAS_THREADS)
-# include <boost/smart_ptr/detail/lwm_nop.hpp>
-#elif defined(BOOST_HAS_PTHREADS)
-# include <boost/smart_ptr/detail/lwm_pthreads.hpp>
-#elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# include <boost/smart_ptr/detail/lwm_win32_cs.hpp>
-#else
-// Use #define BOOST_DISABLE_THREADS to avoid the error
-# error Unrecognized threading platform
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/lightweight_mutex.hpp - lightweight mutex +// +// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd. +// +// 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 <unspecified> boost::detail::lightweight_mutex; +// +// boost::detail::lightweight_mutex is a header-only implementation of +// a subset of the Mutex concept requirements: +// +// http://www.boost.org/doc/html/threads/concepts.html#threads.concepts.Mutex +// +// It maps to a CRITICAL_SECTION on Windows or a pthread_mutex on POSIX. +// + +#include <boost/config.hpp> + +#if !defined(BOOST_HAS_THREADS) +# include <boost/smart_ptr/detail/lwm_nop.hpp> +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/smart_ptr/detail/lwm_pthreads.hpp> +#elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# include <boost/smart_ptr/detail/lwm_win32_cs.hpp> +#else +// Use #define BOOST_DISABLE_THREADS to avoid the error +# error Unrecognized threading platform +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/lwm_nop.hpp b/contrib/src/boost/smart_ptr/detail/lwm_nop.hpp index cc1e97f..521a88e 100644 --- a/contrib/src/boost/smart_ptr/detail/lwm_nop.hpp +++ b/contrib/src/boost/smart_ptr/detail/lwm_nop.hpp @@ -1,37 +1,37 @@ -#ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/detail/lwm_nop.hpp
-//
-// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
-//
-// 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 lightweight_mutex
-{
-public:
-
- typedef lightweight_mutex scoped_lock;
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/lwm_nop.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// 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 lightweight_mutex +{ +public: + + typedef lightweight_mutex scoped_lock; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/lwm_pthreads.hpp b/contrib/src/boost/smart_ptr/detail/lwm_pthreads.hpp index 6a2b70b..8eda518 100644 --- a/contrib/src/boost/smart_ptr/detail/lwm_pthreads.hpp +++ b/contrib/src/boost/smart_ptr/detail/lwm_pthreads.hpp @@ -1,87 +1,87 @@ -#ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/detail/lwm_pthreads.hpp
-//
-// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
-//
-// 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/assert.hpp>
-#include <pthread.h>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class lightweight_mutex
-{
-private:
-
- pthread_mutex_t m_;
-
- lightweight_mutex(lightweight_mutex const &);
- lightweight_mutex & operator=(lightweight_mutex const &);
-
-public:
-
- lightweight_mutex()
- {
-
-// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
-
-#if defined(__hpux) && defined(_DECTHREADS_)
- BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 );
-#else
- BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 );
-#endif
- }
-
- ~lightweight_mutex()
- {
- BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
- }
-
- class scoped_lock;
- friend class scoped_lock;
-
- class scoped_lock
- {
- private:
-
- pthread_mutex_t & m_;
-
- scoped_lock(scoped_lock const &);
- scoped_lock & operator=(scoped_lock const &);
-
- public:
-
- scoped_lock(lightweight_mutex & m): m_(m.m_)
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- }
-
- ~scoped_lock()
- {
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
- }
- };
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/lwm_pthreads.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// 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/assert.hpp> +#include <pthread.h> + +namespace boost +{ + +namespace detail +{ + +class lightweight_mutex +{ +private: + + pthread_mutex_t m_; + + lightweight_mutex(lightweight_mutex const &); + lightweight_mutex & operator=(lightweight_mutex const &); + +public: + + lightweight_mutex() + { + +// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init + +#if defined(__hpux) && defined(_DECTHREADS_) + BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); +#else + BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); +#endif + } + + ~lightweight_mutex() + { + BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); + } + + class scoped_lock; + friend class scoped_lock; + + class scoped_lock + { + private: + + pthread_mutex_t & m_; + + scoped_lock(scoped_lock const &); + scoped_lock & operator=(scoped_lock const &); + + public: + + scoped_lock(lightweight_mutex & m): m_(m.m_) + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + } + + ~scoped_lock() + { + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + } + }; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/lwm_win32_cs.hpp b/contrib/src/boost/smart_ptr/detail/lwm_win32_cs.hpp index a1dbb0f..a93cf09 100644 --- a/contrib/src/boost/smart_ptr/detail/lwm_win32_cs.hpp +++ b/contrib/src/boost/smart_ptr/detail/lwm_win32_cs.hpp @@ -1,119 +1,119 @@ -#ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// 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
-
-namespace boost
-{
-
-namespace detail
-{
-
-#ifndef BOOST_USE_WINDOWS_H
-
-struct critical_section
-{
- struct critical_section_debug * DebugInfo;
- long LockCount;
- long RecursionCount;
- void * OwningThread;
- void * LockSemaphore;
-#if defined(_WIN64)
- unsigned __int64 SpinCount;
-#else
- unsigned long SpinCount;
-#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 *);
-
-#else
-
-typedef ::CRITICAL_SECTION critical_section;
-
-#endif // #ifndef BOOST_USE_WINDOWS_H
-
-class lightweight_mutex
-{
-private:
-
- critical_section cs_;
-
- lightweight_mutex(lightweight_mutex const &);
- lightweight_mutex & operator=(lightweight_mutex const &);
-
-public:
-
- lightweight_mutex()
- {
-#if BOOST_PLAT_WINDOWS_RUNTIME
- InitializeCriticalSectionEx(&cs_, 4000, 0);
-#else
- InitializeCriticalSection(&cs_);
-#endif
- }
-
- ~lightweight_mutex()
- {
- DeleteCriticalSection(&cs_);
- }
-
- class scoped_lock;
- friend class scoped_lock;
-
- class scoped_lock
- {
- private:
-
- lightweight_mutex & m_;
-
- scoped_lock(scoped_lock const &);
- scoped_lock & operator=(scoped_lock const &);
-
- public:
-
- explicit scoped_lock(lightweight_mutex & m): m_(m)
- {
- EnterCriticalSection(&m_.cs_);
- }
-
- ~scoped_lock()
- {
- LeaveCriticalSection(&m_.cs_);
- }
- };
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// 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 + +namespace boost +{ + +namespace detail +{ + +#ifndef BOOST_USE_WINDOWS_H + +struct critical_section +{ + struct critical_section_debug * DebugInfo; + long LockCount; + long RecursionCount; + void * OwningThread; + void * LockSemaphore; +#if defined(_WIN64) + unsigned __int64 SpinCount; +#else + unsigned long SpinCount; +#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 *); + +#else + +typedef ::CRITICAL_SECTION critical_section; + +#endif // #ifndef BOOST_USE_WINDOWS_H + +class lightweight_mutex +{ +private: + + critical_section cs_; + + lightweight_mutex(lightweight_mutex const &); + lightweight_mutex & operator=(lightweight_mutex const &); + +public: + + lightweight_mutex() + { +#if BOOST_PLAT_WINDOWS_RUNTIME + InitializeCriticalSectionEx(&cs_, 4000, 0); +#else + InitializeCriticalSection(&cs_); +#endif + } + + ~lightweight_mutex() + { + DeleteCriticalSection(&cs_); + } + + class scoped_lock; + friend class scoped_lock; + + class scoped_lock + { + private: + + lightweight_mutex & m_; + + scoped_lock(scoped_lock const &); + scoped_lock & operator=(scoped_lock const &); + + public: + + explicit scoped_lock(lightweight_mutex & m): m_(m) + { + EnterCriticalSection(&m_.cs_); + } + + ~scoped_lock() + { + LeaveCriticalSection(&m_.cs_); + } + }; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/operator_bool.hpp b/contrib/src/boost/smart_ptr/detail/operator_bool.hpp index 7de918c..c0289b8 100644 --- a/contrib/src/boost/smart_ptr/detail/operator_bool.hpp +++ b/contrib/src/boost/smart_ptr/detail/operator_bool.hpp @@ -1,64 +1,64 @@ -// This header intentionally has no include guards.
-//
-// 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( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\
- && !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
-
- 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;
- }
-
-#elif defined( _MANAGED )
-
- static void unspecified_bool( this_type*** )
- {
- }
-
- typedef void (*unspecified_bool_type)( this_type*** );
-
- operator unspecified_bool_type() const BOOST_NOEXCEPT
- {
- return px == 0? 0: unspecified_bool;
- }
-
-#elif \
- ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
- ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
- ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
-
- typedef element_type * (this_type::*unspecified_bool_type)() const;
-
- operator unspecified_bool_type() const BOOST_NOEXCEPT
- {
- return px == 0? 0: &this_type::get;
- }
-
-#else
-
- typedef element_type * this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const BOOST_NOEXCEPT
- {
- return px == 0? 0: &this_type::px;
- }
-
-#endif
-
- // operator! is redundant, but some compilers need it
- bool operator! () const BOOST_NOEXCEPT
- {
- return px == 0;
- }
+// This header intentionally has no include guards. +// +// 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( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\ + && !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) + + 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; + } + +#elif defined( _MANAGED ) + + static void unspecified_bool( this_type*** ) + { + } + + typedef void (*unspecified_bool_type)( this_type*** ); + + operator unspecified_bool_type() const BOOST_NOEXCEPT + { + return px == 0? 0: unspecified_bool; + } + +#elif \ + ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \ + ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \ + ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) ) + + typedef element_type * (this_type::*unspecified_bool_type)() const; + + operator unspecified_bool_type() const BOOST_NOEXCEPT + { + return px == 0? 0: &this_type::get; + } + +#else + + typedef element_type * this_type::*unspecified_bool_type; + + operator unspecified_bool_type() const BOOST_NOEXCEPT + { + return px == 0? 0: &this_type::px; + } + +#endif + + // operator! is redundant, but some compilers need it + bool operator! () const BOOST_NOEXCEPT + { + return px == 0; + } diff --git a/contrib/src/boost/smart_ptr/detail/quick_allocator.hpp b/contrib/src/boost/smart_ptr/detail/quick_allocator.hpp index 12dfb83..159bd5e 100644 --- a/contrib/src/boost/smart_ptr/detail/quick_allocator.hpp +++ b/contrib/src/boost/smart_ptr/detail/quick_allocator.hpp @@ -1,199 +1,199 @@ -#ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/quick_allocator.hpp
-//
-// Copyright (c) 2003 David Abrahams
-// Copyright (c) 2003 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 <boost/smart_ptr/detail/lightweight_mutex.hpp>
-#include <boost/type_traits/type_with_alignment.hpp>
-#include <boost/type_traits/alignment_of.hpp>
-
-#include <new> // ::operator new, ::operator delete
-#include <cstddef> // std::size_t
-
-namespace boost
-{
-
-namespace detail
-{
-
-template<unsigned size, unsigned align_> union freeblock
-{
- typedef typename boost::type_with_alignment<align_>::type aligner_type;
- aligner_type aligner;
- char bytes[size];
- freeblock * next;
-};
-
-template<unsigned size, unsigned align_> struct allocator_impl
-{
- typedef freeblock<size, align_> block;
-
- // It may seem odd to use such small pages.
- //
- // However, on a typical Windows implementation that uses
- // the OS allocator, "normal size" pages interact with the
- // "ordinary" operator new, slowing it down dramatically.
- //
- // 512 byte pages are handled by the small object allocator,
- // and don't interfere with ::new.
- //
- // The other alternative is to use much bigger pages (1M.)
- //
- // It is surprisingly easy to hit pathological behavior by
- // varying the page size. g++ 2.96 on Red Hat Linux 7.2,
- // for example, passionately dislikes 496. 512 seems OK.
-
-#if defined(BOOST_QA_PAGE_SIZE)
-
- enum { items_per_page = BOOST_QA_PAGE_SIZE / size };
-
-#else
-
- enum { items_per_page = 512 / size }; // 1048560 / size
-
-#endif
-
-#ifdef BOOST_HAS_THREADS
-
- static lightweight_mutex & mutex()
- {
- static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm;
- static lightweight_mutex * pm = new( &fbm ) lightweight_mutex;
- return *pm;
- }
-
- static lightweight_mutex * mutex_init;
-
-#endif
-
- static block * free;
- static block * page;
- static unsigned last;
-
- static inline void * alloc()
- {
-#ifdef BOOST_HAS_THREADS
- lightweight_mutex::scoped_lock lock( mutex() );
-#endif
- if(block * x = free)
- {
- free = x->next;
- return x;
- }
- else
- {
- if(last == items_per_page)
- {
- // "Listen to me carefully: there is no memory leak"
- // -- Scott Meyers, Eff C++ 2nd Ed Item 10
- page = ::new block[items_per_page];
- last = 0;
- }
-
- return &page[last++];
- }
- }
-
- static inline void * alloc(std::size_t n)
- {
- if(n != size) // class-specific new called for a derived object
- {
- return ::operator new(n);
- }
- else
- {
-#ifdef BOOST_HAS_THREADS
- lightweight_mutex::scoped_lock lock( mutex() );
-#endif
- if(block * x = free)
- {
- free = x->next;
- return x;
- }
- else
- {
- if(last == items_per_page)
- {
- page = ::new block[items_per_page];
- last = 0;
- }
-
- return &page[last++];
- }
- }
- }
-
- static inline void dealloc(void * pv)
- {
- if(pv != 0) // 18.4.1.1/13
- {
-#ifdef BOOST_HAS_THREADS
- lightweight_mutex::scoped_lock lock( mutex() );
-#endif
- block * pb = static_cast<block *>(pv);
- pb->next = free;
- free = pb;
- }
- }
-
- static inline void dealloc(void * pv, std::size_t n)
- {
- if(n != size) // class-specific delete called for a derived object
- {
- ::operator delete(pv);
- }
- else if(pv != 0) // 18.4.1.1/13
- {
-#ifdef BOOST_HAS_THREADS
- lightweight_mutex::scoped_lock lock( mutex() );
-#endif
- block * pb = static_cast<block *>(pv);
- pb->next = free;
- free = pb;
- }
- }
-};
-
-#ifdef BOOST_HAS_THREADS
-
-template<unsigned size, unsigned align_>
- lightweight_mutex * allocator_impl<size, align_>::mutex_init = &allocator_impl<size, align_>::mutex();
-
-#endif
-
-template<unsigned size, unsigned align_>
- freeblock<size, align_> * allocator_impl<size, align_>::free = 0;
-
-template<unsigned size, unsigned align_>
- freeblock<size, align_> * allocator_impl<size, align_>::page = 0;
-
-template<unsigned size, unsigned align_>
- unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page;
-
-template<class T>
-struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value >
-{
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/quick_allocator.hpp +// +// Copyright (c) 2003 David Abrahams +// Copyright (c) 2003 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 <boost/smart_ptr/detail/lightweight_mutex.hpp> +#include <boost/type_traits/type_with_alignment.hpp> +#include <boost/type_traits/alignment_of.hpp> + +#include <new> // ::operator new, ::operator delete +#include <cstddef> // std::size_t + +namespace boost +{ + +namespace detail +{ + +template<unsigned size, unsigned align_> union freeblock +{ + typedef typename boost::type_with_alignment<align_>::type aligner_type; + aligner_type aligner; + char bytes[size]; + freeblock * next; +}; + +template<unsigned size, unsigned align_> struct allocator_impl +{ + typedef freeblock<size, align_> block; + + // It may seem odd to use such small pages. + // + // However, on a typical Windows implementation that uses + // the OS allocator, "normal size" pages interact with the + // "ordinary" operator new, slowing it down dramatically. + // + // 512 byte pages are handled by the small object allocator, + // and don't interfere with ::new. + // + // The other alternative is to use much bigger pages (1M.) + // + // It is surprisingly easy to hit pathological behavior by + // varying the page size. g++ 2.96 on Red Hat Linux 7.2, + // for example, passionately dislikes 496. 512 seems OK. + +#if defined(BOOST_QA_PAGE_SIZE) + + enum { items_per_page = BOOST_QA_PAGE_SIZE / size }; + +#else + + enum { items_per_page = 512 / size }; // 1048560 / size + +#endif + +#ifdef BOOST_HAS_THREADS + + static lightweight_mutex & mutex() + { + static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm; + static lightweight_mutex * pm = new( &fbm ) lightweight_mutex; + return *pm; + } + + static lightweight_mutex * mutex_init; + +#endif + + static block * free; + static block * page; + static unsigned last; + + static inline void * alloc() + { +#ifdef BOOST_HAS_THREADS + lightweight_mutex::scoped_lock lock( mutex() ); +#endif + if(block * x = free) + { + free = x->next; + return x; + } + else + { + if(last == items_per_page) + { + // "Listen to me carefully: there is no memory leak" + // -- Scott Meyers, Eff C++ 2nd Ed Item 10 + page = ::new block[items_per_page]; + last = 0; + } + + return &page[last++]; + } + } + + static inline void * alloc(std::size_t n) + { + if(n != size) // class-specific new called for a derived object + { + return ::operator new(n); + } + else + { +#ifdef BOOST_HAS_THREADS + lightweight_mutex::scoped_lock lock( mutex() ); +#endif + if(block * x = free) + { + free = x->next; + return x; + } + else + { + if(last == items_per_page) + { + page = ::new block[items_per_page]; + last = 0; + } + + return &page[last++]; + } + } + } + + static inline void dealloc(void * pv) + { + if(pv != 0) // 18.4.1.1/13 + { +#ifdef BOOST_HAS_THREADS + lightweight_mutex::scoped_lock lock( mutex() ); +#endif + block * pb = static_cast<block *>(pv); + pb->next = free; + free = pb; + } + } + + static inline void dealloc(void * pv, std::size_t n) + { + if(n != size) // class-specific delete called for a derived object + { + ::operator delete(pv); + } + else if(pv != 0) // 18.4.1.1/13 + { +#ifdef BOOST_HAS_THREADS + lightweight_mutex::scoped_lock lock( mutex() ); +#endif + block * pb = static_cast<block *>(pv); + pb->next = free; + free = pb; + } + } +}; + +#ifdef BOOST_HAS_THREADS + +template<unsigned size, unsigned align_> + lightweight_mutex * allocator_impl<size, align_>::mutex_init = &allocator_impl<size, align_>::mutex(); + +#endif + +template<unsigned size, unsigned align_> + freeblock<size, align_> * allocator_impl<size, align_>::free = 0; + +template<unsigned size, unsigned align_> + freeblock<size, align_> * allocator_impl<size, align_>::page = 0; + +template<unsigned size, unsigned align_> + unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page; + +template<class T> +struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value > +{ +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/shared_count.hpp b/contrib/src/boost/smart_ptr/detail/shared_count.hpp index cd9b262..7996aa4 100644 --- a/contrib/src/boost/smart_ptr/detail/shared_count.hpp +++ b/contrib/src/boost/smart_ptr/detail/shared_count.hpp @@ -1,655 +1,709 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/shared_count.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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)
-//
-
-#ifdef __BORLANDC__
-# pragma warn -8027 // Functions containing try are not expanded inline
-#endif
-
-#include <boost/config.hpp>
-#include <boost/checked_delete.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/smart_ptr/bad_weak_ptr.hpp>
-#include <boost/smart_ptr/detail/sp_counted_base.hpp>
-#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
-#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
-#include <boost/detail/workaround.hpp>
-// In order to avoid circular dependencies with Boost.TR1
-// we make sure that our include of <memory> doesn't try to
-// pull in the TR1 headers: that's why we use this header
-// rather than including <memory> directly:
-#include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
-#include <functional> // std::less
-
-#ifdef BOOST_NO_EXCEPTIONS
-# include <new> // std::bad_alloc
-#endif
-
-#include <boost/core/addressof.hpp>
-
-#if defined( BOOST_SP_DISABLE_DEPRECATED )
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-namespace boost
-{
-
-namespace movelib
-{
-
- template< class T, class D > class unique_ptr;
-
-} // namespace movelib
-
-namespace detail
-{
-
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
-
-int const shared_count_id = 0x2C35F101;
-int const weak_count_id = 0x298C38A4;
-
-#endif
-
-struct sp_nothrow_tag {};
-
-template< class D > struct sp_inplace_tag
-{
-};
-
-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;
-};
-
-class weak_count;
-
-class shared_count
-{
-private:
-
- sp_counted_base * pi_;
-
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- int id_;
-#endif
-
- friend class weak_count;
-
-public:
-
- shared_count(): pi_(0) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
- }
-
- template<class Y> explicit shared_count( Y * p ): pi_( 0 )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
-#ifndef BOOST_NO_EXCEPTIONS
-
- try
- {
- pi_ = new sp_counted_impl_p<Y>( p );
- }
- catch(...)
- {
- boost::checked_delete( p );
- throw;
- }
-
-#else
-
- pi_ = new sp_counted_impl_p<Y>( p );
-
- if( pi_ == 0 )
- {
- boost::checked_delete( p );
- boost::throw_exception( std::bad_alloc() );
- }
-
-#endif
- }
-
-#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
- template<class Y, class D> shared_count( Y * p, D d ): pi_(0)
-#else
- template<class P, class D> shared_count( P p, D d ): pi_(0)
-#endif
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
-#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
- typedef Y* P;
-#endif
-#ifndef BOOST_NO_EXCEPTIONS
-
- try
- {
- pi_ = new sp_counted_impl_pd<P, D>(p, d);
- }
- catch(...)
- {
- d(p); // delete p
- throw;
- }
-
-#else
-
- pi_ = new sp_counted_impl_pd<P, D>(p, d);
-
- if(pi_ == 0)
- {
- d(p); // delete p
- boost::throw_exception(std::bad_alloc());
- }
-
-#endif
- }
-
-#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
-
- template< class P, class D > shared_count( P p, sp_inplace_tag<D> ): pi_( 0 )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
-#ifndef BOOST_NO_EXCEPTIONS
-
- try
- {
- pi_ = new sp_counted_impl_pd< P, D >( p );
- }
- catch( ... )
- {
- D::operator_fn( p ); // delete p
- throw;
- }
-
-#else
-
- pi_ = new sp_counted_impl_pd< P, D >( p );
-
- if( pi_ == 0 )
- {
- D::operator_fn( p ); // delete p
- boost::throw_exception( std::bad_alloc() );
- }
-
-#endif // #ifndef BOOST_NO_EXCEPTIONS
- }
-
-#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
-
- template<class P, class D, class A> shared_count( P p, D d, A a ): pi_( 0 )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#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
- {
- pi_ = a2.allocate( 1 );
- ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
- }
- catch(...)
- {
- d( p );
-
- if( pi_ != 0 )
- {
- a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
- }
-
- throw;
- }
-
-#else
-
- pi_ = a2.allocate( 1 );
-
- if( pi_ != 0 )
- {
- ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
- }
- else
- {
- d( p );
- boost::throw_exception( std::bad_alloc() );
- }
-
-#endif
- }
-
-#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
-
- template< class P, class D, class A > shared_count( P p, sp_inplace_tag< D >, A a ): pi_( 0 )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#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
- {
- pi_ = a2.allocate( 1 );
- ::new( static_cast< void* >( pi_ ) ) impl_type( p, a );
- }
- catch(...)
- {
- D::operator_fn( p );
-
- if( pi_ != 0 )
- {
- a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
- }
-
- throw;
- }
-
-#else
-
- pi_ = a2.allocate( 1 );
-
- if( pi_ != 0 )
- {
- ::new( static_cast< void* >( pi_ ) ) impl_type( p, a );
- }
- else
- {
- D::operator_fn( p );
- boost::throw_exception( std::bad_alloc() );
- }
-
-#endif // #ifndef BOOST_NO_EXCEPTIONS
- }
-
-#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
-
-#ifndef BOOST_NO_AUTO_PTR
-
- // auto_ptr<Y> is special cased to provide the strong guarantee
-
- template<class Y>
- explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
-#ifdef BOOST_NO_EXCEPTIONS
-
- if( pi_ == 0 )
- {
- boost::throw_exception(std::bad_alloc());
- }
-
-#endif
-
- r.release();
- }
-
-#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
-
- template<class Y, class D>
- explicit shared_count( boost::movelib::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 boost::movelib::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();
- }
-
- ~shared_count() // nothrow
- {
- if( pi_ != 0 ) pi_->release();
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- id_ = 0;
-#endif
- }
-
- shared_count(shared_count const & r): pi_(r.pi_) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
- if( pi_ != 0 ) pi_->add_ref_copy();
- }
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- shared_count(shared_count && r): pi_(r.pi_) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
- {
- r.pi_ = 0;
- }
-
-#endif
-
- explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
- shared_count( weak_count const & r, sp_nothrow_tag ); // constructs an empty *this when r.use_count() == 0
-
- shared_count & operator= (shared_count const & r) // nothrow
- {
- sp_counted_base * tmp = r.pi_;
-
- if( tmp != pi_ )
- {
- if( tmp != 0 ) tmp->add_ref_copy();
- if( pi_ != 0 ) pi_->release();
- pi_ = tmp;
- }
-
- return *this;
- }
-
- void swap(shared_count & r) // nothrow
- {
- sp_counted_base * tmp = r.pi_;
- r.pi_ = pi_;
- pi_ = tmp;
- }
-
- long use_count() const // nothrow
- {
- return pi_ != 0? pi_->use_count(): 0;
- }
-
- bool unique() const // nothrow
- {
- return use_count() == 1;
- }
-
- bool empty() const // nothrow
- {
- return pi_ == 0;
- }
-
- friend inline bool operator==(shared_count const & a, shared_count const & b)
- {
- return a.pi_ == b.pi_;
- }
-
- friend inline bool operator<(shared_count const & a, shared_count const & b)
- {
- return std::less<sp_counted_base *>()( a.pi_, b.pi_ );
- }
-
- void * get_deleter( sp_typeinfo const & ti ) const
- {
- return pi_? pi_->get_deleter( ti ): 0;
- }
-
- void * get_untyped_deleter() const
- {
- return pi_? pi_->get_untyped_deleter(): 0;
- }
-};
-
-
-class weak_count
-{
-private:
-
- sp_counted_base * pi_;
-
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- int id_;
-#endif
-
- friend class shared_count;
-
-public:
-
- weak_count(): pi_(0) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(weak_count_id)
-#endif
- {
- }
-
- weak_count(shared_count const & r): pi_(r.pi_) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(weak_count_id)
-#endif
- {
- if(pi_ != 0) pi_->weak_add_ref();
- }
-
- weak_count(weak_count const & r): pi_(r.pi_) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(weak_count_id)
-#endif
- {
- if(pi_ != 0) pi_->weak_add_ref();
- }
-
-// Move support
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- weak_count(weak_count && r): pi_(r.pi_) // nothrow
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(weak_count_id)
-#endif
- {
- r.pi_ = 0;
- }
-
-#endif
-
- ~weak_count() // nothrow
- {
- if(pi_ != 0) pi_->weak_release();
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- id_ = 0;
-#endif
- }
-
- weak_count & operator= (shared_count const & r) // nothrow
- {
- sp_counted_base * tmp = r.pi_;
-
- if( tmp != pi_ )
- {
- if(tmp != 0) tmp->weak_add_ref();
- if(pi_ != 0) pi_->weak_release();
- pi_ = tmp;
- }
-
- return *this;
- }
-
- weak_count & operator= (weak_count const & r) // nothrow
- {
- sp_counted_base * tmp = r.pi_;
-
- if( tmp != pi_ )
- {
- if(tmp != 0) tmp->weak_add_ref();
- if(pi_ != 0) pi_->weak_release();
- pi_ = tmp;
- }
-
- return *this;
- }
-
- void swap(weak_count & r) // nothrow
- {
- sp_counted_base * tmp = r.pi_;
- r.pi_ = pi_;
- pi_ = tmp;
- }
-
- long use_count() const // nothrow
- {
- return pi_ != 0? pi_->use_count(): 0;
- }
-
- bool empty() const // nothrow
- {
- return pi_ == 0;
- }
-
- friend inline bool operator==(weak_count const & a, weak_count const & b)
- {
- return a.pi_ == b.pi_;
- }
-
- friend inline bool operator<(weak_count const & a, weak_count const & b)
- {
- return std::less<sp_counted_base *>()(a.pi_, b.pi_);
- }
-};
-
-inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
-{
- if( pi_ == 0 || !pi_->add_ref_lock() )
- {
- boost::throw_exception( boost::bad_weak_ptr() );
- }
-}
-
-inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ): pi_( r.pi_ )
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- , id_(shared_count_id)
-#endif
-{
- if( pi_ != 0 && !pi_->add_ref_lock() )
- {
- pi_ = 0;
- }
-}
-
-} // namespace detail
-
-} // namespace boost
-
-#if defined( BOOST_SP_DISABLE_DEPRECATED )
-#pragma GCC diagnostic pop
-#endif
-
-#ifdef __BORLANDC__
-# pragma warn .8027 // Functions containing try are not expanded inline
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/shared_count.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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) +// + +#ifdef __BORLANDC__ +# pragma warn -8027 // Functions containing try are not expanded inline +#endif + +#include <boost/config.hpp> +#include <boost/checked_delete.hpp> +#include <boost/throw_exception.hpp> +#include <boost/smart_ptr/bad_weak_ptr.hpp> +#include <boost/smart_ptr/detail/sp_counted_base.hpp> +#include <boost/smart_ptr/detail/sp_counted_impl.hpp> +#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp> +#include <boost/detail/workaround.hpp> +// In order to avoid circular dependencies with Boost.TR1 +// we make sure that our include of <memory> doesn't try to +// pull in the TR1 headers: that's why we use this header +// rather than including <memory> directly: +#include <boost/config/no_tr1/memory.hpp> // std::auto_ptr +#include <functional> // std::less + +#ifdef BOOST_NO_EXCEPTIONS +# include <new> // std::bad_alloc +#endif + +#include <boost/core/addressof.hpp> + +#if defined( BOOST_SP_DISABLE_DEPRECATED ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +namespace boost +{ + +namespace movelib +{ + + template< class T, class D > class unique_ptr; + +} // namespace movelib + +namespace detail +{ + +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + +int const shared_count_id = 0x2C35F101; +int const weak_count_id = 0x298C38A4; + +#endif + +struct sp_nothrow_tag {}; + +template< class D > struct sp_inplace_tag +{ +}; + +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; +}; + +class weak_count; + +class shared_count +{ +private: + + sp_counted_base * pi_; + +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + int id_; +#endif + + friend class weak_count; + +public: + + shared_count(): pi_(0) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + } + + template<class Y> explicit shared_count( Y * p ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { +#ifndef BOOST_NO_EXCEPTIONS + + try + { + pi_ = new sp_counted_impl_p<Y>( p ); + } + catch(...) + { + boost::checked_delete( p ); + throw; + } + +#else + + pi_ = new sp_counted_impl_p<Y>( p ); + + if( pi_ == 0 ) + { + boost::checked_delete( p ); + boost::throw_exception( std::bad_alloc() ); + } + +#endif + } + +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) + template<class Y, class D> shared_count( Y * p, D d ): pi_(0) +#else + template<class P, class D> shared_count( P p, D d ): pi_(0) +#endif +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) + typedef Y* P; +#endif +#ifndef BOOST_NO_EXCEPTIONS + + try + { + pi_ = new sp_counted_impl_pd<P, D>(p, d); + } + catch(...) + { + d(p); // delete p + throw; + } + +#else + + pi_ = new sp_counted_impl_pd<P, D>(p, d); + + if(pi_ == 0) + { + d(p); // delete p + boost::throw_exception(std::bad_alloc()); + } + +#endif + } + +#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) + + template< class P, class D > shared_count( P p, sp_inplace_tag<D> ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { +#ifndef BOOST_NO_EXCEPTIONS + + try + { + pi_ = new sp_counted_impl_pd< P, D >( p ); + } + catch( ... ) + { + D::operator_fn( p ); // delete p + throw; + } + +#else + + pi_ = new sp_counted_impl_pd< P, D >( p ); + + if( pi_ == 0 ) + { + D::operator_fn( p ); // delete p + boost::throw_exception( std::bad_alloc() ); + } + +#endif // #ifndef BOOST_NO_EXCEPTIONS + } + +#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) + + template<class P, class D, class A> shared_count( P p, D d, A a ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#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 ); + +#endif + } + catch(...) + { + d( p ); + + if( pi_ != 0 ) + { + a2.deallocate( static_cast< impl_type* >( pi_ ), 1 ); + } + + throw; + } + +#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 ) + { +#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 + { + d( p ); + boost::throw_exception( std::bad_alloc() ); + } + +#endif + } + +#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) + + template< class P, class D, class A > shared_count( P p, sp_inplace_tag< D >, A a ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#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 ); + +#endif + } + catch(...) + { + D::operator_fn( p ); + + if( pi_ != 0 ) + { + a2.deallocate( static_cast< impl_type* >( pi_ ), 1 ); + } + + throw; + } + +#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 ) + { +#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::operator_fn( p ); + boost::throw_exception( std::bad_alloc() ); + } + +#endif // #ifndef BOOST_NO_EXCEPTIONS + } + +#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) + +#ifndef BOOST_NO_AUTO_PTR + + // auto_ptr<Y> is special cased to provide the strong guarantee + + template<class Y> + explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { +#ifdef BOOST_NO_EXCEPTIONS + + if( pi_ == 0 ) + { + boost::throw_exception(std::bad_alloc()); + } + +#endif + + r.release(); + } + +#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 + + template<class Y, class D> + explicit shared_count( boost::movelib::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 boost::movelib::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(); + } + + ~shared_count() // nothrow + { + if( pi_ != 0 ) pi_->release(); +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + id_ = 0; +#endif + } + + shared_count(shared_count const & r): pi_(r.pi_) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + if( pi_ != 0 ) pi_->add_ref_copy(); + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + shared_count(shared_count && r): pi_(r.pi_) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + r.pi_ = 0; + } + +#endif + + explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0 + shared_count( weak_count const & r, sp_nothrow_tag ); // constructs an empty *this when r.use_count() == 0 + + shared_count & operator= (shared_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + + if( tmp != pi_ ) + { + if( tmp != 0 ) tmp->add_ref_copy(); + if( pi_ != 0 ) pi_->release(); + pi_ = tmp; + } + + return *this; + } + + void swap(shared_count & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + r.pi_ = pi_; + pi_ = tmp; + } + + long use_count() const // nothrow + { + return pi_ != 0? pi_->use_count(): 0; + } + + bool unique() const // nothrow + { + return use_count() == 1; + } + + bool empty() const // nothrow + { + return pi_ == 0; + } + + friend inline bool operator==(shared_count const & a, shared_count const & b) + { + return a.pi_ == b.pi_; + } + + friend inline bool operator<(shared_count const & a, shared_count const & b) + { + return std::less<sp_counted_base *>()( a.pi_, b.pi_ ); + } + + void * get_deleter( sp_typeinfo const & ti ) const + { + return pi_? pi_->get_deleter( ti ): 0; + } + + void * get_untyped_deleter() const + { + return pi_? pi_->get_untyped_deleter(): 0; + } +}; + + +class weak_count +{ +private: + + sp_counted_base * pi_; + +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + int id_; +#endif + + friend class shared_count; + +public: + + weak_count(): pi_(0) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(weak_count_id) +#endif + { + } + + weak_count(shared_count const & r): pi_(r.pi_) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(weak_count_id) +#endif + { + if(pi_ != 0) pi_->weak_add_ref(); + } + + weak_count(weak_count const & r): pi_(r.pi_) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(weak_count_id) +#endif + { + if(pi_ != 0) pi_->weak_add_ref(); + } + +// Move support + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + weak_count(weak_count && r): pi_(r.pi_) // nothrow +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(weak_count_id) +#endif + { + r.pi_ = 0; + } + +#endif + + ~weak_count() // nothrow + { + if(pi_ != 0) pi_->weak_release(); +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + id_ = 0; +#endif + } + + weak_count & operator= (shared_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + + if( tmp != pi_ ) + { + if(tmp != 0) tmp->weak_add_ref(); + if(pi_ != 0) pi_->weak_release(); + pi_ = tmp; + } + + return *this; + } + + weak_count & operator= (weak_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + + if( tmp != pi_ ) + { + if(tmp != 0) tmp->weak_add_ref(); + if(pi_ != 0) pi_->weak_release(); + pi_ = tmp; + } + + return *this; + } + + void swap(weak_count & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + r.pi_ = pi_; + pi_ = tmp; + } + + long use_count() const // nothrow + { + return pi_ != 0? pi_->use_count(): 0; + } + + bool empty() const // nothrow + { + return pi_ == 0; + } + + friend inline bool operator==(weak_count const & a, weak_count const & b) + { + return a.pi_ == b.pi_; + } + + friend inline bool operator<(weak_count const & a, weak_count const & b) + { + return std::less<sp_counted_base *>()(a.pi_, b.pi_); + } +}; + +inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif +{ + if( pi_ == 0 || !pi_->add_ref_lock() ) + { + boost::throw_exception( boost::bad_weak_ptr() ); + } +} + +inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ): pi_( r.pi_ ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif +{ + if( pi_ != 0 && !pi_->add_ref_lock() ) + { + pi_ = 0; + } +} + +} // namespace detail + +} // namespace boost + +#if defined( BOOST_SP_DISABLE_DEPRECATED ) +#pragma GCC diagnostic pop +#endif + +#ifdef __BORLANDC__ +# pragma warn .8027 // Functions containing try are not expanded inline +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_convertible.hpp b/contrib/src/boost/smart_ptr/detail/sp_convertible.hpp index cea7281..4bba9ed 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_convertible.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_convertible.hpp @@ -1,92 +1,92 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-// detail/sp_convertible.hpp
-//
-// Copyright 2008 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_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
-# define BOOST_SP_NO_SP_CONVERTIBLE
-#endif
-
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
-# define BOOST_SP_NO_SP_CONVERTIBLE
-#endif
-
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 )
-# define BOOST_SP_NO_SP_CONVERTIBLE
-#endif
-
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
-
-namespace boost
-{
-
-namespace detail
-{
-
-template< class Y, class T > struct sp_convertible
-{
- typedef char (&yes) [1];
- typedef char (&no) [2];
-
- static yes f( T* );
- static no f( ... );
-
- 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
-{
-};
-
-template< bool > struct sp_enable_if_convertible_impl;
-
-template<> struct sp_enable_if_convertible_impl<true>
-{
- typedef sp_empty type;
-};
-
-template<> struct sp_enable_if_convertible_impl<false>
-{
-};
-
-template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
-{
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_convertible.hpp +// +// Copyright 2008 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_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE ) +# define BOOST_SP_NO_SP_CONVERTIBLE +#endif + +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 ) +# define BOOST_SP_NO_SP_CONVERTIBLE +#endif + +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 ) +# define BOOST_SP_NO_SP_CONVERTIBLE +#endif + +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + +namespace boost +{ + +namespace detail +{ + +template< class Y, class T > struct sp_convertible +{ + typedef char (&yes) [1]; + typedef char (&no) [2]; + + static yes f( T* ); + static no f( ... ); + + 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 +{ +}; + +template< bool > struct sp_enable_if_convertible_impl; + +template<> struct sp_enable_if_convertible_impl<true> +{ + typedef sp_empty type; +}; + +template<> struct sp_enable_if_convertible_impl<false> +{ +}; + +template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value > +{ +}; + +} // namespace detail + +} // namespace boost + +#endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base.hpp index f2f49de..0addf07 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base.hpp @@ -1,96 +1,93 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base.hpp
-//
-// Copyright 2005-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 <boost/smart_ptr/detail/sp_has_sync.hpp>
-
-#if !defined( __c2__ ) && defined( __clang__ ) && defined( __has_extension )
-# if __has_extension( __c_atomic__ )
-# define BOOST_SP_HAS_CLANG_C11_ATOMICS
-# endif
-#endif
-
-#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>
-
-#elif defined( BOOST_SP_USE_PTHREADS )
-# include <boost/smart_ptr/detail/sp_counted_base_pt.hpp>
-
-#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( BOOST_SP_HAS_CLANG_C11_ATOMICS )
-# include <boost/smart_ptr/detail/sp_counted_base_clang.hpp>
-
-#elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
-# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp>
-
-#elif defined( __SNC__ )
-# include <boost/smart_ptr/detail/sp_counted_base_snc_ps3.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 ) ) && !defined(__PATHSCALE__) && !defined( _AIX )
-# include <boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp>
-
-#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) && !defined(__PATHSCALE__) && !defined( __mips16 )
-# include <boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp>
-
-#elif defined( BOOST_SP_HAS_SYNC )
-# include <boost/smart_ptr/detail/sp_counted_base_sync.hpp>
-
-#elif defined(__GNUC__) && ( defined( __sparcv9 ) || ( defined( __sparcv8 ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 402 ) ) )
-# include <boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp>
-
-#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>
-
-#else
-# include <boost/smart_ptr/detail/sp_counted_base_spin.hpp>
-
-#endif
-
-#undef BOOST_SP_HAS_CLANG_C11_ATOMICS
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base.hpp +// +// Copyright 2005-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 <boost/smart_ptr/detail/sp_has_sync.hpp> + +#if defined( __clang__ ) && defined( __has_extension ) +# if __has_extension( __c_atomic__ ) +# define BOOST_SP_HAS_CLANG_C11_ATOMICS +# endif +#endif + +#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> + +#elif defined( BOOST_SP_USE_PTHREADS ) +# include <boost/smart_ptr/detail/sp_counted_base_pt.hpp> + +#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( BOOST_SP_HAS_CLANG_C11_ATOMICS ) +# include <boost/smart_ptr/detail/sp_counted_base_clang.hpp> + +#elif defined( __SNC__ ) +# include <boost/smart_ptr/detail/sp_counted_base_snc_ps3.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 ) ) && !defined(__PATHSCALE__) && !defined( _AIX ) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp> + +#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 ) +# include <boost/smart_ptr/detail/sp_counted_base_sync.hpp> + +#elif defined(__GNUC__) && ( defined( __sparcv9 ) || ( defined( __sparcv8 ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 402 ) ) ) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp> + +#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> + +#else +# include <boost/smart_ptr/detail/sp_counted_base_spin.hpp> + +#endif + +#undef BOOST_SP_HAS_CLANG_C11_ATOMICS + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp index 1374ffb..cebc243 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp @@ -1,151 +1,151 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
-
-//
-// detail/sp_counted_base_acc_ia64.hpp - aC++ on HP-UX IA64
-//
-// Copyright 2007 Baruch Zilber
-// Copyright 2007 Boris Gubenko
-//
-// 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
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-#include <machine/sys/inline.h>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( int * pw )
-{
- // ++*pw;
-
- _Asm_fetchadd(_FASZ_W, _SEM_REL, pw, +1, _LDHINT_NONE);
-}
-
-inline int atomic_decrement( int * pw )
-{
- // return --*pw;
-
- int r = static_cast<int>(_Asm_fetchadd(_FASZ_W, _SEM_REL, pw, -1, _LDHINT_NONE));
- if (1 == r)
- {
- _Asm_mf();
- }
-
- return r - 1;
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- // if( *pw != 0 ) ++*pw;
- // return *pw;
-
- int v = *pw;
-
- for (;;)
- {
- if (0 == v)
- {
- return 0;
- }
-
- _Asm_mov_to_ar(_AREG_CCV,
- v,
- (_UP_CALL_FENCE | _UP_SYS_FENCE | _DOWN_CALL_FENCE | _DOWN_SYS_FENCE));
- int r = static_cast<int>(_Asm_cmpxchg(_SZ_W, _SEM_ACQ, pw, v + 1, _LDHINT_NONE));
- if (r == v)
- {
- return r + 1;
- }
-
- v = r;
- }
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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 static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED + +// +// detail/sp_counted_base_acc_ia64.hpp - aC++ on HP-UX IA64 +// +// Copyright 2007 Baruch Zilber +// Copyright 2007 Boris Gubenko +// +// 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 +// + +#include <boost/detail/sp_typeinfo.hpp> +#include <machine/sys/inline.h> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int * pw ) +{ + // ++*pw; + + _Asm_fetchadd(_FASZ_W, _SEM_REL, pw, +1, _LDHINT_NONE); +} + +inline int atomic_decrement( int * pw ) +{ + // return --*pw; + + int r = static_cast<int>(_Asm_fetchadd(_FASZ_W, _SEM_REL, pw, -1, _LDHINT_NONE)); + if (1 == r) + { + _Asm_mf(); + } + + return r - 1; +} + +inline int atomic_conditional_increment( int * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int v = *pw; + + for (;;) + { + if (0 == v) + { + return 0; + } + + _Asm_mov_to_ar(_AREG_CCV, + v, + (_UP_CALL_FENCE | _UP_SYS_FENCE | _DOWN_CALL_FENCE | _DOWN_SYS_FENCE)); + int r = static_cast<int>(_Asm_cmpxchg(_SZ_W, _SEM_ACQ, pw, v + 1, _LDHINT_NONE)); + if (r == v) + { + return r + 1; + } + + v = r; + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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 static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp index 3770742..fe6c727 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp @@ -1,143 +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
+#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/contrib/src/boost/smart_ptr/detail/sp_counted_base_clang.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_clang.hpp index d78916c..c66b985 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_clang.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_clang.hpp @@ -1,149 +1,140 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-// detail/sp_counted_base_clang.hpp - __c11 clang intrinsics
-//
-// Copyright (c) 2007, 2013, 2015 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 <boost/cstdint.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-typedef _Atomic( boost::int_least32_t ) atomic_int_least32_t;
-
-inline void atomic_increment( atomic_int_least32_t * pw )
-{
- __c11_atomic_fetch_add( pw, 1, __ATOMIC_RELAXED );
-}
-
-inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw )
-{
- return __c11_atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL );
-}
-
-inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw )
-{
- // long r = *pw;
- // if( r != 0 ) ++*pw;
- // return r;
-
- boost::int_least32_t r = __c11_atomic_load( pw, __ATOMIC_RELAXED );
-
- for( ;; )
- {
- if( r == 0 )
- {
- return r;
- }
-
- if( __c11_atomic_compare_exchange_weak( pw, &r, r + 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED ) )
- {
- return r;
- }
- }
-}
-
-#if defined(__clang__)
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wweak-vtables"
-#endif
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- atomic_int_least32_t use_count_; // #shared
- atomic_int_least32_t weak_count_; // #weak + (#shared != 0)
-
-public:
-
- sp_counted_base()
- {
- __c11_atomic_init( &use_count_, 1 );
- __c11_atomic_init( &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 __c11_atomic_load( const_cast< atomic_int_least32_t* >( &use_count_ ), __ATOMIC_ACQUIRE );
- }
-};
-
-#if defined(__clang__)
-# pragma clang diagnostic pop
-#endif
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_clang.hpp - __c11 clang intrinsics +// +// Copyright (c) 2007, 2013, 2015 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 <boost/cstdint.hpp> + +namespace boost +{ + +namespace detail +{ + +typedef _Atomic( boost::int_least32_t ) atomic_int_least32_t; + +inline void atomic_increment( atomic_int_least32_t * pw ) +{ + __c11_atomic_fetch_add( pw, 1, __ATOMIC_RELAXED ); +} + +inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw ) +{ + return __c11_atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL ); +} + +inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + boost::int_least32_t r = __c11_atomic_load( pw, __ATOMIC_RELAXED ); + + for( ;; ) + { + if( r == 0 ) + { + return r; + } + + if( __c11_atomic_compare_exchange_weak( pw, &r, r + 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED ) ) + { + return r; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + atomic_int_least32_t use_count_; // #shared + atomic_int_least32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base() + { + __c11_atomic_init( &use_count_, 1 ); + __c11_atomic_init( &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 __c11_atomic_load( const_cast< atomic_int_least32_t* >( &use_count_ ), __ATOMIC_ACQUIRE ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp index 72887b4..6c268e8 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp @@ -1,171 +1,171 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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)
-//
-//
-// Lock-free algorithm by Alexander Terekhov
-//
-// Thanks to Ben Hitchings for the #weak + (#shared != 0)
-// formulation
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( register long * pw )
-{
- register int a;
-
- asm
- {
-loop:
-
- lwarx a, 0, pw
- addi a, a, 1
- stwcx. a, 0, pw
- bne- loop
- }
-}
-
-inline long atomic_decrement( register long * pw )
-{
- register int a;
-
- asm
- {
- sync
-
-loop:
-
- lwarx a, 0, pw
- addi a, a, -1
- stwcx. a, 0, pw
- bne- loop
-
- isync
- }
-
- return a;
-}
-
-inline long atomic_conditional_increment( register long * pw )
-{
- register int a;
-
- asm
- {
-loop:
-
- lwarx a, 0, pw
- cmpwi a, 0
- beq store
-
- addi a, a, 1
-
-store:
-
- stwcx. a, 0, pw
- bne- loop
- }
-
- return a;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long 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 static_cast<long const volatile &>( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( register long * pw ) +{ + register int a; + + asm + { +loop: + + lwarx a, 0, pw + addi a, a, 1 + stwcx. a, 0, pw + bne- loop + } +} + +inline long atomic_decrement( register long * pw ) +{ + register int a; + + asm + { + sync + +loop: + + lwarx a, 0, pw + addi a, a, -1 + stwcx. a, 0, pw + bne- loop + + isync + } + + return a; +} + +inline long atomic_conditional_increment( register long * pw ) +{ + register int a; + + asm + { +loop: + + lwarx a, 0, pw + cmpwi a, 0 + beq store + + addi a, a, 1 + +store: + + stwcx. a, 0, pw + bne- loop + } + + return a; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long 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 static_cast<long const volatile &>( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp index 2bd790e..f6e3904 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp @@ -1,158 +1,158 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
-
-//
-// detail/sp_counted_base_gcc_ia64.hpp - g++ on IA64
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2006 Peter Dimov
-// Copyright 2005 Ben Hutchings
-//
-// 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
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( int * pw )
-{
- // ++*pw;
-
- int tmp;
-
- // No barrier is required here but fetchadd always has an acquire or
- // release barrier associated with it. We choose release as it should be
- // cheaper.
- __asm__ ("fetchadd4.rel %0=%1,1" :
- "=r"(tmp), "=m"(*pw) :
- "m"( *pw ));
-}
-
-inline int atomic_decrement( int * pw )
-{
- // return --*pw;
-
- int rv;
-
- __asm__ (" fetchadd4.rel %0=%1,-1 ;; \n"
- " cmp.eq p7,p0=1,%0 ;; \n"
- "(p7) ld4.acq %0=%1 " :
- "=&r"(rv), "=m"(*pw) :
- "m"( *pw ) :
- "p7");
-
- return rv;
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- // if( *pw != 0 ) ++*pw;
- // return *pw;
-
- int rv, tmp, tmp2;
-
- __asm__ ("0: ld4 %0=%3 ;; \n"
- " cmp.eq p7,p0=0,%0 ;; \n"
- "(p7) br.cond.spnt 1f \n"
- " mov ar.ccv=%0 \n"
- " add %1=1,%0 ;; \n"
- " cmpxchg4.acq %2=%3,%1,ar.ccv ;; \n"
- " cmp.ne p7,p0=%0,%2 ;; \n"
- "(p7) br.cond.spnt 0b \n"
- " mov %0=%1 ;; \n"
- "1:" :
- "=&r"(rv), "=&r"(tmp), "=&r"(tmp2), "=m"(*pw) :
- "m"( *pw ) :
- "ar.ccv", "p7");
-
- return rv;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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 static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED + +// +// detail/sp_counted_base_gcc_ia64.hpp - g++ on IA64 +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2006 Peter Dimov +// Copyright 2005 Ben Hutchings +// +// 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 +// + +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int * pw ) +{ + // ++*pw; + + int tmp; + + // No barrier is required here but fetchadd always has an acquire or + // release barrier associated with it. We choose release as it should be + // cheaper. + __asm__ ("fetchadd4.rel %0=%1,1" : + "=r"(tmp), "=m"(*pw) : + "m"( *pw )); +} + +inline int atomic_decrement( int * pw ) +{ + // return --*pw; + + int rv; + + __asm__ (" fetchadd4.rel %0=%1,-1 ;; \n" + " cmp.eq p7,p0=1,%0 ;; \n" + "(p7) ld4.acq %0=%1 " : + "=&r"(rv), "=m"(*pw) : + "m"( *pw ) : + "p7"); + + return rv; +} + +inline int atomic_conditional_increment( int * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int rv, tmp, tmp2; + + __asm__ ("0: ld4 %0=%3 ;; \n" + " cmp.eq p7,p0=0,%0 ;; \n" + "(p7) br.cond.spnt 1f \n" + " mov ar.ccv=%0 \n" + " add %1=1,%0 ;; \n" + " cmpxchg4.acq %2=%3,%1,ar.ccv ;; \n" + " cmp.ne p7,p0=%0,%2 ;; \n" + "(p7) br.cond.spnt 0b \n" + " mov %0=%1 ;; \n" + "1:" : + "=&r"(rv), "=&r"(tmp), "=&r"(tmp2), "=m"(*pw) : + "m"( *pw ) : + "ar.ccv", "p7"); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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 static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp index a953bce..545c8ae 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp @@ -1,182 +1,182 @@ -#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
-#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_gcc_mips.hpp - g++ on MIPS
-//
-// Copyright (c) 2009, Spirent Communications, Inc.
-//
-// 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
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( int * pw )
-{
- // ++*pw;
-
- int tmp;
-
- __asm__ __volatile__
- (
- "0:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %0, %1\n\t"
- "addiu %0, 1\n\t"
- "sc %0, %1\n\t"
- ".set pop\n\t"
- "beqz %0, 0b":
- "=&r"( tmp ), "=m"( *pw ):
- "m"( *pw )
- );
-}
-
-inline int atomic_decrement( int * pw )
-{
- // return --*pw;
-
- int rv, tmp;
-
- __asm__ __volatile__
- (
- "0:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %1, %2\n\t"
- "addiu %0, %1, -1\n\t"
- "sc %0, %2\n\t"
- ".set pop\n\t"
- "beqz %0, 0b\n\t"
- "addiu %0, %1, -1":
- "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
- "m"( *pw ):
- "memory"
- );
-
- return rv;
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- // if( *pw != 0 ) ++*pw;
- // return *pw;
-
- int rv, tmp;
-
- __asm__ __volatile__
- (
- "0:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %0, %2\n\t"
- "beqz %0, 1f\n\t"
- "addiu %1, %0, 1\n\t"
- "sc %1, %2\n\t"
- ".set pop\n\t"
- "beqz %1, 0b\n\t"
- "addiu %0, %0, 1\n\t"
- "1:":
- "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
- "m"( *pw ):
- "memory"
- );
-
- return rv;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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 static_cast<int const volatile &>( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
+#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_gcc_mips.hpp - g++ on MIPS +// +// Copyright (c) 2009, Spirent Communications, Inc. +// +// 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 +// + +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int * pw ) +{ + // ++*pw; + + int tmp; + + __asm__ __volatile__ + ( + "0:\n\t" + ".set push\n\t" + ".set mips2\n\t" + "ll %0, %1\n\t" + "addiu %0, 1\n\t" + "sc %0, %1\n\t" + ".set pop\n\t" + "beqz %0, 0b": + "=&r"( tmp ), "=m"( *pw ): + "m"( *pw ) + ); +} + +inline int atomic_decrement( int * pw ) +{ + // return --*pw; + + int rv, tmp; + + __asm__ __volatile__ + ( + "0:\n\t" + ".set push\n\t" + ".set mips2\n\t" + "ll %1, %2\n\t" + "addiu %0, %1, -1\n\t" + "sc %0, %2\n\t" + ".set pop\n\t" + "beqz %0, 0b\n\t" + "addiu %0, %1, -1": + "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ): + "m"( *pw ): + "memory" + ); + + return rv; +} + +inline int atomic_conditional_increment( int * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int rv, tmp; + + __asm__ __volatile__ + ( + "0:\n\t" + ".set push\n\t" + ".set mips2\n\t" + "ll %0, %2\n\t" + "beqz %0, 1f\n\t" + "addiu %1, %0, 1\n\t" + "sc %1, %2\n\t" + ".set pop\n\t" + "beqz %1, 0b\n\t" + "addiu %0, %0, 1\n\t" + "1:": + "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ): + "m"( *pw ): + "memory" + ); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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 static_cast<int const volatile &>( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp index 5cab15a..2e5bc0e 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp @@ -1,182 +1,182 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_gcc_ppc.hpp - g++ on PowerPC
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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)
-//
-//
-// Lock-free algorithm by Alexander Terekhov
-//
-// Thanks to Ben Hitchings for the #weak + (#shared != 0)
-// formulation
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( int * pw )
-{
- // ++*pw;
-
- int tmp;
-
- __asm__
- (
- "0:\n\t"
- "lwarx %1, 0, %2\n\t"
- "addi %1, %1, 1\n\t"
- "stwcx. %1, 0, %2\n\t"
- "bne- 0b":
-
- "=m"( *pw ), "=&b"( tmp ):
- "r"( pw ), "m"( *pw ):
- "cc"
- );
-}
-
-inline int atomic_decrement( int * pw )
-{
- // return --*pw;
-
- int rv;
-
- __asm__ __volatile__
- (
- "sync\n\t"
- "0:\n\t"
- "lwarx %1, 0, %2\n\t"
- "addi %1, %1, -1\n\t"
- "stwcx. %1, 0, %2\n\t"
- "bne- 0b\n\t"
- "isync":
-
- "=m"( *pw ), "=&b"( rv ):
- "r"( pw ), "m"( *pw ):
- "memory", "cc"
- );
-
- return rv;
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- // if( *pw != 0 ) ++*pw;
- // return *pw;
-
- int rv;
-
- __asm__
- (
- "0:\n\t"
- "lwarx %1, 0, %2\n\t"
- "cmpwi %1, 0\n\t"
- "beq 1f\n\t"
- "addi %1, %1, 1\n\t"
- "1:\n\t"
- "stwcx. %1, 0, %2\n\t"
- "bne- 0b":
-
- "=m"( *pw ), "=&b"( rv ):
- "r"( pw ), "m"( *pw ):
- "cc"
- );
-
- return rv;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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 static_cast<int const volatile &>( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_gcc_ppc.hpp - g++ on PowerPC +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int * pw ) +{ + // ++*pw; + + int tmp; + + __asm__ + ( + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "addi %1, %1, 1\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b": + + "=m"( *pw ), "=&b"( tmp ): + "r"( pw ), "m"( *pw ): + "cc" + ); +} + +inline int atomic_decrement( int * pw ) +{ + // return --*pw; + + int rv; + + __asm__ __volatile__ + ( + "sync\n\t" + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "addi %1, %1, -1\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b\n\t" + "isync": + + "=m"( *pw ), "=&b"( rv ): + "r"( pw ), "m"( *pw ): + "memory", "cc" + ); + + return rv; +} + +inline int atomic_conditional_increment( int * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int rv; + + __asm__ + ( + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "cmpwi %1, 0\n\t" + "beq 1f\n\t" + "addi %1, %1, 1\n\t" + "1:\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b": + + "=m"( *pw ), "=&b"( rv ): + "r"( pw ), "m"( *pw ): + "cc" + ); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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 static_cast<int const volatile &>( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp index febb597..c6d20ce 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp @@ -1,167 +1,167 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_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
-//
-// 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> // int32_t
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ )
-{
- __asm__ __volatile__( "cas [%1], %2, %0"
- : "+r" (swap_)
- : "r" (dest_), "r" (compare_)
- : "memory" );
-
- return swap_;
-}
-
-inline int32_t atomic_fetch_and_add( int32_t * pw, int32_t dv )
-{
- // long r = *pw;
- // *pw += dv;
- // return r;
-
- for( ;; )
- {
- int32_t r = *pw;
-
- if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) )
- {
- return r;
- }
- }
-}
-
-inline void atomic_increment( int32_t * pw )
-{
- atomic_fetch_and_add( pw, 1 );
-}
-
-inline int32_t atomic_decrement( int32_t * pw )
-{
- return atomic_fetch_and_add( pw, -1 );
-}
-
-inline int32_t atomic_conditional_increment( int32_t * pw )
-{
- // long r = *pw;
- // if( r != 0 ) ++*pw;
- // return r;
-
- for( ;; )
- {
- int32_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 & );
-
- 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_ ) == 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< int32_t const volatile & >( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_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 +// +// 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> // int32_t + +namespace boost +{ + +namespace detail +{ + +inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ ) +{ + __asm__ __volatile__( "cas [%1], %2, %0" + : "+r" (swap_) + : "r" (dest_), "r" (compare_) + : "memory" ); + + return swap_; +} + +inline int32_t atomic_fetch_and_add( int32_t * pw, int32_t dv ) +{ + // long r = *pw; + // *pw += dv; + // return r; + + for( ;; ) + { + int32_t r = *pw; + + if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) ) + { + return r; + } + } +} + +inline void atomic_increment( int32_t * pw ) +{ + atomic_fetch_and_add( pw, 1 ); +} + +inline int32_t atomic_decrement( int32_t * pw ) +{ + return atomic_fetch_and_add( pw, -1 ); +} + +inline int32_t atomic_conditional_increment( int32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + for( ;; ) + { + int32_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 & ); + + 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_ ) == 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< int32_t const volatile & >( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp index 7887782..173dce5 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp @@ -1,174 +1,174 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_gcc_x86.hpp - g++ on 486+ or AMD64
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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)
-//
-//
-// Lock-free algorithm by Alexander Terekhov
-//
-// Thanks to Ben Hitchings for the #weak + (#shared != 0)
-// formulation
-//
-
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline int atomic_exchange_and_add( int * pw, int dv )
-{
- // int r = *pw;
- // *pw += dv;
- // return r;
-
- int r;
-
- __asm__ __volatile__
- (
- "lock\n\t"
- "xadd %1, %0":
- "=m"( *pw ), "=r"( r ): // outputs (%0, %1)
- "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
- "memory", "cc" // clobbers
- );
-
- return r;
-}
-
-inline void atomic_increment( int * pw )
-{
- //atomic_exchange_and_add( pw, 1 );
-
- __asm__
- (
- "lock\n\t"
- "incl %0":
- "=m"( *pw ): // output (%0)
- "m"( *pw ): // input (%1)
- "cc" // clobbers
- );
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- // int rv = *pw;
- // if( rv != 0 ) ++*pw;
- // return rv;
-
- int rv, tmp;
-
- __asm__
- (
- "movl %0, %%eax\n\t"
- "0:\n\t"
- "test %%eax, %%eax\n\t"
- "je 1f\n\t"
- "movl %%eax, %2\n\t"
- "incl %2\n\t"
- "lock\n\t"
- "cmpxchgl %2, %0\n\t"
- "jne 0b\n\t"
- "1:":
- "=m"( *pw ), "=&a"( rv ), "=&r"( tmp ): // outputs (%0, %1, %2)
- "m"( *pw ): // input (%3)
- "cc" // clobbers
- );
-
- return rv;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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_exchange_and_add( &use_count_, -1 ) == 1 )
- {
- dispose();
- weak_release();
- }
- }
-
- void weak_add_ref() // nothrow
- {
- atomic_increment( &weak_count_ );
- }
-
- void weak_release() // nothrow
- {
- if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 )
- {
- destroy();
- }
- }
-
- long use_count() const // nothrow
- {
- return static_cast<int const volatile &>( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_gcc_x86.hpp - g++ on 486+ or AMD64 +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +inline int atomic_exchange_and_add( int * pw, int dv ) +{ + // int r = *pw; + // *pw += dv; + // return r; + + int r; + + __asm__ __volatile__ + ( + "lock\n\t" + "xadd %1, %0": + "=m"( *pw ), "=r"( r ): // outputs (%0, %1) + "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1) + "memory", "cc" // clobbers + ); + + return r; +} + +inline void atomic_increment( int * pw ) +{ + //atomic_exchange_and_add( pw, 1 ); + + __asm__ + ( + "lock\n\t" + "incl %0": + "=m"( *pw ): // output (%0) + "m"( *pw ): // input (%1) + "cc" // clobbers + ); +} + +inline int atomic_conditional_increment( int * pw ) +{ + // int rv = *pw; + // if( rv != 0 ) ++*pw; + // return rv; + + int rv, tmp; + + __asm__ + ( + "movl %0, %%eax\n\t" + "0:\n\t" + "test %%eax, %%eax\n\t" + "je 1f\n\t" + "movl %%eax, %2\n\t" + "incl %2\n\t" + "lock\n\t" + "cmpxchgl %2, %0\n\t" + "jne 0b\n\t" + "1:": + "=m"( *pw ), "=&a"( rv ), "=&r"( tmp ): // outputs (%0, %1, %2) + "m"( *pw ): // input (%3) + "cc" // clobbers + ); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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_exchange_and_add( &use_count_, -1 ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast<int const volatile &>( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp index d8b2026..5c901f9 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp @@ -1,108 +1,108 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_nt.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long 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()
- {
- ++use_count_;
- }
-
- bool add_ref_lock() // true on success
- {
- if( use_count_ == 0 ) return false;
- ++use_count_;
- return true;
- }
-
- void release() // nothrow
- {
- if( --use_count_ == 0 )
- {
- dispose();
- weak_release();
- }
- }
-
- void weak_add_ref() // nothrow
- {
- ++weak_count_;
- }
-
- void weak_release() // nothrow
- {
- if( --weak_count_ == 0 )
- {
- destroy();
- }
- }
-
- long use_count() const // nothrow
- {
- return use_count_;
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_nt.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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> + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long 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() + { + ++use_count_; + } + + bool add_ref_lock() // true on success + { + if( use_count_ == 0 ) return false; + ++use_count_; + return true; + } + + void release() // nothrow + { + if( --use_count_ == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + ++weak_count_; + } + + void weak_release() // nothrow + { + if( --weak_count_ == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return use_count_; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp index 54d0351..a16d2d8 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp @@ -1,137 +1,137 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_pt.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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 <boost/assert.hpp>
-#include <pthread.h>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long weak_count_; // #weak + (#shared != 0)
-
- mutable pthread_mutex_t m_;
-
-public:
-
- sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
- {
-// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
-
-#if defined(__hpux) && defined(_DECTHREADS_)
- BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 );
-#else
- BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 );
-#endif
- }
-
- virtual ~sp_counted_base() // nothrow
- {
- BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
- }
-
- // 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()
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- ++use_count_;
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
- }
-
- bool add_ref_lock() // true on success
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- bool r = use_count_ == 0? false: ( ++use_count_, true );
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
- return r;
- }
-
- void release() // nothrow
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- long new_use_count = --use_count_;
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
-
- if( new_use_count == 0 )
- {
- dispose();
- weak_release();
- }
- }
-
- void weak_add_ref() // nothrow
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- ++weak_count_;
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
- }
-
- void weak_release() // nothrow
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- long new_weak_count = --weak_count_;
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
-
- if( new_weak_count == 0 )
- {
- destroy();
- }
- }
-
- long use_count() const // nothrow
- {
- BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
- long r = use_count_;
- BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
-
- return r;
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_pt.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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 <boost/assert.hpp> +#include <pthread.h> + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + + mutable pthread_mutex_t m_; + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { +// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init + +#if defined(__hpux) && defined(_DECTHREADS_) + BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); +#else + BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); +#endif + } + + virtual ~sp_counted_base() // nothrow + { + BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); + } + + // 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() + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + ++use_count_; + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + } + + bool add_ref_lock() // true on success + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + bool r = use_count_ == 0? false: ( ++use_count_, true ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + return r; + } + + void release() // nothrow + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + long new_use_count = --use_count_; + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + + if( new_use_count == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + ++weak_count_; + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + } + + void weak_release() // nothrow + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + long new_weak_count = --weak_count_; + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + + if( new_weak_count == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); + long r = use_count_; + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); + + return r; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp index de022ee..56ed79f 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp @@ -1,162 +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
+#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/contrib/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp index c8fbb6d..77734e7 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp @@ -1,132 +1,132 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_spin.hpp - spinlock pool atomic emulation
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2008 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 <boost/smart_ptr/detail/spinlock_pool.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline int atomic_exchange_and_add( int * pw, int dv )
-{
- spinlock_pool<1>::scoped_lock lock( pw );
-
- int r = *pw;
- *pw += dv;
- return r;
-}
-
-inline void atomic_increment( int * pw )
-{
- spinlock_pool<1>::scoped_lock lock( pw );
- ++*pw;
-}
-
-inline int atomic_conditional_increment( int * pw )
-{
- spinlock_pool<1>::scoped_lock lock( pw );
-
- int rv = *pw;
- if( rv != 0 ) ++*pw;
- return rv;
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int 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_exchange_and_add( &use_count_, -1 ) == 1 )
- {
- dispose();
- weak_release();
- }
- }
-
- void weak_add_ref() // nothrow
- {
- atomic_increment( &weak_count_ );
- }
-
- void weak_release() // nothrow
- {
- if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 )
- {
- destroy();
- }
- }
-
- long use_count() const // nothrow
- {
- spinlock_pool<1>::scoped_lock lock( &use_count_ );
- return use_count_;
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_spin.hpp - spinlock pool atomic emulation +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2008 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 <boost/smart_ptr/detail/spinlock_pool.hpp> + +namespace boost +{ + +namespace detail +{ + +inline int atomic_exchange_and_add( int * pw, int dv ) +{ + spinlock_pool<1>::scoped_lock lock( pw ); + + int r = *pw; + *pw += dv; + return r; +} + +inline void atomic_increment( int * pw ) +{ + spinlock_pool<1>::scoped_lock lock( pw ); + ++*pw; +} + +inline int atomic_conditional_increment( int * pw ) +{ + spinlock_pool<1>::scoped_lock lock( pw ); + + int rv = *pw; + if( rv != 0 ) ++*pw; + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int 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_exchange_and_add( &use_count_, -1 ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + spinlock_pool<1>::scoped_lock lock( &use_count_ ); + return use_count_; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SPIN_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp index 8743536..cab8453 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp @@ -1,137 +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
+#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/contrib/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp index 63288c1..fafed0e 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp @@ -1,156 +1,156 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-// detail/sp_counted_base_sync.hpp - g++ 4.1+ __sync intrinsics
-//
-// Copyright (c) 2007 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 <limits.h>
-
-#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
-# include <ia64intrin.h>
-#endif
-
-namespace boost
-{
-
-namespace detail
-{
-
-#if INT_MAX >= 2147483647
-
-typedef int sp_int32_t;
-
-#else
-
-typedef long sp_int32_t;
-
-#endif
-
-inline void atomic_increment( sp_int32_t * pw )
-{
- __sync_fetch_and_add( pw, 1 );
-}
-
-inline sp_int32_t atomic_decrement( sp_int32_t * pw )
-{
- return __sync_fetch_and_add( pw, -1 );
-}
-
-inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw )
-{
- // long r = *pw;
- // if( r != 0 ) ++*pw;
- // return r;
-
- sp_int32_t r = *pw;
-
- for( ;; )
- {
- if( r == 0 )
- {
- return r;
- }
-
- sp_int32_t r2 = __sync_val_compare_and_swap( pw, r, r + 1 );
-
- if( r2 == r )
- {
- return r;
- }
- else
- {
- r = r2;
- }
- }
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- sp_int32_t use_count_; // #shared
- sp_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_ ) == 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< sp_int32_t const volatile & >( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_sync.hpp - g++ 4.1+ __sync intrinsics +// +// Copyright (c) 2007 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 <limits.h> + +#if defined( __ia64__ ) && defined( __INTEL_COMPILER ) +# include <ia64intrin.h> +#endif + +namespace boost +{ + +namespace detail +{ + +#if INT_MAX >= 2147483647 + +typedef int sp_int32_t; + +#else + +typedef long sp_int32_t; + +#endif + +inline void atomic_increment( sp_int32_t * pw ) +{ + __sync_fetch_and_add( pw, 1 ); +} + +inline sp_int32_t atomic_decrement( sp_int32_t * pw ) +{ + return __sync_fetch_and_add( pw, -1 ); +} + +inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + sp_int32_t r = *pw; + + for( ;; ) + { + if( r == 0 ) + { + return r; + } + + sp_int32_t r2 = __sync_val_compare_and_swap( pw, r, r + 1 ); + + if( r2 == r ) + { + return r; + } + else + { + r = r2; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + sp_int32_t use_count_; // #shared + sp_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_ ) == 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< sp_int32_t const volatile & >( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp index d59f3c5..162f309 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp @@ -1,151 +1,151 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED
-
-//
-// detail/sp_counted_base_vacpp_ppc.hpp - xlC(vacpp) on POWER
-// 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
-// Copyright 2012 IBM Corp.
-//
-// 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>
-
-extern "builtin" void __lwsync(void);
-extern "builtin" void __isync(void);
-extern "builtin" int __fetch_and_add(volatile int* addr, int val);
-extern "builtin" int __compare_and_swap(volatile int*, int*, int);
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void atomic_increment( int *pw )
-{
- // ++*pw;
- __lwsync();
- __fetch_and_add(pw, 1);
- __isync();
-}
-
-inline int atomic_decrement( int *pw )
-{
- // return --*pw;
- __lwsync();
- int originalValue = __fetch_and_add(pw, -1);
- __isync();
-
- return (originalValue - 1);
-}
-
-inline int atomic_conditional_increment( int *pw )
-{
- // if( *pw != 0 ) ++*pw;
- // return *pw;
-
- __lwsync();
- int v = *const_cast<volatile int*>(pw);
- for (;;)
- // loop until state is known
- {
- if (v == 0) return 0;
- if (__compare_and_swap(pw, &v, v + 1))
- {
- __isync(); return (v + 1);
- }
- }
-}
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- int use_count_; // #shared
- int weak_count_; // #weak + (#shared != 0)
- char pad[64] __attribute__((__aligned__(64)));
- // pad to prevent false sharing
-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 *const_cast<volatile int*>(&use_count_);
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED + +// +// detail/sp_counted_base_vacpp_ppc.hpp - xlC(vacpp) on POWER +// 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 +// Copyright 2012 IBM Corp. +// +// 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> + +extern "builtin" void __lwsync(void); +extern "builtin" void __isync(void); +extern "builtin" int __fetch_and_add(volatile int* addr, int val); +extern "builtin" int __compare_and_swap(volatile int*, int*, int); + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int *pw ) +{ + // ++*pw; + __lwsync(); + __fetch_and_add(pw, 1); + __isync(); +} + +inline int atomic_decrement( int *pw ) +{ + // return --*pw; + __lwsync(); + int originalValue = __fetch_and_add(pw, -1); + __isync(); + + return (originalValue - 1); +} + +inline int atomic_conditional_increment( int *pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + __lwsync(); + int v = *const_cast<volatile int*>(pw); + for (;;) + // loop until state is known + { + if (v == 0) return 0; + if (__compare_and_swap(pw, &v, v + 1)) + { + __isync(); return (v + 1); + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int weak_count_; // #weak + (#shared != 0) + char pad[64] __attribute__((__aligned__(64))); + // pad to prevent false sharing +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 *const_cast<volatile int*>(&use_count_); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_VACPP_PPC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp index 7126f8d..4ba509c 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp @@ -1,131 +1,131 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_base_w32.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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)
-//
-//
-// Lock-free algorithm by Alexander Terekhov
-//
-// Thanks to Ben Hitchings for the #weak + (#shared != 0)
-// formulation
-//
-
-#include <boost/smart_ptr/detail/sp_interlocked.hpp>
-#include <boost/detail/workaround.hpp>
-#include <boost/detail/sp_typeinfo.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long 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()
- {
- BOOST_SP_INTERLOCKED_INCREMENT( &use_count_ );
- }
-
- bool add_ref_lock() // true on success
- {
- for( ;; )
- {
- long tmp = static_cast< long const volatile& >( use_count_ );
- if( tmp == 0 ) return false;
-
-#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1200 )
-
- // work around a code generation bug
-
- long tmp2 = tmp + 1;
- if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true;
-
-#else
-
- if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true;
-
-#endif
- }
- }
-
- void release() // nothrow
- {
- if( BOOST_SP_INTERLOCKED_DECREMENT( &use_count_ ) == 0 )
- {
- dispose();
- weak_release();
- }
- }
-
- void weak_add_ref() // nothrow
- {
- BOOST_SP_INTERLOCKED_INCREMENT( &weak_count_ );
- }
-
- void weak_release() // nothrow
- {
- if( BOOST_SP_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 )
- {
- destroy();
- }
- }
-
- long use_count() const // nothrow
- {
- return static_cast<long const volatile &>( use_count_ );
- }
-};
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_w32.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/smart_ptr/detail/sp_interlocked.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/detail/sp_typeinfo.hpp> + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long 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() + { + BOOST_SP_INTERLOCKED_INCREMENT( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + for( ;; ) + { + long tmp = static_cast< long const volatile& >( use_count_ ); + if( tmp == 0 ) return false; + +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1200 ) + + // work around a code generation bug + + long tmp2 = tmp + 1; + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; + +#else + + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + +#endif + } + } + + void release() // nothrow + { + if( BOOST_SP_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + BOOST_SP_INTERLOCKED_INCREMENT( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( BOOST_SP_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast<long const volatile &>( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_counted_impl.hpp b/contrib/src/boost/smart_ptr/detail/sp_counted_impl.hpp index de6cd55..1222f3c 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_counted_impl.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_counted_impl.hpp @@ -1,263 +1,271 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// detail/sp_counted_impl.hpp
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 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>
-
-#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)
-# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
-#endif
-
-#include <boost/checked_delete.hpp>
-#include <boost/smart_ptr/detail/sp_counted_base.hpp>
-
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
-#include <boost/smart_ptr/detail/quick_allocator.hpp>
-#endif
-
-#if defined(BOOST_SP_USE_STD_ALLOCATOR)
-#include <memory> // std::allocator
-#endif
-
-#include <cstddef> // std::size_t
-
-namespace boost
-{
-
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
-
-void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );
-void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );
-
-#endif
-
-namespace detail
-{
-
-template<class X> class sp_counted_impl_p: public sp_counted_base
-{
-private:
-
- X * px_;
-
- sp_counted_impl_p( sp_counted_impl_p const & );
- sp_counted_impl_p & operator= ( sp_counted_impl_p const & );
-
- typedef sp_counted_impl_p<X> this_type;
-
-public:
-
- explicit sp_counted_impl_p( X * px ): px_( px )
- {
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_scalar_constructor_hook( px, sizeof(X), this );
-#endif
- }
-
- virtual void dispose() // nothrow
- {
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
- boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
-#endif
- boost::checked_delete( px_ );
- }
-
- virtual void * get_deleter( sp_typeinfo const & )
- {
- return 0;
- }
-
- virtual void * get_untyped_deleter()
- {
- return 0;
- }
-
-#if defined(BOOST_SP_USE_STD_ALLOCATOR)
-
- void * operator new( std::size_t )
- {
- return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
- }
-
- void operator delete( void * p )
- {
- std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
- }
-
-#endif
-
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
-
- void * operator new( std::size_t )
- {
- return quick_allocator<this_type>::alloc();
- }
-
- void operator delete( void * p )
- {
- quick_allocator<this_type>::dealloc( p );
- }
-
-#endif
-};
-
-//
-// Borland's Codeguard trips up over the -Vx- option here:
-//
-#ifdef __CODEGUARD__
-# pragma option push -Vx-
-#endif
-
-template<class P, class D> class sp_counted_impl_pd: public sp_counted_base
-{
-private:
-
- P ptr; // copy constructor must not throw
- D del; // copy constructor must not throw
-
- sp_counted_impl_pd( sp_counted_impl_pd const & );
- sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );
-
- typedef sp_counted_impl_pd<P, D> this_type;
-
-public:
-
- // pre: d(p) must not throw
-
- sp_counted_impl_pd( P p, D & d ): ptr( p ), del( d )
- {
- }
-
- sp_counted_impl_pd( P p ): ptr( p ), del()
- {
- }
-
- virtual void dispose() // nothrow
- {
- del( ptr );
- }
-
- virtual void * get_deleter( sp_typeinfo const & ti )
- {
- 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 )
- {
- return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
- }
-
- void operator delete( void * p )
- {
- std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
- }
-
-#endif
-
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
-
- void * operator new( std::size_t )
- {
- return quick_allocator<this_type>::alloc();
- }
-
- void operator delete( void * p )
- {
- quick_allocator<this_type>::dealloc( p );
- }
-
-#endif
-};
-
-template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base
-{
-private:
-
- P p_; // copy constructor must not throw
- D d_; // copy constructor must not throw
- A a_; // copy constructor must not throw
-
- sp_counted_impl_pda( sp_counted_impl_pda const & );
- sp_counted_impl_pda & operator= ( sp_counted_impl_pda const & );
-
- typedef sp_counted_impl_pda<P, D, A> this_type;
-
-public:
-
- // pre: d( p ) must not throw
-
- sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( d ), a_( a )
- {
- }
-
- sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a )
- {
- }
-
- virtual void dispose() // nothrow
- {
- d_( p_ );
- }
-
- 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_ );
-
- this->~this_type();
-
- a2.deallocate( this, 1 );
- }
-
- virtual void * get_deleter( sp_typeinfo const & ti )
- {
- return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;
- }
-
- virtual void * get_untyped_deleter()
- {
- return &reinterpret_cast<char&>( d_ );
- }
-};
-
-#ifdef __CODEGUARD__
-# pragma option pop
-#endif
-
-} // namespace detail
-
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_impl.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 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> + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR) +# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible. +#endif + +#include <boost/checked_delete.hpp> +#include <boost/smart_ptr/detail/sp_counted_base.hpp> + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) +#include <boost/smart_ptr/detail/quick_allocator.hpp> +#endif + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) +#include <memory> // std::allocator +#endif + +#include <cstddef> // std::size_t + +namespace boost +{ + +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + +void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn ); +void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn ); + +#endif + +namespace detail +{ + +template<class X> class sp_counted_impl_p: public sp_counted_base +{ +private: + + X * px_; + + sp_counted_impl_p( sp_counted_impl_p const & ); + sp_counted_impl_p & operator= ( sp_counted_impl_p const & ); + + typedef sp_counted_impl_p<X> this_type; + +public: + + explicit sp_counted_impl_p( X * px ): px_( px ) + { +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + boost::sp_scalar_constructor_hook( px, sizeof(X), this ); +#endif + } + + virtual void dispose() // nothrow + { +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + boost::sp_scalar_destructor_hook( px_, sizeof(X), this ); +#endif + boost::checked_delete( px_ ); + } + + virtual void * get_deleter( sp_typeinfo const & ) + { + return 0; + } + + virtual void * get_untyped_deleter() + { + return 0; + } + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) + + void * operator new( std::size_t ) + { + return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) ); + } + + void operator delete( void * p ) + { + std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 ); + } + +#endif + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) + + void * operator new( std::size_t ) + { + return quick_allocator<this_type>::alloc(); + } + + void operator delete( void * p ) + { + quick_allocator<this_type>::dealloc( p ); + } + +#endif +}; + +// +// Borland's Codeguard trips up over the -Vx- option here: +// +#ifdef __CODEGUARD__ +# pragma option push -Vx- +#endif + +template<class P, class D> class sp_counted_impl_pd: public sp_counted_base +{ +private: + + P ptr; // copy constructor must not throw + D del; // copy constructor must not throw + + sp_counted_impl_pd( sp_counted_impl_pd const & ); + sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & ); + + typedef sp_counted_impl_pd<P, D> this_type; + +public: + + // pre: d(p) must not throw + + sp_counted_impl_pd( P p, D & d ): ptr( p ), del( d ) + { + } + + sp_counted_impl_pd( P p ): ptr( p ), del() + { + } + + virtual void dispose() // nothrow + { + del( ptr ); + } + + virtual void * get_deleter( sp_typeinfo const & ti ) + { + 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 ) + { + return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) ); + } + + void operator delete( void * p ) + { + std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 ); + } + +#endif + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) + + void * operator new( std::size_t ) + { + return quick_allocator<this_type>::alloc(); + } + + void operator delete( void * p ) + { + quick_allocator<this_type>::dealloc( p ); + } + +#endif +}; + +template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base +{ +private: + + P p_; // copy constructor must not throw + D d_; // copy constructor must not throw + A a_; // copy constructor must not throw + + sp_counted_impl_pda( sp_counted_impl_pda const & ); + sp_counted_impl_pda & operator= ( sp_counted_impl_pda const & ); + + typedef sp_counted_impl_pda<P, D, A> this_type; + +public: + + // pre: d( p ) must not throw + + sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( d ), a_( a ) + { + } + + sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a ) + { + } + + virtual void dispose() // nothrow + { + d_( p_ ); + } + + 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 ); + } + + virtual void * get_deleter( sp_typeinfo const & ti ) + { + return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0; + } + + virtual void * get_untyped_deleter() + { + return &reinterpret_cast<char&>( d_ ); + } +}; + +#ifdef __CODEGUARD__ +# pragma option pop +#endif + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_disable_deprecated.hpp b/contrib/src/boost/smart_ptr/detail/sp_disable_deprecated.hpp index ac34bd6..f79bdf3 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_disable_deprecated.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_disable_deprecated.hpp @@ -1,40 +1,40 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/smart_ptr/detail/sp_disable_deprecated.hpp
-//
-// Copyright 2015 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>
-
-#if defined( __GNUC__ ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || ( __cplusplus >= 201103L ) )
-
-# if defined( BOOST_GCC )
-
-# if BOOST_GCC >= 40600
-# define BOOST_SP_DISABLE_DEPRECATED
-# endif
-
-# elif defined( __clang__ ) && defined( __has_warning )
-
-# if __has_warning( "-Wdeprecated-declarations" )
-# define BOOST_SP_DISABLE_DEPRECATED
-# endif
-
-# endif
-
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/smart_ptr/detail/sp_disable_deprecated.hpp +// +// Copyright 2015 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> + +#if defined( __GNUC__ ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || ( __cplusplus >= 201103L ) ) + +# if defined( BOOST_GCC ) + +# if BOOST_GCC >= 40600 +# define BOOST_SP_DISABLE_DEPRECATED +# endif + +# elif defined( __clang__ ) && defined( __has_warning ) + +# if __has_warning( "-Wdeprecated-declarations" ) +# define BOOST_SP_DISABLE_DEPRECATED +# endif + +# endif + +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_DISABLE_DEPRECATED_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/sp_has_sync.hpp b/contrib/src/boost/smart_ptr/detail/sp_has_sync.hpp index 882ba66..16de21d 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_has_sync.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_has_sync.hpp @@ -1,69 +1,69 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/smart_ptr/detail/sp_has_sync.hpp
-//
-// Copyright (c) 2008, 2009 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)
-//
-// Defines the BOOST_SP_HAS_SYNC macro if the __sync_* intrinsics
-// are available.
-//
-
-#ifndef BOOST_SP_NO_SYNC
-
-#if !defined( __c2__ ) && defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 )
-
-# define BOOST_SP_HAS_SYNC
-
-#elif defined( __IBMCPP__ ) && ( __IBMCPP__ >= 1210 ) && !defined( __COMPILER_VER__ )
-
-# define BOOST_SP_HAS_SYNC
-
-#elif !defined( __c2__ ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
-
-#define BOOST_SP_HAS_SYNC
-
-#if defined( __arm__ ) || defined( __armel__ )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#if defined( __hppa ) || defined( __hppa__ )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#if defined( __m68k__ )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#if defined( __sh__ )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#if defined( __sparc__ )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1110 )
-#undef BOOST_SP_HAS_SYNC
-#endif
-
-#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
+#ifndef BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/smart_ptr/detail/sp_has_sync.hpp +// +// Copyright (c) 2008, 2009 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) +// +// Defines the BOOST_SP_HAS_SYNC macro if the __sync_* intrinsics +// are available. +// + +#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 + +#if defined( __arm__ ) || defined( __armel__ ) +#undef BOOST_SP_HAS_SYNC +#endif + +#if defined( __hppa ) || defined( __hppa__ ) +#undef BOOST_SP_HAS_SYNC +#endif + +#if defined( __m68k__ ) +#undef BOOST_SP_HAS_SYNC +#endif + +#if defined( __sh__ ) +#undef BOOST_SP_HAS_SYNC +#endif + +#if defined( __sparc__ ) +#undef BOOST_SP_HAS_SYNC +#endif + +#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1110 ) +#undef BOOST_SP_HAS_SYNC +#endif + +#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/contrib/src/boost/smart_ptr/detail/sp_interlocked.hpp b/contrib/src/boost/smart_ptr/detail/sp_interlocked.hpp index eca9f7c..79cae14 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_interlocked.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_interlocked.hpp @@ -1,163 +1,163 @@ -#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 );
-
-# if defined( BOOST_MSVC ) && BOOST_MSVC == 1310
-//From MSDN, Visual Studio .NET 2003 spedific: To declare one of the interlocked functions
-//for use as an intrinsic, the function must be declared with the leading underscore and
-//the new function must appear in a #pragma intrinsic statement.
-# pragma intrinsic( _InterlockedIncrement )
-# pragma intrinsic( _InterlockedDecrement )
-# pragma intrinsic( _InterlockedCompareExchange )
-# pragma intrinsic( _InterlockedExchange )
-# pragma intrinsic( _InterlockedExchangeAdd )
-# endif
-
-#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
+#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 ); + +# if defined( BOOST_MSVC ) && BOOST_MSVC == 1310 +//From MSDN, Visual Studio .NET 2003 spedific: To declare one of the interlocked functions +//for use as an intrinsic, the function must be declared with the leading underscore and +//the new function must appear in a #pragma intrinsic statement. +# pragma intrinsic( _InterlockedIncrement ) +# pragma intrinsic( _InterlockedDecrement ) +# pragma intrinsic( _InterlockedCompareExchange ) +# pragma intrinsic( _InterlockedExchange ) +# pragma intrinsic( _InterlockedExchangeAdd ) +# endif + +#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/contrib/src/boost/smart_ptr/detail/sp_nullptr_t.hpp b/contrib/src/boost/smart_ptr/detail/sp_nullptr_t.hpp index d8ce65f..219ae80 100644 --- a/contrib/src/boost/smart_ptr/detail/sp_nullptr_t.hpp +++ b/contrib/src/boost/smart_ptr/detail/sp_nullptr_t.hpp @@ -1,45 +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( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) )
-
- 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
+#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( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) ) + + 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/contrib/src/boost/smart_ptr/detail/spinlock.hpp b/contrib/src/boost/smart_ptr/detail/spinlock.hpp index df2d397..19f93d7 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock.hpp @@ -1,68 +1,65 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/detail/spinlock.hpp
-//
-// Copyright (c) 2008 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)
-//
-// struct spinlock
-// {
-// void lock();
-// bool try_lock();
-// void unlock();
-//
-// class scoped_lock;
-// };
-//
-// #define BOOST_DETAIL_SPINLOCK_INIT <unspecified>
-//
-
-#include <boost/config.hpp>
-#include <boost/smart_ptr/detail/sp_has_sync.hpp>
-
-#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( BOOST_NO_CXX11_HDR_ATOMIC )
-# include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
-
-#elif defined(__GNUC__) && defined( __arm__ ) && !defined( __thumb__ )
-# include <boost/smart_ptr/detail/spinlock_gcc_arm.hpp>
-
-#elif defined( BOOST_SP_HAS_SYNC )
-# include <boost/smart_ptr/detail/spinlock_sync.hpp>
-
-#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# include <boost/smart_ptr/detail/spinlock_w32.hpp>
-
-#elif defined(BOOST_HAS_PTHREADS)
-# include <boost/smart_ptr/detail/spinlock_pt.hpp>
-
-#elif !defined(BOOST_HAS_THREADS)
-# include <boost/smart_ptr/detail/spinlock_nt.hpp>
-
-#else
-# error Unrecognized threading platform
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/spinlock.hpp +// +// Copyright (c) 2008 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) +// +// struct spinlock +// { +// void lock(); +// bool try_lock(); +// void unlock(); +// +// class scoped_lock; +// }; +// +// #define BOOST_DETAIL_SPINLOCK_INIT <unspecified> +// + +#include <boost/config.hpp> +#include <boost/smart_ptr/detail/sp_has_sync.hpp> + +#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__ ) +# include <boost/smart_ptr/detail/spinlock_gcc_arm.hpp> + +#elif defined( BOOST_SP_HAS_SYNC ) +# include <boost/smart_ptr/detail/spinlock_sync.hpp> + +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# include <boost/smart_ptr/detail/spinlock_w32.hpp> + +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/smart_ptr/detail/spinlock_pt.hpp> + +#elif !defined(BOOST_HAS_THREADS) +# include <boost/smart_ptr/detail/spinlock_nt.hpp> + +#else +# error Unrecognized threading platform +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp index cd68af5..24d08a8 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp @@ -1,121 +1,121 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
-
-//
-// Copyright (c) 2008, 2011 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>
-
-#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
-
-# define BOOST_SP_ARM_BARRIER ""
-
-#endif
-
-namespace boost
-{
-
-namespace detail
-{
-
-class spinlock
-{
-public:
-
- int v_;
-
-public:
-
- bool try_lock()
- {
- int r;
-
-#ifdef BOOST_SP_ARM_HAS_LDREX
-
- __asm__ __volatile__(
- "ldrex %0, [%2]; \n"
- "cmp %0, %1; \n"
- "strexne %0, %1, [%2]; \n"
- BOOST_SP_ARM_BARRIER :
- "=&r"( r ): // outputs
- "r"( 1 ), "r"( &v_ ): // inputs
- "memory", "cc" );
-
-#else
-
- __asm__ __volatile__(
- "swp %0, %1, [%2];\n"
- BOOST_SP_ARM_BARRIER :
- "=&r"( r ): // outputs
- "r"( 1 ), "r"( &v_ ): // inputs
- "memory", "cc" );
-
-#endif
-
- return r == 0;
- }
-
- void lock()
- {
- for( unsigned k = 0; !try_lock(); ++k )
- {
- boost::detail::yield( k );
- }
- }
-
- void unlock()
- {
- __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" );
- *const_cast< int volatile* >( &v_ ) = 0;
- __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" );
- }
-
-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 {0}
-
-#undef BOOST_SP_ARM_BARRIER
-#undef BOOST_SP_ARM_HAS_LDREX
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED + +// +// Copyright (c) 2008, 2011 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> + +#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 + +# define BOOST_SP_ARM_BARRIER "" + +#endif + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + int v_; + +public: + + bool try_lock() + { + int r; + +#ifdef BOOST_SP_ARM_HAS_LDREX + + __asm__ __volatile__( + "ldrex %0, [%2]; \n" + "cmp %0, %1; \n" + "strexne %0, %1, [%2]; \n" + BOOST_SP_ARM_BARRIER : + "=&r"( r ): // outputs + "r"( 1 ), "r"( &v_ ): // inputs + "memory", "cc" ); + +#else + + __asm__ __volatile__( + "swp %0, %1, [%2];\n" + BOOST_SP_ARM_BARRIER : + "=&r"( r ): // outputs + "r"( 1 ), "r"( &v_ ): // inputs + "memory", "cc" ); + +#endif + + return r == 0; + } + + void lock() + { + for( unsigned k = 0; !try_lock(); ++k ) + { + boost::detail::yield( k ); + } + } + + void unlock() + { + __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" ); + *const_cast< int volatile* >( &v_ ) = 0; + __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" ); + } + +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 {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/contrib/src/boost/smart_ptr/detail/spinlock_nt.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_nt.hpp index 920d67e..1f399d0 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_nt.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_nt.hpp @@ -1,89 +1,89 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// Copyright (c) 2008 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/assert.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class spinlock
-{
-public:
-
- bool locked_;
-
-public:
-
- inline bool try_lock()
- {
- if( locked_ )
- {
- return false;
- }
- else
- {
- locked_ = true;
- return true;
- }
- }
-
- inline void lock()
- {
- BOOST_ASSERT( !locked_ );
- locked_ = true;
- }
-
- inline void unlock()
- {
- BOOST_ASSERT( locked_ );
- locked_ = false;
- }
-
-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 { false }
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2008 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/assert.hpp> + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + bool locked_; + +public: + + inline bool try_lock() + { + if( locked_ ) + { + return false; + } + else + { + locked_ = true; + return true; + } + } + + inline void lock() + { + BOOST_ASSERT( !locked_ ); + locked_ = true; + } + + inline void unlock() + { + BOOST_ASSERT( locked_ ); + locked_ = false; + } + +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 { false } + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/spinlock_pool.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_pool.hpp index 28fe03e..39cf180 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_pool.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_pool.hpp @@ -1,91 +1,91 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// boost/detail/spinlock_pool.hpp
-//
-// Copyright (c) 2008 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)
-//
-// spinlock_pool<0> is reserved for atomic<>, when/if it arrives
-// spinlock_pool<1> is reserved for shared_ptr reference counts
-// spinlock_pool<2> is reserved for shared_ptr atomic access
-//
-
-#include <boost/config.hpp>
-#include <boost/smart_ptr/detail/spinlock.hpp>
-#include <cstddef>
-
-namespace boost
-{
-
-namespace detail
-{
-
-template< int M > class spinlock_pool
-{
-private:
-
- static spinlock pool_[ 41 ];
-
-public:
-
- static spinlock & spinlock_for( void const * pv )
- {
-#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64
- std::size_t i = reinterpret_cast< unsigned long long >( pv ) % 41;
-#else
- std::size_t i = reinterpret_cast< std::size_t >( pv ) % 41;
-#endif
- return pool_[ i ];
- }
-
- class scoped_lock
- {
- private:
-
- spinlock & sp_;
-
- scoped_lock( scoped_lock const & );
- scoped_lock & operator=( scoped_lock const & );
-
- public:
-
- explicit scoped_lock( void const * pv ): sp_( spinlock_for( pv ) )
- {
- sp_.lock();
- }
-
- ~scoped_lock()
- {
- sp_.unlock();
- }
- };
-};
-
-template< int M > spinlock spinlock_pool< M >::pool_[ 41 ] =
-{
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT,
- BOOST_DETAIL_SPINLOCK_INIT
-};
-
-} // namespace detail
-} // namespace boost
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/spinlock_pool.hpp +// +// Copyright (c) 2008 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) +// +// spinlock_pool<0> is reserved for atomic<>, when/if it arrives +// spinlock_pool<1> is reserved for shared_ptr reference counts +// spinlock_pool<2> is reserved for shared_ptr atomic access +// + +#include <boost/config.hpp> +#include <boost/smart_ptr/detail/spinlock.hpp> +#include <cstddef> + +namespace boost +{ + +namespace detail +{ + +template< int M > class spinlock_pool +{ +private: + + static spinlock pool_[ 41 ]; + +public: + + static spinlock & spinlock_for( void const * pv ) + { +#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 + std::size_t i = reinterpret_cast< unsigned long long >( pv ) % 41; +#else + std::size_t i = reinterpret_cast< std::size_t >( pv ) % 41; +#endif + return pool_[ i ]; + } + + class scoped_lock + { + private: + + spinlock & sp_; + + scoped_lock( scoped_lock const & ); + scoped_lock & operator=( scoped_lock const & ); + + public: + + explicit scoped_lock( void const * pv ): sp_( spinlock_for( pv ) ) + { + sp_.lock(); + } + + ~scoped_lock() + { + sp_.unlock(); + } + }; +}; + +template< int M > spinlock spinlock_pool< M >::pool_[ 41 ] = +{ + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, BOOST_DETAIL_SPINLOCK_INIT, + BOOST_DETAIL_SPINLOCK_INIT +}; + +} // namespace detail +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_POOL_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/spinlock_pt.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_pt.hpp index f55e61f..f9cabfc 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_pt.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_pt.hpp @@ -1,79 +1,79 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// Copyright (c) 2008 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 <pthread.h>
-
-namespace boost
-{
-
-namespace detail
-{
-
-class spinlock
-{
-public:
-
- pthread_mutex_t v_;
-
-public:
-
- bool try_lock()
- {
- return pthread_mutex_trylock( &v_ ) == 0;
- }
-
- void lock()
- {
- pthread_mutex_lock( &v_ );
- }
-
- void unlock()
- {
- pthread_mutex_unlock( &v_ );
- }
-
-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 { PTHREAD_MUTEX_INITIALIZER }
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2008 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 <pthread.h> + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + pthread_mutex_t v_; + +public: + + bool try_lock() + { + return pthread_mutex_trylock( &v_ ) == 0; + } + + void lock() + { + pthread_mutex_lock( &v_ ); + } + + void unlock() + { + pthread_mutex_unlock( &v_ ); + } + +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 { PTHREAD_MUTEX_INITIALIZER } + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp index 6e46229..a61c1cd 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp @@ -1,83 +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
+#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/contrib/src/boost/smart_ptr/detail/spinlock_sync.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_sync.hpp index f948306..a7145c5 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_sync.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_sync.hpp @@ -1,87 +1,87 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// Copyright (c) 2008 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>
-
-#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
-# include <ia64intrin.h>
-#endif
-
-namespace boost
-{
-
-namespace detail
-{
-
-class spinlock
-{
-public:
-
- int v_;
-
-public:
-
- bool try_lock()
- {
- int r = __sync_lock_test_and_set( &v_, 1 );
- return r == 0;
- }
-
- void lock()
- {
- for( unsigned k = 0; !try_lock(); ++k )
- {
- boost::detail::yield( k );
- }
- }
-
- void unlock()
- {
- __sync_lock_release( &v_ );
- }
-
-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 {0}
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2008 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> + +#if defined( __ia64__ ) && defined( __INTEL_COMPILER ) +# include <ia64intrin.h> +#endif + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + int v_; + +public: + + bool try_lock() + { + int r = __sync_lock_test_and_set( &v_, 1 ); + return r == 0; + } + + void lock() + { + for( unsigned k = 0; !try_lock(); ++k ) + { + boost::detail::yield( k ); + } + } + + void unlock() + { + __sync_lock_release( &v_ ); + } + +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 {0} + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/spinlock_w32.hpp b/contrib/src/boost/smart_ptr/detail/spinlock_w32.hpp index 71243ab..d34e4fc 100644 --- a/contrib/src/boost/smart_ptr/detail/spinlock_w32.hpp +++ b/contrib/src/boost/smart_ptr/detail/spinlock_w32.hpp @@ -1,113 +1,113 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// Copyright (c) 2008 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/sp_interlocked.hpp>
-#include <boost/smart_ptr/detail/yield_k.hpp>
-
-// BOOST_COMPILER_FENCE
-
-#if defined(__INTEL_COMPILER)
-
-#define BOOST_COMPILER_FENCE __memory_barrier();
-
-#elif defined( _MSC_VER ) && _MSC_VER >= 1310
-
-extern "C" void _ReadWriteBarrier();
-#pragma intrinsic( _ReadWriteBarrier )
-
-#define BOOST_COMPILER_FENCE _ReadWriteBarrier();
-
-#elif defined(__GNUC__)
-
-#define BOOST_COMPILER_FENCE __asm__ __volatile__( "" : : : "memory" );
-
-#else
-
-#define BOOST_COMPILER_FENCE
-
-#endif
-
-//
-
-namespace boost
-{
-
-namespace detail
-{
-
-class spinlock
-{
-public:
-
- long v_;
-
-public:
-
- bool try_lock()
- {
- long r = BOOST_SP_INTERLOCKED_EXCHANGE( &v_, 1 );
-
- BOOST_COMPILER_FENCE
-
- return r == 0;
- }
-
- void lock()
- {
- for( unsigned k = 0; !try_lock(); ++k )
- {
- boost::detail::yield( k );
- }
- }
-
- void unlock()
- {
- BOOST_COMPILER_FENCE
- *const_cast< long volatile* >( &v_ ) = 0;
- }
-
-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 {0}
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2008 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/sp_interlocked.hpp> +#include <boost/smart_ptr/detail/yield_k.hpp> + +// BOOST_COMPILER_FENCE + +#if defined(__INTEL_COMPILER) + +#define BOOST_COMPILER_FENCE __memory_barrier(); + +#elif defined( _MSC_VER ) && _MSC_VER >= 1310 + +extern "C" void _ReadWriteBarrier(); +#pragma intrinsic( _ReadWriteBarrier ) + +#define BOOST_COMPILER_FENCE _ReadWriteBarrier(); + +#elif defined(__GNUC__) + +#define BOOST_COMPILER_FENCE __asm__ __volatile__( "" : : : "memory" ); + +#else + +#define BOOST_COMPILER_FENCE + +#endif + +// + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + long v_; + +public: + + bool try_lock() + { + long r = BOOST_SP_INTERLOCKED_EXCHANGE( &v_, 1 ); + + BOOST_COMPILER_FENCE + + return r == 0; + } + + void lock() + { + for( unsigned k = 0; !try_lock(); ++k ) + { + boost::detail::yield( k ); + } + } + + void unlock() + { + BOOST_COMPILER_FENCE + *const_cast< long volatile* >( &v_ ) = 0; + } + +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 {0} + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/detail/yield_k.hpp b/contrib/src/boost/smart_ptr/detail/yield_k.hpp index 8f146b9..44d1836 100644 --- a/contrib/src/boost/smart_ptr/detail/yield_k.hpp +++ b/contrib/src/boost/smart_ptr/detail/yield_k.hpp @@ -1,177 +1,177 @@ -#ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
-#define BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// yield_k.hpp
-//
-// Copyright (c) 2008 Peter Dimov
-// Copyright (c) Microsoft Corporation 2014
-//
-// void yield( unsigned k );
-//
-// Typical use:
-//
-// for( unsigned k = 0; !try_lock(); ++k ) yield( k );
-//
-// 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 <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();
-
-#define BOOST_SMT_PAUSE _mm_pause();
-
-#elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
-
-#define BOOST_SMT_PAUSE __asm__ __volatile__( "rep; nop" : : : "memory" );
-
-#endif
-
-//
-
-#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
-
-#if defined( BOOST_USE_WINDOWS_H )
-# include <windows.h>
-#endif
-
-namespace boost
-{
-
-namespace detail
-{
-
-#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
-#if !BOOST_COMP_CLANG || !defined __MINGW32__
- extern "C" void __stdcall Sleep( unsigned long ms );
-#else
-#include <_mingw.h>
-#if !defined __MINGW64_VERSION_MAJOR
- extern "C" void __stdcall Sleep( unsigned long ms );
-#else
- extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long ms );
-#endif
-#endif
-#endif
-
-inline void yield( unsigned k )
-{
- if( k < 4 )
- {
- }
-#if defined( BOOST_SMT_PAUSE )
- else if( k < 16 )
- {
- BOOST_SMT_PAUSE
- }
-#endif
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- else if( k < 32 )
- {
- Sleep( 0 );
- }
- else
- {
- Sleep( 1 );
- }
-#else
- else
- {
- // Sleep isn't supported on the Windows Runtime.
- std::this_thread::yield();
- }
-#endif
-}
-
-} // namespace detail
-
-} // namespace boost
-
-#elif defined( BOOST_HAS_PTHREADS )
-
-#ifndef _AIX
-#include <sched.h>
-#else
- // AIX's sched.h defines ::var which sometimes conflicts with Lambda's var
- extern "C" int sched_yield(void);
-#endif
-
-#include <time.h>
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void yield( unsigned k )
-{
- if( k < 4 )
- {
- }
-#if defined( BOOST_SMT_PAUSE )
- else if( k < 16 )
- {
- BOOST_SMT_PAUSE
- }
-#endif
- else if( k < 32 || k & 1 )
- {
- sched_yield();
- }
- else
- {
- // g++ -Wextra warns on {} or {0}
- struct timespec rqtp = { 0, 0 };
-
- // POSIX says that timespec has tv_sec and tv_nsec
- // But it doesn't guarantee order or placement
-
- rqtp.tv_sec = 0;
- rqtp.tv_nsec = 1000;
-
- nanosleep( &rqtp, 0 );
- }
-}
-
-} // namespace detail
-
-} // namespace boost
-
-#else
-
-namespace boost
-{
-
-namespace detail
-{
-
-inline void yield( unsigned )
-{
-}
-
-} // namespace detail
-
-} // namespace boost
-
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// yield_k.hpp +// +// Copyright (c) 2008 Peter Dimov +// Copyright (c) Microsoft Corporation 2014 +// +// void yield( unsigned k ); +// +// Typical use: +// +// for( unsigned k = 0; !try_lock(); ++k ) yield( k ); +// +// 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 <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(); + +#define BOOST_SMT_PAUSE _mm_pause(); + +#elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) ) + +#define BOOST_SMT_PAUSE __asm__ __volatile__( "rep; nop" : : : "memory" ); + +#endif + +// + +#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) + +#if defined( BOOST_USE_WINDOWS_H ) +# include <windows.h> +#endif + +namespace boost +{ + +namespace detail +{ + +#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME +#if !BOOST_COMP_CLANG || !defined __MINGW32__ + extern "C" void __stdcall Sleep( unsigned long ms ); +#else +#include <_mingw.h> +#if !defined __MINGW64_VERSION_MAJOR + extern "C" void __stdcall Sleep( unsigned long ms ); +#else + extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long ms ); +#endif +#endif +#endif + +inline void yield( unsigned k ) +{ + if( k < 4 ) + { + } +#if defined( BOOST_SMT_PAUSE ) + else if( k < 16 ) + { + BOOST_SMT_PAUSE + } +#endif +#if !BOOST_PLAT_WINDOWS_RUNTIME + else if( k < 32 ) + { + Sleep( 0 ); + } + else + { + Sleep( 1 ); + } +#else + else + { + // Sleep isn't supported on the Windows Runtime. + std::this_thread::yield(); + } +#endif +} + +} // namespace detail + +} // namespace boost + +#elif defined( BOOST_HAS_PTHREADS ) + +#ifndef _AIX +#include <sched.h> +#else + // AIX's sched.h defines ::var which sometimes conflicts with Lambda's var + extern "C" int sched_yield(void); +#endif + +#include <time.h> + +namespace boost +{ + +namespace detail +{ + +inline void yield( unsigned k ) +{ + if( k < 4 ) + { + } +#if defined( BOOST_SMT_PAUSE ) + else if( k < 16 ) + { + BOOST_SMT_PAUSE + } +#endif + else if( k < 32 || k & 1 ) + { + sched_yield(); + } + else + { + // g++ -Wextra warns on {} or {0} + struct timespec rqtp = { 0, 0 }; + + // POSIX says that timespec has tv_sec and tv_nsec + // But it doesn't guarantee order or placement + + rqtp.tv_sec = 0; + rqtp.tv_nsec = 1000; + + nanosleep( &rqtp, 0 ); + } +} + +} // namespace detail + +} // namespace boost + +#else + +namespace boost +{ + +namespace detail +{ + +inline void yield( unsigned ) +{ +} + +} // namespace detail + +} // namespace boost + +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_YIELD_K_HPP_INCLUDED diff --git a/contrib/src/boost/smart_ptr/shared_ptr.hpp b/contrib/src/boost/smart_ptr/shared_ptr.hpp index b58a29c..bcefda8 100644 --- a/contrib/src/boost/smart_ptr/shared_ptr.hpp +++ b/contrib/src/boost/smart_ptr/shared_ptr.hpp @@ -1,1139 +1,1077 @@ -#ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED
-#define BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED
-
-//
-// shared_ptr.hpp
-//
-// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
-// Copyright (c) 2001-2008 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/config.hpp> // for broken compiler workarounds
-
-// In order to avoid circular dependencies with Boost.TR1
-// we make sure that our include of <memory> doesn't try to
-// pull in the TR1 headers: that's why we use this header
-// rather than including <memory> directly:
-#include <boost/config/no_tr1/memory.hpp> // std::auto_ptr
-
-#include <boost/assert.hpp>
-#include <boost/checked_delete.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/smart_ptr/detail/shared_count.hpp>
-#include <boost/detail/workaround.hpp>
-#include <boost/smart_ptr/detail/sp_convertible.hpp>
-#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
-#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
-#include <boost/smart_ptr/detail/sp_noexcept.hpp>
-
-#if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
-#include <boost/smart_ptr/detail/spinlock_pool.hpp>
-#endif
-
-#include <algorithm> // for std::swap
-#include <functional> // for std::less
-#include <typeinfo> // for std::bad_cast
-#include <cstddef> // for std::size_t
-
-#if !defined(BOOST_NO_IOSTREAM)
-#if !defined(BOOST_NO_IOSFWD)
-#include <iosfwd> // for std::basic_ostream
-#else
-#include <ostream>
-#endif
-#endif
-
-#if defined( BOOST_SP_DISABLE_DEPRECATED )
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-namespace boost
-{
-
-template<class T> class shared_ptr;
-template<class T> class weak_ptr;
-template<class T> class enable_shared_from_this;
-class enable_shared_from_raw;
-
-namespace movelib
-{
-
- template< class T, class D > class unique_ptr;
-
-} // namespace movelib
-
-namespace detail
-{
-
-// sp_element, element_type
-
-template< class T > struct sp_element
-{
- typedef T type;
-};
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T > struct sp_element< T[] >
-{
- typedef T type;
-};
-
-#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 )
-
-template< class T, std::size_t N > struct sp_element< T[N] >
-{
- typedef T type;
-};
-
-#endif
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// sp_dereference, return type of operator*
-
-template< class T > struct sp_dereference
-{
- typedef T & type;
-};
-
-template<> struct sp_dereference< void >
-{
- typedef void type;
-};
-
-#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
-
-template<> struct sp_dereference< void const >
-{
- typedef void type;
-};
-
-template<> struct sp_dereference< void volatile >
-{
- typedef void type;
-};
-
-template<> struct sp_dereference< void const volatile >
-{
- typedef void type;
-};
-
-#endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T > struct sp_dereference< T[] >
-{
- typedef void type;
-};
-
-#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 )
-
-template< class T, std::size_t N > struct sp_dereference< T[N] >
-{
- typedef void type;
-};
-
-#endif
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// sp_member_access, return type of operator->
-
-template< class T > struct sp_member_access
-{
- typedef T * type;
-};
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T > struct sp_member_access< T[] >
-{
- typedef void type;
-};
-
-#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 )
-
-template< class T, std::size_t N > struct sp_member_access< T[N] >
-{
- typedef void type;
-};
-
-#endif
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// sp_array_access, return type of operator[]
-
-template< class T > struct sp_array_access
-{
- typedef void type;
-};
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T > struct sp_array_access< T[] >
-{
- typedef T & type;
-};
-
-#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 )
-
-template< class T, std::size_t N > struct sp_array_access< T[N] >
-{
- typedef T & type;
-};
-
-#endif
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// sp_extent, for operator[] index check
-
-template< class T > struct sp_extent
-{
- enum _vt { value = 0 };
-};
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T, std::size_t N > struct sp_extent< T[N] >
-{
- enum _vt { value = N };
-};
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// enable_shared_from_this support
-
-template< class X, class Y, class T > inline void sp_enable_shared_from_this( boost::shared_ptr<X> const * ppx, Y const * py, boost::enable_shared_from_this< T > const * pe )
-{
- if( pe != 0 )
- {
- pe->_internal_accept_owner( ppx, const_cast< Y* >( py ) );
- }
-}
-
-template< class X, class Y > inline void sp_enable_shared_from_this( boost::shared_ptr<X> * ppx, Y const * py, boost::enable_shared_from_raw const * pe );
-
-#ifdef _MANAGED
-
-// Avoid C4793, ... causes native code generation
-
-struct sp_any_pointer
-{
- template<class T> sp_any_pointer( T* ) {}
-};
-
-inline void sp_enable_shared_from_this( sp_any_pointer, sp_any_pointer, sp_any_pointer )
-{
-}
-
-#else // _MANAGED
-
-inline void sp_enable_shared_from_this( ... )
-{
-}
-
-#endif // _MANAGED
-
-#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR )
-
-// rvalue auto_ptr support based on a technique by Dave Abrahams
-
-template< class T, class R > struct sp_enable_if_auto_ptr
-{
-};
-
-template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
-{
- typedef R type;
-};
-
-#endif
-
-// sp_assert_convertible
-
-template< class Y, class T > inline void sp_assert_convertible()
-{
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
-
- // static_assert( sp_convertible< Y, T >::value );
- typedef char tmp[ sp_convertible< Y, T >::value? 1: -1 ];
- (void)sizeof( tmp );
-
-#else
-
- T* p = static_cast< Y* >( 0 );
- (void)p;
-
-#endif
-}
-
-// pointer constructor helper
-
-template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T > * ppx, Y * p, boost::detail::shared_count & pn )
-{
- boost::detail::shared_count( p ).swap( pn );
- boost::detail::sp_enable_shared_from_this( ppx, p, p );
-}
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * p, boost::detail::shared_count & pn )
-{
- sp_assert_convertible< Y[], T[] >();
- boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn );
-}
-
-template< class T, std::size_t N, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * p, boost::detail::shared_count & pn )
-{
- sp_assert_convertible< Y[N], T[N] >();
- boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn );
-}
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-// deleter constructor helper
-
-template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T > * ppx, Y * p )
-{
- boost::detail::sp_enable_shared_from_this( ppx, p, p );
-}
-
-#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ )
-{
- sp_assert_convertible< Y[], T[] >();
-}
-
-template< class T, std::size_t N, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * /*p*/ )
-{
- sp_assert_convertible< Y[N], T[N] >();
-}
-
-#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
-} // namespace detail
-
-
-//
-// shared_ptr
-//
-// An enhanced relative of scoped_ptr with reference counted copy semantics.
-// The object pointed to is deleted when the last shared_ptr pointing to it
-// is destroyed or reset.
-//
-
-template<class T> class shared_ptr
-{
-private:
-
- // Borland 5.5.1 specific workaround
- typedef shared_ptr<T> this_type;
-
-public:
-
- typedef typename boost::detail::sp_element< T >::type element_type;
-
- shared_ptr() BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+
- {
- }
-
-#if !defined( BOOST_NO_CXX11_NULLPTR )
-
- shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws
- {
- }
-
-#endif
-
- template<class Y>
- explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete
- {
- boost::detail::sp_pointer_construct( this, p, pn );
- }
-
- //
- // Requirements: D's copy constructor must not throw
- //
- // shared_ptr will release p by calling d(p)
- //
-
- template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d )
- {
- boost::detail::sp_deleter_construct( this, p );
- }
-
-#if !defined( BOOST_NO_CXX11_NULLPTR )
-
- template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d )
- {
- }
-
-#endif
-
- // As above, but with allocator. A's copy constructor shall not throw.
-
- template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
- {
- boost::detail::sp_deleter_construct( this, p );
- }
-
-#if !defined( BOOST_NO_CXX11_NULLPTR )
-
- template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a )
- {
- }
-
-#endif
-
-// generated copy constructor, destructor are fine...
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
-// ... except in C++0x, move disables the implicit copy
-
- shared_ptr( shared_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
- {
- }
-
-#endif
-
- template<class Y>
- explicit shared_ptr( weak_ptr<Y> const & r ): pn( r.pn ) // may throw
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- // it is now safe to copy r.px, as pn(r.pn) did not throw
- px = r.px;
- }
-
- template<class Y>
- shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag )
- BOOST_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() )
- {
- if( !pn.empty() )
- {
- px = r.px;
- }
- }
-
- template<class Y>
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
-
- shared_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
-
-#else
-
- shared_ptr( shared_ptr<Y> const & r )
-
-#endif
- BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
- {
- boost::detail::sp_assert_convertible< Y, T >();
- }
-
- // aliasing
- template< class Y >
- shared_ptr( shared_ptr<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn )
- {
- }
-
-#ifndef BOOST_NO_AUTO_PTR
-
- template<class Y>
- explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- Y * tmp = r.get();
- pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( this, tmp );
- }
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- template<class Y>
- shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- Y * tmp = r.get();
- pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( this, tmp );
- }
-
-#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
- template<class Ap>
- explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn()
- {
- typedef typename Ap::element_type Y;
-
- boost::detail::sp_assert_convertible< Y, T >();
-
- Y * tmp = r.get();
- pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( this, tmp );
- }
-
-#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-
-#endif // BOOST_NO_AUTO_PTR
-
-#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- template< class Y, class D >
- shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn()
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- typename std::unique_ptr< Y, D >::pointer tmp = r.get();
- pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( this, tmp );
- }
-
-#endif
-
- template< class Y, class D >
- shared_ptr( boost::movelib::unique_ptr< Y, D > r ): px( r.get() ), pn()
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- typename boost::movelib::unique_ptr< Y, D >::pointer tmp = r.get();
- pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( this, tmp );
- }
-
- // assignment
-
- shared_ptr & operator=( shared_ptr const & r ) BOOST_SP_NOEXCEPT
- {
- this_type(r).swap(*this);
- return *this;
- }
-
-#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
-
- template<class Y>
- shared_ptr & operator=(shared_ptr<Y> const & r) BOOST_NOEXCEPT
- {
- this_type(r).swap(*this);
- return *this;
- }
-
-#endif
-
-#ifndef BOOST_NO_AUTO_PTR
-
- template<class Y>
- shared_ptr & operator=( std::auto_ptr<Y> & r )
- {
- this_type( r ).swap( *this );
- return *this;
- }
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- template<class Y>
- shared_ptr & operator=( std::auto_ptr<Y> && r )
- {
- this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
- return *this;
- }
-
-#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
-
- template<class Ap>
- typename boost::detail::sp_enable_if_auto_ptr< Ap, shared_ptr & >::type operator=( Ap r )
- {
- this_type( r ).swap( *this );
- return *this;
- }
-
-#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-
-#endif // BOOST_NO_AUTO_PTR
-
-#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- template<class Y, class D>
- shared_ptr & operator=( std::unique_ptr<Y, D> && r )
- {
- this_type( static_cast< std::unique_ptr<Y, D> && >( r ) ).swap(*this);
- return *this;
- }
-
-#endif
-
- template<class Y, class D>
- shared_ptr & operator=( boost::movelib::unique_ptr<Y, D> r )
- {
- // this_type( static_cast< unique_ptr<Y, D> && >( r ) ).swap( *this );
-
- boost::detail::sp_assert_convertible< Y, T >();
-
- typename boost::movelib::unique_ptr< Y, D >::pointer p = r.get();
-
- shared_ptr tmp;
-
- tmp.px = p;
- tmp.pn = boost::detail::shared_count( r );
-
- boost::detail::sp_deleter_construct( &tmp, p );
-
- tmp.swap( *this );
-
- return *this;
- }
-
-// Move support
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- shared_ptr( shared_ptr && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn()
- {
- pn.swap( r.pn );
- r.px = 0;
- }
-
- template<class Y>
-#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
-
- shared_ptr( shared_ptr<Y> && r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
-
-#else
-
- shared_ptr( shared_ptr<Y> && r )
-
-#endif
- BOOST_NOEXCEPT : px( r.px ), pn()
- {
- boost::detail::sp_assert_convertible< Y, T >();
-
- pn.swap( r.pn );
- r.px = 0;
- }
-
- shared_ptr & operator=( shared_ptr && r ) BOOST_SP_NOEXCEPT
- {
- this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
- return *this;
- }
-
- template<class Y>
- shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_NOEXCEPT
- {
- this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
- return *this;
- }
-
- // aliasing move
- template<class Y>
- shared_ptr( shared_ptr<Y> && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn()
- {
- pn.swap( r.pn );
- r.px = 0;
- }
-
-#endif
-
-#if !defined( BOOST_NO_CXX11_NULLPTR )
-
- shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT // never throws
- {
- this_type().swap(*this);
- return *this;
- }
-
-#endif
-
- void reset() BOOST_NOEXCEPT // never throws in 1.30+
- {
- this_type().swap(*this);
- }
-
- template<class Y> void reset( Y * p ) // Y must be complete
- {
- BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
- this_type( p ).swap( *this );
- }
-
- template<class Y, class D> void reset( Y * p, D d )
- {
- this_type( p, d ).swap( *this );
- }
-
- template<class Y, class D, class A> void reset( Y * p, D d, A a )
- {
- this_type( p, d, a ).swap( *this );
- }
-
- template<class Y> void reset( shared_ptr<Y> const & r, element_type * p )
- {
- this_type( r, p ).swap( *this );
- }
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
- template<class Y> void reset( shared_ptr<Y> && r, element_type * p )
- {
- this_type( static_cast< shared_ptr<Y> && >( r ), p ).swap( *this );
- }
-
-#endif
-
- // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
- typename boost::detail::sp_dereference< T >::type operator* () const
- {
- BOOST_ASSERT( px != 0 );
- return *px;
- }
-
- // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
- typename boost::detail::sp_member_access< T >::type operator-> () const
- {
- BOOST_ASSERT( px != 0 );
- return px;
- }
-
- // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
- typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const
- {
- BOOST_ASSERT( px != 0 );
- BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
-
- return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
- }
-
- element_type * get() const BOOST_NOEXCEPT
- {
- return px;
- }
-
-// implicit conversion to "bool"
-#include <boost/smart_ptr/detail/operator_bool.hpp>
-
- bool unique() const BOOST_NOEXCEPT
- {
- return pn.unique();
- }
-
- long use_count() const BOOST_NOEXCEPT
- {
- return pn.use_count();
- }
-
- void swap( shared_ptr & other ) BOOST_NOEXCEPT
- {
- std::swap(px, other.px);
- pn.swap(other.pn);
- }
-
- template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT
- {
- return pn < rhs.pn;
- }
-
- template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT
- {
- return pn < rhs.pn;
- }
-
- void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT
- {
- return pn.get_deleter( ti );
- }
-
- void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT
- {
- return pn.get_untyped_deleter();
- }
-
- bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT
- {
- return px == r.px && pn == r.pn;
- }
-
-// Tasteless as this may seem, making all members public allows member templates
-// to work in the absence of member template friends. (Matthew Langston)
-
-#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
-
-private:
-
- template<class Y> friend class shared_ptr;
- template<class Y> friend class weak_ptr;
-
-
-#endif
-
- element_type * px; // contained pointer
- boost::detail::shared_count pn; // reference counter
-
-}; // shared_ptr
-
-template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
-{
- return a.get() == b.get();
-}
-
-template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
-{
- return a.get() != b.get();
-}
-
-#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
-
-// Resolve the ambiguity between our op!= and the one in rel_ops
-
-template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) BOOST_NOEXCEPT
-{
- return a.get() != b.get();
-}
-
-#endif
-
-#if !defined( BOOST_NO_CXX11_NULLPTR )
-
-template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
-{
- return p.get() == 0;
-}
-
-template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT
-{
- return p.get() == 0;
-}
-
-template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
-{
- return p.get() != 0;
-}
-
-template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT
-{
- return p.get() != 0;
-}
-
-#endif
-
-template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
-{
- return a.owner_before( b );
-}
-
-template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) BOOST_NOEXCEPT
-{
- a.swap(b);
-}
-
-template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT
-{
- (void) static_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = static_cast< E* >( r.get() );
- return shared_ptr<T>( r, p );
-}
-
-template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT
-{
- (void) const_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = const_cast< E* >( r.get() );
- return shared_ptr<T>( r, p );
-}
-
-template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT
-{
- (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = dynamic_cast< E* >( r.get() );
- return p? shared_ptr<T>( r, p ): shared_ptr<T>();
-}
-
-template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT
-{
- (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = reinterpret_cast< E* >( r.get() );
- return shared_ptr<T>( r, p );
-}
-
-#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
-template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
-{
- (void) static_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = static_cast< E* >( r.get() );
- return shared_ptr<T>( std::move(r), p );
-}
-
-template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
-{
- (void) const_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = const_cast< E* >( r.get() );
- return shared_ptr<T>( std::move(r), p );
-}
-
-template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
-{
- (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = dynamic_cast< E* >( r.get() );
- return p? shared_ptr<T>( std::move(r), p ): shared_ptr<T>();
-}
-
-template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
-{
- (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
-
- typedef typename shared_ptr<T>::element_type E;
-
- E * p = reinterpret_cast< E* >( r.get() );
- return shared_ptr<T>( std::move(r), p );
-}
-
-#endif // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
-
-// get_pointer() enables boost::mem_fn to recognize shared_ptr
-
-template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT
-{
- return p.get();
-}
-
-// operator<<
-
-#if !defined(BOOST_NO_IOSTREAM)
-
-#if defined(BOOST_NO_TEMPLATED_IOSTREAMS) || ( defined(__GNUC__) && (__GNUC__ < 3) )
-
-template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p)
-{
- os << p.get();
- return os;
-}
-
-#else
-
-// in STLport's no-iostreams mode no iostream symbols can be used
-#ifndef _STLP_NO_IOSTREAMS
-
-# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT)
-// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL
-using std::basic_ostream;
-template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p)
-# else
-template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
-# endif
-{
- os << p.get();
- return os;
-}
-
-#endif // _STLP_NO_IOSTREAMS
-
-#endif // __GNUC__ < 3
-
-#endif // !defined(BOOST_NO_IOSTREAM)
-
-// get_deleter
-
-namespace detail
-{
-
-#if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \
- ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \
- ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) )
-
-// g++ 2.9x doesn't allow static_cast<X const *>(void *)
-// apparently EDG 2.38 and HP aCC A.03.35 also don't accept it
-
-template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p)
-{
- void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D));
- return const_cast<D *>(static_cast<D const *>(q));
-}
-
-#else
-
-template<class D, class T> D * basic_get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT
-{
- return static_cast<D *>( p._internal_get_deleter(BOOST_SP_TYPEID(D)) );
-}
-
-#endif
-
-class esft2_deleter_wrapper
-{
-private:
-
- shared_ptr<void const volatile> deleter_;
-
-public:
-
- esft2_deleter_wrapper()
- {
- }
-
- template< class T > void set_deleter( shared_ptr<T> const & deleter )
- {
- deleter_ = deleter;
- }
-
- template<typename D> D* get_deleter() const BOOST_NOEXCEPT
- {
- return boost::detail::basic_get_deleter<D>( deleter_ );
- }
-
- template< class T> void operator()( T* )
- {
- BOOST_ASSERT( deleter_.use_count() <= 1 );
- deleter_.reset();
- }
-};
-
-} // namespace detail
-
-template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT
-{
- D *del = boost::detail::basic_get_deleter<D>(p);
-
- if(del == 0)
- {
- boost::detail::esft2_deleter_wrapper *del_wrapper = boost::detail::basic_get_deleter<boost::detail::esft2_deleter_wrapper>(p);
-// The following get_deleter method call is fully qualified because
-// older versions of gcc (2.95, 3.2.3) fail to compile it when written del_wrapper->get_deleter<D>()
- if(del_wrapper) del = del_wrapper->::boost::detail::esft2_deleter_wrapper::get_deleter<D>();
- }
-
- return del;
-}
-
-// atomic access
-
-#if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
-
-template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_NOEXCEPT
-{
- return false;
-}
-
-template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p )
-{
- boost::detail::spinlock_pool<2>::scoped_lock lock( p );
- return *p;
-}
-
-template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int )
-{
- return atomic_load( p );
-}
-
-template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r )
-{
- boost::detail::spinlock_pool<2>::scoped_lock lock( p );
- p->swap( r );
-}
-
-template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int )
-{
- atomic_store( p, r ); // std::move( r )
-}
-
-template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r )
-{
- boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p );
-
- sp.lock();
- p->swap( r );
- sp.unlock();
-
- return r; // return std::move( r )
-}
-
-template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int )
-{
- return atomic_exchange( p, r ); // std::move( r )
-}
-
-template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w )
-{
- boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p );
-
- sp.lock();
-
- if( p->_internal_equiv( *v ) )
- {
- p->swap( w );
-
- sp.unlock();
-
- return true;
- }
- else
- {
- shared_ptr<T> tmp( *p );
-
- sp.unlock();
-
- tmp.swap( *v );
- return false;
- }
-}
-
-template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int )
-{
- return atomic_compare_exchange( p, v, w ); // std::move( w )
-}
-
-#endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS)
-
-// hash_value
-
-template< class T > struct hash;
-
-template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT
-{
- return boost::hash< typename boost::shared_ptr<T>::element_type* >()( p.get() );
-}
-
-} // namespace boost
-
-#if defined( BOOST_SP_DISABLE_DEPRECATED )
-#pragma GCC diagnostic pop
-#endif
-
-#endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED
+#ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED +#define BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED + +// +// shared_ptr.hpp +// +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001-2008 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/config.hpp> // for broken compiler workarounds + +// In order to avoid circular dependencies with Boost.TR1 +// we make sure that our include of <memory> doesn't try to +// pull in the TR1 headers: that's why we use this header +// rather than including <memory> directly: +#include <boost/config/no_tr1/memory.hpp> // std::auto_ptr + +#include <boost/assert.hpp> +#include <boost/checked_delete.hpp> +#include <boost/throw_exception.hpp> +#include <boost/smart_ptr/detail/shared_count.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/smart_ptr/detail/sp_convertible.hpp> +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> +#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp> + +#if !defined(BOOST_SP_NO_ATOMIC_ACCESS) +#include <boost/smart_ptr/detail/spinlock_pool.hpp> +#endif + +#include <algorithm> // for std::swap +#include <functional> // for std::less +#include <typeinfo> // for std::bad_cast +#include <cstddef> // for std::size_t + +#if !defined(BOOST_NO_IOSTREAM) +#if !defined(BOOST_NO_IOSFWD) +#include <iosfwd> // for std::basic_ostream +#else +#include <ostream> +#endif +#endif + +#if defined( BOOST_SP_DISABLE_DEPRECATED ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +namespace boost +{ + +template<class T> class shared_ptr; +template<class T> class weak_ptr; +template<class T> class enable_shared_from_this; +class enable_shared_from_raw; + +namespace movelib +{ + + template< class T, class D > class unique_ptr; + +} // namespace movelib + +namespace detail +{ + +// sp_element, element_type + +template< class T > struct sp_element +{ + typedef T type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_element< T[] > +{ + typedef T type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_element< T[N] > +{ + typedef T type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_dereference, return type of operator* + +template< class T > struct sp_dereference +{ + typedef T & type; +}; + +template<> struct sp_dereference< void > +{ + typedef void type; +}; + +#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) + +template<> struct sp_dereference< void const > +{ + typedef void type; +}; + +template<> struct sp_dereference< void volatile > +{ + typedef void type; +}; + +template<> struct sp_dereference< void const volatile > +{ + typedef void type; +}; + +#endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_dereference< T[] > +{ + typedef void type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_dereference< T[N] > +{ + typedef void type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_member_access, return type of operator-> + +template< class T > struct sp_member_access +{ + typedef T * type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_member_access< T[] > +{ + typedef void type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_member_access< T[N] > +{ + typedef void type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_array_access, return type of operator[] + +template< class T > struct sp_array_access +{ + typedef void type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_array_access< T[] > +{ + typedef T & type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_array_access< T[N] > +{ + typedef T & type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_extent, for operator[] index check + +template< class T > struct sp_extent +{ + enum _vt { value = 0 }; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, std::size_t N > struct sp_extent< T[N] > +{ + enum _vt { value = N }; +}; + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// enable_shared_from_this support + +template< class X, class Y, class T > inline void sp_enable_shared_from_this( boost::shared_ptr<X> const * ppx, Y const * py, boost::enable_shared_from_this< T > const * pe ) +{ + if( pe != 0 ) + { + pe->_internal_accept_owner( ppx, const_cast< Y* >( py ) ); + } +} + +template< class X, class Y > inline void sp_enable_shared_from_this( boost::shared_ptr<X> * ppx, Y const * py, boost::enable_shared_from_raw const * pe ); + +#ifdef _MANAGED + +// Avoid C4793, ... causes native code generation + +struct sp_any_pointer +{ + template<class T> sp_any_pointer( T* ) {} +}; + +inline void sp_enable_shared_from_this( sp_any_pointer, sp_any_pointer, sp_any_pointer ) +{ +} + +#else // _MANAGED + +inline void sp_enable_shared_from_this( ... ) +{ +} + +#endif // _MANAGED + +#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR ) + +// rvalue auto_ptr support based on a technique by Dave Abrahams + +template< class T, class R > struct sp_enable_if_auto_ptr +{ +}; + +template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R > +{ + typedef R type; +}; + +#endif + +// sp_assert_convertible + +template< class Y, class T > inline void sp_assert_convertible() +{ +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + + // static_assert( sp_convertible< Y, T >::value ); + typedef char tmp[ sp_convertible< Y, T >::value? 1: -1 ]; + (void)sizeof( tmp ); + +#else + + T* p = static_cast< Y* >( 0 ); + (void)p; + +#endif +} + +// pointer constructor helper + +template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T > * ppx, Y * p, boost::detail::shared_count & pn ) +{ + boost::detail::shared_count( p ).swap( pn ); + boost::detail::sp_enable_shared_from_this( ppx, p, p ); +} + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * p, boost::detail::shared_count & pn ) +{ + sp_assert_convertible< Y[], T[] >(); + boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn ); +} + +template< class T, std::size_t N, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * p, boost::detail::shared_count & pn ) +{ + sp_assert_convertible< Y[N], T[N] >(); + boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn ); +} + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// deleter constructor helper + +template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T > * ppx, Y * p ) +{ + boost::detail::sp_enable_shared_from_this( ppx, p, p ); +} + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ ) +{ + sp_assert_convertible< Y[], T[] >(); +} + +template< class T, std::size_t N, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * /*p*/ ) +{ + sp_assert_convertible< Y[N], T[N] >(); +} + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +} // namespace detail + + +// +// shared_ptr +// +// An enhanced relative of scoped_ptr with reference counted copy semantics. +// The object pointed to is deleted when the last shared_ptr pointing to it +// is destroyed or reset. +// + +template<class T> class shared_ptr +{ +private: + + // Borland 5.5.1 specific workaround + typedef shared_ptr<T> this_type; + +public: + + typedef typename boost::detail::sp_element< T >::type element_type; + + shared_ptr() BOOST_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+ + { + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + shared_ptr( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn() // never throws + { + } + +#endif + + template<class Y> + explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete + { + boost::detail::sp_pointer_construct( this, p, pn ); + } + + // + // Requirements: D's copy constructor must not throw + // + // shared_ptr will release p by calling d(p) + // + + template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d ) + { + boost::detail::sp_deleter_construct( this, p ); + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d ) + { + } + +#endif + + // As above, but with allocator. A's copy constructor shall not throw. + + template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a ) + { + boost::detail::sp_deleter_construct( this, p ); + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a ) + { + } + +#endif + +// generated copy constructor, destructor are fine... + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +// ... except in C++0x, move disables the implicit copy + + shared_ptr( shared_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) + { + } + +#endif + + template<class Y> + explicit shared_ptr( weak_ptr<Y> const & r ): pn( r.pn ) // may throw + { + boost::detail::sp_assert_convertible< Y, T >(); + + // it is now safe to copy r.px, as pn(r.pn) did not throw + px = r.px; + } + + template<class Y> + shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag ) + BOOST_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() ) + { + if( !pn.empty() ) + { + px = r.px; + } + } + + template<class Y> +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + + shared_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() ) + +#else + + shared_ptr( shared_ptr<Y> const & r ) + +#endif + BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) + { + boost::detail::sp_assert_convertible< Y, T >(); + } + + // aliasing + template< class Y > + shared_ptr( shared_ptr<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + { + } + +#ifndef BOOST_NO_AUTO_PTR + + template<class Y> + explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + Y * tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template<class Y> + shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + Y * tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + +#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + + template<class Ap> + explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn() + { + typedef typename Ap::element_type Y; + + boost::detail::sp_assert_convertible< Y, T >(); + + Y * tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + +#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +#endif // BOOST_NO_AUTO_PTR + +#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template< class Y, class D > + shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + typename std::unique_ptr< Y, D >::pointer tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + +#endif + + template< class Y, class D > + shared_ptr( boost::movelib::unique_ptr< Y, D > r ): px( r.get() ), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + typename boost::movelib::unique_ptr< Y, D >::pointer tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + + // assignment + + shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT + { + this_type(r).swap(*this); + return *this; + } + +#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) + + template<class Y> + shared_ptr & operator=(shared_ptr<Y> const & r) BOOST_NOEXCEPT + { + this_type(r).swap(*this); + return *this; + } + +#endif + +#ifndef BOOST_NO_AUTO_PTR + + template<class Y> + shared_ptr & operator=( std::auto_ptr<Y> & r ) + { + this_type( r ).swap( *this ); + return *this; + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template<class Y> + shared_ptr & operator=( std::auto_ptr<Y> && r ) + { + this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this ); + return *this; + } + +#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + + template<class Ap> + typename boost::detail::sp_enable_if_auto_ptr< Ap, shared_ptr & >::type operator=( Ap r ) + { + this_type( r ).swap( *this ); + return *this; + } + +#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +#endif // BOOST_NO_AUTO_PTR + +#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template<class Y, class D> + shared_ptr & operator=( std::unique_ptr<Y, D> && r ) + { + this_type( static_cast< std::unique_ptr<Y, D> && >( r ) ).swap(*this); + return *this; + } + +#endif + + template<class Y, class D> + shared_ptr & operator=( boost::movelib::unique_ptr<Y, D> r ) + { + // this_type( static_cast< unique_ptr<Y, D> && >( r ) ).swap( *this ); + + boost::detail::sp_assert_convertible< Y, T >(); + + typename boost::movelib::unique_ptr< Y, D >::pointer p = r.get(); + + shared_ptr tmp; + + tmp.px = p; + tmp.pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( &tmp, p ); + + tmp.swap( *this ); + + return *this; + } + +// Move support + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + shared_ptr( shared_ptr && r ) BOOST_NOEXCEPT : px( r.px ), pn() + { + pn.swap( r.pn ); + r.px = 0; + } + + template<class Y> +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + + shared_ptr( shared_ptr<Y> && r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() ) + +#else + + shared_ptr( shared_ptr<Y> && r ) + +#endif + BOOST_NOEXCEPT : px( r.px ), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + pn.swap( r.pn ); + r.px = 0; + } + + shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT + { + this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); + return *this; + } + + template<class Y> + shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_NOEXCEPT + { + this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this ); + return *this; + } + +#endif + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT // never throws + { + this_type().swap(*this); + return *this; + } + +#endif + + void reset() BOOST_NOEXCEPT // never throws in 1.30+ + { + this_type().swap(*this); + } + + template<class Y> void reset( Y * p ) // Y must be complete + { + BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors + this_type( p ).swap( *this ); + } + + template<class Y, class D> void reset( Y * p, D d ) + { + this_type( p, d ).swap( *this ); + } + + template<class Y, class D, class A> void reset( Y * p, D d, A a ) + { + this_type( p, d, a ).swap( *this ); + } + + template<class Y> void reset( shared_ptr<Y> const & r, element_type * p ) + { + this_type( r, p ).swap( *this ); + } + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_dereference< T >::type operator* () const + { + BOOST_ASSERT( px != 0 ); + return *px; + } + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_member_access< T >::type operator-> () const + { + BOOST_ASSERT( px != 0 ); + return px; + } + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const + { + BOOST_ASSERT( px != 0 ); + BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) ); + + return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] ); + } + + element_type * get() const BOOST_NOEXCEPT + { + return px; + } + +// implicit conversion to "bool" +#include <boost/smart_ptr/detail/operator_bool.hpp> + + bool unique() const BOOST_NOEXCEPT + { + return pn.unique(); + } + + long use_count() const BOOST_NOEXCEPT + { + return pn.use_count(); + } + + void swap( shared_ptr & other ) BOOST_NOEXCEPT + { + std::swap(px, other.px); + pn.swap(other.pn); + } + + template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT + { + return pn < rhs.pn; + } + + template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT + { + return pn < rhs.pn; + } + + void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT + { + return pn.get_deleter( ti ); + } + + void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT + { + return pn.get_untyped_deleter(); + } + + bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT + { + return px == r.px && pn == r.pn; + } + +// Tasteless as this may seem, making all members public allows member templates +// to work in the absence of member template friends. (Matthew Langston) + +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + +private: + + template<class Y> friend class shared_ptr; + template<class Y> friend class weak_ptr; + + +#endif + + element_type * px; // contained pointer + boost::detail::shared_count pn; // reference counter + +}; // shared_ptr + +template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT +{ + return a.get() == b.get(); +} + +template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT +{ + return a.get() != b.get(); +} + +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) BOOST_NOEXCEPT +{ + return a.get() != b.get(); +} + +#endif + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +#endif + +template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT +{ + return a.owner_before( b ); +} + +template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) BOOST_NOEXCEPT +{ + a.swap(b); +} + +template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT +{ + (void) static_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = static_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); +} + +template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT +{ + (void) const_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = const_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); +} + +template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT +{ + (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = dynamic_cast< E* >( r.get() ); + return p? shared_ptr<T>( r, p ): shared_ptr<T>(); +} + +template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT +{ + (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = reinterpret_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); +} + +// get_pointer() enables boost::mem_fn to recognize shared_ptr + +template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT +{ + return p.get(); +} + +// operator<< + +#if !defined(BOOST_NO_IOSTREAM) + +#if defined(BOOST_NO_TEMPLATED_IOSTREAMS) || ( defined(__GNUC__) && (__GNUC__ < 3) ) + +template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p) +{ + os << p.get(); + return os; +} + +#else + +// in STLport's no-iostreams mode no iostream symbols can be used +#ifndef _STLP_NO_IOSTREAMS + +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT) +// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL +using std::basic_ostream; +template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p) +# else +template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p) +# endif +{ + os << p.get(); + return os; +} + +#endif // _STLP_NO_IOSTREAMS + +#endif // __GNUC__ < 3 + +#endif // !defined(BOOST_NO_IOSTREAM) + +// get_deleter + +namespace detail +{ + +#if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ + ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ + ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) + +// g++ 2.9x doesn't allow static_cast<X const *>(void *) +// apparently EDG 2.38 and HP aCC A.03.35 also don't accept it + +template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p) +{ + void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D)); + return const_cast<D *>(static_cast<D const *>(q)); +} + +#else + +template<class D, class T> D * basic_get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return static_cast<D *>( p._internal_get_deleter(BOOST_SP_TYPEID(D)) ); +} + +#endif + +class esft2_deleter_wrapper +{ +private: + + shared_ptr<void const volatile> deleter_; + +public: + + esft2_deleter_wrapper() + { + } + + template< class T > void set_deleter( shared_ptr<T> const & deleter ) + { + deleter_ = deleter; + } + + template<typename D> D* get_deleter() const BOOST_NOEXCEPT + { + return boost::detail::basic_get_deleter<D>( deleter_ ); + } + + template< class T> void operator()( T* ) + { + BOOST_ASSERT( deleter_.use_count() <= 1 ); + deleter_.reset(); + } +}; + +} // namespace detail + +template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + D *del = boost::detail::basic_get_deleter<D>(p); + + if(del == 0) + { + boost::detail::esft2_deleter_wrapper *del_wrapper = boost::detail::basic_get_deleter<boost::detail::esft2_deleter_wrapper>(p); +// The following get_deleter method call is fully qualified because +// older versions of gcc (2.95, 3.2.3) fail to compile it when written del_wrapper->get_deleter<D>() + if(del_wrapper) del = del_wrapper->::boost::detail::esft2_deleter_wrapper::get_deleter<D>(); + } + + return del; +} + +// atomic access + +#if !defined(BOOST_SP_NO_ATOMIC_ACCESS) + +template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_NOEXCEPT +{ + return false; +} + +template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) +{ + boost::detail::spinlock_pool<2>::scoped_lock lock( p ); + return *p; +} + +template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) +{ + return atomic_load( p ); +} + +template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) +{ + boost::detail::spinlock_pool<2>::scoped_lock lock( p ); + p->swap( r ); +} + +template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) +{ + atomic_store( p, r ); // std::move( r ) +} + +template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T> r ) +{ + boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); + + sp.lock(); + p->swap( r ); + sp.unlock(); + + return r; // return std::move( r ) +} + +template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) +{ + return atomic_exchange( p, r ); // std::move( r ) +} + +template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w ) +{ + boost::detail::spinlock & sp = boost::detail::spinlock_pool<2>::spinlock_for( p ); + + sp.lock(); + + if( p->_internal_equiv( *v ) ) + { + p->swap( w ); + + sp.unlock(); + + return true; + } + else + { + shared_ptr<T> tmp( *p ); + + sp.unlock(); + + tmp.swap( *v ); + return false; + } +} + +template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) +{ + return atomic_compare_exchange( p, v, w ); // std::move( w ) +} + +#endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS) + +// hash_value + +template< class T > struct hash; + +template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return boost::hash< typename boost::shared_ptr<T>::element_type* >()( p.get() ); +} + +} // namespace boost + +#if defined( BOOST_SP_DISABLE_DEPRECATED ) +#pragma GCC diagnostic pop +#endif + +#endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED |