Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/smart_ptr/detail/atomic_count_gcc.hpp @ 125:34e428693f5d vext
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Thu, 14 Jun 2018 11:15:39 +0100 |
parents | 2665513ce2d3 |
children |
rev | line source |
---|---|
Chris@16 | 1 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED |
Chris@16 | 2 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED |
Chris@16 | 3 |
Chris@16 | 4 // |
Chris@16 | 5 // boost/detail/atomic_count_gcc.hpp |
Chris@16 | 6 // |
Chris@16 | 7 // atomic_count for GNU libstdc++ v3 |
Chris@16 | 8 // |
Chris@16 | 9 // http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html |
Chris@16 | 10 // |
Chris@16 | 11 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. |
Chris@16 | 12 // Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org> |
Chris@16 | 13 // Copyright 2003-2005 Peter Dimov |
Chris@16 | 14 // |
Chris@16 | 15 // Distributed under the Boost Software License, Version 1.0. (See |
Chris@16 | 16 // accompanying file LICENSE_1_0.txt or copy at |
Chris@16 | 17 // http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 18 // |
Chris@16 | 19 |
Chris@16 | 20 #if __GNUC__ * 100 + __GNUC_MINOR__ >= 402 |
Chris@16 | 21 # include <ext/atomicity.h> |
Chris@16 | 22 #else |
Chris@16 | 23 # include <bits/atomicity.h> |
Chris@16 | 24 #endif |
Chris@16 | 25 |
Chris@16 | 26 namespace boost |
Chris@16 | 27 { |
Chris@16 | 28 |
Chris@16 | 29 namespace detail |
Chris@16 | 30 { |
Chris@16 | 31 |
Chris@16 | 32 #if defined(__GLIBCXX__) // g++ 3.4+ |
Chris@16 | 33 |
Chris@16 | 34 using __gnu_cxx::__atomic_add; |
Chris@16 | 35 using __gnu_cxx::__exchange_and_add; |
Chris@16 | 36 |
Chris@16 | 37 #endif |
Chris@16 | 38 |
Chris@16 | 39 class atomic_count |
Chris@16 | 40 { |
Chris@16 | 41 public: |
Chris@16 | 42 |
Chris@16 | 43 explicit atomic_count( long v ) : value_( v ) {} |
Chris@16 | 44 |
Chris@16 | 45 long operator++() |
Chris@16 | 46 { |
Chris@16 | 47 return __exchange_and_add( &value_, +1 ) + 1; |
Chris@16 | 48 } |
Chris@16 | 49 |
Chris@16 | 50 long operator--() |
Chris@16 | 51 { |
Chris@16 | 52 return __exchange_and_add( &value_, -1 ) - 1; |
Chris@16 | 53 } |
Chris@16 | 54 |
Chris@16 | 55 operator long() const |
Chris@16 | 56 { |
Chris@16 | 57 return __exchange_and_add( &value_, 0 ); |
Chris@16 | 58 } |
Chris@16 | 59 |
Chris@16 | 60 private: |
Chris@16 | 61 |
Chris@16 | 62 atomic_count(atomic_count const &); |
Chris@16 | 63 atomic_count & operator=(atomic_count const &); |
Chris@16 | 64 |
Chris@16 | 65 mutable _Atomic_word value_; |
Chris@16 | 66 }; |
Chris@16 | 67 |
Chris@16 | 68 } // namespace detail |
Chris@16 | 69 |
Chris@16 | 70 } // namespace boost |
Chris@16 | 71 |
Chris@16 | 72 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED |