src/sysc/packages/boost/detail/atomic_count_gcc.hpp

Go to the documentation of this file.
00001 #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
00002 #define BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
00003 
00004 //
00005 //  boost/detail/atomic_count_gcc.hpp
00006 //
00007 //  atomic_count for GNU libstdc++ v3
00008 //
00009 //  http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
00010 //
00011 //  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
00012 //  Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org>
00013 //
00014 //  Permission to copy, use, modify, sell and distribute this software
00015 //  is granted provided this copyright notice appears in all copies.
00016 //  This software is provided "as is" without express or implied
00017 //  warranty, and with no claim as to its suitability for any purpose.
00018 //
00019 
00020 #include <bits/atomicity.h>
00021 
00022 namespace boost
00023 {
00024 
00025 namespace detail
00026 {
00027 
00028 class atomic_count
00029 {
00030 public:
00031 
00032     explicit atomic_count(long v) : value_(v) {}
00033 
00034     void operator++()
00035     {
00036         __atomic_add(&value_, 1);
00037     }
00038 
00039     long operator--()
00040     {
00041         return !__exchange_and_add(&value_, -1);
00042     }
00043 
00044     operator long() const
00045     {
00046         return __exchange_and_add(&value_, 0);
00047     }
00048 
00049 private:
00050 
00051     atomic_count(atomic_count const &);
00052     atomic_count & operator=(atomic_count const &);
00053 
00054     _Atomic_word value_;
00055 };
00056 
00057 } // namespace detail
00058 
00059 } // namespace boost
00060 
00061 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED

Generated on Wed Apr 25 13:53:28 2007 for SystemC by  doxygen 1.5.1