Last change
on this file since 44 was
44,
checked in by cholod, 12 years ago
|
Load NEMO_TMP into vendor/nemo/current.
|
File size:
1.2 KB
|
Line | |
---|
1 | #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED |
---|
2 | #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED |
---|
3 | |
---|
4 | // |
---|
5 | // boost/detail/atomic_count_sync.hpp |
---|
6 | // |
---|
7 | // atomic_count for g++ 4.1+ |
---|
8 | // |
---|
9 | // http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html |
---|
10 | // |
---|
11 | // Copyright 2007 Peter Dimov |
---|
12 | // |
---|
13 | // Distributed under the Boost Software License, Version 1.0. (See |
---|
14 | // accompanying file LICENSE_1_0.txt or copy at |
---|
15 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
16 | // |
---|
17 | |
---|
18 | #if defined( __ia64__ ) && defined( __INTEL_COMPILER ) |
---|
19 | # include <ia64intrin.h> |
---|
20 | #endif |
---|
21 | |
---|
22 | namespace boost |
---|
23 | { |
---|
24 | |
---|
25 | namespace detail |
---|
26 | { |
---|
27 | |
---|
28 | class atomic_count |
---|
29 | { |
---|
30 | public: |
---|
31 | |
---|
32 | explicit atomic_count( long v ) : value_( v ) {} |
---|
33 | |
---|
34 | long operator++() |
---|
35 | { |
---|
36 | return __sync_add_and_fetch( &value_, 1 ); |
---|
37 | } |
---|
38 | |
---|
39 | long operator--() |
---|
40 | { |
---|
41 | return __sync_add_and_fetch( &value_, -1 ); |
---|
42 | } |
---|
43 | |
---|
44 | operator long() const |
---|
45 | { |
---|
46 | return __sync_fetch_and_add( &value_, 0 ); |
---|
47 | } |
---|
48 | |
---|
49 | private: |
---|
50 | |
---|
51 | atomic_count(atomic_count const &); |
---|
52 | atomic_count & operator=(atomic_count const &); |
---|
53 | |
---|
54 | mutable long value_; |
---|
55 | }; |
---|
56 | |
---|
57 | } // namespace detail |
---|
58 | |
---|
59 | } // namespace boost |
---|
60 | |
---|
61 | #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED |
---|
Note: See
TracBrowser
for help on using the repository browser.