Boost logo

Boost-Commit :

From: xushiweizh_at_[hidden]
Date: 2008-05-05 23:27:56


Author: xushiwei
Date: 2008-05-05 23:27:56 EDT (Mon, 05 May 2008)
New Revision: 45163
URL: http://svn.boost.org/trac/boost/changeset/45163

Log:
atomic for windows
Added:
   sandbox/memory/boost/memory/winapi/atomic/windows.hpp (contents, props changed)
Text files modified:
   sandbox/memory/boost/memory/winapi/winbase.h | 27 +++++++++++++++++++++++++++
   1 files changed, 27 insertions(+), 0 deletions(-)

Added: sandbox/memory/boost/memory/winapi/atomic/windows.hpp
==============================================================================
--- (empty file)
+++ sandbox/memory/boost/memory/winapi/atomic/windows.hpp 2008-05-05 23:27:56 EDT (Mon, 05 May 2008)
@@ -0,0 +1,66 @@
+//
+// boost/memory/winapi/atomic/windows.hpp (*)
+//
+// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
+//
+// 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)
+//
+// See http://www.boost.org/libs/memory/index.htm for documentation.
+//
+#ifndef BOOST_MEMORY_WINAPI_ATOMIC_WINDOWS_HPP
+#define BOOST_MEMORY_WINAPI_ATOMIC_WINDOWS_HPP
+
+// -------------------------------------------------------------------------
+
+// we use our own implementation of InterlockedExchangePointer because of problems with the one in system headers
+__forceinline PVOID WINAPI boost_InterlockedExchangePointer(PVOID* Target, PVOID Value)
+{
+ return reinterpret_cast<PVOID>(static_cast<LONG_PTR>(
+ InterlockedExchange(
+ reinterpret_cast<LONG*>(Target),
+ static_cast<LONG>(reinterpret_cast<LONG_PTR>(Value))
+ )
+ ));
+}
+
+#undef InterlockedExchangePointer
+#define InterlockedExchangePointer boost_InterlockedExchangePointer
+
+// -------------------------------------------------------------------------
+
+#if defined(BOOST_WINSDK_VC6)
+
+__forceinline PVOID WINAPI boost_InterlockedCompareExchange(
+ LPLONG Destination, LONG Exchange, LONG Comperand)
+{
+ return InterlockedCompareExchange(
+ (PVOID*)Destination, (PVOID)Exchange, (PVOID)Comperand);
+}
+
+#define InterlockedCompareExchange boost_InterlockedCompareExchange
+#define InterlockedCompareExchangePointer InterlockedCompareExchange
+
+#elif !defined(InterlockedCompareExchangePointer)
+
+__forceinline PVOID WINAPI boost_InterlockedCompareExchangePointer(
+ PVOID* Destination, PVOID Exchange, PVOID Comperand)
+{
+ return reinterpret_cast<PVOID>(static_cast<LONG_PTR>(
+ InterlockedCompareExchange(
+ reinterpret_cast<LONG*>(Destination),
+ static_cast<LONG>(reinterpret_cast<LONG_PTR>(Exchange)),
+ static_cast<LONG>(reinterpret_cast<LONG_PTR>(Comperand))
+ )
+ ));
+}
+
+#define InterlockedCompareExchangePointer boost_InterlockedCompareExchangePointer
+
+#endif
+
+// -------------------------------------------------------------------------
+// $Log: $
+
+#endif /* BOOST_MEMORY_WINAPI_ATOMIC_WINDOWS_HPP */

Modified: sandbox/memory/boost/memory/winapi/winbase.h
==============================================================================
--- sandbox/memory/boost/memory/winapi/winbase.h (original)
+++ sandbox/memory/boost/memory/winapi/winbase.h 2008-05-05 23:27:56 EDT (Mon, 05 May 2008)
@@ -22,6 +22,33 @@
 #include <winbase.h>
 #endif
 
+#ifndef _BASETSD_H_
+#include <basetsd.h>
+#endif
+
+#if !defined(_W64)
+ #define BOOST_WINSDK_VC6
+ #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+ #define _W64 __w64
+ #else
+ #define _W64
+ #endif
+#endif
+
+#if defined(BOOST_WINSDK_VC6)
+ #if defined(_WIN64)
+ typedef __int64 LONG_PTR, *PLONG_PTR;
+ typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
+ #else
+ typedef _W64 long LONG_PTR, *PLONG_PTR;
+ typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
+ #endif
+#endif
+
+#ifndef BOOST_MEMORY_WINAPI_ATOMIC_WINDOWS_HPP
+#include "atomic/windows.hpp"
+#endif
+
 #else
 
 #define BOOST_NO_WINSDK


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