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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Small C++ header which defines implementation specific macros used to | 33 // Small C++ header which defines implementation specific macros used to |
34 // identify the STL implementation. | 34 // identify the STL implementation. |
35 // - libc++: captures __config for _LIBCPP_VERSION | 35 // - libc++: captures __config for _LIBCPP_VERSION |
36 // - libstdc++: captures bits/c++config.h for __GLIBCXX__ | 36 // - libstdc++: captures bits/c++config.h for __GLIBCXX__ |
37 #include <cstddef> | 37 #include <cstddef> |
38 | 38 |
39 #include "base/base_export.h" | 39 #include "base/base_export.h" |
40 #include "build/build_config.h" | 40 #include "build/build_config.h" |
41 | 41 |
42 #if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) | |
43 // windows.h #defines this (only on x64). This causes problems because the | |
44 // public API also uses MemoryBarrier at the public name for this fence. So, on | |
45 // X64, undef it, and call its documented | |
46 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) | |
47 // implementation directly. | |
48 #undef MemoryBarrier | |
49 #endif | |
50 | |
51 namespace base { | 42 namespace base { |
52 namespace subtle { | 43 namespace subtle { |
53 | 44 |
54 typedef int32_t Atomic32; | 45 typedef int32_t Atomic32; |
55 #ifdef ARCH_CPU_64_BITS | 46 #ifdef ARCH_CPU_64_BITS |
56 // We need to be able to go between Atomic64 and AtomicWord implicitly. This | 47 // We need to be able to go between Atomic64 and AtomicWord implicitly. This |
57 // means Atomic64 and AtomicWord should be the same type on 64-bit. | 48 // means Atomic64 and AtomicWord should be the same type on 64-bit. |
58 #if defined(__ILP32__) || defined(OS_NACL) | 49 #if defined(__ILP32__) || defined(OS_NACL) |
59 // NaCl's intptr_t is not actually 64-bits on 64-bit! | 50 // NaCl's intptr_t is not actually 64-bits on 64-bit! |
60 // http://code.google.com/p/nativeclient/issues/detail?id=1162 | 51 // http://code.google.com/p/nativeclient/issues/detail?id=1162 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Some toolchains support C++11 language features without supporting library | 167 // Some toolchains support C++11 language features without supporting library |
177 // features (recent compiler, older STL). Whitelist libstdc++ and libc++ that we | 168 // features (recent compiler, older STL). Whitelist libstdc++ and libc++ that we |
178 // know will have <atomic> when compiling C++11. | 169 // know will have <atomic> when compiling C++11. |
179 #if ((__cplusplus >= 201103L) && \ | 170 #if ((__cplusplus >= 201103L) && \ |
180 ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20110216)) || \ | 171 ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20110216)) || \ |
181 (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11)))) | 172 (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11)))) |
182 # include "base/atomicops_internals_portable.h" | 173 # include "base/atomicops_internals_portable.h" |
183 #else // Otherwise use a platform specific implementation. | 174 #else // Otherwise use a platform specific implementation. |
184 # if defined(THREAD_SANITIZER) | 175 # if defined(THREAD_SANITIZER) |
185 # error "Thread sanitizer must use the portable atomic operations" | 176 # error "Thread sanitizer must use the portable atomic operations" |
186 # elif (defined(OS_WIN) && defined(COMPILER_MSVC) && \ | |
187 defined(ARCH_CPU_X86_FAMILY)) | |
188 # include "base/atomicops_internals_x86_msvc.h" | |
189 # elif defined(OS_MACOSX) | 177 # elif defined(OS_MACOSX) |
190 # include "base/atomicops_internals_mac.h" | 178 # include "base/atomicops_internals_mac.h" |
191 # elif defined(OS_NACL) | 179 # elif defined(OS_NACL) |
192 # include "base/atomicops_internals_gcc.h" | 180 # include "base/atomicops_internals_gcc.h" |
193 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARMEL) | 181 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARMEL) |
194 # include "base/atomicops_internals_arm_gcc.h" | 182 # include "base/atomicops_internals_arm_gcc.h" |
195 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM64) | 183 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM64) |
196 # include "base/atomicops_internals_arm64_gcc.h" | 184 # include "base/atomicops_internals_arm64_gcc.h" |
197 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) | 185 # elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) |
198 # include "base/atomicops_internals_x86_gcc.h" | 186 # include "base/atomicops_internals_x86_gcc.h" |
199 # elif (defined(COMPILER_GCC) && \ | 187 # elif (defined(COMPILER_GCC) && \ |
200 (defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_MIPS64_FAMILY))) | 188 (defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_MIPS64_FAMILY))) |
201 # include "base/atomicops_internals_mips_gcc.h" | 189 # include "base/atomicops_internals_mips_gcc.h" |
202 # else | 190 # else |
203 # error "Atomic operations are not supported on your platform" | 191 # error "Atomic operations are not supported on your platform" |
204 # endif | 192 # endif |
205 #endif // Portable / non-portable includes. | 193 #endif // Portable / non-portable includes. |
206 | 194 |
207 // On some platforms we need additional declarations to make | 195 // On some platforms we need additional declarations to make |
208 // AtomicWord compatible with our other Atomic* types. | 196 // AtomicWord compatible with our other Atomic* types. |
209 #if defined(OS_MACOSX) || defined(OS_OPENBSD) | 197 #if defined(OS_MACOSX) || defined(OS_OPENBSD) |
210 #include "base/atomicops_internals_atomicword_compat.h" | 198 #include "base/atomicops_internals_atomicword_compat.h" |
211 #endif | 199 #endif |
212 | 200 |
213 #endif // BASE_ATOMICOPS_H_ | 201 #endif // BASE_ATOMICOPS_H_ |
OLD | NEW |