1 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED
5 // boost/detail/atomic_count_gcc_x86.hpp
7 // atomic_count for g++ on 486+/AMD64
9 // Copyright 2007 Peter Dimov
11 // Distributed under the Boost Software License, Version 1.0. (See
12 // accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
26 explicit atomic_count( long v ) : value_( static_cast< int >( v ) ) {}
30 return atomic_exchange_and_add( &value_, +1 ) + 1;
35 return atomic_exchange_and_add( &value_, -1 ) - 1;
40 return atomic_exchange_and_add( &value_, 0 );
45 atomic_count(atomic_count const &);
46 atomic_count & operator=(atomic_count const &);
52 static int atomic_exchange_and_add( int * pw, int dv )
64 "+m"( *pw ), "=r"( r ): // outputs (%0, %1)
65 "1"( dv ): // inputs (%2 == %1)
66 "memory", "cc" // clobbers
77 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED