]> git.lyx.org Git - lyx.git/blob - 3rdparty/boost/boost/smart_ptr/detail/sp_interlocked.hpp
Update to boost 1.68
[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 #elif defined( __LP64__ )
36
37 // We have to use intrin.h on Cygwin 64
38 # define BOOST_SP_HAS_INTRIN_H
39
40 // Intel C++ on Windows on VC10+ stdlib
41 #elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
42
43 # define BOOST_SP_HAS_INTRIN_H
44
45 #endif
46
47 #if defined( BOOST_USE_WINDOWS_H )
48
49 # include <windows.h>
50
51 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
52 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
53 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
54 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
55 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
56
57 #elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H )
58
59 #include <intrin.h>
60
61 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
62 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
63 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
64 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
65 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
66
67 #elif defined( _WIN32_WCE )
68
69 #if _WIN32_WCE >= 0x600
70
71 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
72 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
73 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
74 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
75 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
76
77 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
78 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
79 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
80 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
81 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
82
83 #else
84
85 // under Windows CE we still have old-style Interlocked* functions
86
87 extern "C" long __cdecl InterlockedIncrement( long* );
88 extern "C" long __cdecl InterlockedDecrement( long* );
89 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
90 extern "C" long __cdecl InterlockedExchange( long*, long );
91 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
92
93 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
94 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
95 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
96 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
97 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
98
99 #endif
100
101 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
102
103 #if defined( __CLRCALL_PURE_OR_CDECL )
104
105 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * );
106 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * );
107 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long );
108 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long );
109 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long );
110
111 #else
112
113 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
114 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
115 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
116 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
117 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
118
119 # if defined( BOOST_MSVC ) && BOOST_MSVC == 1310
120 //From MSDN, Visual Studio .NET 2003 spedific: To declare one of the interlocked functions
121 //for use as an intrinsic, the function must be declared with the leading underscore and
122 //the new function must appear in a #pragma intrinsic statement.
123 #  pragma intrinsic( _InterlockedIncrement )
124 #  pragma intrinsic( _InterlockedDecrement )
125 #  pragma intrinsic( _InterlockedCompareExchange )
126 #  pragma intrinsic( _InterlockedExchange )
127 #  pragma intrinsic( _InterlockedExchangeAdd )
128 # endif
129
130 #endif
131
132 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
133 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
134 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
135 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
136 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
137
138 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
139
140 namespace boost
141 {
142
143 namespace detail
144 {
145
146 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
147 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
148 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
149 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
150 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
151
152 } // namespace detail
153
154 } // namespace boost
155
156 # define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
157 # define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
158 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange
159 # define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
160 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd
161
162 #else
163
164 # error "Interlocked intrinsics not available"
165
166 #endif
167
168 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED