|
Boost-Commit : |
From: pdimov_at_[hidden]
Date: 2008-04-05 11:06:32
Author: pdimov
Date: 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
New Revision: 44055
URL: http://svn.boost.org/trac/boost/changeset/44055
Log:
spinlock_nt.hpp added, Cygwin fixes.
Added:
trunk/boost/detail/spinlock_nt.hpp (contents, props changed)
trunk/libs/smart_ptr/test/spinlock_try_test.cpp (contents, props changed)
Text files modified:
trunk/boost/detail/interlocked.hpp | 2 +-
trunk/boost/detail/spinlock.hpp | 4 +++-
trunk/boost/detail/yield_k.hpp | 3 ++-
trunk/libs/smart_ptr/test/Jamfile.v2 | 1 +
trunk/libs/smart_ptr/test/spinlock_test.cpp | 17 +----------------
5 files changed, 8 insertions(+), 19 deletions(-)
Modified: trunk/boost/detail/interlocked.hpp
==============================================================================
--- trunk/boost/detail/interlocked.hpp (original)
+++ trunk/boost/detail/interlocked.hpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -92,7 +92,7 @@
# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange
# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
-#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
+#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
namespace boost
{
Modified: trunk/boost/detail/spinlock.hpp
==============================================================================
--- trunk/boost/detail/spinlock.hpp (original)
+++ trunk/boost/detail/spinlock.hpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -32,10 +32,12 @@
#if defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
# include <boost/detail/spinlock_sync.hpp>
-#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
+#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <boost/detail/spinlock_w32.hpp>
#elif defined(BOOST_HAS_PTHREADS)
# include <boost/detail/spinlock_pt.hpp>
+#elif !defined(BOOST_HAS_THREADS)
+# include <boost/detail/spinlock_nt.hpp>
#else
# error Unrecognized threading platform
#endif
Added: trunk/boost/detail/spinlock_nt.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/detail/spinlock_nt.hpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -0,0 +1,67 @@
+#ifndef BOOST_DETAIL_SPINLOCK_NT_HPP_INCLUDED
+#define BOOST_DETAIL_SPINLOCK_NT_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+//
+// 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)
+//
+
+namespace boost
+{
+
+namespace detail
+{
+
+class spinlock
+{
+public:
+
+ inline bool try_lock()
+ {
+ return true;
+ }
+
+ inline void lock()
+ {
+ }
+
+ inline void unlock()
+ {
+ }
+
+public:
+
+ class scoped_lock
+ {
+ private:
+
+ scoped_lock( scoped_lock const & );
+ scoped_lock & operator=( scoped_lock const & );
+
+ public:
+
+ explicit scoped_lock( spinlock & /*sp*/ )
+ {
+ }
+
+ ~scoped_lock()
+ {
+ }
+ };
+};
+
+} // namespace detail
+} // namespace boost
+
+#define BOOST_DETAIL_SPINLOCK_INIT {}
+
+#endif // #ifndef BOOST_DETAIL_SPINLOCK_NT_HPP_INCLUDED
Modified: trunk/boost/detail/yield_k.hpp
==============================================================================
--- trunk/boost/detail/yield_k.hpp (original)
+++ trunk/boost/detail/yield_k.hpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -25,7 +25,7 @@
#include <boost/config.hpp>
-#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
+#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
#if defined( BOOST_USE_WINDOWS_H )
# include <windows.h>
@@ -33,6 +33,7 @@
#if defined(_MSC_VER) && _MSC_VER >= 1310
extern "C" void _mm_pause();
+# pragma intrinsic( _mm_pause )
#endif
namespace boost
Modified: trunk/libs/smart_ptr/test/Jamfile.v2
==============================================================================
--- trunk/libs/smart_ptr/test/Jamfile.v2 (original)
+++ trunk/libs/smart_ptr/test/Jamfile.v2 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -39,5 +39,6 @@
[ run esft_constructor_test.cpp ]
[ run yield_k_test.cpp ]
[ run spinlock_test.cpp ]
+ [ run spinlock_try_test.cpp ]
;
}
Modified: trunk/libs/smart_ptr/test/spinlock_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/spinlock_test.cpp (original)
+++ trunk/libs/smart_ptr/test/spinlock_test.cpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -9,7 +9,6 @@
//
#include <boost/detail/spinlock.hpp>
-#include <boost/detail/lightweight_test.hpp>
// Sanity check only
@@ -18,29 +17,15 @@
int main()
{
- BOOST_TEST( sp.try_lock() );
- BOOST_TEST( !sp.try_lock() );
- BOOST_TEST( sp2.try_lock() );
- BOOST_TEST( !sp.try_lock() );
- BOOST_TEST( !sp2.try_lock() );
- sp.unlock();
- sp2.unlock();
-
sp.lock();
- BOOST_TEST( !sp.try_lock() );
sp2.lock();
- BOOST_TEST( !sp.try_lock() );
- BOOST_TEST( !sp2.try_lock() );
sp.unlock();
sp2.unlock();
{
boost::detail::spinlock::scoped_lock lock( sp );
- BOOST_TEST( !sp.try_lock() );
boost::detail::spinlock::scoped_lock lock2( sp2 );
- BOOST_TEST( !sp.try_lock() );
- BOOST_TEST( !sp2.try_lock() );
}
- return boost::report_errors();
+ return 0;
}
Added: trunk/libs/smart_ptr/test/spinlock_try_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/spinlock_try_test.cpp 2008-04-05 11:06:31 EDT (Sat, 05 Apr 2008)
@@ -0,0 +1,46 @@
+//
+// spinlock_try_test.cpp
+//
+// Copyright 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/spinlock.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+// Sanity check only
+
+static boost::detail::spinlock sp = BOOST_DETAIL_SPINLOCK_INIT;
+static boost::detail::spinlock sp2 = BOOST_DETAIL_SPINLOCK_INIT;
+
+int main()
+{
+ BOOST_TEST( sp.try_lock() );
+ BOOST_TEST( !sp.try_lock() );
+ BOOST_TEST( sp2.try_lock() );
+ BOOST_TEST( !sp.try_lock() );
+ BOOST_TEST( !sp2.try_lock() );
+ sp.unlock();
+ sp2.unlock();
+
+ sp.lock();
+ BOOST_TEST( !sp.try_lock() );
+ sp2.lock();
+ BOOST_TEST( !sp.try_lock() );
+ BOOST_TEST( !sp2.try_lock() );
+ sp.unlock();
+ sp2.unlock();
+
+ {
+ boost::detail::spinlock::scoped_lock lock( sp );
+ BOOST_TEST( !sp.try_lock() );
+ boost::detail::spinlock::scoped_lock lock2( sp2 );
+ BOOST_TEST( !sp.try_lock() );
+ BOOST_TEST( !sp2.try_lock() );
+ }
+
+ return boost::report_errors();
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk