]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/detail/interlocked.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
e3f508622582a4f71aa81effcd042eb06d63bf73
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / detail / interlocked.hpp
1 #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED\r
2 #define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED\r
3 \r
4 // MS compatible compilers support #pragma once\r
5 \r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
7 # pragma once\r
8 #endif\r
9 \r
10 //\r
11 //  boost/detail/interlocked.hpp\r
12 //\r
13 //  Copyright 2005 Peter Dimov\r
14 //\r
15 //  Distributed under the Boost Software License, Version 1.0. (See\r
16 //  accompanying file LICENSE_1_0.txt or copy at\r
17 //  http://www.boost.org/LICENSE_1_0.txt)\r
18 //\r
19 \r
20 #include <boost/config.hpp>\r
21 \r
22 #if defined( BOOST_USE_WINDOWS_H )\r
23 \r
24 # include <windows.h>\r
25 \r
26 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement\r
27 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement\r
28 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange\r
29 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange\r
30 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd\r
31 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer\r
32 # define BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer\r
33 \r
34 #elif defined(_WIN32_WCE)\r
35 \r
36 // under Windows CE we still have old-style Interlocked* functions\r
37 \r
38 extern "C" long __cdecl InterlockedIncrement( long* );\r
39 extern "C" long __cdecl InterlockedDecrement( long* );\r
40 extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );\r
41 extern "C" long __cdecl InterlockedExchange( long*, long );\r
42 extern "C" long __cdecl InterlockedExchangeAdd( long*, long );\r
43 \r
44 # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement\r
45 # define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement\r
46 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange\r
47 # define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange\r
48 # define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd\r
49 \r
50 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \\r
51     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare)))\r
52 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \\r
53     ((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange)))\r
54 \r
55 #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )\r
56 \r
57 #if defined( __CLRCALL_PURE_OR_CDECL )\r
58 \r
59 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * );\r
60 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * );\r
61 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long );\r
62 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long );\r
63 extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long );\r
64 \r
65 #else\r
66 \r
67 extern "C" long __cdecl _InterlockedIncrement( long volatile * );\r
68 extern "C" long __cdecl _InterlockedDecrement( long volatile * );\r
69 extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );\r
70 extern "C" long __cdecl _InterlockedExchange( long volatile *, long );\r
71 extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );\r
72 \r
73 #endif\r
74 \r
75 # pragma intrinsic( _InterlockedIncrement )\r
76 # pragma intrinsic( _InterlockedDecrement )\r
77 # pragma intrinsic( _InterlockedCompareExchange )\r
78 # pragma intrinsic( _InterlockedExchange )\r
79 # pragma intrinsic( _InterlockedExchangeAdd )\r
80 \r
81 # if defined(_M_IA64) || defined(_M_AMD64)\r
82 \r
83 extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* );\r
84 extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* );\r
85 \r
86 #  pragma intrinsic( _InterlockedCompareExchangePointer )\r
87 #  pragma intrinsic( _InterlockedExchangePointer )\r
88 \r
89 #  define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer\r
90 #  define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer\r
91 \r
92 # else\r
93 \r
94 #  define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \\r
95     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))\r
96 #  define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \\r
97     ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))\r
98 \r
99 # endif\r
100 \r
101 # define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement\r
102 # define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement\r
103 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange\r
104 # define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange\r
105 # define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd\r
106 \r
107 #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )\r
108 \r
109 namespace boost\r
110 {\r
111 \r
112 namespace detail\r
113 {\r
114 \r
115 extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );\r
116 extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );\r
117 extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );\r
118 extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );\r
119 extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );\r
120 \r
121 } // namespace detail\r
122 \r
123 } // namespace boost\r
124 \r
125 # define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement\r
126 # define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement\r
127 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange\r
128 # define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange\r
129 # define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd\r
130 \r
131 # define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \\r
132     ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))\r
133 # define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \\r
134     ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))\r
135 \r
136 #else\r
137 \r
138 # error "Interlocked intrinsics not available"\r
139 \r
140 #endif\r
141 \r
142 #endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED\r