1
#ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
2
#define BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
9
// boost/detail/atomic_count_win32.hpp
11
// Copyright (c) 2001, 2002, 2003 Peter Dimov
13
// Permission to copy, use, modify, sell and distribute this software
14
// is granted provided this copyright notice appears in all copies.
15
// This software is provided "as is" without express or implied
16
// warranty, and with no claim as to its suitability for any purpose.
19
#ifdef BOOST_USE_WINDOWS_H
29
#ifndef BOOST_USE_WINDOWS_H
33
// Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users]
35
extern "C" long_type __cdecl _InterlockedIncrement(long volatile *);
36
extern "C" long_type __cdecl _InterlockedDecrement(long volatile *);
38
#pragma intrinsic(_InterlockedIncrement)
39
#pragma intrinsic(_InterlockedDecrement)
41
inline long InterlockedIncrement(long volatile * lp)
43
return _InterlockedIncrement(lp);
46
inline long InterlockedDecrement(long volatile* lp)
48
return _InterlockedDecrement(lp);
53
extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement(long volatile *);
54
extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement(long volatile *);
58
#endif // #ifndef BOOST_USE_WINDOWS_H
64
explicit atomic_count(long v): value_(v)
70
// Some older <windows.h> versions do not accept volatile
71
return InterlockedIncrement(const_cast<long*>(&value_));
76
return InterlockedDecrement(const_cast<long*>(&value_));
86
atomic_count(atomic_count const &);
87
atomic_count & operator=(atomic_count const &);
96
#endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED