1 #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
5 // Copyright (c) 2008, 2011 Peter Dimov
7 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
12 #include <boost/smart_ptr/detail/yield_k.hpp>
14 #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__)
16 # define BOOST_SP_ARM_BARRIER "dmb"
17 # define BOOST_SP_ARM_HAS_LDREX
19 #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__)
21 # define BOOST_SP_ARM_BARRIER "mcr p15, 0, r0, c7, c10, 5"
22 # define BOOST_SP_ARM_HAS_LDREX
26 # define BOOST_SP_ARM_BARRIER ""
48 #ifdef BOOST_SP_ARM_HAS_LDREX
53 "strexne %0, %1, [%2]; \n"
54 BOOST_SP_ARM_BARRIER :
55 "=&r"( r ): // outputs
56 "r"( 1 ), "r"( &v_ ): // inputs
63 BOOST_SP_ARM_BARRIER :
64 "=&r"( r ): // outputs
65 "r"( 1 ), "r"( &v_ ): // inputs
75 for( unsigned k = 0; !try_lock(); ++k )
77 boost::detail::yield( k );
83 __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" );
84 *const_cast< int volatile* >( &v_ ) = 0;
85 __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" );
96 scoped_lock( scoped_lock const & );
97 scoped_lock & operator=( scoped_lock const & );
101 explicit scoped_lock( spinlock & sp ): sp_( sp )
113 } // namespace detail
116 #define BOOST_DETAIL_SPINLOCK_INIT {0}
118 #undef BOOST_SP_ARM_BARRIER
119 #undef BOOST_SP_ARM_HAS_LDREX
121 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED