fixing stuff
[dyninst.git] / dynutil / h / dyn_detail / boost / detail / interlocked.hpp
1 #ifndef DYN_DETAIL_BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
2 #define DYN_DETAIL_BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED
3
4 // MS compatible compilers support #pragma once
5
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7 # pragma once
8 #endif
9
10 //
11 //  boost/detail/interlocked.hpp
12 //
13 //  Copyright 2005 Peter Dimov
14 //
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)
18 //
19
20 #include <dyn_detail/boost/config.hpp>
21
22 #if defined( DYN_DETAIL_BOOST_USE_WINDOWS_H )
23
24 # include <windows.h>
25
26 # define DYN_DETAIL_BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
27 # define DYN_DETAIL_BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
28 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
29 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
30 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
31 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer
32 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer
33
34 #elif defined(_WIN32_WCE)
35
36 // under Windows CE we still have old-style Interlocked* functions
37
38 extern "C" long __cdecl InterlockedIncrement( long* );
39 extern "C" long __cdecl InterlockedDecrement( long* );
40 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
41 extern "C" long __cdecl InterlockedExchange( long*, long );
42 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
43
44 # define DYN_DETAIL_BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
45 # define DYN_DETAIL_BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
46 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
47 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
48 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
49
50 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
51     ((void*)DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare)))
52 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
53     ((void*)DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange)))
54
55 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
56
57 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
58 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
59 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
60 extern "C" long __cdecl _InterlockedExchange( long volatile *, long);
61 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long);
62
63 # pragma intrinsic( _InterlockedIncrement )
64 # pragma intrinsic( _InterlockedDecrement )
65 # pragma intrinsic( _InterlockedCompareExchange )
66 # pragma intrinsic( _InterlockedExchange )
67 # pragma intrinsic( _InterlockedExchangeAdd )
68
69 # if defined(_M_IA64) || defined(_M_AMD64)
70
71 extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* );
72 extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* );
73
74 #  pragma intrinsic( _InterlockedCompareExchangePointer )
75 #  pragma intrinsic( _InterlockedExchangePointer )
76
77 #  define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer
78 #  define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer
79
80 # else
81
82 #  define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
83     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))
84 #  define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
85     ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))
86
87 # endif
88
89 # define DYN_DETAIL_BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement
90 # define DYN_DETAIL_BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement
91 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
92 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange
93 # define BDYN_DETAIL_OOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
94
95 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
96 namespace dyn_detail
97 {
98   
99 namespace boost
100 {
101
102 namespace detail
103 {
104
105 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
106 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
107 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
108 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
109 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
110
111 } // namespace detail
112
113 } // namespace boost
114
115 } // namespace dyn_detail
116
117 # define DYN_DETAIL_BOOST_INTERLOCKED_INCREMENT ::dyn_detail::boost::detail::InterlockedIncrement
118 # define DYN_DETAIL_BOOST_INTERLOCKED_DECREMENT ::dyn_detail::boost::detail::InterlockedDecrement
119 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE ::dyn_detail::boost::detail::InterlockedCompareExchange
120 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE ::dyn_detail::boost::detail::InterlockedExchange
121 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_ADD ::dyn_detail::boost::detail::InterlockedExchangeAdd
122
123 # define DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
124     ((void*)DYN_DETAIL_BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))
125 # define DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
126     ((void*)DYN_DETAIL_BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))
127
128 #else
129
130 # error "Interlocked intrinsics not available"
131
132 #endif
133
134 #endif // #ifndef DYN_DETAIL_BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED