Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/detail/interlocked.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED | |
2 #define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED | |
3 | |
4 // | |
5 // boost/detail/interlocked.hpp | |
6 // | |
7 // Copyright 2005 Peter Dimov | |
8 // | |
9 // Distributed under the Boost Software License, Version 1.0. (See | |
10 // accompanying file LICENSE_1_0.txt or copy at | |
11 // http://www.boost.org/LICENSE_1_0.txt) | |
12 // | |
13 | |
14 #include <boost/config.hpp> | |
15 | |
16 // MS compatible compilers support #pragma once | |
17 #ifdef BOOST_HAS_PRAGMA_ONCE | |
18 #pragma once | |
19 #endif | |
20 | |
21 #if defined( BOOST_USE_WINDOWS_H ) | |
22 | |
23 # include <windows.h> | |
24 | |
25 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement | |
26 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement | |
27 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange | |
28 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange | |
29 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd | |
30 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer | |
31 # define BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer | |
32 | |
33 #elif defined( BOOST_USE_INTRIN_H ) | |
34 | |
35 #include <intrin.h> | |
36 | |
37 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement | |
38 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement | |
39 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange | |
40 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange | |
41 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd | |
42 | |
43 # if defined(_M_IA64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__x86_64) | |
44 | |
45 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer | |
46 # define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer | |
47 | |
48 # else | |
49 | |
50 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ | |
51 ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) | |
52 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ | |
53 ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) | |
54 | |
55 # endif | |
56 | |
57 #elif defined(_WIN32_WCE) | |
58 | |
59 #if _WIN32_WCE >= 0x600 | |
60 | |
61 extern "C" long __cdecl _InterlockedIncrement( long volatile * ); | |
62 extern "C" long __cdecl _InterlockedDecrement( long volatile * ); | |
63 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); | |
64 extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); | |
65 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); | |
66 | |
67 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement | |
68 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement | |
69 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange | |
70 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange | |
71 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd | |
72 | |
73 #else | |
74 // under Windows CE we still have old-style Interlocked* functions | |
75 | |
76 extern "C" long __cdecl InterlockedIncrement( long* ); | |
77 extern "C" long __cdecl InterlockedDecrement( long* ); | |
78 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); | |
79 extern "C" long __cdecl InterlockedExchange( long*, long ); | |
80 extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); | |
81 | |
82 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement | |
83 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement | |
84 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange | |
85 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange | |
86 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd | |
87 | |
88 #endif | |
89 | |
90 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ | |
91 ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare))) | |
92 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ | |
93 ((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange))) | |
94 | |
95 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) | |
96 | |
97 #if defined( BOOST_MSVC ) && BOOST_MSVC >= 1500 | |
98 | |
99 #include <intrin.h> | |
100 | |
101 #elif defined( __CLRCALL_PURE_OR_CDECL ) | |
102 | |
103 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); | |
104 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); | |
105 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); | |
106 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); | |
107 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); | |
108 | |
109 #else | |
110 | |
111 extern "C" long __cdecl _InterlockedIncrement( long volatile * ); | |
112 extern "C" long __cdecl _InterlockedDecrement( long volatile * ); | |
113 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); | |
114 extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); | |
115 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); | |
116 | |
117 #endif | |
118 | |
119 # if defined(_M_IA64) || defined(_M_AMD64) | |
120 | |
121 extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* ); | |
122 extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* ); | |
123 | |
124 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer | |
125 # define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer | |
126 | |
127 # else | |
128 | |
129 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ | |
130 ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) | |
131 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ | |
132 ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) | |
133 | |
134 # endif | |
135 | |
136 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement | |
137 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement | |
138 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange | |
139 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange | |
140 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd | |
141 | |
142 // Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. | |
143 #elif defined(__MINGW64_VERSION_MAJOR) | |
144 | |
145 // MinGW-w64 provides intrin.h for both 32 and 64-bit targets. | |
146 #include <intrin.h> | |
147 | |
148 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement | |
149 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement | |
150 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange | |
151 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange | |
152 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd | |
153 # if defined(__x86_64__) || defined(__x86_64) | |
154 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer | |
155 # define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer | |
156 # else | |
157 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ | |
158 ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) | |
159 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ | |
160 ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) | |
161 # endif | |
162 | |
163 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) | |
164 | |
165 #define BOOST_INTERLOCKED_IMPORT __declspec(dllimport) | |
166 | |
167 namespace boost | |
168 { | |
169 | |
170 namespace detail | |
171 { | |
172 | |
173 extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedIncrement( long volatile * ); | |
174 extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedDecrement( long volatile * ); | |
175 extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedCompareExchange( long volatile *, long, long ); | |
176 extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchange( long volatile *, long ); | |
177 extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchangeAdd( long volatile *, long ); | |
178 | |
179 # if defined(_M_IA64) || defined(_M_AMD64) | |
180 extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedCompareExchangePointer( void* volatile *, void*, void* ); | |
181 extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedExchangePointer( void* volatile *, void* ); | |
182 # endif | |
183 | |
184 } // namespace detail | |
185 | |
186 } // namespace boost | |
187 | |
188 # define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement | |
189 # define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement | |
190 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange | |
191 # define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange | |
192 # define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd | |
193 | |
194 # if defined(_M_IA64) || defined(_M_AMD64) | |
195 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::boost::detail::InterlockedCompareExchangePointer | |
196 # define BOOST_INTERLOCKED_EXCHANGE_POINTER ::boost::detail::InterlockedExchangePointer | |
197 # else | |
198 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ | |
199 ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) | |
200 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ | |
201 ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) | |
202 # endif | |
203 | |
204 #else | |
205 | |
206 # error "Interlocked intrinsics not available" | |
207 | |
208 #endif | |
209 | |
210 #endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED |