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

Unified Diff: runtime/vm/atomic_test.cc

Issue 1277473004: Safe and efficient stack-limit based interrupt checking in C++. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Explicitly signal task ready. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/atomic_macos.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/atomic_test.cc
diff --git a/runtime/vm/atomic_test.cc b/runtime/vm/atomic_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e0fdbe920bf788a9265a25efd69975743d0664d7
--- /dev/null
+++ b/runtime/vm/atomic_test.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "platform/assert.h"
+#include "platform/utils.h"
+#include "vm/atomic.h"
+#include "vm/globals.h"
+#include "vm/unit_test.h"
+
+namespace dart {
+
+UNIT_TEST_CASE(FetchAndIncrement) {
+ uintptr_t v = 42;
+ EXPECT_EQ(42, AtomicOperations::FetchAndIncrement(&v));
+ EXPECT_EQ(43, v);
+}
+
+
+UNIT_TEST_CASE(FetchAndAdd) {
+ intptr_t v = 42;
+ EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 0));
+ EXPECT_EQ(42, v);
+ EXPECT_EQ(42, AtomicOperations::FetchAndAdd(&v, 2));
+ EXPECT_EQ(44, v);
+ EXPECT_EQ(44, AtomicOperations::FetchAndAdd(&v, -2));
+ EXPECT_EQ(42, v);
+}
+
+
+UNIT_TEST_CASE(LoadRelaxed) {
+ uword v = 42;
+ EXPECT_EQ(42, AtomicOperations::LoadRelaxed(&v));
+}
+
+} // namespace dart
« 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