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/config.hpp> 47 #include <boost/smart_ptr/detail/sp_has_sync.hpp> 48 49 #if defined( BOOST_AC_DISABLE_THREADS ) 50 # include <boost/smart_ptr/detail/atomic_count_nt.hpp> 51 52 #elif defined( BOOST_AC_USE_STD_ATOMIC ) 53 # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> 54 55 #elif defined( BOOST_AC_USE_SPINLOCK ) 56 # include <boost/smart_ptr/detail/atomic_count_spin.hpp> 57 58 #elif defined( BOOST_AC_USE_PTHREADS ) 59 # include <boost/smart_ptr/detail/atomic_count_pt.hpp> 60 61 #elif defined( BOOST_SP_DISABLE_THREADS ) 62 # include <boost/smart_ptr/detail/atomic_count_nt.hpp> 63 64 #elif defined( BOOST_SP_USE_STD_ATOMIC ) 65 # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> 66 67 #elif defined( BOOST_SP_USE_SPINLOCK ) 68 # include <boost/smart_ptr/detail/atomic_count_spin.hpp> 69 70 #elif defined( BOOST_SP_USE_PTHREADS ) 71 # include <boost/smart_ptr/detail/atomic_count_pt.hpp> 72 73 #elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) 74 # include <boost/smart_ptr/detail/atomic_count_nt.hpp> 75 76 #elif !defined( BOOST_NO_CXX11_HDR_ATOMIC ) 77 # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> 78 79 #elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ ) 80 # include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> 81 82 #elif defined( BOOST_SP_HAS_SYNC ) 83 # include <boost/smart_ptr/detail/atomic_count_sync.hpp> 84 85 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 86 # include <boost/smart_ptr/detail/atomic_count_win32.hpp> 87 88 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) 89 # include <boost/smart_ptr/detail/atomic_count_gcc.hpp> 90 91 #elif !defined( BOOST_HAS_THREADS ) 92 # include <boost/smart_ptr/detail/atomic_count_nt.hpp> 93 94 #else 95 # include <boost/smart_ptr/detail/atomic_count_spin.hpp> 96 97 #endif 98 99 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED 100