BVB Source Codes

mars Show interlocked.hpp Source code

Return Download mars: download interlocked.hpp Source code - Download mars Source code - Type:.hpp
  1. #ifndef BOOST_ATOMIC_DETAIL_INTERLOCKED_HPP
  2. #define BOOST_ATOMIC_DETAIL_INTERLOCKED_HPP
  3.  
  4. //  Copyright (c) 2009 Helge Bahmann
  5. //  Copyright (c) 2012 - 2014 Andrey Semashev
  6. //
  7. //  Distributed under the Boost Software License, Version 1.0.
  8. //  See accompanying file LICENSE_1_0.txt or copy at
  9. //  http://www.boost.org/LICENSE_1_0.txt)
  10.  
  11. #include <boost/atomic/detail/config.hpp>
  12.  
  13. #ifdef BOOST_HAS_PRAGMA_ONCE
  14. #pragma once
  15. #endif
  16.  
  17. #if defined(_WIN32_WCE)
  18.  
  19. #if _WIN32_WCE >= 0x600
  20.  
  21. extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
  22. extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
  23. extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
  24.  
  25. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) _InterlockedCompareExchange((long*)(dest), exchange, compare)
  26. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) _InterlockedExchangeAdd((long*)(dest), (long)(addend))
  27. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) _InterlockedExchange((long*)(dest), (long)(newval))
  28.  
  29. #else // _WIN32_WCE >= 0x600
  30.  
  31. extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
  32. extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
  33. extern "C" long __cdecl InterlockedExchange( long*, long );
  34.  
  35. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) InterlockedCompareExchange((long*)(dest), exchange, compare)
  36. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) InterlockedExchangeAdd((long*)(dest), (long)(addend))
  37. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) InterlockedExchange((long*)(dest), (long)(newval))
  38.  
  39. #endif // _WIN32_WCE >= 0x600
  40.  
  41. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) ((void*)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest), (long)(exchange), (long)(compare)))
  42. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, exchange) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE((long*)(dest), (long)(exchange)))
  43.  
  44. #elif defined(_MSC_VER) && _MSC_VER >= 1310
  45.  
  46. #if _MSC_VER < 1400
  47.  
  48. extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
  49. extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
  50. extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
  51.  
  52. #if defined(BOOST_MSVC)
  53. #pragma intrinsic(_InterlockedCompareExchange)
  54. #pragma intrinsic(_InterlockedExchangeAdd)
  55. #pragma intrinsic(_InterlockedExchange)
  56. #endif
  57.  
  58. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) _InterlockedCompareExchange((long*)(dest), exchange, compare)
  59. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) _InterlockedExchangeAdd((long*)(dest), (long)(addend))
  60. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) _InterlockedExchange((long*)(dest), (long)(newval))
  61.  
  62. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) ((void*)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest), (long)(exchange), (long)(compare)))
  63. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, exchange) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE((long*)(dest), (long)(exchange)))
  64.  
  65. #else // _MSC_VER < 1400
  66.  
  67. #include <intrin.h>
  68.  
  69. #if defined(BOOST_MSVC)
  70. #pragma intrinsic(_InterlockedCompareExchange)
  71. #pragma intrinsic(_InterlockedExchangeAdd)
  72. #pragma intrinsic(_InterlockedExchange)
  73. #pragma intrinsic(_InterlockedAnd)
  74. #pragma intrinsic(_InterlockedOr)
  75. #pragma intrinsic(_InterlockedXor)
  76. #endif
  77.  
  78. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) _InterlockedCompareExchange((long*)(dest), (long)(exchange), (long)(compare))
  79. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) _InterlockedExchangeAdd((long*)(dest), (long)(addend))
  80. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) _InterlockedExchange((long*)(dest), (long)(newval))
  81. #define BOOST_ATOMIC_INTERLOCKED_AND(dest, arg) _InterlockedAnd((long*)(dest), (long)(arg))
  82. #define BOOST_ATOMIC_INTERLOCKED_OR(dest, arg) _InterlockedOr((long*)(dest), (long)(arg))
  83. #define BOOST_ATOMIC_INTERLOCKED_XOR(dest, arg) _InterlockedXor((long*)(dest), (long)(arg))
  84.  
  85. #if (defined(_M_IX86) && _M_IX86 >= 500) || defined(_M_AMD64) || defined(_M_IA64)
  86. #if defined(BOOST_MSVC)
  87. #pragma intrinsic(_InterlockedCompareExchange64)
  88. #endif
  89. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(dest, exchange, compare) _InterlockedCompareExchange64((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  90. #endif
  91.  
  92. #if _MSC_VER >= 1500 && defined(_M_AMD64)
  93. #if defined(BOOST_MSVC)
  94. #pragma intrinsic(_InterlockedCompareExchange128)
  95. #endif
  96. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE128(dest, exchange, compare) _InterlockedCompareExchange128((__int64*)(dest), ((const __int64*)(&exchange))[1], ((const __int64*)(&exchange))[0], (__int64*)(compare))
  97. #endif
  98.  
  99. #if _MSC_VER >= 1600
  100.  
  101. // MSVC 2010 and later provide intrinsics for 8 and 16 bit integers.
  102. // Note that for each bit count these macros must be either all defined or all not defined.
  103. // Otherwise atomic<> operations will be implemented inconsistently.
  104.  
  105. #if defined(BOOST_MSVC)
  106. #pragma intrinsic(_InterlockedCompareExchange8)
  107. #pragma intrinsic(_InterlockedExchangeAdd8)
  108. #pragma intrinsic(_InterlockedExchange8)
  109. #pragma intrinsic(_InterlockedAnd8)
  110. #pragma intrinsic(_InterlockedOr8)
  111. #pragma intrinsic(_InterlockedXor8)
  112. #endif
  113.  
  114. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8(dest, exchange, compare) _InterlockedCompareExchange8((char*)(dest), (char)(exchange), (char)(compare))
  115. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8(dest, addend) _InterlockedExchangeAdd8((char*)(dest), (char)(addend))
  116. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE8(dest, newval) _InterlockedExchange8((char*)(dest), (char)(newval))
  117. #define BOOST_ATOMIC_INTERLOCKED_AND8(dest, arg) _InterlockedAnd8((char*)(dest), (char)(arg))
  118. #define BOOST_ATOMIC_INTERLOCKED_OR8(dest, arg) _InterlockedOr8((char*)(dest), (char)(arg))
  119. #define BOOST_ATOMIC_INTERLOCKED_XOR8(dest, arg) _InterlockedXor8((char*)(dest), (char)(arg))
  120.  
  121. #if defined(BOOST_MSVC)
  122. #pragma intrinsic(_InterlockedCompareExchange16)
  123. #pragma intrinsic(_InterlockedExchangeAdd16)
  124. #pragma intrinsic(_InterlockedExchange16)
  125. #pragma intrinsic(_InterlockedAnd16)
  126. #pragma intrinsic(_InterlockedOr16)
  127. #pragma intrinsic(_InterlockedXor16)
  128. #endif
  129.  
  130. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16(dest, exchange, compare) _InterlockedCompareExchange16((short*)(dest), (short)(exchange), (short)(compare))
  131. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16(dest, addend) _InterlockedExchangeAdd16((short*)(dest), (short)(addend))
  132. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE16(dest, newval) _InterlockedExchange16((short*)(dest), (short)(newval))
  133. #define BOOST_ATOMIC_INTERLOCKED_AND16(dest, arg) _InterlockedAnd16((short*)(dest), (short)(arg))
  134. #define BOOST_ATOMIC_INTERLOCKED_OR16(dest, arg) _InterlockedOr16((short*)(dest), (short)(arg))
  135. #define BOOST_ATOMIC_INTERLOCKED_XOR16(dest, arg) _InterlockedXor16((short*)(dest), (short)(arg))
  136.  
  137. #endif // _MSC_VER >= 1600
  138.  
  139. #if defined(_M_AMD64) || defined(_M_IA64)
  140.  
  141. #if defined(BOOST_MSVC)
  142. #pragma intrinsic(_InterlockedExchangeAdd64)
  143. #pragma intrinsic(_InterlockedExchange64)
  144. #pragma intrinsic(_InterlockedAnd64)
  145. #pragma intrinsic(_InterlockedOr64)
  146. #pragma intrinsic(_InterlockedXor64)
  147. #endif
  148.  
  149. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, addend) _InterlockedExchangeAdd64((__int64*)(dest), (__int64)(addend))
  150. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(dest, newval) _InterlockedExchange64((__int64*)(dest), (__int64)(newval))
  151. #define BOOST_ATOMIC_INTERLOCKED_AND64(dest, arg) _InterlockedAnd64((__int64*)(dest), (__int64)(arg))
  152. #define BOOST_ATOMIC_INTERLOCKED_OR64(dest, arg) _InterlockedOr64((__int64*)(dest), (__int64)(arg))
  153. #define BOOST_ATOMIC_INTERLOCKED_XOR64(dest, arg) _InterlockedXor64((__int64*)(dest), (__int64)(arg))
  154.  
  155. #if defined(BOOST_MSVC)
  156. #pragma intrinsic(_InterlockedCompareExchangePointer)
  157. #pragma intrinsic(_InterlockedExchangePointer)
  158. #endif
  159.  
  160. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) _InterlockedCompareExchangePointer((void**)(dest), (void*)(exchange), (void*)(compare))
  161. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) _InterlockedExchangePointer((void**)(dest), (void*)(newval))
  162. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64((long*)(dest), byte_offset))
  163.  
  164. #elif defined(_M_IX86)
  165.  
  166. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) ((void*)_InterlockedCompareExchange((long*)(dest), (long)(exchange), (long)(compare)))
  167. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) ((void*)_InterlockedExchange((long*)(dest), (long)(newval)))
  168. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD((long*)(dest), byte_offset))
  169.  
  170. #endif
  171.  
  172. #if _MSC_VER >= 1700 && defined(_M_ARM)
  173.  
  174. #if defined(BOOST_MSVC)
  175. #pragma intrinsic(_InterlockedExchangeAdd64)
  176. #pragma intrinsic(_InterlockedExchange64)
  177. #pragma intrinsic(_InterlockedAnd64)
  178. #pragma intrinsic(_InterlockedOr64)
  179. #pragma intrinsic(_InterlockedXor64)
  180. #endif
  181.  
  182. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, addend) _InterlockedExchangeAdd64((__int64*)(dest), (__int64)(addend))
  183. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(dest, newval) _InterlockedExchange64((__int64*)(dest), (__int64)(newval))
  184. #define BOOST_ATOMIC_INTERLOCKED_AND64(dest, arg) _InterlockedAnd64((__int64*)(dest), (__int64)(arg))
  185. #define BOOST_ATOMIC_INTERLOCKED_OR64(dest, arg) _InterlockedOr64((__int64*)(dest), (__int64)(arg))
  186. #define BOOST_ATOMIC_INTERLOCKED_XOR64(dest, arg) _InterlockedXor64((__int64*)(dest), (__int64)(arg))
  187.  
  188. #if defined(BOOST_MSVC)
  189. #pragma intrinsic(_InterlockedCompareExchange8_nf)
  190. #pragma intrinsic(_InterlockedCompareExchange8_acq)
  191. #pragma intrinsic(_InterlockedCompareExchange8_rel)
  192. #pragma intrinsic(_InterlockedCompareExchange16_nf)
  193. #pragma intrinsic(_InterlockedCompareExchange16_acq)
  194. #pragma intrinsic(_InterlockedCompareExchange16_rel)
  195. #pragma intrinsic(_InterlockedCompareExchange_nf)
  196. #pragma intrinsic(_InterlockedCompareExchange_acq)
  197. #pragma intrinsic(_InterlockedCompareExchange_rel)
  198. #pragma intrinsic(_InterlockedCompareExchange64)
  199. #pragma intrinsic(_InterlockedCompareExchange64_nf)
  200. #pragma intrinsic(_InterlockedCompareExchange64_acq)
  201. #pragma intrinsic(_InterlockedCompareExchange64_rel)
  202. #pragma intrinsic(_InterlockedCompareExchangePointer)
  203. #pragma intrinsic(_InterlockedCompareExchangePointer_nf)
  204. #pragma intrinsic(_InterlockedCompareExchangePointer_acq)
  205. #pragma intrinsic(_InterlockedCompareExchangePointer_rel)
  206. #endif
  207.  
  208. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELAXED(dest, exchange, compare) _InterlockedCompareExchange8_nf((char*)(dest), (char)(exchange), (char)(compare))
  209. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_ACQUIRE(dest, exchange, compare) _InterlockedCompareExchange8_acq((char*)(dest), (char)(exchange), (char)(compare))
  210. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELEASE(dest, exchange, compare) _InterlockedCompareExchange8_rel((char*)(dest), (char)(exchange), (char)(compare))
  211. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELAXED(dest, exchange, compare) _InterlockedCompareExchange16_nf((short*)(dest), (short)(exchange), (short)(compare))
  212. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_ACQUIRE(dest, exchange, compare) _InterlockedCompareExchange16_acq((short*)(dest), (short)(exchange), (short)(compare))
  213. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELEASE(dest, exchange, compare) _InterlockedCompareExchange16_rel((short*)(dest), (short)(exchange), (short)(compare))
  214. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELAXED(dest, exchange, compare) _InterlockedCompareExchange_nf((long*)(dest), (long)(exchange), (long)(compare))
  215. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_ACQUIRE(dest, exchange, compare) _InterlockedCompareExchange_acq((long*)(dest), (long)(exchange), (long)(compare))
  216. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELEASE(dest, exchange, compare) _InterlockedCompareExchange_rel((long*)(dest), (long)(exchange), (long)(compare))
  217. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(dest, exchange, compare) _InterlockedCompareExchange64((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  218. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELAXED(dest, exchange, compare) _InterlockedCompareExchange64_nf((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  219. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_ACQUIRE(dest, exchange, compare) _InterlockedCompareExchange64_acq((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  220. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELEASE(dest, exchange, compare) _InterlockedCompareExchange64_rel((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  221. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) _InterlockedCompareExchangePointer((void**)(dest), (void*)(exchange), (void*)(compare))
  222. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER_RELAXED(dest, exchange, compare) _InterlockedCompareExchangePointer_nf((void**)(dest), (void*)(exchange), (void*)(compare))
  223. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER_ACQUIRE(dest, exchange, compare) _InterlockedCompareExchangePointer_acq((void**)(dest), (void*)(exchange), (void*)(compare))
  224. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER_RELEASE(dest, exchange, compare) _InterlockedCompareExchangePointer_rel((void**)(dest), (void*)(exchange), (void*)(compare))
  225.  
  226. #if defined(BOOST_MSVC)
  227. #pragma intrinsic(_InterlockedExchangeAdd8_nf)
  228. #pragma intrinsic(_InterlockedExchangeAdd8_acq)
  229. #pragma intrinsic(_InterlockedExchangeAdd8_rel)
  230. #pragma intrinsic(_InterlockedExchangeAdd16_nf)
  231. #pragma intrinsic(_InterlockedExchangeAdd16_acq)
  232. #pragma intrinsic(_InterlockedExchangeAdd16_rel)
  233. #pragma intrinsic(_InterlockedExchangeAdd_nf)
  234. #pragma intrinsic(_InterlockedExchangeAdd_acq)
  235. #pragma intrinsic(_InterlockedExchangeAdd_rel)
  236. #pragma intrinsic(_InterlockedExchangeAdd64_nf)
  237. #pragma intrinsic(_InterlockedExchangeAdd64_acq)
  238. #pragma intrinsic(_InterlockedExchangeAdd64_rel)
  239. #endif
  240.  
  241. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELAXED(dest, addend) _InterlockedExchangeAdd8_nf((char*)(dest), (char)(addend))
  242. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_ACQUIRE(dest, addend) _InterlockedExchangeAdd8_acq((char*)(dest), (char)(addend))
  243. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELEASE(dest, addend) _InterlockedExchangeAdd8_rel((char*)(dest), (char)(addend))
  244. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELAXED(dest, addend) _InterlockedExchangeAdd16_nf((short*)(dest), (short)(addend))
  245. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_ACQUIRE(dest, addend) _InterlockedExchangeAdd16_acq((short*)(dest), (short)(addend))
  246. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELEASE(dest, addend) _InterlockedExchangeAdd16_rel((short*)(dest), (short)(addend))
  247. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELAXED(dest, addend) _InterlockedExchangeAdd_nf((long*)(dest), (long)(addend))
  248. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_ACQUIRE(dest, addend) _InterlockedExchangeAdd_acq((long*)(dest), (long)(addend))
  249. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELEASE(dest, addend) _InterlockedExchangeAdd_rel((long*)(dest), (long)(addend))
  250. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELAXED(dest, addend) _InterlockedExchangeAdd64_nf((__int64*)(dest), (__int64)(addend))
  251. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_ACQUIRE(dest, addend) _InterlockedExchangeAdd64_acq((__int64*)(dest), (__int64)(addend))
  252. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELEASE(dest, addend) _InterlockedExchangeAdd64_rel((__int64*)(dest), (__int64)(addend))
  253.  
  254. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD((long*)(dest), byte_offset))
  255. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELAXED(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELAXED((long*)(dest), byte_offset))
  256. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_ACQUIRE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_ACQUIRE((long*)(dest), byte_offset))
  257. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELEASE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELEASE((long*)(dest), byte_offset))
  258.  
  259. #if defined(BOOST_MSVC)
  260. #pragma intrinsic(_InterlockedExchange8_nf)
  261. #pragma intrinsic(_InterlockedExchange8_acq)
  262. #pragma intrinsic(_InterlockedExchange16_nf)
  263. #pragma intrinsic(_InterlockedExchange16_acq)
  264. #pragma intrinsic(_InterlockedExchange_nf)
  265. #pragma intrinsic(_InterlockedExchange_acq)
  266. #pragma intrinsic(_InterlockedExchange64_nf)
  267. #pragma intrinsic(_InterlockedExchange64_acq)
  268. #pragma intrinsic(_InterlockedExchangePointer)
  269. #pragma intrinsic(_InterlockedExchangePointer_nf)
  270. #pragma intrinsic(_InterlockedExchangePointer_acq)
  271. #if _MSC_VER >= 1800
  272. #pragma intrinsic(_InterlockedExchange8_rel)
  273. #pragma intrinsic(_InterlockedExchange16_rel)
  274. #pragma intrinsic(_InterlockedExchange_rel)
  275. #pragma intrinsic(_InterlockedExchange64_rel)
  276. #pragma intrinsic(_InterlockedExchangePointer_rel)
  277. #endif
  278. #endif
  279.  
  280. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELAXED(dest, newval) _InterlockedExchange8_nf((char*)(dest), (char)(newval))
  281. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_ACQUIRE(dest, newval) _InterlockedExchange8_acq((char*)(dest), (char)(newval))
  282. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELAXED(dest, newval) _InterlockedExchange16_nf((short*)(dest), (short)(newval))
  283. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_ACQUIRE(dest, newval) _InterlockedExchange16_acq((short*)(dest), (short)(newval))
  284. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELAXED(dest, newval) _InterlockedExchange_nf((long*)(dest), (long)(newval))
  285. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ACQUIRE(dest, newval) _InterlockedExchange_acq((long*)(dest), (long)(newval))
  286. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELAXED(dest, newval) _InterlockedExchange64_nf((__int64*)(dest), (__int64)(newval))
  287. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_ACQUIRE(dest, newval) _InterlockedExchange64_acq((__int64*)(dest), (__int64)(newval))
  288. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) _InterlockedExchangePointer((void**)(dest), (void*)(newval))
  289. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER_RELAXED(dest, newval) _InterlockedExchangePointer_nf((void**)(dest), (void*)(newval))
  290. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER_ACQUIRE(dest, newval) _InterlockedExchangePointer_acq((void**)(dest), (void*)(newval))
  291.  
  292. #if _MSC_VER >= 1800
  293. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELEASE(dest, newval) _InterlockedExchange8_rel((char*)(dest), (char)(newval))
  294. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELEASE(dest, newval) _InterlockedExchange16_rel((short*)(dest), (short)(newval))
  295. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELEASE(dest, newval) _InterlockedExchange_rel((long*)(dest), (long)(newval))
  296. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELEASE(dest, newval) _InterlockedExchange64_rel((__int64*)(dest), (__int64)(newval))
  297. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER_RELEASE(dest, newval) _InterlockedExchangePointer_rel((void**)(dest), (void*)(newval))
  298. #else
  299. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELEASE(dest, newval) BOOST_ATOMIC_INTERLOCKED_EXCHANGE8(dest, newval)
  300. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELEASE(dest, newval) BOOST_ATOMIC_INTERLOCKED_EXCHANGE16(dest, newval)
  301. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELEASE(dest, newval) BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval)
  302. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELEASE(dest, newval) BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(dest, newval)
  303. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER_RELEASE(dest, newval) BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval)
  304. #endif
  305.  
  306. #if defined(BOOST_MSVC)
  307. #pragma intrinsic(_InterlockedAnd8_nf)
  308. #pragma intrinsic(_InterlockedAnd8_acq)
  309. #pragma intrinsic(_InterlockedAnd8_rel)
  310. #pragma intrinsic(_InterlockedAnd16_nf)
  311. #pragma intrinsic(_InterlockedAnd16_acq)
  312. #pragma intrinsic(_InterlockedAnd16_rel)
  313. #pragma intrinsic(_InterlockedAnd_nf)
  314. #pragma intrinsic(_InterlockedAnd_acq)
  315. #pragma intrinsic(_InterlockedAnd_rel)
  316. #pragma intrinsic(_InterlockedAnd64_nf)
  317. #pragma intrinsic(_InterlockedAnd64_acq)
  318. #pragma intrinsic(_InterlockedAnd64_rel)
  319. #endif
  320.  
  321. #define BOOST_ATOMIC_INTERLOCKED_AND8_RELAXED(dest, arg) _InterlockedAnd8_nf((char*)(dest), (char)(arg))
  322. #define BOOST_ATOMIC_INTERLOCKED_AND8_ACQUIRE(dest, arg) _InterlockedAnd8_acq((char*)(dest), (char)(arg))
  323. #define BOOST_ATOMIC_INTERLOCKED_AND8_RELEASE(dest, arg) _InterlockedAnd8_rel((char*)(dest), (char)(arg))
  324. #define BOOST_ATOMIC_INTERLOCKED_AND16_RELAXED(dest, arg) _InterlockedAnd16_nf((short*)(dest), (short)(arg))
  325. #define BOOST_ATOMIC_INTERLOCKED_AND16_ACQUIRE(dest, arg) _InterlockedAnd16_acq((short*)(dest), (short)(arg))
  326. #define BOOST_ATOMIC_INTERLOCKED_AND16_RELEASE(dest, arg) _InterlockedAnd16_rel((short*)(dest), (short)(arg))
  327. #define BOOST_ATOMIC_INTERLOCKED_AND_RELAXED(dest, arg) _InterlockedAnd_nf((long*)(dest), (long)(arg))
  328. #define BOOST_ATOMIC_INTERLOCKED_AND_ACQUIRE(dest, arg) _InterlockedAnd_acq((long*)(dest), (long)(arg))
  329. #define BOOST_ATOMIC_INTERLOCKED_AND_RELEASE(dest, arg) _InterlockedAnd_rel((long*)(dest), (long)(arg))
  330. #define BOOST_ATOMIC_INTERLOCKED_AND64_RELAXED(dest, arg) _InterlockedAnd64_nf((__int64*)(dest), (__int64)(arg))
  331. #define BOOST_ATOMIC_INTERLOCKED_AND64_ACQUIRE(dest, arg) _InterlockedAnd64_acq((__int64*)(dest), (__int64)(arg))
  332. #define BOOST_ATOMIC_INTERLOCKED_AND64_RELEASE(dest, arg) _InterlockedAnd64_rel((__int64*)(dest), (__int64)(arg))
  333.  
  334. #if defined(BOOST_MSVC)
  335. #pragma intrinsic(_InterlockedOr8_nf)
  336. #pragma intrinsic(_InterlockedOr8_acq)
  337. #pragma intrinsic(_InterlockedOr8_rel)
  338. #pragma intrinsic(_InterlockedOr16_nf)
  339. #pragma intrinsic(_InterlockedOr16_acq)
  340. #pragma intrinsic(_InterlockedOr16_rel)
  341. #pragma intrinsic(_InterlockedOr_nf)
  342. #pragma intrinsic(_InterlockedOr_acq)
  343. #pragma intrinsic(_InterlockedOr_rel)
  344. #pragma intrinsic(_InterlockedOr64_nf)
  345. #pragma intrinsic(_InterlockedOr64_acq)
  346. #pragma intrinsic(_InterlockedOr64_rel)
  347. #endif
  348.  
  349. #define BOOST_ATOMIC_INTERLOCKED_OR8_RELAXED(dest, arg) _InterlockedOr8_nf((char*)(dest), (char)(arg))
  350. #define BOOST_ATOMIC_INTERLOCKED_OR8_ACQUIRE(dest, arg) _InterlockedOr8_acq((char*)(dest), (char)(arg))
  351. #define BOOST_ATOMIC_INTERLOCKED_OR8_RELEASE(dest, arg) _InterlockedOr8_rel((char*)(dest), (char)(arg))
  352. #define BOOST_ATOMIC_INTERLOCKED_OR16_RELAXED(dest, arg) _InterlockedOr16_nf((short*)(dest), (short)(arg))
  353. #define BOOST_ATOMIC_INTERLOCKED_OR16_ACQUIRE(dest, arg) _InterlockedOr16_acq((short*)(dest), (short)(arg))
  354. #define BOOST_ATOMIC_INTERLOCKED_OR16_RELEASE(dest, arg) _InterlockedOr16_rel((short*)(dest), (short)(arg))
  355. #define BOOST_ATOMIC_INTERLOCKED_OR_RELAXED(dest, arg) _InterlockedOr_nf((long*)(dest), (long)(arg))
  356. #define BOOST_ATOMIC_INTERLOCKED_OR_ACQUIRE(dest, arg) _InterlockedOr_acq((long*)(dest), (long)(arg))
  357. #define BOOST_ATOMIC_INTERLOCKED_OR_RELEASE(dest, arg) _InterlockedOr_rel((long*)(dest), (long)(arg))
  358. #define BOOST_ATOMIC_INTERLOCKED_OR64_RELAXED(dest, arg) _InterlockedOr64_nf((__int64*)(dest), (__int64)(arg))
  359. #define BOOST_ATOMIC_INTERLOCKED_OR64_ACQUIRE(dest, arg) _InterlockedOr64_acq((__int64*)(dest), (__int64)(arg))
  360. #define BOOST_ATOMIC_INTERLOCKED_OR64_RELEASE(dest, arg) _InterlockedOr64_rel((__int64*)(dest), (__int64)(arg))
  361.  
  362. #if defined(BOOST_MSVC)
  363. #pragma intrinsic(_InterlockedXor8_nf)
  364. #pragma intrinsic(_InterlockedXor8_acq)
  365. #pragma intrinsic(_InterlockedXor8_rel)
  366. #pragma intrinsic(_InterlockedXor16_nf)
  367. #pragma intrinsic(_InterlockedXor16_acq)
  368. #pragma intrinsic(_InterlockedXor16_rel)
  369. #pragma intrinsic(_InterlockedXor_nf)
  370. #pragma intrinsic(_InterlockedXor_acq)
  371. #pragma intrinsic(_InterlockedXor_rel)
  372. #pragma intrinsic(_InterlockedXor64_nf)
  373. #pragma intrinsic(_InterlockedXor64_acq)
  374. #pragma intrinsic(_InterlockedXor64_rel)
  375. #endif
  376.  
  377. #define BOOST_ATOMIC_INTERLOCKED_XOR8_RELAXED(dest, arg) _InterlockedXor8_nf((char*)(dest), (char)(arg))
  378. #define BOOST_ATOMIC_INTERLOCKED_XOR8_ACQUIRE(dest, arg) _InterlockedXor8_acq((char*)(dest), (char)(arg))
  379. #define BOOST_ATOMIC_INTERLOCKED_XOR8_RELEASE(dest, arg) _InterlockedXor8_rel((char*)(dest), (char)(arg))
  380. #define BOOST_ATOMIC_INTERLOCKED_XOR16_RELAXED(dest, arg) _InterlockedXor16_nf((short*)(dest), (short)(arg))
  381. #define BOOST_ATOMIC_INTERLOCKED_XOR16_ACQUIRE(dest, arg) _InterlockedXor16_acq((short*)(dest), (short)(arg))
  382. #define BOOST_ATOMIC_INTERLOCKED_XOR16_RELEASE(dest, arg) _InterlockedXor16_rel((short*)(dest), (short)(arg))
  383. #define BOOST_ATOMIC_INTERLOCKED_XOR_RELAXED(dest, arg) _InterlockedXor_nf((long*)(dest), (long)(arg))
  384. #define BOOST_ATOMIC_INTERLOCKED_XOR_ACQUIRE(dest, arg) _InterlockedXor_acq((long*)(dest), (long)(arg))
  385. #define BOOST_ATOMIC_INTERLOCKED_XOR_RELEASE(dest, arg) _InterlockedXor_rel((long*)(dest), (long)(arg))
  386. #define BOOST_ATOMIC_INTERLOCKED_XOR64_RELAXED(dest, arg) _InterlockedXor64_nf((__int64*)(dest), (__int64)(arg))
  387. #define BOOST_ATOMIC_INTERLOCKED_XOR64_ACQUIRE(dest, arg) _InterlockedXor64_acq((__int64*)(dest), (__int64)(arg))
  388. #define BOOST_ATOMIC_INTERLOCKED_XOR64_RELEASE(dest, arg) _InterlockedXor64_rel((__int64*)(dest), (__int64)(arg))
  389.  
  390. #endif // _MSC_VER >= 1700 && defined(_M_ARM)
  391.  
  392. #endif // _MSC_VER < 1400
  393.  
  394. #else // defined(_MSC_VER) && _MSC_VER >= 1310
  395.  
  396. #if defined(BOOST_USE_WINDOWS_H)
  397.  
  398. #include <windows.h>
  399.  
  400. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) InterlockedCompareExchange((long*)(dest), (long)(exchange), (long)(compare))
  401. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) InterlockedExchange((long*)(dest), (long)(newval))
  402. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) InterlockedExchangeAdd((long*)(dest), (long)(addend))
  403.  
  404. #if defined(_WIN64)
  405.  
  406. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(dest, exchange, compare) InterlockedCompareExchange64((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  407. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(dest, newval) InterlockedExchange64((__int64*)(dest), (__int64)(newval))
  408. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, addend) InterlockedExchangeAdd64((__int64*)(dest), (__int64)(addend))
  409.  
  410. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) InterlockedCompareExchangePointer((void**)(dest), (void*)(exchange), (void*)(compare))
  411. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) InterlockedExchangePointer((void**)(dest), (void*)(newval))
  412. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, byte_offset))
  413.  
  414. #else // defined(_WIN64)
  415.  
  416. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) ((void*)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare))
  417. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval))
  418. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, byte_offset))
  419.  
  420. #endif // defined(_WIN64)
  421.  
  422. #else // defined(BOOST_USE_WINDOWS_H)
  423.  
  424. #if defined(__MINGW64__)
  425. #define BOOST_ATOMIC_INTERLOCKED_IMPORT
  426. #else
  427. #define BOOST_ATOMIC_INTERLOCKED_IMPORT __declspec(dllimport)
  428. #endif
  429.  
  430. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  431. namespace atomics {
  432. namespace detail {
  433.  
  434. extern "C" {
  435.  
  436. BOOST_ATOMIC_INTERLOCKED_IMPORT long __stdcall InterlockedCompareExchange(long volatile*, long, long);
  437. BOOST_ATOMIC_INTERLOCKED_IMPORT long __stdcall InterlockedExchange(long volatile*, long);
  438. BOOST_ATOMIC_INTERLOCKED_IMPORT long __stdcall InterlockedExchangeAdd(long volatile*, long);
  439.  
  440. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare) mars_boost::atomics::detail::InterlockedCompareExchange((long*)(dest), (long)(exchange), (long)(compare))
  441. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval) mars_boost::atomics::detail::InterlockedExchange((long*)(dest), (long)(newval))
  442. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, addend) mars_boost::atomics::detail::InterlockedExchangeAdd((long*)(dest), (long)(addend))
  443.  
  444. #if defined(_WIN64)
  445.  
  446. BOOST_ATOMIC_INTERLOCKED_IMPORT __int64 __stdcall InterlockedCompareExchange64(__int64 volatile*, __int64, __int64);
  447. BOOST_ATOMIC_INTERLOCKED_IMPORT __int64 __stdcall InterlockedExchange64(__int64 volatile*, __int64);
  448. BOOST_ATOMIC_INTERLOCKED_IMPORT __int64 __stdcall InterlockedExchangeAdd64(__int64 volatile*, __int64);
  449.  
  450. BOOST_ATOMIC_INTERLOCKED_IMPORT void* __stdcall InterlockedCompareExchangePointer(void* volatile *, void*, void*);
  451. BOOST_ATOMIC_INTERLOCKED_IMPORT void* __stdcall InterlockedExchangePointer(void* volatile *, void*);
  452.  
  453. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(dest, exchange, compare) mars_boost::atomics::detail::InterlockedCompareExchange64((__int64*)(dest), (__int64)(exchange), (__int64)(compare))
  454. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(dest, newval) mars_boost::atomics::detail::InterlockedExchange64((__int64*)(dest), (__int64)(newval))
  455. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, addend) mars_boost::atomics::detail::InterlockedExchangeAdd64((__int64*)(dest), (__int64)(addend))
  456.  
  457. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) mars_boost::atomics::detail::InterlockedCompareExchangePointer((void**)(dest), (void*)(exchange), (void*)(compare))
  458. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) mars_boost::atomics::detail::InterlockedExchangePointer((void**)(dest), (void*)(newval))
  459. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(dest, byte_offset))
  460.  
  461. #else // defined(_WIN64)
  462.  
  463. #define BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest, exchange, compare) ((void*)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(dest, exchange, compare))
  464. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_POINTER(dest, newval) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE(dest, newval))
  465. #define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(dest, byte_offset))
  466.  
  467. #endif // defined(_WIN64)
  468.  
  469. } // extern "C"
  470.  
  471. } // namespace detail
  472. } // namespace atomics
  473. } // namespace mars_boost
  474.  
  475. #undef BOOST_ATOMIC_INTERLOCKED_IMPORT
  476.  
  477. #endif // defined(BOOST_USE_WINDOWS_H)
  478.  
  479. #endif // defined(_MSC_VER)
  480.  
  481. #endif
  482.  
downloadinterlocked.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top