Chris@16: // Chris@16: // detail/gcc_sync_fenced_block.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP Chris@16: #define BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(__GNUC__) \ Chris@16: && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \ Chris@16: && !defined(__INTEL_COMPILER) && !defined(__ICL) \ Chris@16: && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: class gcc_sync_fenced_block Chris@16: : private noncopyable Chris@16: { Chris@16: public: Chris@16: enum half_or_full_t { half, full }; Chris@16: Chris@16: // Constructor. Chris@16: explicit gcc_sync_fenced_block(half_or_full_t) Chris@16: : value_(0) Chris@16: { Chris@16: __sync_lock_test_and_set(&value_, 1); Chris@16: } Chris@16: Chris@16: // Destructor. Chris@16: ~gcc_sync_fenced_block() Chris@16: { Chris@16: __sync_lock_release(&value_); Chris@16: } Chris@16: Chris@16: private: Chris@16: int value_; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // defined(__GNUC__) Chris@16: // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) Chris@16: // && !defined(__INTEL_COMPILER) && !defined(__ICL) Chris@16: // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP