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