OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_ATOMIC_WIN_H_ | 5 #ifndef RUNTIME_VM_ATOMIC_WIN_H_ |
6 #define RUNTIME_VM_ATOMIC_WIN_H_ | 6 #define RUNTIME_VM_ATOMIC_WIN_H_ |
7 | 7 |
8 #if !defined RUNTIME_VM_ATOMIC_H_ | 8 #if !defined RUNTIME_VM_ATOMIC_H_ |
9 #error Do not include atomic_win.h directly. Use atomic.h instead. | 9 #error Do not include atomic_win.h directly. Use atomic.h instead. |
10 #endif | 10 #endif |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #if defined(HOST_ARCH_X64) | 95 #if defined(HOST_ARCH_X64) |
96 InterlockedExchangeAdd64(reinterpret_cast<LONGLONG*>(p), | 96 InterlockedExchangeAdd64(reinterpret_cast<LONGLONG*>(p), |
97 static_cast<LONGLONG>(-value)); | 97 static_cast<LONGLONG>(-value)); |
98 #elif defined(HOST_ARCH_IA32) | 98 #elif defined(HOST_ARCH_IA32) |
99 InterlockedExchangeAdd(reinterpret_cast<LONG*>(p), static_cast<LONG>(-value)); | 99 InterlockedExchangeAdd(reinterpret_cast<LONG*>(p), static_cast<LONG>(-value)); |
100 #else | 100 #else |
101 #error Unsupported host architecture. | 101 #error Unsupported host architecture. |
102 #endif | 102 #endif |
103 } | 103 } |
104 | 104 |
105 #if !defined(USING_SIMULATOR) | |
106 inline uword AtomicOperations::CompareAndSwapWord(uword* ptr, | 105 inline uword AtomicOperations::CompareAndSwapWord(uword* ptr, |
107 uword old_value, | 106 uword old_value, |
108 uword new_value) { | 107 uword new_value) { |
109 #if defined(HOST_ARCH_X64) | 108 #if defined(HOST_ARCH_X64) |
110 return static_cast<uword>(InterlockedCompareExchange64( | 109 return static_cast<uword>(InterlockedCompareExchange64( |
111 reinterpret_cast<LONGLONG*>(ptr), static_cast<LONGLONG>(new_value), | 110 reinterpret_cast<LONGLONG*>(ptr), static_cast<LONGLONG>(new_value), |
112 static_cast<LONGLONG>(old_value))); | 111 static_cast<LONGLONG>(old_value))); |
113 #elif defined(HOST_ARCH_IA32) | 112 #elif defined(HOST_ARCH_IA32) |
114 return static_cast<uword>(InterlockedCompareExchange( | 113 return static_cast<uword>(InterlockedCompareExchange( |
115 reinterpret_cast<LONG*>(ptr), static_cast<LONG>(new_value), | 114 reinterpret_cast<LONG*>(ptr), static_cast<LONG>(new_value), |
116 static_cast<LONG>(old_value))); | 115 static_cast<LONG>(old_value))); |
117 #else | 116 #else |
118 #error Unsupported host architecture. | 117 #error Unsupported host architecture. |
119 #endif | 118 #endif |
120 } | 119 } |
121 inline uint32_t AtomicOperations::CompareAndSwapUint32(uint32_t* ptr, | 120 inline uint32_t AtomicOperations::CompareAndSwapUint32(uint32_t* ptr, |
122 uint32_t old_value, | 121 uint32_t old_value, |
123 uint32_t new_value) { | 122 uint32_t new_value) { |
124 #if (defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32)) | 123 #if (defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32)) |
125 return static_cast<uint32_t>(InterlockedCompareExchange( | 124 return static_cast<uint32_t>(InterlockedCompareExchange( |
126 reinterpret_cast<LONG*>(ptr), static_cast<LONG>(new_value), | 125 reinterpret_cast<LONG*>(ptr), static_cast<LONG>(new_value), |
127 static_cast<LONG>(old_value))); | 126 static_cast<LONG>(old_value))); |
128 #else | 127 #else |
129 #error Unsupported host architecture. | 128 #error Unsupported host architecture. |
130 #endif | 129 #endif |
131 } | 130 } |
132 #endif // !defined(USING_SIMULATOR) | |
133 | 131 |
134 } // namespace dart | 132 } // namespace dart |
135 | 133 |
136 #endif // RUNTIME_VM_ATOMIC_WIN_H_ | 134 #endif // RUNTIME_VM_ATOMIC_WIN_H_ |
OLD | NEW |