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 // Permission to copy, use, modify, sell and distribute this software
16 // is granted provided this copyright notice appears in all copies.
17 // This software is provided "as is" without express or implied
18 // warranty, and with no claim as to its suitability for any purpose.
21 #ifdef BOOST_USE_WINDOWS_H
31 #ifndef BOOST_USE_WINDOWS_H
35 // Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users]
37 extern "C" long_type __cdecl _InterlockedIncrement(long volatile *);
38 extern "C" long_type __cdecl _InterlockedDecrement(long volatile *);
40 #pragma intrinsic(_InterlockedIncrement)
41 #pragma intrinsic(_InterlockedDecrement)
43 inline long InterlockedIncrement(long volatile * lp)
45 return _InterlockedIncrement(lp);
48 inline long InterlockedDecrement(long volatile* lp)
50 return _InterlockedDecrement(lp);
55 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement(long volatile *);
56 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement(long volatile *);
60 #endif // #ifndef BOOST_USE_WINDOWS_H
66 explicit atomic_count(long v): value_(v)
72 // Some older <windows.h> versions do not accept volatile
73 return InterlockedIncrement(const_cast<long*>(&value_));
78 return InterlockedDecrement(const_cast<long*>(&value_));
88 atomic_count(atomic_count const &);
89 atomic_count & operator=(atomic_count const &);
98 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED