1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
2 #define BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // boost/detail/atomic_count_win32.hpp
13 // Copyright (c) 2001, 2002, 2003 Peter Dimov
15 // Distributed under the Boost Software License, Version 1.0. (See
16 // accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifdef BOOST_USE_WINDOWS_H
30 #ifndef BOOST_USE_WINDOWS_H
34 // Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users]
36 extern "C" long_type __cdecl _InterlockedIncrement(long volatile *);
37 extern "C" long_type __cdecl _InterlockedDecrement(long volatile *);
39 #pragma intrinsic(_InterlockedIncrement)
40 #pragma intrinsic(_InterlockedDecrement)
42 inline long InterlockedIncrement(long volatile * lp)
44 return _InterlockedIncrement(lp);
47 inline long InterlockedDecrement(long volatile* lp)
49 return _InterlockedDecrement(lp);
54 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement(long volatile *);
55 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement(long volatile *);
59 #endif // #ifndef BOOST_USE_WINDOWS_H
65 explicit atomic_count(long v): value_(v)
71 // Some older <windows.h> versions do not accept volatile
72 return InterlockedIncrement(const_cast<long*>(&value_));
77 return InterlockedDecrement(const_cast<long*>(&value_));
87 atomic_count(atomic_count const &);
88 atomic_count & operator=(atomic_count const &);
97 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED