interlocked.hpp
Go to the documentation of this file.
00001 #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
00002 #define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
00003 
00004 // MS compatible compilers support #pragma once
00005 
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009 
00010 //
00011 //  boost/detail/interlocked.hpp
00012 //
00013 //  Copyright 2005 Peter Dimov
00014 //
00015 //  Distributed under the Boost Software License, Version 1.0. (See
00016 //  accompanying file LICENSE_1_0.txt or copy at
00017 //  http://www.boost.org/LICENSE_1_0.txt)
00018 //
00019 
00020 #include <boost/config.hpp>
00021 
00022 #if defined( BOOST_USE_WINDOWS_H )
00023 
00024 # include <windows.h>
00025 
00026 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
00027 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
00028 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
00029 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
00030 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
00031 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer
00032 # define BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer
00033 
00034 #elif defined(_WIN32_WCE)
00035 
00036 // under Windows CE we still have old-style Interlocked* functions
00037 
00038 extern "C" long __cdecl InterlockedIncrement( long* );
00039 extern "C" long __cdecl InterlockedDecrement( long* );
00040 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
00041 extern "C" long __cdecl InterlockedExchange( long*, long );
00042 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
00043 
00044 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
00045 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
00046 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
00047 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
00048 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
00049 
00050 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
00051     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare)))
00052 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
00053     ((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange)))
00054 
00055 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
00056 
00057 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
00058 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
00059 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
00060 extern "C" long __cdecl _InterlockedExchange( long volatile *, long);
00061 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long);
00062 
00063 # pragma intrinsic( _InterlockedIncrement )
00064 # pragma intrinsic( _InterlockedDecrement )
00065 # pragma intrinsic( _InterlockedCompareExchange )
00066 # pragma intrinsic( _InterlockedExchange )
00067 # pragma intrinsic( _InterlockedExchangeAdd )
00068 
00069 # if defined(_M_IA64) || defined(_M_AMD64)
00070 
00071 extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* );
00072 extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* );
00073 
00074 #  pragma intrinsic( _InterlockedCompareExchangePointer )
00075 #  pragma intrinsic( _InterlockedExchangePointer )
00076 
00077 #  define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer
00078 #  define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer
00079 
00080 # else
00081 
00082 #  define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
00083     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))
00084 #  define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
00085     ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))
00086 
00087 # endif
00088 
00089 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement
00090 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement
00091 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
00092 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange
00093 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
00094 
00095 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
00096 
00097 namespace boost
00098 {
00099 
00100 namespace detail
00101 {
00102 
00103 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
00104 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
00105 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
00106 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
00107 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
00108 
00109 } // namespace detail
00110 
00111 } // namespace boost
00112 
00113 # define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
00114 # define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
00115 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange
00116 # define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
00117 # define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd
00118 
00119 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
00120     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))
00121 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
00122     ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))
00123 
00124 #else
00125 
00126 # error "Interlocked intrinsics not available"
00127 
00128 #endif
00129 
00130 #endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29