Boost logo

Boost-Commit :

From: xushiweizh_at_[hidden]
Date: 2008-07-11 19:18:35


Author: xushiwei
Date: 2008-07-11 19:18:35 EDT (Fri, 11 Jul 2008)
New Revision: 47331
URL: http://svn.boost.org/trac/boost/changeset/47331

Log:
TaggedCompareAndSwap
Text files modified:
   sandbox/memory/boost/detail/winapi/atomic/windows.hpp | 32 ++++++++++++++++++++++++++++++++
   1 files changed, 32 insertions(+), 0 deletions(-)

Modified: sandbox/memory/boost/detail/winapi/atomic/windows.hpp
==============================================================================
--- sandbox/memory/boost/detail/winapi/atomic/windows.hpp (original)
+++ sandbox/memory/boost/detail/winapi/atomic/windows.hpp 2008-07-11 19:18:35 EDT (Fri, 11 Jul 2008)
@@ -87,6 +87,22 @@
         return ok;
 }
 
+__forceinline bool WINAPI TaggedCompareAndSwap(
+ LONG32 Destination[2], LONG32 Exchange, LONG32 NewTag, LONG32 Comperand, LONG32 Tag)
+{
+ bool ok;
+ __asm {
+ mov eax, Comperand
+ mov edx, Tag
+ mov ebx, Exchange
+ mov ecx, NewTag
+ mov edi, Destination
+ lock cmpxchg8b [edi]
+ setz ok
+ }
+ return ok;
+}
+
 #if defined(_WIN32)
 
 template <class Type>
@@ -97,6 +113,14 @@
                 (LONG32*)Destination, (LONG32)Comperand, (LONG32)Exchange, (LONG32)Tag);
 }
 
+template <class Type>
+__forceinline bool WINAPI TaggedCompareAndSwap(
+ Type* Destination[2], Type* Exchange, Type* NewTag, Type* Comperand, Type* Tag)
+{
+ return TaggedCompareAndSwap(
+ (LONG32*)Destination, (LONG32)Exchange, (LONG32)NewTag, (LONG32)Comperand, (LONG32)Tag);
+}
+
 #elif defined(_WIN64)
 
 template <class Type>
@@ -107,6 +131,14 @@
                 (LONG64*)Destination, (LONG64)Comperand, (LONG64)Exchange, (LONG64)Tag);
 }
 
+template <class Type>
+__forceinline bool WINAPI TaggedCompareAndSwap(
+ Type* Destination[2], Type* Exchange, Type* NewTag, Type* Comperand, Type* Tag)
+{
+ return TaggedCompareAndSwap(
+ (LONG64*)Destination, (LONG64)Exchange, (LONG64)NewTag, (LONG64)Comperand, (LONG64)Tag);
+}
+
 #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