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 // Permission to copy, use, modify, sell and distribute this software
15 // is granted provided this copyright notice appears in all copies.
16 // This software is provided "as is" without express or implied
17 // warranty, and with no claim as to its suitability for any purpose.
20 #include <bits/atomicity.h>
32 explicit atomic_count(long v) : value_(v) {}
36 __atomic_add(&value_, 1);
41 return !__exchange_and_add(&value_, -1);
46 return __exchange_and_add(&value_, 0);
51 atomic_count(atomic_count const &);
52 atomic_count & operator=(atomic_count const &);
61 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED