| OLD | NEW |
| 1 /* Copyright (c) 2006, Google Inc. | 1 /* Copyright (c) 2006, Google Inc. |
| 2 * All rights reserved. | 2 * All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 * | 29 * |
| 30 * --- | 30 * --- |
| 31 * Author: Sanjay Ghemawat | 31 * Author: Sanjay Ghemawat |
| 32 */ | 32 */ |
| 33 | 33 |
| 34 // For atomic operations on statistics counters, see atomic_stats_counter.h. | |
| 35 // For atomic operations on sequence numbers, see atomic_sequence_num.h. | |
| 36 // For atomic operations on reference counts, see atomic_refcount.h. | |
| 37 | |
| 38 // Some fast atomic operations -- typically with machine-dependent | 34 // Some fast atomic operations -- typically with machine-dependent |
| 39 // implementations. This file may need editing as Google code is | 35 // implementations. This file may need editing as Google code is |
| 40 // ported to different architectures. | 36 // ported to different architectures. |
| 41 | 37 |
| 42 // The routines exported by this module are subtle. If you use them, even if | 38 // The routines exported by this module are subtle. If you use them, even if |
| 43 // you get the code right, it will depend on careful reasoning about atomicity | 39 // you get the code right, it will depend on careful reasoning about atomicity |
| 44 // and memory ordering; it will be less readable, and harder to maintain. If | 40 // and memory ordering; it will be less readable, and harder to maintain. If |
| 45 // you plan to use these routines, you should have a good reason, such as solid | 41 // you plan to use these routines, you should have a good reason, such as solid |
| 46 // evidence that performance would otherwise suffer, or there being no | 42 // evidence that performance would otherwise suffer, or there being no |
| 47 // alternative. You should assume only properties explicitly guaranteed by the | 43 // alternative. You should assume only properties explicitly guaranteed by the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 76 // and operations listed below. Implementations are to provide Atomic32 | 72 // and operations listed below. Implementations are to provide Atomic32 |
| 77 // and Atomic64 operations. If there is a mismatch between intptr_t and | 73 // and Atomic64 operations. If there is a mismatch between intptr_t and |
| 78 // the Atomic32 or Atomic64 types for a platform, the platform-specific header | 74 // the Atomic32 or Atomic64 types for a platform, the platform-specific header |
| 79 // should define the macro, AtomicWordCastType in a clause similar to the | 75 // should define the macro, AtomicWordCastType in a clause similar to the |
| 80 // following: | 76 // following: |
| 81 // #if ...pointers are 64 bits... | 77 // #if ...pointers are 64 bits... |
| 82 // # define AtomicWordCastType base::subtle::Atomic64 | 78 // # define AtomicWordCastType base::subtle::Atomic64 |
| 83 // #else | 79 // #else |
| 84 // # define AtomicWordCastType Atomic32 | 80 // # define AtomicWordCastType Atomic32 |
| 85 // #endif | 81 // #endif |
| 86 // TODO(csilvers): figure out ARCH_PIII/ARCH_K8 (perhaps via ./configure?) | |
| 87 // ------------------------------------------------------------------------ | 82 // ------------------------------------------------------------------------ |
| 88 | 83 |
| 89 #include "base/arm_instruction_set_select.h" | |
| 90 | |
| 91 // TODO(csilvers): match piii, not just __i386. Also, match k8 | |
| 92 #if defined(__MACH__) && defined(__APPLE__) | 84 #if defined(__MACH__) && defined(__APPLE__) |
| 93 #include "base/atomicops-internals-macosx.h" | 85 #include "base/atomicops-internals-macosx.h" |
| 94 #elif defined(__GNUC__) && defined(ARMV6) | |
| 95 #include "base/atomicops-internals-arm-v6plus.h" | |
| 96 #elif defined(ARMV3) | |
| 97 #include "base/atomicops-internals-arm-generic.h" | |
| 98 #elif defined(_WIN32) | 86 #elif defined(_WIN32) |
| 99 #include "base/atomicops-internals-windows.h" | 87 #include "base/atomicops-internals-windows.h" |
| 100 #elif defined(__GNUC__) && (defined(__i386) || defined(__x86_64__)) | |
| 101 #include "base/atomicops-internals-x86.h" | |
| 102 #elif defined(__linux__) && defined(__PPC__) | |
| 103 #include "base/atomicops-internals-linuxppc.h" | |
| 104 #else | 88 #else |
| 105 // Assume x86 for now. If you need to support a new architecture and | 89 #include "base/atomicops_internals_portable.h" |
| 106 // don't know how to implement atomic ops, you can probably get away | |
| 107 // with using pthreads, since atomicops is only used by spinlock.h/cc | |
| 108 //#error You need to implement atomic operations for this architecture | |
| 109 #include "base/atomicops-internals-x86.h" | |
| 110 #endif | 90 #endif |
| 111 | 91 |
| 112 // Signed type that can hold a pointer and supports the atomic ops below, as | 92 // Signed type that can hold a pointer and supports the atomic ops below, as |
| 113 // well as atomic loads and stores. Instances must be naturally-aligned. | 93 // well as atomic loads and stores. Instances must be naturally-aligned. |
| 114 typedef intptr_t AtomicWord; | 94 typedef intptr_t AtomicWord; |
| 115 | 95 |
| 116 #ifdef AtomicWordCastType | 96 #ifdef AtomicWordCastType |
| 117 // ------------------------------------------------------------------------ | 97 // ------------------------------------------------------------------------ |
| 118 // This section is needed only when explicit type casting is required to | 98 // This section is needed only when explicit type casting is required to |
| 119 // cast AtomicWord to one of the basic atomic types (Atomic64 or Atomic32). | 99 // cast AtomicWord to one of the basic atomic types (Atomic64 or Atomic32). |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 return base::subtle::Acquire_Load(ptr); | 362 return base::subtle::Acquire_Load(ptr); |
| 383 } | 363 } |
| 384 inline base::subtle::Atomic64 Release_Load( | 364 inline base::subtle::Atomic64 Release_Load( |
| 385 volatile const base::subtle::Atomic64* ptr) { | 365 volatile const base::subtle::Atomic64* ptr) { |
| 386 return base::subtle::Release_Load(ptr); | 366 return base::subtle::Release_Load(ptr); |
| 387 } | 367 } |
| 388 | 368 |
| 389 #endif // BASE_HAS_ATOMIC64 | 369 #endif // BASE_HAS_ATOMIC64 |
| 390 | 370 |
| 391 #endif // THREAD_ATOMICOPS_H_ | 371 #endif // THREAD_ATOMICOPS_H_ |
| OLD | NEW |