PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/boost/thread/win32/interlocked_read.hpp

http://hadesmem.googlecode.com/
C++ Header | 80 lines | 61 code | 12 blank | 7 comment | 0 complexity | a0c1e4d0e6653bde3b538da5ff97472b MD5 | raw file
 1#ifndef BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
 2#define BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
 3
 4//  interlocked_read_win32.hpp
 5//
 6//  (C) Copyright 2005-8 Anthony Williams 
 7//
 8//  Distributed under the Boost Software License, Version 1.0. (See
 9//  accompanying file LICENSE_1_0.txt or copy at
10//  http://www.boost.org/LICENSE_1_0.txt)
11
12#include <boost/detail/interlocked.hpp>
13
14#include <boost/config/abi_prefix.hpp>
15
16#ifdef BOOST_MSVC
17
18extern "C" void _ReadWriteBarrier(void);
19#pragma intrinsic(_ReadWriteBarrier)
20
21namespace boost
22{
23    namespace detail
24    {
25        inline long interlocked_read_acquire(long volatile* x)
26        {
27            long const res=*x;
28            _ReadWriteBarrier();
29            return res;
30        }
31        inline void* interlocked_read_acquire(void* volatile* x)
32        {
33            void* const res=*x;
34            _ReadWriteBarrier();
35            return res;
36        }
37
38        inline void interlocked_write_release(long volatile* x,long value)
39        {
40            _ReadWriteBarrier();
41            *x=value;
42        }
43        inline void interlocked_write_release(void* volatile* x,void* value)
44        {
45            _ReadWriteBarrier();
46            *x=value;
47        }
48    }
49}
50
51#else
52
53namespace boost
54{
55    namespace detail
56    {
57        inline long interlocked_read_acquire(long volatile* x)
58        {
59            return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
60        }
61        inline void* interlocked_read_acquire(void* volatile* x)
62        {
63            return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
64        }
65        inline void interlocked_write_release(long volatile* x,long value)
66        {
67            BOOST_INTERLOCKED_EXCHANGE(x,value);
68        }
69        inline void interlocked_write_release(void* volatile* x,void* value)
70        {
71            BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value);
72        }
73    }
74}
75
76#endif
77
78#include <boost/config/abi_suffix.hpp>
79
80#endif