| 1 | #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED |
| 2 | #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED |
| 3 | |
| 4 | // MS compatible compilers support #pragma once |
| 5 | |
| 6 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
| 7 | # pragma once |
| 8 | #endif |
| 9 | |
| 10 | // |
| 11 | // boost/detail/atomic_count.hpp - thread/SMP safe reference counter |
| 12 | // |
| 13 | // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. |
| 14 | // Copyright (c) 2013 Peter Dimov |
| 15 | // |
| 16 | // Distributed under the Boost Software License, Version 1.0. |
| 17 | // See accompanying file LICENSE_1_0.txt or copy at |
| 18 | // http://www.boost.org/LICENSE_1_0.txt |
| 19 | // |
| 20 | // typedef <implementation-defined> boost::detail::atomic_count; |
| 21 | // |
| 22 | // atomic_count a(n); |
| 23 | // |
| 24 | // (n is convertible to long) |
| 25 | // |
| 26 | // Effects: Constructs an atomic_count with an initial value of n |
| 27 | // |
| 28 | // a; |
| 29 | // |
| 30 | // Returns: (long) the current value of a |
| 31 | // Memory Ordering: acquire |
| 32 | // |
| 33 | // ++a; |
| 34 | // |
| 35 | // Effects: Atomically increments the value of a |
| 36 | // Returns: (long) the new value of a |
| 37 | // Memory Ordering: acquire/release |
| 38 | // |
| 39 | // --a; |
| 40 | // |
| 41 | // Effects: Atomically decrements the value of a |
| 42 | // Returns: (long) the new value of a |
| 43 | // Memory Ordering: acquire/release |
| 44 | // |
| 45 | |
| 46 | #include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp> |
| 47 | #include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp> |
| 48 | #include <boost/config.hpp> |
| 49 | |
| 50 | #if defined( BOOST_AC_DISABLE_THREADS ) |
| 51 | # include <boost/smart_ptr/detail/atomic_count_nt.hpp> |
| 52 | |
| 53 | #elif defined( BOOST_AC_USE_STD_ATOMIC ) |
| 54 | # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> |
| 55 | |
| 56 | #elif defined( BOOST_AC_USE_SPINLOCK ) |
| 57 | # include <boost/smart_ptr/detail/atomic_count_spin.hpp> |
| 58 | |
| 59 | #elif defined( BOOST_AC_USE_PTHREADS ) |
| 60 | # include <boost/smart_ptr/detail/atomic_count_pt.hpp> |
| 61 | |
| 62 | #elif defined( BOOST_SP_DISABLE_THREADS ) |
| 63 | # include <boost/smart_ptr/detail/atomic_count_nt.hpp> |
| 64 | |
| 65 | #elif defined( BOOST_SP_USE_STD_ATOMIC ) |
| 66 | # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> |
| 67 | |
| 68 | #elif defined( BOOST_SP_USE_SPINLOCK ) |
| 69 | # include <boost/smart_ptr/detail/atomic_count_spin.hpp> |
| 70 | |
| 71 | #elif defined( BOOST_SP_USE_PTHREADS ) |
| 72 | # include <boost/smart_ptr/detail/atomic_count_pt.hpp> |
| 73 | |
| 74 | #elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) |
| 75 | # include <boost/smart_ptr/detail/atomic_count_nt.hpp> |
| 76 | |
| 77 | #elif defined( BOOST_SP_HAS_GCC_INTRINSICS ) |
| 78 | # include <boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp> |
| 79 | |
| 80 | #elif !defined( BOOST_NO_CXX11_HDR_ATOMIC ) |
| 81 | # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> |
| 82 | |
| 83 | #elif defined( BOOST_SP_HAS_SYNC_INTRINSICS ) |
| 84 | # include <boost/smart_ptr/detail/atomic_count_sync.hpp> |
| 85 | |
| 86 | #elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ ) |
| 87 | # include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> |
| 88 | |
| 89 | #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) |
| 90 | # include <boost/smart_ptr/detail/atomic_count_win32.hpp> |
| 91 | |
| 92 | #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) |
| 93 | # include <boost/smart_ptr/detail/atomic_count_gcc.hpp> |
| 94 | |
| 95 | #elif !defined( BOOST_HAS_THREADS ) |
| 96 | # include <boost/smart_ptr/detail/atomic_count_nt.hpp> |
| 97 | |
| 98 | #else |
| 99 | # include <boost/smart_ptr/detail/atomic_count_spin.hpp> |
| 100 | |
| 101 | #endif |
| 102 | |
| 103 | #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED |
| 104 | |