|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81736 - trunk/boost/atomic/detail
From: tim_at_[hidden]
Date: 2012-12-06 07:35:32
Author: timblechmann
Date: 2012-12-06 07:35:32 EST (Thu, 06 Dec 2012)
New Revision: 81736
URL: http://svn.boost.org/trac/boost/changeset/81736
Log:
atomic: make use of gcc's __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
__i686__ is not enabled for every platform supporting cmpxchg8b. to work
around this, we provide a separate implementation via gcc's atomic builtins
Text files modified:
trunk/boost/atomic/detail/gcc-x86.hpp | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
Modified: trunk/boost/atomic/detail/gcc-x86.hpp
==============================================================================
--- trunk/boost/atomic/detail/gcc-x86.hpp (original)
+++ trunk/boost/atomic/detail/gcc-x86.hpp 2012-12-06 07:35:32 EST (Thu, 06 Dec 2012)
@@ -2,6 +2,7 @@
#define BOOST_ATOMIC_DETAIL_GCC_X86_HPP
// Copyright (c) 2009 Helge Bahmann
+// Copyright (c) 2012 Tim Blechmann
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
@@ -1510,12 +1511,18 @@
};
#endif
-#if defined(__i686__) && !defined(__x86_64__)
+#if !defined(__x86_64__) && (defined(__i686__) || defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))
template<typename T>
bool
platform_cmpxchg64_strong(T & expected, T desired, volatile T * ptr)
{
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+ const T oldval = __sync_val_compare_and_swap(ptr, expected, desired);
+ const bool result = (oldval == expected);
+ expected = oldval;
+ return result;
+#else
int scratch;
T prev = expected;
/* Make sure ebx is saved and restored properly in case
@@ -1543,6 +1550,7 @@
bool success = (prev == expected);
expected = prev;
return success;
+#endif
}
template<typename T>
@@ -1571,7 +1579,7 @@
}
/* pull in 64-bit atomic type using cmpxchg8b above */
-#if defined(__i686__) && !defined(__x86_64__)
+#if !defined(__x86_64__) && (defined(__i686__) || defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))
#include <boost/atomic/detail/cas64strong.hpp>
#endif
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