1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED
2 #define BOOST_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 ) ) {}
34 "+m"( value_ ): // output (%0)
42 return atomic_exchange_and_add( &value_, -1 ) - 1;
47 return atomic_exchange_and_add( &value_, 0 );
52 atomic_count(atomic_count const &);
53 atomic_count & operator=(atomic_count const &);
59 static int atomic_exchange_and_add( int * pw, int dv )
71 "+m"( *pw ), "=r"( r ): // outputs (%0, %1)
72 "1"( dv ): // inputs (%2 == %1)
73 "memory", "cc" // clobbers
84 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED