YouCompleteMe/cpp/BoostParts/boost/thread/win32/interlocked_read.hpp

83 lines
2.1 KiB
C++
Raw Normal View History

2012-05-10 00:45:30 -04:00
#ifndef BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
#define BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
// interlocked_read_win32.hpp
//
2013-01-13 17:38:19 -05:00
// (C) Copyright 2005-8 Anthony Williams
// (C) Copyright 2012 Vicente J. Botet Escriba
2012-05-10 00:45:30 -04:00
//
// 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/detail/interlocked.hpp>
2013-01-13 17:38:19 -05:00
#include <boost/thread/detail/config.hpp>
2012-05-10 00:45:30 -04:00
#include <boost/config/abi_prefix.hpp>
#ifdef BOOST_MSVC
extern "C" void _ReadWriteBarrier(void);
#pragma intrinsic(_ReadWriteBarrier)
namespace boost
{
namespace detail
{
2013-01-13 17:38:19 -05:00
inline long interlocked_read_acquire(long volatile* x) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
long const res=*x;
_ReadWriteBarrier();
return res;
}
2013-01-13 17:38:19 -05:00
inline void* interlocked_read_acquire(void* volatile* x) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
void* const res=*x;
_ReadWriteBarrier();
return res;
}
2013-01-13 17:38:19 -05:00
inline void interlocked_write_release(long volatile* x,long value) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
_ReadWriteBarrier();
*x=value;
}
2013-01-13 17:38:19 -05:00
inline void interlocked_write_release(void* volatile* x,void* value) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
_ReadWriteBarrier();
*x=value;
}
}
}
#else
namespace boost
{
namespace detail
{
2013-01-13 17:38:19 -05:00
inline long interlocked_read_acquire(long volatile* x) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
}
2013-01-13 17:38:19 -05:00
inline void* interlocked_read_acquire(void* volatile* x) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
}
2013-01-13 17:38:19 -05:00
inline void interlocked_write_release(long volatile* x,long value) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
BOOST_INTERLOCKED_EXCHANGE(x,value);
}
2013-01-13 17:38:19 -05:00
inline void interlocked_write_release(void* volatile* x,void* value) BOOST_NOEXCEPT
2012-05-10 00:45:30 -04:00
{
BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value);
}
}
}
#endif
#include <boost/config/abi_suffix.hpp>
#endif