2005-03-18 01:27:11 +00:00
|
|
|
#ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
|
|
|
|
#define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
|
|
|
|
|
|
|
|
// MS compatible compilers support #pragma once
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
|
|
# pragma once
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// boost/detail/interlocked.hpp
|
|
|
|
//
|
|
|
|
// Copyright 2005 Peter Dimov
|
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <boost/config.hpp>
|
|
|
|
|
|
|
|
#if defined( BOOST_USE_WINDOWS_H )
|
|
|
|
|
|
|
|
# include <windows.h>
|
|
|
|
|
2005-09-07 15:02:16 +00:00
|
|
|
# define BOOST_INTERLOCKED_INCREMENT ::InterlockedIncrement
|
|
|
|
# define BOOST_INTERLOCKED_DECREMENT ::InterlockedDecrement
|
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::InterlockedCompareExchange
|
|
|
|
# define BOOST_INTERLOCKED_EXCHANGE ::InterlockedExchange
|
2005-09-13 09:37:02 +00:00
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::InterlockedCompareExchangePointer
|
2005-03-18 01:27:11 +00:00
|
|
|
|
|
|
|
#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
|
|
|
|
|
|
|
|
extern "C" long __cdecl _InterlockedIncrement( long volatile * );
|
|
|
|
extern "C" long __cdecl _InterlockedDecrement( long volatile * );
|
|
|
|
extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
|
2005-09-07 15:02:16 +00:00
|
|
|
extern "C" long __cdecl _InterlockedExchange( long volatile *, long);
|
2005-09-13 09:37:02 +00:00
|
|
|
extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* );
|
2005-03-18 01:27:11 +00:00
|
|
|
|
|
|
|
# pragma intrinsic( _InterlockedIncrement )
|
|
|
|
# pragma intrinsic( _InterlockedDecrement )
|
|
|
|
# pragma intrinsic( _InterlockedCompareExchange )
|
2005-09-07 15:02:16 +00:00
|
|
|
# pragma intrinsic( _InterlockedExchange )
|
2005-09-13 09:37:02 +00:00
|
|
|
# pragma intrinsic( _InterlockedCompareExchangePointer )
|
2005-03-18 01:27:11 +00:00
|
|
|
|
2005-09-07 15:02:16 +00:00
|
|
|
# define BOOST_INTERLOCKED_INCREMENT ::_InterlockedIncrement
|
|
|
|
# define BOOST_INTERLOCKED_DECREMENT ::_InterlockedDecrement
|
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::_InterlockedCompareExchange
|
|
|
|
# define BOOST_INTERLOCKED_EXCHANGE ::_InterlockedExchange
|
2005-09-13 09:37:02 +00:00
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::_InterlockedCompareExchangePointer
|
2005-03-18 01:27:11 +00:00
|
|
|
|
|
|
|
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
|
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
|
|
|
extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
|
|
|
|
extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
|
|
|
|
extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
|
2005-09-07 15:02:16 +00:00
|
|
|
extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
|
2005-09-13 09:37:02 +00:00
|
|
|
extern "C" __declspec(dllimport) void* __stdcall InterlockedCompareExchangePointer( void* volatile *, void*, void* );
|
2005-03-18 01:27:11 +00:00
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
} // namespace boost
|
|
|
|
|
2005-09-07 15:02:16 +00:00
|
|
|
# define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
|
|
|
|
# define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
|
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange
|
|
|
|
# define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
|
2005-09-13 09:37:02 +00:00
|
|
|
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::boost::detail::InterlockedCompareExchangePointer
|
2005-03-18 01:27:11 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# error "Interlocked intrinsics not available"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-09-13 09:37:02 +00:00
|
|
|
#define BOOST_INTERLOCKED_READ(x) BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0)
|
|
|
|
#define BOOST_INTERLOCKED_READ_POINTER(x) BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0)
|
|
|
|
|
|
|
|
|
2005-03-18 01:27:11 +00:00
|
|
|
#endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
|