| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2012 Google Inc. All rights reserved. | 2 // Copyright 2012 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, | 116 Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, |
| 117 Atomic32 increment); | 117 Atomic32 increment); |
| 118 | 118 |
| 119 // These following lower-level operations are typically useful only to people | 119 // These following lower-level operations are typically useful only to people |
| 120 // implementing higher-level synchronization operations like spinlocks, | 120 // implementing higher-level synchronization operations like spinlocks, |
| 121 // mutexes, and condition-variables. They combine CompareAndSwap(), a load, or | 121 // mutexes, and condition-variables. They combine CompareAndSwap(), a load, or |
| 122 // a store with appropriate memory-ordering instructions. "Acquire" operations | 122 // a store with appropriate memory-ordering instructions. "Acquire" operations |
| 123 // ensure that no later memory access can be reordered ahead of the operation. | 123 // ensure that no later memory access can be reordered ahead of the operation. |
| 124 // "Release" operations ensure that no previous memory access can be reordered | 124 // "Release" operations ensure that no previous memory access can be reordered |
| 125 // after the operation. "Barrier" operations have both "Acquire" and "Release" | 125 // after the operation. "Barrier" operations have both "Acquire" and "Release" |
| 126 // semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory | 126 // semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no |
| 127 // access. | 127 // memory access. |
| 128 Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, | 128 Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, |
| 129 Atomic32 old_value, | 129 Atomic32 old_value, |
| 130 Atomic32 new_value); | 130 Atomic32 new_value); |
| 131 Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, | 131 Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, |
| 132 Atomic32 old_value, | 132 Atomic32 old_value, |
| 133 Atomic32 new_value); | 133 Atomic32 new_value); |
| 134 | 134 |
| 135 #if defined(__MINGW32__) && defined(MemoryBarrier) | 135 // This function was renamed from MemoryBarrier to MemoryBarrierInternal |
| 136 #undef MemoryBarrier | 136 // because MemoryBarrier is a define in Windows ARM builds and we do not |
| 137 #endif | 137 // undefine it because we call it from this function. |
| 138 void MemoryBarrier(); | 138 void MemoryBarrierInternal(); |
| 139 void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); | 139 void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); |
| 140 void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); | 140 void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); |
| 141 void Release_Store(volatile Atomic32* ptr, Atomic32 value); | 141 void Release_Store(volatile Atomic32* ptr, Atomic32 value); |
| 142 | 142 |
| 143 Atomic32 NoBarrier_Load(volatile const Atomic32* ptr); | 143 Atomic32 NoBarrier_Load(volatile const Atomic32* ptr); |
| 144 Atomic32 Acquire_Load(volatile const Atomic32* ptr); | 144 Atomic32 Acquire_Load(volatile const Atomic32* ptr); |
| 145 Atomic32 Release_Load(volatile const Atomic32* ptr); | 145 Atomic32 Release_Load(volatile const Atomic32* ptr); |
| 146 | 146 |
| 147 // 64-bit atomic operations (only available on 64-bit processors). | 147 // 64-bit atomic operations (only available on 64-bit processors). |
| 148 #ifdef GOOGLE_PROTOBUF_ARCH_64_BIT | 148 #ifdef GOOGLE_PROTOBUF_ARCH_64_BIT |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 | 173 |
| 174 // Include our platform specific implementation. | 174 // Include our platform specific implementation. |
| 175 #define GOOGLE_PROTOBUF_ATOMICOPS_ERROR \ | 175 #define GOOGLE_PROTOBUF_ATOMICOPS_ERROR \ |
| 176 "Atomic operations are not supported on your platform" | 176 "Atomic operations are not supported on your platform" |
| 177 | 177 |
| 178 // ThreadSanitizer, http://clang.llvm.org/docs/ThreadSanitizer.html. | 178 // ThreadSanitizer, http://clang.llvm.org/docs/ThreadSanitizer.html. |
| 179 #if defined(THREAD_SANITIZER) | 179 #if defined(THREAD_SANITIZER) |
| 180 #include <google/protobuf/stubs/atomicops_internals_tsan.h> | 180 #include <google/protobuf/stubs/atomicops_internals_tsan.h> |
| 181 // MSVC. | 181 // MSVC. |
| 182 #elif defined(_MSC_VER) | 182 #elif defined(_MSC_VER) |
| 183 #if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) | 183 #if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) || d
efined(GOOGLE_PROTOBUF_ARCH_ARM) |
| 184 #include <google/protobuf/stubs/atomicops_internals_x86_msvc.h> | 184 #include <google/protobuf/stubs/atomicops_internals_x86_msvc.h> |
| 185 #else | 185 #else |
| 186 #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR | 186 #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR |
| 187 #endif | 187 #endif |
| 188 | 188 |
| 189 // Solaris | 189 // Solaris |
| 190 #elif defined(GOOGLE_PROTOBUF_OS_SOLARIS) | 190 #elif defined(GOOGLE_PROTOBUF_OS_SOLARIS) |
| 191 #include <google/protobuf/stubs/atomicops_internals_solaris.h> | 191 #include <google/protobuf/stubs/atomicops_internals_solaris.h> |
| 192 | 192 |
| 193 // AIX | 193 // AIX |
| 194 #elif defined(GOOGLE_PROTOBUF_OS_AIX) | 194 #elif defined(GOOGLE_PROTOBUF_OS_AIX) |
| 195 #include <google/protobuf/stubs/atomicops_internals_power.h> | 195 #include <google/protobuf/stubs/atomicops_internals_power.h> |
| 196 | 196 |
| 197 // Apple. | 197 // Apple. |
| 198 #elif defined(GOOGLE_PROTOBUF_OS_APPLE) | 198 #elif defined(GOOGLE_PROTOBUF_OS_APPLE) |
| 199 #if __has_feature(cxx_atomic) || _GNUC_VER >= 407 |
| 200 #include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h> |
| 201 #else // __has_feature(cxx_atomic) || _GNUC_VER >= 407 |
| 199 #include <google/protobuf/stubs/atomicops_internals_macosx.h> | 202 #include <google/protobuf/stubs/atomicops_internals_macosx.h> |
| 203 #endif // __has_feature(cxx_atomic) || _GNUC_VER >= 407 |
| 200 | 204 |
| 201 // GCC. | 205 // GCC. |
| 202 #elif defined(__GNUC__) | 206 #elif defined(__GNUC__) |
| 203 #if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) | 207 #if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) |
| 204 #include <google/protobuf/stubs/atomicops_internals_x86_gcc.h> | 208 #include <google/protobuf/stubs/atomicops_internals_x86_gcc.h> |
| 205 #elif defined(GOOGLE_PROTOBUF_ARCH_ARM) && defined(__linux__) | 209 #elif defined(GOOGLE_PROTOBUF_ARCH_ARM) && defined(__linux__) |
| 210 #if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) |
| 211 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> |
| 212 #else |
| 206 #include <google/protobuf/stubs/atomicops_internals_arm_gcc.h> | 213 #include <google/protobuf/stubs/atomicops_internals_arm_gcc.h> |
| 214 #endif |
| 207 #elif defined(GOOGLE_PROTOBUF_ARCH_AARCH64) | 215 #elif defined(GOOGLE_PROTOBUF_ARCH_AARCH64) |
| 208 #include <google/protobuf/stubs/atomicops_internals_arm64_gcc.h> | 216 #include <google/protobuf/stubs/atomicops_internals_arm64_gcc.h> |
| 209 #elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX) | 217 #elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX) |
| 210 #include <google/protobuf/stubs/atomicops_internals_arm_qnx.h> | 218 #include <google/protobuf/stubs/atomicops_internals_arm_qnx.h> |
| 211 #elif defined(GOOGLE_PROTOBUF_ARCH_MIPS) || defined(GOOGLE_PROTOBUF_ARCH_MIPS64) | 219 #elif defined(GOOGLE_PROTOBUF_ARCH_MIPS) || defined(GOOGLE_PROTOBUF_ARCH_MIPS64) |
| 212 #include <google/protobuf/stubs/atomicops_internals_mips_gcc.h> | 220 #include <google/protobuf/stubs/atomicops_internals_mips_gcc.h> |
| 213 #elif defined(GOOGLE_PROTOBUF_ARCH_POWER) | 221 #elif defined(GOOGLE_PROTOBUF_ARCH_POWER) |
| 214 #include <google/protobuf/stubs/atomicops_internals_power.h> | 222 #include <google/protobuf/stubs/atomicops_internals_power.h> |
| 215 #elif defined(__native_client__) | 223 #elif defined(__native_client__) |
| 216 #include <google/protobuf/stubs/atomicops_internals_pnacl.h> | 224 #include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h> |
| 217 #elif defined(GOOGLE_PROTOBUF_ARCH_PPC) | 225 #elif defined(GOOGLE_PROTOBUF_ARCH_PPC) |
| 218 #include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h> | 226 #include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h> |
| 219 #elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) | 227 #elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) |
| 220 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> | 228 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> |
| 221 #elif defined(__clang__) | 229 #elif defined(__clang__) |
| 222 #if __has_extension(c_atomic) | 230 #if __has_extension(c_atomic) |
| 223 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> | 231 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> |
| 224 #else | 232 #else |
| 225 #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR | 233 #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR |
| 226 #endif | 234 #endif |
| (...skipping 10 matching lines...) Expand all Loading... |
| 237 // compatible with our other Atomic* types. | 245 // compatible with our other Atomic* types. |
| 238 #if defined(GOOGLE_PROTOBUF_OS_APPLE) | 246 #if defined(GOOGLE_PROTOBUF_OS_APPLE) |
| 239 #include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h> | 247 #include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h> |
| 240 #endif | 248 #endif |
| 241 | 249 |
| 242 #undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR | 250 #undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR |
| 243 | 251 |
| 244 #endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY | 252 #endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY |
| 245 | 253 |
| 246 #endif // GOOGLE_PROTOBUF_ATOMICOPS_H_ | 254 #endif // GOOGLE_PROTOBUF_ATOMICOPS_H_ |
| OLD | NEW |