2 // detail/gcc_sync_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
12 #define BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
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__)
25 #include <boost/asio/detail/noncopyable.hpp>
27 #include <boost/asio/detail/push_options.hpp>
33 class gcc_sync_fenced_block
37 enum half_or_full_t { half, full };
40 explicit gcc_sync_fenced_block(half_or_full_t)
43 __sync_lock_test_and_set(&value_, 1);
47 ~gcc_sync_fenced_block()
49 __sync_lock_release(&value_);
60 #include <boost/asio/detail/pop_options.hpp>
62 #endif // defined(__GNUC__)
63 // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
64 // && !defined(__INTEL_COMPILER) && !defined(__ICL)
65 // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
67 #endif // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP