1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
2 #define BOOST_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>
14 // Distributed under the Boost Software License, Version 1.0. (See
15 // accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
19 #include <bits/atomicity.h>
31 explicit atomic_count(long v) : value_(v) {}
35 __atomic_add(&value_, 1);
40 return __exchange_and_add(&value_, -1) - 1;
45 return __exchange_and_add(&value_, 0);
50 atomic_count(atomic_count const &);
51 atomic_count & operator=(atomic_count const &);
53 mutable _Atomic_word value_;
60 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED