| 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 26 matching lines...) Expand all Loading... |
| 37 #include <google/protobuf/stubs/atomicops.h> | 37 #include <google/protobuf/stubs/atomicops.h> |
| 38 | 38 |
| 39 #ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ | 39 #ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ |
| 40 | 40 |
| 41 #include <windows.h> | 41 #include <windows.h> |
| 42 | 42 |
| 43 namespace google { | 43 namespace google { |
| 44 namespace protobuf { | 44 namespace protobuf { |
| 45 namespace internal { | 45 namespace internal { |
| 46 | 46 |
| 47 inline void MemoryBarrierInternal() { | 47 inline void MemoryBarrier() { |
| 48 // On ARM this is a define while on x86/x64 this is | 48 // We use MemoryBarrier from WinNT.h |
| 49 // a function declared in WinNT.h | 49 ::MemoryBarrier(); |
| 50 MemoryBarrier(); | |
| 51 } | 50 } |
| 52 | 51 |
| 53 Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, | 52 Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, |
| 54 Atomic32 old_value, | 53 Atomic32 old_value, |
| 55 Atomic32 new_value) { | 54 Atomic32 new_value) { |
| 56 LONG result = InterlockedCompareExchange( | 55 LONG result = InterlockedCompareExchange( |
| 57 reinterpret_cast<volatile LONG*>(ptr), | 56 reinterpret_cast<volatile LONG*>(ptr), |
| 58 static_cast<LONG>(new_value), | 57 static_cast<LONG>(new_value), |
| 59 static_cast<LONG>(old_value)); | 58 static_cast<LONG>(old_value)); |
| 60 return static_cast<Atomic32>(result); | 59 return static_cast<Atomic32>(result); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 103 } |
| 105 | 104 |
| 106 #endif // defined(_WIN64) | 105 #endif // defined(_WIN64) |
| 107 | 106 |
| 108 } // namespace internal | 107 } // namespace internal |
| 109 } // namespace protobuf | 108 } // namespace protobuf |
| 110 } // namespace google | 109 } // namespace google |
| 111 | 110 |
| 112 #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ | 111 #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ |
| 113 #endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY | 112 #endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY |
| OLD | NEW |