| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2015 Google Inc. All rights reserved. | 2 // Copyright 2015 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 "bne- 0b \n\t" | 90 "bne- 0b \n\t" |
| 91 : [temp] "=&r"(temp) | 91 : [temp] "=&r"(temp) |
| 92 : [increment] "r"(increment), [ptr] "r"(ptr) | 92 : [increment] "r"(increment), [ptr] "r"(ptr) |
| 93 : "cc", "memory"); | 93 : "cc", "memory"); |
| 94 | 94 |
| 95 return temp; | 95 return temp; |
| 96 } | 96 } |
| 97 | 97 |
| 98 inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, | 98 inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, |
| 99 Atomic32 increment) { | 99 Atomic32 increment) { |
| 100 MemoryBarrier(); | 100 MemoryBarrierInternal(); |
| 101 Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); | 101 Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); |
| 102 MemoryBarrier(); | 102 MemoryBarrierInternal(); |
| 103 return res; | 103 return res; |
| 104 } | 104 } |
| 105 | 105 |
| 106 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, | 106 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, |
| 107 Atomic32 old_value, Atomic32 new_value) { | 107 Atomic32 old_value, Atomic32 new_value) { |
| 108 Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); | 108 Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); |
| 109 MemoryBarrier(); | 109 MemoryBarrierInternal(); |
| 110 return res; | 110 return res; |
| 111 } | 111 } |
| 112 | 112 |
| 113 inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, | 113 inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, |
| 114 Atomic32 old_value, Atomic32 new_value) { | 114 Atomic32 old_value, Atomic32 new_value) { |
| 115 MemoryBarrier(); | 115 MemoryBarrierInternal(); |
| 116 Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); | 116 Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); |
| 117 return res; | 117 return res; |
| 118 } | 118 } |
| 119 | 119 |
| 120 inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) { | 120 inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) { |
| 121 *ptr = value; | 121 *ptr = value; |
| 122 } | 122 } |
| 123 | 123 |
| 124 inline void MemoryBarrier() { __asm__ __volatile__("sync" : : : "memory"); } | 124 inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"
); } |
| 125 | 125 |
| 126 inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) { | 126 inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) { |
| 127 *ptr = value; | 127 *ptr = value; |
| 128 MemoryBarrier(); | 128 MemoryBarrierInternal(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) { | 131 inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) { |
| 132 MemoryBarrier(); | 132 MemoryBarrierInternal(); |
| 133 *ptr = value; | 133 *ptr = value; |
| 134 } | 134 } |
| 135 | 135 |
| 136 inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; } | 136 inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; } |
| 137 | 137 |
| 138 inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) { | 138 inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) { |
| 139 Atomic32 value = *ptr; | 139 Atomic32 value = *ptr; |
| 140 MemoryBarrier(); | 140 MemoryBarrierInternal(); |
| 141 return value; | 141 return value; |
| 142 } | 142 } |
| 143 | 143 |
| 144 inline Atomic32 Release_Load(volatile const Atomic32 *ptr) { | 144 inline Atomic32 Release_Load(volatile const Atomic32 *ptr) { |
| 145 MemoryBarrier(); | 145 MemoryBarrierInternal(); |
| 146 return *ptr; | 146 return *ptr; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace internal | 149 } // namespace internal |
| 150 } // namespace protobuf | 150 } // namespace protobuf |
| 151 } // namespace google | 151 } // namespace google |
| 152 | 152 |
| 153 #undef ATOMICOPS_COMPILER_BARRIER | 153 #undef ATOMICOPS_COMPILER_BARRIER |
| 154 | 154 |
| 155 #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PPC_GCC_H_ | 155 #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PPC_GCC_H_ |
| OLD | NEW |