Chris@102: #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED Chris@102: #define BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED Chris@102: Chris@102: // MS compatible compilers support #pragma once Chris@102: Chris@102: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: // Chris@102: // boost/detail/sp_interlocked.hpp Chris@102: // Chris@102: // Copyright 2005, 2014 Peter Dimov Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. Chris@102: // See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt Chris@102: // Chris@102: Chris@102: #include Chris@102: Chris@102: // BOOST_SP_HAS_INTRIN_H Chris@102: Chris@102: // VC9 has intrin.h, but it collides with Chris@102: #if defined( BOOST_MSVC ) && BOOST_MSVC >= 1600 Chris@102: Chris@102: # define BOOST_SP_HAS_INTRIN_H Chris@102: Chris@102: // Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. Chris@102: #elif defined( __MINGW64_VERSION_MAJOR ) Chris@102: Chris@102: // MinGW-w64 provides intrin.h for both 32 and 64-bit targets. Chris@102: # define BOOST_SP_HAS_INTRIN_H Chris@102: Chris@102: // Intel C++ on Windows on VC10+ stdlib Chris@102: #elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520 Chris@102: Chris@102: # define BOOST_SP_HAS_INTRIN_H Chris@102: Chris@102: #endif Chris@102: Chris@102: #if defined( BOOST_USE_WINDOWS_H ) Chris@102: Chris@102: # include Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd Chris@102: Chris@102: #elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H ) Chris@102: Chris@102: #include Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd Chris@102: Chris@102: #elif defined( _WIN32_WCE ) Chris@102: Chris@102: #if _WIN32_WCE >= 0x600 Chris@102: Chris@102: extern "C" long __cdecl _InterlockedIncrement( long volatile * ); Chris@102: extern "C" long __cdecl _InterlockedDecrement( long volatile * ); Chris@102: extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); Chris@102: extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); Chris@102: extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd Chris@102: Chris@102: #else Chris@102: Chris@102: // under Windows CE we still have old-style Interlocked* functions Chris@102: Chris@102: extern "C" long __cdecl InterlockedIncrement( long* ); Chris@102: extern "C" long __cdecl InterlockedDecrement( long* ); Chris@102: extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); Chris@102: extern "C" long __cdecl InterlockedExchange( long*, long ); Chris@102: extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd Chris@102: Chris@102: #endif Chris@102: Chris@102: #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) Chris@102: Chris@102: #if defined( __CLRCALL_PURE_OR_CDECL ) Chris@102: Chris@102: extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); Chris@102: extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); Chris@102: extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); Chris@102: extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); Chris@102: extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); Chris@102: Chris@102: #else Chris@102: Chris@102: extern "C" long __cdecl _InterlockedIncrement( long volatile * ); Chris@102: extern "C" long __cdecl _InterlockedDecrement( long volatile * ); Chris@102: extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); Chris@102: extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); Chris@102: extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); Chris@102: Chris@102: #endif Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd Chris@102: Chris@102: #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) Chris@102: Chris@102: namespace boost Chris@102: { Chris@102: Chris@102: namespace detail Chris@102: { Chris@102: Chris@102: extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * ); Chris@102: extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * ); Chris@102: extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long ); Chris@102: extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long ); Chris@102: extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long ); Chris@102: Chris@102: } // namespace detail Chris@102: Chris@102: } // namespace boost Chris@102: Chris@102: # define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement Chris@102: # define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement Chris@102: # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange Chris@102: # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd Chris@102: Chris@102: #else Chris@102: Chris@102: # error "Interlocked intrinsics not available" Chris@102: Chris@102: #endif Chris@102: Chris@102: #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED