fence_arch_ops_gcc_aarch32.hpp 1.7 KB

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