| 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 10 matching lines...) Expand all Loading... |
| 21 // versions are provided when no barriers are needed: | 21 // versions are provided when no barriers are needed: |
| 22 // NoBarrier_Store() | 22 // NoBarrier_Store() |
| 23 // NoBarrier_Load() | 23 // NoBarrier_Load() |
| 24 // Although there are currently no compiler enforcement, you are encouraged | 24 // Although there are currently no compiler enforcement, you are encouraged |
| 25 // to use these. | 25 // to use these. |
| 26 // | 26 // |
| 27 | 27 |
| 28 #ifndef BASE_ATOMICOPS_H_ | 28 #ifndef BASE_ATOMICOPS_H_ |
| 29 #define BASE_ATOMICOPS_H_ | 29 #define BASE_ATOMICOPS_H_ |
| 30 | 30 |
| 31 #include "base/basictypes.h" | 31 #include <stdint.h> |
| 32 |
| 32 #include "build/build_config.h" | 33 #include "build/build_config.h" |
| 33 | 34 |
| 34 #if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) | 35 #if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) |
| 35 // windows.h #defines this (only on x64). This causes problems because the | 36 // windows.h #defines this (only on x64). This causes problems because the |
| 36 // public API also uses MemoryBarrier at the public name for this fence. So, on | 37 // public API also uses MemoryBarrier at the public name for this fence. So, on |
| 37 // X64, undef it, and call its documented | 38 // X64, undef it, and call its documented |
| 38 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) | 39 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) |
| 39 // implementation directly. | 40 // implementation directly. |
| 40 #undef MemoryBarrier | 41 #undef MemoryBarrier |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 namespace base { | 44 namespace base { |
| 44 namespace subtle { | 45 namespace subtle { |
| 45 | 46 |
| 46 typedef int32 Atomic32; | 47 typedef int32_t Atomic32; |
| 47 #ifdef ARCH_CPU_64_BITS | 48 #ifdef ARCH_CPU_64_BITS |
| 48 // We need to be able to go between Atomic64 and AtomicWord implicitly. This | 49 // We need to be able to go between Atomic64 and AtomicWord implicitly. This |
| 49 // means Atomic64 and AtomicWord should be the same type on 64-bit. | 50 // means Atomic64 and AtomicWord should be the same type on 64-bit. |
| 50 #if defined(__ILP32__) || defined(OS_NACL) | 51 #if defined(__ILP32__) || defined(OS_NACL) |
| 51 // NaCl's intptr_t is not actually 64-bits on 64-bit! | 52 // NaCl's intptr_t is not actually 64-bits on 64-bit! |
| 52 // http://code.google.com/p/nativeclient/issues/detail?id=1162 | 53 // http://code.google.com/p/nativeclient/issues/detail?id=1162 |
| 53 typedef int64_t Atomic64; | 54 typedef int64_t Atomic64; |
| 54 #else | 55 #else |
| 55 typedef intptr_t Atomic64; | 56 typedef intptr_t Atomic64; |
| 56 #endif | 57 #endif |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 #error "Atomic operations are not supported on your platform" | 156 #error "Atomic operations are not supported on your platform" |
| 156 #endif | 157 #endif |
| 157 | 158 |
| 158 // On some platforms we need additional declarations to make | 159 // On some platforms we need additional declarations to make |
| 159 // AtomicWord compatible with our other Atomic* types. | 160 // AtomicWord compatible with our other Atomic* types. |
| 160 #if defined(OS_MACOSX) || defined(OS_OPENBSD) | 161 #if defined(OS_MACOSX) || defined(OS_OPENBSD) |
| 161 #include "base/atomicops_internals_atomicword_compat.h" | 162 #include "base/atomicops_internals_atomicword_compat.h" |
| 162 #endif | 163 #endif |
| 163 | 164 |
| 164 #endif // BASE_ATOMICOPS_H_ | 165 #endif // BASE_ATOMICOPS_H_ |
| OLD | NEW |