]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/detail/gcc_arm_fenced_block.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / detail / gcc_arm_fenced_block.hpp
1 //
2 // detail/gcc_arm_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 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/push_options.hpp>
23
24 namespace boost {
25 namespace asio {
26 namespace detail {
27
28 class gcc_arm_fenced_block
29 : private noncopyable
30 {
31 public:
32 enum half_t { half };
33 enum full_t { full };
34
35 // Constructor for a half fenced block.
36 explicit gcc_arm_fenced_block(half_t)
37 {
38 }
39
40 // Constructor for a full fenced block.
41 explicit gcc_arm_fenced_block(full_t)
42 {
43 barrier();
44 }
45
46 // Destructor.
47 ~gcc_arm_fenced_block()
48 {
49 barrier();
50 }
51
52 private:
53 static void barrier()
54 {
55 #if defined(__ARM_ARCH_4__) \
56 || defined(__ARM_ARCH_4T__) \
57 || defined(__ARM_ARCH_5__) \
58 || defined(__ARM_ARCH_5E__) \
59 || defined(__ARM_ARCH_5T__) \
60 || defined(__ARM_ARCH_5TE__) \
61 || defined(__ARM_ARCH_5TEJ__) \
62 || defined(__ARM_ARCH_6__) \
63 || defined(__ARM_ARCH_6J__) \
64 || defined(__ARM_ARCH_6K__) \
65 || defined(__ARM_ARCH_6Z__) \
66 || defined(__ARM_ARCH_6ZK__) \
67 || defined(__ARM_ARCH_6T2__)
68 # if defined(__thumb__)
69 // This is just a placeholder and almost certainly not sufficient.
70 __asm__ __volatile__ ("" : : : "memory");
71 # else // defined(__thumb__)
72 int a = 0, b = 0;
73 __asm__ __volatile__ ("swp %0, %1, [%2]"
74 : "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc");
75 # endif // defined(__thumb__)
76 #else
77 // ARMv7 and later.
78 __asm__ __volatile__ ("dmb" : : : "memory");
79 #endif
80 }
81 };
82
83 } // namespace detail
84 } // namespace asio
85 } // namespace boost
86
87 #include <boost/asio/detail/pop_options.hpp>
88
89 #endif // defined(__GNUC__) && defined(__arm__)
90
91 #endif // BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP