1 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
\r
2 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
\r
5 // boost/detail/atomic_count_gcc.hpp
\r
7 // atomic_count for GNU libstdc++ v3
\r
9 // http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
\r
11 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
\r
12 // Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org>
\r
13 // Copyright 2003-2005 Peter Dimov
\r
15 // Distributed under the Boost Software License, Version 1.0. (See
\r
16 // accompanying file LICENSE_1_0.txt or copy at
\r
17 // http://www.boost.org/LICENSE_1_0.txt)
\r
20 #if __GNUC__ * 100 + __GNUC_MINOR__ >= 402
\r
21 # include <ext/atomicity.h>
\r
23 # include <bits/atomicity.h>
\r
32 #if defined(__GLIBCXX__) // g++ 3.4+
\r
34 using __gnu_cxx::__atomic_add;
\r
35 using __gnu_cxx::__exchange_and_add;
\r
43 explicit atomic_count( long v ) : value_( v ) {}
\r
47 return __exchange_and_add( &value_, +1 ) + 1;
\r
52 return __exchange_and_add( &value_, -1 ) - 1;
\r
55 operator long() const
\r
57 return __exchange_and_add( &value_, 0 );
\r
62 atomic_count(atomic_count const &);
\r
63 atomic_count & operator=(atomic_count const &);
\r
65 mutable _Atomic_word value_;
\r
68 } // namespace detail
\r
70 } // namespace boost
\r
72 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
\r