fence_arch_ops_gcc_aarch64.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_gcc_aarch64.hpp
  10. *
  11. * This header contains implementation of the \c fence_arch_operations struct.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_GCC_AARCH64_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_GCC_AARCH64_HPP_INCLUDED_
  15. #include <boost/memory_order.hpp>
  16. #include <boost/atomic/detail/config.hpp>
  17. #include <boost/atomic/detail/header.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. namespace boost {
  22. namespace atomics {
  23. namespace detail {
  24. //! Fence operations for AArch64
  25. struct fence_arch_operations_gcc_aarch64
  26. {
  27. static BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
  28. {
  29. if (order != memory_order_relaxed)
  30. {
  31. if (order == memory_order_consume || order == memory_order_acquire)
  32. __asm__ __volatile__ ("dmb ishld\n\t" ::: "memory");
  33. else
  34. __asm__ __volatile__ ("dmb ish\n\t" ::: "memory");
  35. }
  36. }
  37. static BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
  38. {
  39. if (order != memory_order_relaxed)
  40. __asm__ __volatile__ ("" ::: "memory");
  41. }
  42. };
  43. typedef fence_arch_operations_gcc_aarch64 fence_arch_operations;
  44. } // namespace detail
  45. } // namespace atomics
  46. } // namespace boost
  47. #include <boost/atomic/detail/footer.hpp>
  48. #endif // BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_GCC_AARCH64_HPP_INCLUDED_