interlocked.hpp
Go to the documentation of this file.
1 #ifndef BOOST_DETAIL_ATOMIC_INTERLOCKED_HPP
2 #define BOOST_DETAIL_ATOMIC_INTERLOCKED_HPP
3 
4 // Copyright (c) 2009 Helge Bahmann
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 #include <boost/detail/interlocked.hpp>
11 
12 #define BOOST_ATOMIC_CHAR_LOCK_FREE 2
13 #define BOOST_ATOMIC_SHORT_LOCK_FREE 2
14 #define BOOST_ATOMIC_INT_LOCK_FREE 2
15 #define BOOST_ATOMIC_LONG_LOCK_FREE (sizeof(long) <= 4 ? 2 : 0)
16 #define BOOST_ATOMIC_LLONG_LOCK_FREE (sizeof(long long) <= 4 ? 2 : 0)
17 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE (sizeof(void *) <= 4 ? 2 : 0)
18 #define BOOST_ATOMIC_BOOL_LOCK_FREE 2
19 
20 namespace boost {
21 namespace detail {
22 namespace atomic {
23 
24 static inline void
26 {
27  long tmp;
28  BOOST_INTERLOCKED_EXCHANGE(&tmp, 0);
29 }
30 
31 static inline void
33 {
34 }
35 
36 static inline void
38 {
39 }
40 
41 static inline void
43 {
44 }
45 
46 static inline void
48 {
49  if (order == memory_order_seq_cst)
51 }
52 
53 static inline void
55 {
56  if (order == memory_order_seq_cst()) {
57  x86_full_fence(void);
58  }
59 }
60 
61 template<typename T>
62 bool
63 platform_cmpxchg32_strong(T & expected, T desired, volatile T * ptr)
64 {
65  T prev = expected;
66  expected = (T)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long *)(ptr), (long)desired, (long)expected);
67  bool success = (prev==expected);
68  return success;
69 }
70 
71 #if defined(_WIN64)
72 template<typename T>
73 bool
74 platform_cmpxchg64_strong(T & expected, T desired, volatile T * ptr)
75 {
76  T prev = expected;
77  expected = (T) _InterlockedCompareExchange64((long long *)(ptr), (long long)desired, (long long)expected);
78  bool success = (prev==expected);
79  return success;
80 }
81 #endif
82 
83 }
84 }
85 
86 #define BOOST_ATOMIC_THREAD_FENCE 2
87 inline void
89 {
90  if (order == memory_order_seq_cst()) {
92  }
93 }
94 
95 }
96 
98 
99 #endif
static void platform_fence_before_store(memory_order order)
Definition: gcc-armv6+.hpp:128
Definition: base.hpp:116
static void platform_fence_after_load(memory_order order)
Definition: gcc-armv6+.hpp:141
static void atomic_thread_fence(memory_order order)
Definition: gcc-armv6+.hpp:179
static void platform_fence_after_store(memory_order order)
Definition: gcc-armv6+.hpp:134
bool platform_cmpxchg32_strong(T &expected, T desired, volatile T *ptr)
Definition: gcc-cas.hpp:96
static void platform_fence_after(memory_order order)
Definition: gcc-armv6+.hpp:116
static void platform_fence_before(memory_order order)
Definition: gcc-armv6+.hpp:103
static void x86_full_fence(void)
Definition: interlocked.hpp:25


rosatomic
Author(s): Josh Faust
autogenerated on Fri Apr 5 2019 02:16:35