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 VM_ATOMIC_WIN_H_ | 5 #ifndef VM_ATOMIC_WIN_H_ |
6 #define VM_ATOMIC_WIN_H_ | 6 #define VM_ATOMIC_WIN_H_ |
7 | 7 |
8 #if !defined VM_ATOMIC_H_ | 8 #if !defined 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 |
11 | 11 |
12 #if !defined(TARGET_OS_WINDOWS) | 12 #if !defined(TARGET_OS_WINDOWS) |
13 #error This file should only be included on Windows builds. | 13 #error This file should only be included on Windows builds. |
14 #endif | 14 #endif |
15 | 15 |
| 16 #include <atomic> |
| 17 |
16 namespace dart { | 18 namespace dart { |
17 | 19 |
| 20 template<typename T> T AtomicOperations::LoadAcquire(T* ptr) { |
| 21 return atomic_load_explicit(ptr, memory_order_acquire); |
| 22 } |
| 23 |
| 24 |
| 25 template<typename T> void AtomicOperations::StoreRelease(T* ptr, T val) { |
| 26 return atomic_store_explicit(ptr, val, memory_order_release); |
| 27 } |
| 28 |
| 29 |
18 inline uintptr_t AtomicOperations::FetchAndIncrement(uintptr_t* p) { | 30 inline uintptr_t AtomicOperations::FetchAndIncrement(uintptr_t* p) { |
19 #if defined(HOST_ARCH_X64) | 31 #if defined(HOST_ARCH_X64) |
20 return static_cast<uintptr_t>( | 32 return static_cast<uintptr_t>( |
21 InterlockedIncrement64(reinterpret_cast<LONGLONG*>(p))) - 1; | 33 InterlockedIncrement64(reinterpret_cast<LONGLONG*>(p))) - 1; |
22 #elif defined(HOST_ARCH_IA32) | 34 #elif defined(HOST_ARCH_IA32) |
23 return static_cast<uintptr_t>( | 35 return static_cast<uintptr_t>( |
24 InterlockedIncrement(reinterpret_cast<LONG*>(p))) - 1; | 36 InterlockedIncrement(reinterpret_cast<LONG*>(p))) - 1; |
25 #else | 37 #else |
26 #error Unsupported host architecture. | 38 #error Unsupported host architecture. |
27 #endif | 39 #endif |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 static_cast<LONG>(old_value))); | 117 static_cast<LONG>(old_value))); |
106 #else | 118 #else |
107 #error Unsupported host architecture. | 119 #error Unsupported host architecture. |
108 #endif | 120 #endif |
109 } | 121 } |
110 #endif // !defined(USING_SIMULATOR) | 122 #endif // !defined(USING_SIMULATOR) |
111 | 123 |
112 } // namespace dart | 124 } // namespace dart |
113 | 125 |
114 #endif // VM_ATOMIC_WIN_H_ | 126 #endif // VM_ATOMIC_WIN_H_ |
OLD | NEW |