]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/gcc_arm_fenced_block.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / detail / gcc_arm_fenced_block.hpp
1 //
2 // detail/gcc_arm_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
11 #ifndef BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
12 #define BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19
20 #if defined(__GNUC__) && defined(__arm__)
21
22 #include <boost/asio/detail/noncopyable.hpp>
23
24 #include <boost/asio/detail/push_options.hpp>
25
26 namespace boost {
27 namespace asio {
28 namespace detail {
29
30 class gcc_arm_fenced_block
31 : private noncopyable
32 {
33 public:
34 enum half_t { half };
35 enum full_t { full };
36
37 // Constructor for a half fenced block.
38 explicit gcc_arm_fenced_block(half_t)
39 {
40 }
41
42 // Constructor for a full fenced block.
43 explicit gcc_arm_fenced_block(full_t)
44 {
45 barrier();
46 }
47
48 // Destructor.
49 ~gcc_arm_fenced_block()
50 {
51 barrier();
52 }
53
54 private:
55 static void barrier()
56 {
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__)
74 int a = 0, b = 0;
75 __asm__ __volatile__ ("swp %0, %1, [%2]"
76 : "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc");
77 # endif // defined(__thumb__)
78 #else
79 // ARMv7 and later.
80 __asm__ __volatile__ ("dmb" : : : "memory");
81 #endif
82 }
83 };
84
85 } // namespace detail
86 } // namespace asio
87 } // namespace boost
88
89 #include <boost/asio/detail/pop_options.hpp>
90
91 #endif // defined(__GNUC__) && defined(__arm__)
92
93 #endif // BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP