summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 21:45:24 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 21:45:24 +0000
commit2c57915bb705f2b45d525b56b103d930603441de (patch)
tree1e0d38023ae6fb14669e3564be210973cc988337 /base
parentc792594135cc099020fde19176325e5ae7218dc4 (diff)
downloadchromium_src-2c57915bb705f2b45d525b56b103d930603441de.zip
chromium_src-2c57915bb705f2b45d525b56b103d930603441de.tar.gz
chromium_src-2c57915bb705f2b45d525b56b103d930603441de.tar.bz2
Tweak atomicops implementation for Mac OS X to compile correctly when __LP64__
is defined. Patch by Ben Karel <eschew@gmail.com>. BUG=54554 TEST= - base_unittests --gtest_filter='AtomicOpsTest.*' - Compile base/string_util.cc (outside of Chromium) as 64-bit code on Mac OS X 10.6. Review URL: http://codereview.chromium.org/6091007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/atomicops_internals_x86_macosx.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/base/atomicops_internals_x86_macosx.h b/base/atomicops_internals_x86_macosx.h
index 5de7df3..29e58e3 100644
--- a/base/atomicops_internals_x86_macosx.h
+++ b/base/atomicops_internals_x86_macosx.h
@@ -110,7 +110,7 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64 *ptr,
Atomic64 prev_value;
do {
if (OSAtomicCompareAndSwap64(old_value, new_value,
- const_cast<Atomic64*>(ptr))) {
+ reinterpret_cast<volatile int64_t*>(ptr))) {
return old_value;
}
prev_value = *ptr;
@@ -124,18 +124,19 @@ inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64 *ptr,
do {
old_value = *ptr;
} while (!OSAtomicCompareAndSwap64(old_value, new_value,
- const_cast<Atomic64*>(ptr)));
+ reinterpret_cast<volatile int64_t*>(ptr)));
return old_value;
}
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64 *ptr,
Atomic64 increment) {
- return OSAtomicAdd64(increment, const_cast<Atomic64*>(ptr));
+ return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
}
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64 *ptr,
Atomic64 increment) {
- return OSAtomicAdd64Barrier(increment, const_cast<Atomic64*>(ptr));
+ return OSAtomicAdd64Barrier(increment,
+ reinterpret_cast<volatile int64_t*>(ptr));
}
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64 *ptr,
@@ -143,8 +144,8 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64 *ptr,
Atomic64 new_value) {
Atomic64 prev_value;
do {
- if (OSAtomicCompareAndSwap64Barrier(old_value, new_value,
- const_cast<Atomic64*>(ptr))) {
+ if (OSAtomicCompareAndSwap64Barrier(
+ old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
return old_value;
}
prev_value = *ptr;
@@ -193,12 +194,11 @@ inline Atomic64 Release_Load(volatile const Atomic64 *ptr) {
// MacOS uses long for intptr_t, AtomicWord and Atomic32 are always different
// on the Mac, even when they are the same size. We need to explicitly cast
-// from AtomicWord to Atomic32/64 to implement the AtomicWord interface.
-#ifdef __LP64__
-#define AtomicWordCastType Atomic64
-#else
+// from AtomicWord to Atomic32 to implement the AtomicWord interface.
+// When in 64-bit mode, AtomicWord is the same as Atomic64, so we need not
+// add duplicate definitions.
+#ifndef __LP64__
#define AtomicWordCastType Atomic32
-#endif
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
@@ -273,6 +273,7 @@ inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
}
#undef AtomicWordCastType
+#endif
} // namespace base::subtle
} // namespace base