Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: third_party/tcmalloc/chromium/src/base/atomicops.h

Issue 2818713003: Revert of tcmalloc: Use C++11 atomics where appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
34 // Some fast atomic operations -- typically with machine-dependent 38 // Some fast atomic operations -- typically with machine-dependent
35 // implementations. This file may need editing as Google code is 39 // implementations. This file may need editing as Google code is
36 // ported to different architectures. 40 // ported to different architectures.
37 41
38 // The routines exported by this module are subtle. If you use them, even if 42 // The routines exported by this module are subtle. If you use them, even if
39 // you get the code right, it will depend on careful reasoning about atomicity 43 // you get the code right, it will depend on careful reasoning about atomicity
40 // and memory ordering; it will be less readable, and harder to maintain. If 44 // and memory ordering; it will be less readable, and harder to maintain. If
41 // you plan to use these routines, you should have a good reason, such as solid 45 // you plan to use these routines, you should have a good reason, such as solid
42 // evidence that performance would otherwise suffer, or there being no 46 // evidence that performance would otherwise suffer, or there being no
43 // alternative. You should assume only properties explicitly guaranteed by the 47 // alternative. You should assume only properties explicitly guaranteed by the
(...skipping 28 matching lines...) Expand all
72 // and operations listed below. Implementations are to provide Atomic32 76 // and operations listed below. Implementations are to provide Atomic32
73 // and Atomic64 operations. If there is a mismatch between intptr_t and 77 // and Atomic64 operations. If there is a mismatch between intptr_t and
74 // the Atomic32 or Atomic64 types for a platform, the platform-specific header 78 // the Atomic32 or Atomic64 types for a platform, the platform-specific header
75 // should define the macro, AtomicWordCastType in a clause similar to the 79 // should define the macro, AtomicWordCastType in a clause similar to the
76 // following: 80 // following:
77 // #if ...pointers are 64 bits... 81 // #if ...pointers are 64 bits...
78 // # define AtomicWordCastType base::subtle::Atomic64 82 // # define AtomicWordCastType base::subtle::Atomic64
79 // #else 83 // #else
80 // # define AtomicWordCastType Atomic32 84 // # define AtomicWordCastType Atomic32
81 // #endif 85 // #endif
86 // TODO(csilvers): figure out ARCH_PIII/ARCH_K8 (perhaps via ./configure?)
82 // ------------------------------------------------------------------------ 87 // ------------------------------------------------------------------------
83 88
89 #include "base/arm_instruction_set_select.h"
90
91 // TODO(csilvers): match piii, not just __i386. Also, match k8
84 #if defined(__MACH__) && defined(__APPLE__) 92 #if defined(__MACH__) && defined(__APPLE__)
85 #include "base/atomicops-internals-macosx.h" 93 #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"
86 #elif defined(_WIN32) 98 #elif defined(_WIN32)
87 #include "base/atomicops-internals-windows.h" 99 #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"
88 #else 104 #else
89 #include "base/atomicops_internals_portable.h" 105 // Assume x86 for now. If you need to support a new architecture and
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"
90 #endif 110 #endif
91 111
92 // Signed type that can hold a pointer and supports the atomic ops below, as 112 // Signed type that can hold a pointer and supports the atomic ops below, as
93 // well as atomic loads and stores. Instances must be naturally-aligned. 113 // well as atomic loads and stores. Instances must be naturally-aligned.
94 typedef intptr_t AtomicWord; 114 typedef intptr_t AtomicWord;
95 115
96 #ifdef AtomicWordCastType 116 #ifdef AtomicWordCastType
97 // ------------------------------------------------------------------------ 117 // ------------------------------------------------------------------------
98 // This section is needed only when explicit type casting is required to 118 // This section is needed only when explicit type casting is required to
99 // cast AtomicWord to one of the basic atomic types (Atomic64 or Atomic32). 119 // cast AtomicWord to one of the basic atomic types (Atomic64 or Atomic32).
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return base::subtle::Acquire_Load(ptr); 382 return base::subtle::Acquire_Load(ptr);
363 } 383 }
364 inline base::subtle::Atomic64 Release_Load( 384 inline base::subtle::Atomic64 Release_Load(
365 volatile const base::subtle::Atomic64* ptr) { 385 volatile const base::subtle::Atomic64* ptr) {
366 return base::subtle::Release_Load(ptr); 386 return base::subtle::Release_Load(ptr);
367 } 387 }
368 388
369 #endif // BASE_HAS_ATOMIC64 389 #endif // BASE_HAS_ATOMIC64
370 390
371 #endif // THREAD_ATOMICOPS_H_ 391 #endif // THREAD_ATOMICOPS_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/README.chromium ('k') | third_party/tcmalloc/chromium/src/base/atomicops-internals-arm-generic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698