ops_msvc_common.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2009 Helge Bahmann
  7. * Copyright (c) 2012 Tim Blechmann
  8. * Copyright (c) 2014, 2019 Andrey Semashev
  9. */
  10. /*!
  11. * \file atomic/detail/ops_msvc_common.hpp
  12. *
  13. * This header contains common tools for MSVC implementation of the atomic operations.
  14. */
  15. #ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_
  16. #define BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_
  17. #include <boost/atomic/detail/config.hpp>
  18. #include <boost/atomic/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. // Define compiler barriers
  23. #if defined(__INTEL_COMPILER)
  24. #define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() __memory_barrier()
  25. #elif defined(__clang__)
  26. #define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() __atomic_signal_fence(__ATOMIC_SEQ_CST)
  27. #elif defined(_MSC_VER) && !defined(_WIN32_WCE)
  28. extern "C" void _ReadWriteBarrier(void);
  29. #pragma intrinsic(_ReadWriteBarrier)
  30. #define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() _ReadWriteBarrier()
  31. #endif
  32. #ifndef BOOST_ATOMIC_DETAIL_COMPILER_BARRIER
  33. #define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER()
  34. #endif
  35. #include <boost/atomic/detail/footer.hpp>
  36. #endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_