Realistic 3D camera system
3D camera system components
gcc_arm_fenced_block.hpp
Go to the documentation of this file.
1 //
2 // detail/gcc_arm_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
12 #define 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 "asio/detail/config.hpp"
19 
20 #if defined(__GNUC__) && defined(__arm__)
21 
23 
24 namespace asio {
25 namespace detail {
26 
27 class gcc_arm_fenced_block
28  : private noncopyable
29 {
30 public:
31  enum half_t { half };
32  enum full_t { full };
33 
34  // Constructor for a half fenced block.
35  explicit gcc_arm_fenced_block(half_t)
36  {
37  }
38 
39  // Constructor for a full fenced block.
40  explicit gcc_arm_fenced_block(full_t)
41  {
42  barrier();
43  }
44 
45  // Destructor.
46  ~gcc_arm_fenced_block()
47  {
48  barrier();
49  }
50 
51 private:
52  static void barrier()
53  {
54 #if defined(__ARM_ARCH_4__) \
55  || defined(__ARM_ARCH_4T__) \
56  || defined(__ARM_ARCH_5__) \
57  || defined(__ARM_ARCH_5E__) \
58  || defined(__ARM_ARCH_5T__) \
59  || defined(__ARM_ARCH_5TE__) \
60  || defined(__ARM_ARCH_5TEJ__) \
61  || defined(__ARM_ARCH_6__) \
62  || defined(__ARM_ARCH_6J__) \
63  || defined(__ARM_ARCH_6K__) \
64  || defined(__ARM_ARCH_6Z__) \
65  || defined(__ARM_ARCH_6ZK__) \
66  || defined(__ARM_ARCH_6T2__)
67 # if defined(__thumb__)
68  // This is just a placeholder and almost certainly not sufficient.
69  __asm__ __volatile__ ("" : : : "memory");
70 # else // defined(__thumb__)
71  int a = 0, b = 0;
72  __asm__ __volatile__ ("swp %0, %1, [%2]"
73  : "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc");
74 # endif // defined(__thumb__)
75 #else
76  // ARMv7 and later.
77  __asm__ __volatile__ ("dmb" : : : "memory");
78 #endif
79  }
80 };
81 
82 } // namespace detail
83 } // namespace asio
84 
86 
87 #endif // defined(__GNUC__) && defined(__arm__)
88 
89 #endif // ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
asio::basic_streambuf< Allocator > & b
Definition: read.hpp:702