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

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

Issue 1287853005: Compatible atomics: volatile for LoadRelaxed, replace FetchAndAdd with FetchAndDecrement. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Additional comments. Created 5 years, 4 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_macos.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
11 namespace dart { 11 namespace dart {
12 12
13 UNIT_TEST_CASE(FetchAndIncrement) { 13 UNIT_TEST_CASE(FetchAndIncrement) {
14 uintptr_t v = 42; 14 uintptr_t v = 42;
15 EXPECT_EQ(static_cast<uintptr_t>(42), 15 EXPECT_EQ(static_cast<uintptr_t>(42),
16 AtomicOperations::FetchAndIncrement(&v)); 16 AtomicOperations::FetchAndIncrement(&v));
17 EXPECT_EQ(static_cast<uintptr_t>(43), v); 17 EXPECT_EQ(static_cast<uintptr_t>(43), v);
18 } 18 }
19 19
20 20
21 UNIT_TEST_CASE(FetchAndAdd) { 21 UNIT_TEST_CASE(FetchAndDecrement) {
22 intptr_t v = 42; 22 uintptr_t v = 42;
23 EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 0)); 23 EXPECT_EQ(static_cast<uintptr_t>(42),
24 EXPECT_EQ(42, v); 24 AtomicOperations::FetchAndDecrement(&v));
25 EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 2)); 25 EXPECT_EQ(static_cast<uintptr_t>(41), v);
26 EXPECT_EQ(44, v);
27 EXPECT_EQ(44, AtomicOperations::FetchAndAdd(&v, -2));
28 EXPECT_EQ(42, v);
29 } 26 }
30 27
31 28
32 UNIT_TEST_CASE(LoadRelaxed) { 29 UNIT_TEST_CASE(LoadRelaxed) {
33 uword v = 42; 30 uword v = 42;
34 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v)); 31 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v));
35 } 32 }
36 33
37 } // namespace dart 34 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/atomic_macos.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698