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

Side by Side Diff: runtime/vm/atomic_test.cc

Issue 1562253002: Add a CompareAndSwapUint32 variant to AtomicOperations so that it is possible to a CAS of a 32 bit … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « runtime/vm/atomic_simulator.h ('k') | runtime/vm/atomic_win.h » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "platform/utils.h" 6 #include "platform/utils.h"
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 13 matching lines...) Expand all
24 AtomicOperations::FetchAndDecrement(&v)); 24 AtomicOperations::FetchAndDecrement(&v));
25 EXPECT_EQ(static_cast<uintptr_t>(41), v); 25 EXPECT_EQ(static_cast<uintptr_t>(41), v);
26 } 26 }
27 27
28 28
29 UNIT_TEST_CASE(LoadRelaxed) { 29 UNIT_TEST_CASE(LoadRelaxed) {
30 uword v = 42; 30 uword v = 42;
31 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v)); 31 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v));
32 } 32 }
33 33
34
35 UNIT_TEST_CASE(CompareAndSwapWord) {
36 uword old_value = 42;
37 uword new_value = 100;
38 uword result = AtomicOperations::CompareAndSwapWord(
39 &old_value, old_value, new_value);
40 EXPECT_EQ(static_cast<uword>(42), result);
41 }
42
43
44 UNIT_TEST_CASE(CompareAndSwapUint32) {
45 uint32_t old_value = 42;
46 uint32_t new_value = 100;
47 uint32_t result = AtomicOperations::CompareAndSwapUint32(
48 &old_value, old_value, new_value);
49 EXPECT_EQ(static_cast<uint32_t>(42), result);
50 }
51
34 } // namespace dart 52 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/atomic_simulator.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698