6917N/AFixes issues in atomic operations.
6917N/A-// Copyright 2014 Google Inc. All rights reserved.
6917N/A+// Copyright 2013 Red Hat Inc. All rights reserved.
6917N/A // Redistribution and use in source and binary forms, with or without
6917N/A // modification, are permitted provided that the following conditions are
6917N/A // copyright notice, this list of conditions and the following disclaimer
6917N/A // in the documentation
and/or other materials provided with the
6917N/A-// * Neither the name of Google Inc. nor the names of its
6917N/A+// * Neither the name of Red Hat Inc. nor the names of its
6917N/A // contributors may be used to endorse or promote products derived from
6917N/A // this software without specific prior written permission.
6917N/A-#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_
6917N/A-#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_
6917N/A+#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_
6917N/A+#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_
6917N/A inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
6917N/A- return (Atomic32)atomic_cas_32((volatile uint32_t*)ptr, (uint32_t)old_value, (uint32_t)new_value);
6917N/A+ __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
6917N/A+ __ATOMIC_RELAXED, __ATOMIC_RELAXED);
6917N/A inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
6917N/A- return (Atomic32)atomic_swap_32((volatile uint32_t*)ptr, (uint32_t)new_value);
6917N/A+ return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED);
6917N/A inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
6917N/A- return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment);
6917N/A-inline void MemoryBarrier(void) {
6917N/A+ return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED);
6917N/A inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
6917N/A- Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment);
6917N/A+ return __atomic_add_fetch(ptr, increment, __ATOMIC_SEQ_CST);
6917N/A inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
6917N/A- Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
6917N/A+ __atomic_compare_exchange(ptr, &old_value, &new_value, true,
6917N/A+ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
6917N/A inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
6917N/A- return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
6917N/A+ __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
6917N/A+ __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
6917N/A inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
6917N/A+ __atomic_store_n(ptr, value, __ATOMIC_RELAXED);
6917N/A+inline void MemoryBarrier() {
6917N/A inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
6917N/A+ __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST);
6917N/A inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
6917N/A+ __atomic_store_n(ptr, value, __ATOMIC_RELEASE);
6917N/A inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
6917N/A+ return __atomic_load_n(ptr, __ATOMIC_RELAXED);
6917N/A inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
6917N/A+ return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
6917N/A inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
6917N/A+ return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
6917N/A-#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
6917N/A-inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
6917N/A- return atomic_cas_64((volatile uint64_t*)ptr, (uint64_t)old_value, (uint64_t)new_value);
6917N/A-inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value) {
6917N/A- return atomic_swap_64((volatile uint64_t*)ptr, (uint64_t)new_value);
6917N/A-inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {
6917N/A- return atomic_add_64_nv((volatile uint64_t*)ptr, increment);
6917N/A+inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
6917N/A+ __atomic_store_n(ptr, value, __ATOMIC_RELEASE);
6917N/A-inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {
6917N/A- Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment);
6917N/A+inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
6917N/A+ return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
6917N/A inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
6917N/A- Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
6917N/A+ __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
6917N/A+ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
6917N/A-inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
6917N/A+inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
6917N/A- return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
6917N/A-inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
6917N/A-inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
6917N/A+ __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
6917N/A+ __ATOMIC_RELAXED, __ATOMIC_RELAXED);
6917N/A-inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
6917N/A-inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
6917N/A-inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
6917N/A-inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
6917N/A+#endif // defined(__LP64__)
6917N/A-#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_
6917N/A+#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_