| 
									
										
										
										
											2002-05-21 16:48:20 +00:00
										 |  |  |  | #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
 | 
					
						
							|  |  |  |  | #define BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | //  boost/detail/atomic_count_gcc.hpp
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | //  atomic_count for GNU libstdc++ v3
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | //  http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | //  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
 | 
					
						
							|  |  |  |  | //  Copyright (c) 2002 Lars Gullik Bj<42>nnes <larsbj@lyx.org>
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | //  Permission to copy, use, modify, sell and distribute this software
 | 
					
						
							|  |  |  |  | //  is granted provided this copyright notice appears in all copies.
 | 
					
						
							|  |  |  |  | //  This software is provided "as is" without express or implied
 | 
					
						
							|  |  |  |  | //  warranty, and with no claim as to its suitability for any purpose.
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #include <bits/atomicity.h>
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace boost | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace detail | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class atomic_count | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | public: | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     explicit atomic_count(long v) : value_(v) {} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     void operator++() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         __atomic_add(&value_, 1); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     long operator--() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2004-06-27 15:40:29 +00:00
										 |  |  |  |         return __exchange_and_add(&value_, -1) - 1; | 
					
						
							| 
									
										
										
										
											2002-05-21 16:48:20 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     operator long() const | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return __exchange_and_add(&value_, 0); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     atomic_count(atomic_count const &); | 
					
						
							|  |  |  |  |     atomic_count & operator=(atomic_count const &); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-27 15:09:46 +00:00
										 |  |  |  |     mutable _Atomic_word value_; | 
					
						
							| 
									
										
										
										
											2002-05-21 16:48:20 +00:00
										 |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } // namespace detail
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } // namespace boost
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
 |