|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-05-05 09:45:34
Author: xushiwei
Date: 2008-05-05 09:45:33 EDT (Mon, 05 May 2008)
New Revision: 45139
URL: http://svn.boost.org/trac/boost/changeset/45139
Log:
atomic:
1. InterlockedIncrement/InterlockedDecrement
2. InterlockedExchange/InterlockedExchangePointer
3. InterlockedExchangeAdd
4. InterlockedCompareExchange/InterlockedCompareExchangePointer
Added:
sandbox/memory/boost/memory/winapi/atomic/
sandbox/memory/boost/memory/winapi/atomic/atomic_builtins.hpp (contents, props changed)
Text files modified:
sandbox/memory/boost/memory/winapi/winbase.h | 4 ++++
sandbox/memory/libs/memory/test/test_basic/test.dsp | 8 ++++----
2 files changed, 8 insertions(+), 4 deletions(-)
Added: sandbox/memory/boost/memory/winapi/atomic/atomic_builtins.hpp
==============================================================================
--- (empty file)
+++ sandbox/memory/boost/memory/winapi/atomic/atomic_builtins.hpp 2008-05-05 09:45:33 EDT (Mon, 05 May 2008)
@@ -0,0 +1,65 @@
+//
+// boost/memory/winapi/atomic/atomic_builtins.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_ATOMIC_BUILTINS_HPP
+#define BOOST_MEMORY_WINAPI_ATOMIC_ATOMIC_BUILTINS_HPP
+
+// -------------------------------------------------------------------------
+
+__forceinline LONG WINAPI InterlockedIncrement(volatile LPLONG lpAddend)
+{
+ return __sync_fetch_and_add(lpAddend, 1) + 1;
+}
+
+__forceinline LONG WINAPI InterlockedDecrement(volatile LPLONG lpAddend)
+{
+ return __sync_sub_and_fetch(lpAddend, 1);
+}
+
+// -------------------------------------------------------------------------
+
+__forceinline LONG WINAPI InterlockedExchange(volatile LPLONG Target, LONG Value)
+{
+ __sync_synchronize();
+ return __sync_lock_test_and_set(Target, Value);
+}
+
+__forceinline PVOID WINAPI InterlockedExchangePointer(volatile PVOID* Target, PVOID Value)
+{
+ __sync_synchronize();
+ return (PVOID)__sync_lock_test_and_set(Target, Value);
+}
+
+// -------------------------------------------------------------------------
+
+__forceinline LONG WINAPI InterlockedExchangeAdd(volatile LPLONG Addend, LONG Value)
+{
+ return __sync_fetch_and_add(Addend, Value);
+}
+
+// -------------------------------------------------------------------------
+
+__forceinline PVOID WINAPI InterlockedCompareExchange(
+ volatile LPLONG Destination, LONG Exchange, LONG Comperand)
+{
+ return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
+}
+
+__forceinline PVOID WINAPI InterlockedCompareExchangePointer(
+ volatile PVOID* Destination, PVOID Exchange, PVOID Comperand)
+{
+ return (PVOID)__sync_val_compare_and_swap(Destination, Comperand, Exchange);
+}
+
+// -------------------------------------------------------------------------
+// $Log: $
+
+#endif /* BOOST_MEMORY_WINAPI_ATOMIC_ATOMIC_BUILTINS_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 09:45:33 EDT (Mon, 05 May 2008)
@@ -34,6 +34,10 @@
#include "posix/pthread.hpp"
#endif
+#ifndef BOOST_MEMORY_WINAPI_ATOMIC_ATOMIC_BUILTINS_HPP
+#include "atomic/atomic_builtins.hpp"
+#endif
+
#endif
// -------------------------------------------------------------------------
Modified: sandbox/memory/libs/memory/test/test_basic/test.dsp
==============================================================================
--- sandbox/memory/libs/memory/test/test_basic/test.dsp (original)
+++ sandbox/memory/libs/memory/test/test_basic/test.dsp 2008-05-05 09:45:33 EDT (Mon, 05 May 2008)
@@ -42,7 +42,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../../../../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
@@ -51,7 +51,7 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"../lib"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"../../lib"
!ELSEIF "$(CFG)" == "test - Win32 Debug"
@@ -67,7 +67,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
@@ -76,7 +76,7 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../lib"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../lib"
!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