1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
2 #define BOOST_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
5 // boost/detail/atomic_count_sync.hpp
7 // atomic_count for g++ 4.1+
9 // http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
11 // Copyright 2007 Peter Dimov
13 // Distributed under the Boost Software License, Version 1.0. (See
14 // accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
28 explicit atomic_count( long v ) : value_( v ) {}
32 __sync_add_and_fetch( &value_, 1 );
37 return __sync_add_and_fetch( &value_, -1 );
42 return __sync_fetch_and_add( &value_, 0 );
47 atomic_count(atomic_count const &);
48 atomic_count & operator=(atomic_count const &);
57 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED