$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: pdimov_at_[hidden]
Date: 2008-04-09 17:08:39
Author: pdimov
Date: 2008-04-09 17:08:39 EDT (Wed, 09 Apr 2008)
New Revision: 44138
URL: http://svn.boost.org/trac/boost/changeset/44138
Log:
spinlock_gcc_arm.hpp added.
Added:
   trunk/boost/detail/spinlock_gcc_arm.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/detail/spinlock.hpp |     4 +++-                                    
   1 files changed, 3 insertions(+), 1 deletions(-)
Modified: trunk/boost/detail/spinlock.hpp
==============================================================================
--- trunk/boost/detail/spinlock.hpp	(original)
+++ trunk/boost/detail/spinlock.hpp	2008-04-09 17:08:39 EDT (Wed, 09 Apr 2008)
@@ -30,7 +30,9 @@
 
 #include <boost/config.hpp>
 
-#if defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
+#if defined(__GNUC__) && defined( __arm__ )
+#  include <boost/detail/spinlock_gcc_arm.hpp>
+#elif defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
 #  include <boost/detail/spinlock_sync.hpp>
 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 #  include <boost/detail/spinlock_w32.hpp>
Added: trunk/boost/detail/spinlock_gcc_arm.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/detail/spinlock_gcc_arm.hpp	2008-04-09 17:08:39 EDT (Wed, 09 Apr 2008)
@@ -0,0 +1,85 @@
+#ifndef BOOST_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
+#define BOOST_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
+
+//
+//  Copyright (c) 2008 Peter Dimov
+//
+//  Distributed under the Boost Software License, Version 1.0.
+//  See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/detail/yield_k.hpp>
+
+namespace boost
+{
+
+namespace detail
+{
+
+class spinlock
+{
+public:
+
+    int v_;
+
+public:
+
+    bool try_lock()
+    {
+        int r;
+
+        __asm__ __volatile__(
+            "swp %0, %1, [%2]":
+            "=r"( r ): // outputs
+            "r"( 1 ), "r"( &v_ ): // inputs
+            "memory", "cc" );
+
+        return r == 0;
+    }
+
+    void lock()
+    {
+        for( unsigned k = 0; !try_lock(); ++k )
+        {
+            boost::detail::yield( k );
+        }
+    }
+
+    void unlock()
+    {
+        __asm__ __volatile__( "" ::: "memory" );
+        *const_cast< int volatile* >( &v_ ) = 0;
+    }
+
+public:
+
+    class scoped_lock
+    {
+    private:
+
+        spinlock & sp_;
+
+        scoped_lock( scoped_lock const & );
+        scoped_lock & operator=( scoped_lock const & );
+
+    public:
+
+        explicit scoped_lock( spinlock & sp ): sp_( sp )
+        {
+            sp.lock();
+        }
+
+        ~scoped_lock()
+        {
+            sp_.unlock();
+        }
+    };
+};
+
+} // namespace detail
+} // namespace boost
+
+#define BOOST_DETAIL_SPINLOCK_INIT {0}
+
+#endif // #ifndef BOOST_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED