]> git.lyx.org Git - lyx.git/blob - 3rdparty/boost/boost/smart_ptr/detail/sp_interlocked.hpp
move boost to 3rdparty directory
[lyx.git] / 3rdparty / boost / boost / smart_ptr / detail / sp_interlocked.hpp
1 #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SP_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/sp_interlocked.hpp
12 //
13 //  Copyright 2005, 2014 Peter Dimov
14 //
15 //  Distributed under the Boost Software License, Version 1.0.
16 //  See accompanying file LICENSE_1_0.txt or copy at
17 //  http://www.boost.org/LICENSE_1_0.txt
18 //
19
20 #include <boost/config.hpp>
21
22 // BOOST_SP_HAS_INTRIN_H
23
24 // VC9 has intrin.h, but it collides with <utility>
25 #if defined( BOOST_MSVC ) && BOOST_MSVC >= 1600
26
27 # define BOOST_SP_HAS_INTRIN_H
28
29 // Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets.
30 #elif defined( __MINGW64_VERSION_MAJOR )
31
32 // MinGW-w64 provides intrin.h for both 32 and 64-bit targets.
33 # define BOOST_SP_HAS_INTRIN_H
34
35 // Intel C++ on Windows on VC10+ stdlib
36 #elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
37
38 # define BOOST_SP_HAS_INTRIN_H
39
40 #endif
41
42 #if defined( BOOST_USE_WINDOWS_H )
43
44 # include <windows.h>
45
46 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
47 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
48 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
49 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
50 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
51
52 #elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H )
53
54 #include <intrin.h>
55
56 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
57 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
58 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
59 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
60 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
61
62 #elif defined( _WIN32_WCE )
63
64 #if _WIN32_WCE >= 0x600
65
66 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
67 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
68 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
69 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
70 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
71
72 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
73 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
74 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
75 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
76 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
77
78 #else
79
80 // under Windows CE we still have old-style Interlocked* functions
81
82 extern "C" long __cdecl InterlockedIncrement( long* );
83 extern "C" long __cdecl InterlockedDecrement( long* );
84 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
85 extern "C" long __cdecl InterlockedExchange( long*, long );
86 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
87
88 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
89 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
90 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
91 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
92 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
93
94 #endif
95
96 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
97
98 #if defined( __CLRCALL_PURE_OR_CDECL )
99
100 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * );
101 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * );
102 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long );
103 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long );
104 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long );
105
106 #else
107
108 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
109 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
110 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
111 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
112 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
113
114 #endif
115
116 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
117 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
118 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
119 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
120 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
121
122 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
123
124 namespace boost
125 {
126
127 namespace detail
128 {
129
130 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
131 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
132 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
133 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
134 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
135
136 } // namespace detail
137
138 } // namespace boost
139
140 # define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
141 # define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
142 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange
143 # define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
144 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd
145
146 #else
147
148 # error "Interlocked intrinsics not available"
149
150 #endif
151
152 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED