Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-04-05 12:32:49


Author: pdimov
Date: 2008-04-05 12:32:49 EDT (Sat, 05 Apr 2008)
New Revision: 44058
URL: http://svn.boost.org/trac/boost/changeset/44058

Log:
BOOST_COMPILER_FENCE factored out.
Text files modified:
   trunk/boost/detail/spinlock_w32.hpp | 35 +++++++++++++++++++++++++----------
   1 files changed, 25 insertions(+), 10 deletions(-)

Modified: trunk/boost/detail/spinlock_w32.hpp
==============================================================================
--- trunk/boost/detail/spinlock_w32.hpp (original)
+++ trunk/boost/detail/spinlock_w32.hpp 2008-04-05 12:32:49 EDT (Sat, 05 Apr 2008)
@@ -18,11 +18,31 @@
 #include <boost/detail/interlocked.hpp>
 #include <boost/detail/yield_k.hpp>
 
-#if defined( _MSC_VER ) && _MSC_VER >= 1310
- extern "C" void _ReadWriteBarrier();
-# pragma intrinsic( _ReadWriteBarrier )
+// BOOST_COMPILER_FENCE
+
+#if defined(__INTEL_COMPILER)
+
+#define BOOST_COMPILER_FENCE __memory_barrier();
+
+#elif defined( _MSC_VER ) && _MSC_VER >= 1310
+
+extern "C" void _ReadWriteBarrier();
+#pragma intrinsic( _ReadWriteBarrier )
+
+#define BOOST_COMPILER_FENCE _ReadWriteBarrier();
+
+#elif defined(__GNUC__)
+
+#define BOOST_COMPILER_FENCE __asm__ __volatile__( "" ::: "memory" );
+
+#else
+
+#define BOOST_COMPILER_FENCE
+
 #endif
 
+//
+
 namespace boost
 {
 
@@ -41,9 +61,7 @@
     {
         long r = BOOST_INTERLOCKED_EXCHANGE( &v_, 1 );
 
-#if defined( _MSC_VER ) && _MSC_VER >= 1310
- _ReadWriteBarrier();
-#endif
+ BOOST_COMPILER_FENCE
 
         return r == 0;
     }
@@ -58,10 +76,7 @@
 
     void unlock()
     {
-#if defined( _MSC_VER ) && _MSC_VER >= 1310
- _ReadWriteBarrier();
-#endif
-
+ BOOST_COMPILER_FENCE
         *const_cast< long volatile* >( &v_ ) = 0;
     }
 


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