2 // detail/gcc_arm_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
12 #define BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(__GNUC__) && defined(__arm__)
22 #include <boost/asio/detail/noncopyable.hpp>
24 #include <boost/asio/detail/push_options.hpp>
30 class gcc_arm_fenced_block
37 // Constructor for a half fenced block.
38 explicit gcc_arm_fenced_block(half_t)
42 // Constructor for a full fenced block.
43 explicit gcc_arm_fenced_block(full_t)
49 ~gcc_arm_fenced_block()
57 #if defined(__ARM_ARCH_4__) \
58 || defined(__ARM_ARCH_4T__) \
59 || defined(__ARM_ARCH_5__) \
60 || defined(__ARM_ARCH_5E__) \
61 || defined(__ARM_ARCH_5T__) \
62 || defined(__ARM_ARCH_5TE__) \
63 || defined(__ARM_ARCH_5TEJ__) \
64 || defined(__ARM_ARCH_6__) \
65 || defined(__ARM_ARCH_6J__) \
66 || defined(__ARM_ARCH_6K__) \
67 || defined(__ARM_ARCH_6Z__) \
68 || defined(__ARM_ARCH_6ZK__) \
69 || defined(__ARM_ARCH_6T2__)
70 # if defined(__thumb__)
71 // This is just a placeholder and almost certainly not sufficient.
72 __asm__ __volatile__ ("" : : : "memory");
73 # else // defined(__thumb__)
75 __asm__ __volatile__ ("swp %0, %1, [%2]"
76 : "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc");
77 # endif // defined(__thumb__)
80 __asm__ __volatile__ ("dmb" : : : "memory");
89 #include <boost/asio/detail/pop_options.hpp>
91 #endif // defined(__GNUC__) && defined(__arm__)
93 #endif // BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP