File indexing completed on 2025-01-18 09:51:43
0001 #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED
0003
0004
0005
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <boost/config.hpp>
0021
0022
0023
0024
0025 #if defined( BOOST_MSVC ) && BOOST_MSVC >= 1600
0026
0027 # define BOOST_SP_HAS_INTRIN_H
0028
0029
0030 #elif defined( __MINGW64_VERSION_MAJOR )
0031
0032
0033 # define BOOST_SP_HAS_INTRIN_H
0034
0035 #elif defined( __LP64__ )
0036
0037
0038 # define BOOST_SP_HAS_INTRIN_H
0039
0040
0041 #elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
0042
0043 # define BOOST_SP_HAS_INTRIN_H
0044
0045
0046 #elif defined( __clang__ ) && defined( _MSC_VER ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
0047
0048 # define BOOST_SP_HAS_INTRIN_H
0049
0050 #endif
0051
0052 #if defined( BOOST_USE_WINDOWS_H )
0053
0054 # include <windows.h>
0055
0056 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
0057 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
0058 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
0059 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
0060 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
0061
0062 #elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H )
0063
0064 #include <intrin.h>
0065
0066 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
0067 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
0068 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
0069 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
0070 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
0071
0072 #elif defined( _WIN32_WCE )
0073
0074 #if _WIN32_WCE >= 0x600
0075
0076 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
0077 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
0078 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
0079 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
0080 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
0081
0082 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
0083 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
0084 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
0085 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
0086 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
0087
0088 #else
0089
0090
0091
0092 extern "C" long __cdecl InterlockedIncrement( long* );
0093 extern "C" long __cdecl InterlockedDecrement( long* );
0094 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
0095 extern "C" long __cdecl InterlockedExchange( long*, long );
0096 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
0097
0098 # define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement
0099 # define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement
0100 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
0101 # define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange
0102 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
0103
0104 #endif
0105
0106 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
0107
0108 #if defined( __CLRCALL_PURE_OR_CDECL )
0109
0110 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * );
0111 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * );
0112 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long );
0113 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long );
0114 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long );
0115
0116 #else
0117
0118 extern "C" long __cdecl _InterlockedIncrement( long volatile * );
0119 extern "C" long __cdecl _InterlockedDecrement( long volatile * );
0120 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
0121 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
0122 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
0123
0124 # if defined( BOOST_MSVC ) && BOOST_MSVC == 1310
0125
0126
0127
0128 # pragma intrinsic( _InterlockedIncrement )
0129 # pragma intrinsic( _InterlockedDecrement )
0130 # pragma intrinsic( _InterlockedCompareExchange )
0131 # pragma intrinsic( _InterlockedExchange )
0132 # pragma intrinsic( _InterlockedExchangeAdd )
0133 # endif
0134
0135 #endif
0136
0137 # define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement
0138 # define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement
0139 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
0140 # define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange
0141 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
0142
0143 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
0144
0145 namespace boost
0146 {
0147
0148 namespace detail
0149 {
0150
0151 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
0152 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
0153 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
0154 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
0155 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
0156
0157 }
0158
0159 }
0160
0161 # define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
0162 # define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
0163 # define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange
0164 # define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
0165 # define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd
0166
0167 #else
0168
0169 # error "Interlocked intrinsics not available"
0170
0171 #endif
0172
0173 #endif