]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/detail/gcc_sync_fenced_block.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / detail / gcc_sync_fenced_block.hpp
1 //
2 // detail/gcc_sync_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #ifndef BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
12 #define BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19
20 #if defined(__GNUC__) \
21 && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
22 && !defined(__INTEL_COMPILER) && !defined(__ICL) \
23 && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
24
25 #include <boost/asio/detail/push_options.hpp>
26
27 namespace boost {
28 namespace asio {
29 namespace detail {
30
31 class gcc_sync_fenced_block
32 : private noncopyable
33 {
34 public:
35 enum half_or_full_t { half, full };
36
37 // Constructor.
38 explicit gcc_sync_fenced_block(half_or_full_t)
39 : value_(0)
40 {
41 __sync_lock_test_and_set(&value_, 1);
42 }
43
44 // Destructor.
45 ~gcc_sync_fenced_block()
46 {
47 __sync_lock_release(&value_);
48 }
49
50 private:
51 int value_;
52 };
53
54 } // namespace detail
55 } // namespace asio
56 } // namespace boost
57
58 #include <boost/asio/detail/pop_options.hpp>
59
60 #endif // defined(__GNUC__)
61 // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
62 // && !defined(__INTEL_COMPILER) && !defined(__ICL)
63 // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
64
65 #endif // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP