Chromium Code Reviews| Index: runtime/vm/atomic_win.h |
| diff --git a/runtime/vm/atomic_win.h b/runtime/vm/atomic_win.h |
| index 24be3b12c8bc33573215d4fe583a94fa22482974..ccec5278351f366388ad60ec6b1ab0cfad81526a 100644 |
| --- a/runtime/vm/atomic_win.h |
| +++ b/runtime/vm/atomic_win.h |
| @@ -28,6 +28,19 @@ inline uintptr_t AtomicOperations::FetchAndIncrement(uintptr_t* p) { |
| } |
| +inline intptr_t AtomicOperations::FetchAndAdd(intptr_t* p, intptr_t delta) { |
| +#if defined(TARGET_ARCH_X64) |
| + return static_cast<intptr_t>( |
| + InterlockedAdd64(reinterpret_cast<LONGLONG*>(p), delta)) - 1; |
|
Ivan Posva
2015/08/07 20:55:46
What does the -1 mean here?
koda
2015/08/07 21:05:22
Fixed to 'delta' (InterlockedAdd returns the value
|
| +#elif defined(TARGET_ARCH_IA32) |
| + return static_cast<intptr_t>( |
| + InterlockedAdd(reinterpret_cast<LONG*>(p), delta)) - 1; |
| +#else |
| + UNIMPLEMENTED(); |
| +#endif |
| +} |
| + |
| + |
| #if !defined(USING_SIMULATOR) |
| inline uword AtomicOperations::CompareAndSwapWord(uword* ptr, |
| uword old_value, |
| @@ -48,6 +61,13 @@ inline uword AtomicOperations::CompareAndSwapWord(uword* ptr, |
| } |
| #endif // !defined(USING_SIMULATOR) |
| + |
| +inline uword AtomicOperations::LoadRelaxed(uword* ptr) { |
| + // TODO(koda): Consider using C++11 <atomic> to avoid the barrier on more |
| + // compilers/platforms. |
| + return FetchAndAdd(reinterpret_cast<intptr_t*>(ptr), 0); |
| +} |
| + |
| } // namespace dart |
| #endif // VM_ATOMIC_WIN_H_ |