1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From c87ad09331d239d6566e5eb409898ae38f04799a Mon Sep 17 00:00:00 2001
From: Peter Dimov <pdimov@boostpro.com>
Date: Mon, 7 Nov 2011 17:50:31 +0000
Subject: [PATCH] Add ARM memory barriers. Refs #5372.
SVN-Revision: 75389
---
boost/smart_ptr/detail/spinlock_gcc_arm.hpp | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/boost/smart_ptr/detail/spinlock_gcc_arm.hpp b/boost/smart_ptr/detail/spinlock_gcc_arm.hpp
index ba6c511..f58ea44 100644
--- a/boost/smart_ptr/detail/spinlock_gcc_arm.hpp
+++ b/boost/smart_ptr/detail/spinlock_gcc_arm.hpp
@@ -2,7 +2,7 @@
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
//
-// Copyright (c) 2008 Peter Dimov
+// Copyright (c) 2008, 2011 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
@@ -11,6 +11,20 @@
#include <boost/smart_ptr/detail/yield_k.hpp>
+#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
+
+# define BOOST_SP_ARM_BARRIER "dmb"
+
+#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
+
+# define BOOST_SP_ARM_BARRIER "mcr p15, 0, r0, c7, c10, 5"
+
+#else
+
+# define BOOST_SP_ARM_BARRIER ""
+
+#endif
+
namespace boost
{
@@ -30,7 +44,8 @@ class spinlock
int r;
__asm__ __volatile__(
- "swp %0, %1, [%2]":
+ "swp %0, %1, [%2]\n\t"
+ BOOST_SP_ARM_BARRIER :
"=&r"( r ): // outputs
"r"( 1 ), "r"( &v_ ): // inputs
"memory", "cc" );
@@ -48,7 +63,7 @@ class spinlock
void unlock()
{
- __asm__ __volatile__( "" ::: "memory" );
+ __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" );
*const_cast< int volatile* >( &v_ ) = 0;
}
@@ -82,4 +97,6 @@ class spinlock
#define BOOST_DETAIL_SPINLOCK_INIT {0}
+#undef BOOST_SP_ARM_BARRIER
+
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
--
1.7.10
|