Fix issue 412: update protobuf for 64-bit compatibility on Mac OS X - patch from Mark Mentovai

This commit is contained in:
xiaofeng@google.com 2012-11-14 13:38:10 +00:00
parent a058718f7a
commit a4491ea142
2 changed files with 9 additions and 8 deletions

View File

@ -44,7 +44,7 @@
// On LP64 platforms, AtomicWord and Atomic64 are both always long, // On LP64 platforms, AtomicWord and Atomic64 are both always long,
// so this problem doesn't occur. // so this problem doesn't occur.
#if !defined(GOOGLE_PROTOBUF_HOST_ARCH_64_BIT) #if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -117,6 +117,6 @@ inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
#endif // !defined(GOOGLE_PROTOBUF_HOST_ARCH_64_BIT) #endif // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_

View File

@ -136,7 +136,7 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 prev_value; Atomic64 prev_value;
do { do {
if (OSAtomicCompareAndSwap64(old_value, new_value, if (OSAtomicCompareAndSwap64(old_value, new_value,
const_cast<Atomic64*>(ptr))) { reinterpret_cast<volatile int64_t*>(ptr))) {
return old_value; return old_value;
} }
prev_value = *ptr; prev_value = *ptr;
@ -150,18 +150,19 @@ inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
do { do {
old_value = *ptr; old_value = *ptr;
} while (!OSAtomicCompareAndSwap64(old_value, new_value, } while (!OSAtomicCompareAndSwap64(old_value, new_value,
const_cast<Atomic64*>(ptr))); reinterpret_cast<volatile int64_t*>(ptr)));
return old_value; return old_value;
} }
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) { 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, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) { 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, inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
@ -169,8 +170,8 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 new_value) { Atomic64 new_value) {
Atomic64 prev_value; Atomic64 prev_value;
do { do {
if (OSAtomicCompareAndSwap64Barrier(old_value, new_value, if (OSAtomicCompareAndSwap64Barrier(
const_cast<Atomic64*>(ptr))) { old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
return old_value; return old_value;
} }
prev_value = *ptr; prev_value = *ptr;