Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: runtime/vm/atomic_win.h

Issue 1644393003: Use InterlockedExchangeAdd varient instead of InterlockedAdd which doesn't seem to be available on … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-usage Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 10 matching lines...) Expand all
21 InterlockedIncrement64(reinterpret_cast<LONGLONG*>(p))) - 1; 21 InterlockedIncrement64(reinterpret_cast<LONGLONG*>(p))) - 1;
22 #elif defined(HOST_ARCH_IA32) 22 #elif defined(HOST_ARCH_IA32)
23 return static_cast<uintptr_t>( 23 return static_cast<uintptr_t>(
24 InterlockedIncrement(reinterpret_cast<LONG*>(p))) - 1; 24 InterlockedIncrement(reinterpret_cast<LONG*>(p))) - 1;
25 #else 25 #else
26 #error Unsupported host architecture. 26 #error Unsupported host architecture.
27 #endif 27 #endif
28 } 28 }
29 29
30 30
31 inline uintptr_t AtomicOperations::FetchAndIncrementBy(intptr_t* p, 31 inline uintptr_t AtomicOperations::FetchAndIncrementBy(intptr_t* p,
rmacnak 2016/01/30 01:04:20 Since this changes the (as yet unused) return valu
siva 2016/01/30 01:07:26 Will fix in a new CL.
32 intptr_t value) { 32 intptr_t value) {
33 #if defined(HOST_ARCH_X64) 33 #if defined(HOST_ARCH_X64)
34 return static_cast<uintptr_t>( 34 return static_cast<uintptr_t>(
35 InterlockedAdd64(reinterpret_cast<LONGLONG*>(p), 35 InterlockedExchangeAdd64(reinterpret_cast<LONGLONG*>(p),
36 static_cast<LONGLONG>(value))) - value; 36 static_cast<LONGLONG>(value)));
37 #elif defined(HOST_ARCH_IA32) 37 #elif defined(HOST_ARCH_IA32)
38 return static_cast<uintptr_t>( 38 return static_cast<uintptr_t>(
39 InterlockedAdd(reinterpret_cast<LONG*>(p), 39 InterlockedExchangeAdd(reinterpret_cast<LONG*>(p),
40 static_cast<LONG>(value))) - value; 40 static_cast<LONG>(value)));
41 #else 41 #else
42 #error Unsupported host architecture. 42 #error Unsupported host architecture.
43 #endif 43 #endif
44 } 44 }
45 45
46 46
47 inline uintptr_t AtomicOperations::FetchAndDecrement(uintptr_t* p) { 47 inline uintptr_t AtomicOperations::FetchAndDecrement(uintptr_t* p) {
48 #if defined(HOST_ARCH_X64) 48 #if defined(HOST_ARCH_X64)
49 return static_cast<uintptr_t>( 49 return static_cast<uintptr_t>(
50 InterlockedDecrement64(reinterpret_cast<LONGLONG*>(p))) + 1; 50 InterlockedDecrement64(reinterpret_cast<LONGLONG*>(p))) + 1;
51 #elif defined(HOST_ARCH_IA32) 51 #elif defined(HOST_ARCH_IA32)
52 return static_cast<uintptr_t>( 52 return static_cast<uintptr_t>(
53 InterlockedDecrement(reinterpret_cast<LONG*>(p))) + 1; 53 InterlockedDecrement(reinterpret_cast<LONG*>(p))) + 1;
54 #else 54 #else
55 #error Unsupported host architecture. 55 #error Unsupported host architecture.
56 #endif 56 #endif
57 } 57 }
58 58
59 59
60 inline uintptr_t AtomicOperations::FetchAndDecrementBy(intptr_t* p, 60 inline uintptr_t AtomicOperations::FetchAndDecrementBy(intptr_t* p,
61 intptr_t value) { 61 intptr_t value) {
62 #if defined(HOST_ARCH_X64) 62 #if defined(HOST_ARCH_X64)
63 return static_cast<uintptr_t>( 63 return static_cast<uintptr_t>(
64 InterlockedAdd64(reinterpret_cast<LONGLONG*>(p), 64 InterlockedExchangeAdd64(reinterpret_cast<LONGLONG*>(p),
65 static_cast<LONGLONG>(-value))) + value; 65 static_cast<LONGLONG>(-value)));
66 #elif defined(HOST_ARCH_IA32) 66 #elif defined(HOST_ARCH_IA32)
67 return static_cast<uintptr_t>( 67 return static_cast<uintptr_t>(
68 InterlockedAdd(reinterpret_cast<LONG*>(p), 68 InterlockedExchangeAdd(reinterpret_cast<LONG*>(p),
69 static_cast<LONG>(-value))) + value; 69 static_cast<LONG>(-value)));
70 #else 70 #else
71 #error Unsupported host architecture. 71 #error Unsupported host architecture.
72 #endif 72 #endif
73 } 73 }
74 74
75 75
76 #if !defined(USING_SIMULATOR) 76 #if !defined(USING_SIMULATOR)
77 inline uword AtomicOperations::CompareAndSwapWord(uword* ptr, 77 inline uword AtomicOperations::CompareAndSwapWord(uword* ptr,
78 uword old_value, 78 uword old_value,
79 uword new_value) { 79 uword new_value) {
(...skipping 21 matching lines...) Expand all
101 static_cast<LONG>(old_value))); 101 static_cast<LONG>(old_value)));
102 #else 102 #else
103 #error Unsupported host architecture. 103 #error Unsupported host architecture.
104 #endif 104 #endif
105 } 105 }
106 #endif // !defined(USING_SIMULATOR) 106 #endif // !defined(USING_SIMULATOR)
107 107
108 } // namespace dart 108 } // namespace dart
109 109
110 #endif // VM_ATOMIC_WIN_H_ 110 #endif // VM_ATOMIC_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698