OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // For atomic operations on reference counts, see atomic_refcount.h. | 5 // For atomic operations on reference counts, see atomic_refcount.h. |
6 // For atomic operations on sequence numbers, see atomic_sequence_num.h. | 6 // For atomic operations on sequence numbers, see atomic_sequence_num.h. |
7 | 7 |
8 // The routines exported by this module are subtle. If you use them, even if | 8 // The routines exported by this module are subtle. If you use them, even if |
9 // you get the code right, it will depend on careful reasoning about atomicity | 9 // you get the code right, it will depend on careful reasoning about atomicity |
10 // and memory ordering; it will be less readable, and harder to maintain. If | 10 // and memory ordering; it will be less readable, and harder to maintain. If |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void Acquire_Store(volatile Atomic64* ptr, Atomic64 value); | 137 void Acquire_Store(volatile Atomic64* ptr, Atomic64 value); |
138 void Release_Store(volatile Atomic64* ptr, Atomic64 value); | 138 void Release_Store(volatile Atomic64* ptr, Atomic64 value); |
139 Atomic64 NoBarrier_Load(volatile const Atomic64* ptr); | 139 Atomic64 NoBarrier_Load(volatile const Atomic64* ptr); |
140 Atomic64 Acquire_Load(volatile const Atomic64* ptr); | 140 Atomic64 Acquire_Load(volatile const Atomic64* ptr); |
141 Atomic64 Release_Load(volatile const Atomic64* ptr); | 141 Atomic64 Release_Load(volatile const Atomic64* ptr); |
142 #endif // ARCH_CPU_64_BITS | 142 #endif // ARCH_CPU_64_BITS |
143 | 143 |
144 } // namespace subtle | 144 } // namespace subtle |
145 } // namespace base | 145 } // namespace base |
146 | 146 |
147 // Try to use a portable implementation based on C++11 atomics. | 147 #if defined(OS_WIN) |
148 // | 148 // TODO(jfb): The MSVC header includes windows.h, which other files end up |
149 // Some toolchains support C++11 language features without supporting library | 149 // relying on. Fix this as part of crbug.com/559247. |
150 // features (recent compiler, older STL). Whitelist libstdc++ and libc++ that we | 150 # include "base/atomicops_internals_x86_msvc.h" |
151 // know will have <atomic> when compiling C++11. | 151 #else |
152 #if ((__cplusplus >= 201103L) && \ | |
153 ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20110216)) || \ | |
154 (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11)))) | |
155 # include "base/atomicops_internals_portable.h" | 152 # include "base/atomicops_internals_portable.h" |
156 #else // Otherwise use a platform specific implementation. | 153 #endif |
157 # if defined(THREAD_SANITIZER) | |
158 # error "Thread sanitizer must use the portable atomic operations" | |
159 # elif (defined(OS_WIN) && defined(COMPILER_MSVC) && \ | |
160 defined(ARCH_CPU_X86_FAMILY)) | |
161 # include "base/atomicops_internals_x86_msvc.h" | |
162 # elif defined(OS_MACOSX) | |
163 # include "base/atomicops_internals_mac.h" | |
164 # else | |
165 # error "Atomic operations are not supported on your platform" | |
166 # endif | |
167 #endif // Portable / non-portable includes. | |
168 | 154 |
169 // On some platforms we need additional declarations to make | 155 // On some platforms we need additional declarations to make |
170 // AtomicWord compatible with our other Atomic* types. | 156 // AtomicWord compatible with our other Atomic* types. |
171 #if defined(OS_MACOSX) || defined(OS_OPENBSD) | 157 #if defined(OS_MACOSX) || defined(OS_OPENBSD) |
172 #include "base/atomicops_internals_atomicword_compat.h" | 158 #include "base/atomicops_internals_atomicword_compat.h" |
173 #endif | 159 #endif |
174 | 160 |
175 #endif // BASE_ATOMICOPS_H_ | 161 #endif // BASE_ATOMICOPS_H_ |
OLD | NEW |