Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:42

0001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED
0003 
0004 // boost/detail/atomic_count_gcc_atomic.hpp
0005 //
0006 // atomic_count for g++ 4.7+
0007 //
0008 // Copyright 2007, 2020 Peter Dimov
0009 //
0010 // Distributed under the Boost Software License, Version 1.0.
0011 // https://www.boost.org/LICENSE_1_0.txt
0012 
0013 #include <boost/cstdint.hpp>
0014 
0015 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0016 
0017 #include <boost/config/pragma_message.hpp>
0018 BOOST_PRAGMA_MESSAGE("Using __atomic atomic_count")
0019 
0020 #endif
0021 
0022 namespace boost
0023 {
0024 
0025 namespace detail
0026 {
0027 
0028 class atomic_count
0029 {
0030 public:
0031 
0032     explicit atomic_count( long v ): value_( static_cast< boost::int_least32_t >( v ) )
0033     {
0034     }
0035 
0036     long operator++()
0037     {
0038         return __atomic_add_fetch( &value_, +1, __ATOMIC_ACQ_REL );
0039     }
0040 
0041     long operator--()
0042     {
0043         return __atomic_add_fetch( &value_, -1, __ATOMIC_ACQ_REL );
0044     }
0045 
0046     operator long() const
0047     {
0048         return __atomic_load_n( &value_, __ATOMIC_ACQUIRE );
0049     }
0050 
0051 private:
0052 
0053     atomic_count(atomic_count const &);
0054     atomic_count & operator=(atomic_count const &);
0055 
0056     boost::int_least32_t value_;
0057 };
0058 
0059 } // namespace detail
0060 
0061 } // namespace boost
0062 
0063 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED