| 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 |
| 11 // you plan to use these routines, you should have a good reason, such as solid | 11 // you plan to use these routines, you should have a good reason, such as solid |
| 12 // evidence that performance would otherwise suffer, or there being no | 12 // evidence that performance would otherwise suffer, or there being no |
| 13 // alternative. You should assume only properties explicitly guaranteed by the | 13 // alternative. You should assume only properties explicitly guaranteed by the |
| 14 // specifications in this file. You are almost certainly _not_ writing code | 14 // specifications in this file. You are almost certainly _not_ writing code |
| 15 // just for the x86; if you assume x86 semantics, x86 hardware bugs and | 15 // just for the x86; if you assume x86 semantics, x86 hardware bugs and |
| 16 // implementations on other archtectures will cause your code to break. If you | 16 // implementations on other archtectures will cause your code to break. If you |
| 17 // do not know what you are doing, avoid these routines, and use a Mutex. | 17 // do not know what you are doing, avoid these routines, and use a Mutex. |
| 18 // | 18 // |
| 19 // It is incorrect to make direct assignments to/from an atomic variable. | 19 // It is incorrect to make direct assignments to/from an atomic variable. |
| 20 // You should use one of the Load or Store routines. The NoBarrier | 20 // You should use one of the Load or Store routines. The NoBarrier |
| 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 #pragma once | |
| 31 | 30 |
| 32 #include "base/basictypes.h" | 31 #include "base/basictypes.h" |
| 33 #include "build/build_config.h" | 32 #include "build/build_config.h" |
| 34 | 33 |
| 35 namespace base { | 34 namespace base { |
| 36 namespace subtle { | 35 namespace subtle { |
| 37 | 36 |
| 38 typedef int32 Atomic32; | 37 typedef int32 Atomic32; |
| 39 #ifdef ARCH_CPU_64_BITS | 38 #ifdef ARCH_CPU_64_BITS |
| 40 // We need to be able to go between Atomic64 and AtomicWord implicitly. This | 39 // We need to be able to go between Atomic64 and AtomicWord implicitly. This |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 #error "Atomic operations are not supported on your platform" | 142 #error "Atomic operations are not supported on your platform" |
| 144 #endif | 143 #endif |
| 145 | 144 |
| 146 // On some platforms we need additional declarations to make | 145 // On some platforms we need additional declarations to make |
| 147 // AtomicWord compatible with our other Atomic* types. | 146 // AtomicWord compatible with our other Atomic* types. |
| 148 #if defined(OS_MACOSX) || defined(OS_OPENBSD) | 147 #if defined(OS_MACOSX) || defined(OS_OPENBSD) |
| 149 #include "base/atomicops_internals_atomicword_compat.h" | 148 #include "base/atomicops_internals_atomicword_compat.h" |
| 150 #endif | 149 #endif |
| 151 | 150 |
| 152 #endif // BASE_ATOMICOPS_H_ | 151 #endif // BASE_ATOMICOPS_H_ |
| OLD | NEW |