fence_arch_ops_msvc_arm.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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) 2020 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/fence_arch_ops_msvc_arm.hpp
  10. *
  11. * This header contains implementation of the \c fence_arch_operations struct.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_ARM_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_ARM_HPP_INCLUDED_
  15. #include <boost/memory_order.hpp>
  16. #include <boost/atomic/detail/config.hpp>
  17. #include <boost/atomic/detail/ops_msvc_common.hpp>
  18. #include <boost/atomic/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. extern "C" void __dmb(unsigned int);
  23. #if defined(BOOST_MSVC)
  24. #pragma intrinsic(__dmb)
  25. #endif
  26. namespace boost {
  27. namespace atomics {
  28. namespace detail {
  29. //! Fence operations for ARM
  30. struct fence_arch_operations_msvc_arm
  31. {
  32. static BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
  33. {
  34. BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
  35. if (order != memory_order_relaxed)
  36. hardware_full_fence();
  37. BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
  38. }
  39. static BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
  40. {
  41. if (order != memory_order_relaxed)
  42. BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
  43. }
  44. static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT
  45. {
  46. __dmb(0xB); // _ARM_BARRIER_ISH, see armintr.h from MSVC 11 and later
  47. }
  48. };
  49. typedef fence_arch_operations_msvc_arm fence_arch_operations;
  50. } // namespace detail
  51. } // namespace atomics
  52. } // namespace boost
  53. #include <boost/atomic/detail/footer.hpp>
  54. #endif // BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_ARM_HPP_INCLUDED_