fence_ops_linux_arm.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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, 2011 Helge Bahmann
  7. * Copyright (c) 2009 Phil Endecott
  8. * Copyright (c) 2013 Tim Blechmann
  9. * Linux-specific code by Phil Endecott
  10. * Copyright (c) 2014 Andrey Semashev
  11. */
  12. /*!
  13. * \file atomic/detail/fence_ops_linux_arm.hpp
  14. *
  15. * This header contains implementation of the \c fence_operations struct.
  16. */
  17. #ifndef BOOST_ATOMIC_DETAIL_FENCE_OPS_LINUX_ARM_HPP_INCLUDED_
  18. #define BOOST_ATOMIC_DETAIL_FENCE_OPS_LINUX_ARM_HPP_INCLUDED_
  19. #include <boost/memory_order.hpp>
  20. #include <boost/atomic/detail/config.hpp>
  21. #include <boost/atomic/detail/header.hpp>
  22. #ifdef BOOST_HAS_PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. namespace boost {
  26. namespace atomics {
  27. namespace detail {
  28. //! Fence operations based on Linux-specific system routines
  29. struct fence_operations_linux_arm
  30. {
  31. static BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
  32. {
  33. if (order != memory_order_relaxed)
  34. hardware_full_fence();
  35. }
  36. static BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
  37. {
  38. if (order != memory_order_relaxed)
  39. __asm__ __volatile__ ("" ::: "memory");
  40. }
  41. static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT
  42. {
  43. // See the comment in core_ops_linux_arm.hpp regarding the function pointer below
  44. typedef void (*kernel_dmb_t)(void);
  45. ((kernel_dmb_t)0xffff0fa0)();
  46. }
  47. };
  48. typedef fence_operations_linux_arm fence_operations;
  49. } // namespace detail
  50. } // namespace atomics
  51. } // namespace boost
  52. #include <boost/atomic/detail/footer.hpp>
  53. #endif // BOOST_ATOMIC_DETAIL_FENCE_OPS_LINUX_ARM_HPP_INCLUDED_