summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2016-06-03 22:22:23 +0200
committerBen Gamari <ben@smart-cactus.org>2016-06-04 09:35:49 +0200
commiteda73a3ad3fdd98cf877b25c3c984c6e1b2217fc (patch)
treeac8bb4159a447d16283abd9dace93719032b3921 /testsuite/tests/rts
parent4aa299db6b1025822673713a110b17c002ddcfaf (diff)
downloadhaskell-eda73a3ad3fdd98cf877b25c3c984c6e1b2217fc.tar.gz
RTS SMP: Use compiler built-ins on all platforms.
Use C compiler builtins for atomic SMP primitives. This saves a lot of CPP ifdefs. Add test for atomic xchg: Test if __sync_lock_test_and_set() builtin stores the second argument. The gcc manual says the actual value stored is implementation defined. Test Plan: validate and eyeball generated assembler code Reviewers: kgardas, simonmar, hvr, bgamari, austin, erikd Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2233
Diffstat (limited to 'testsuite/tests/rts')
-rw-r--r--testsuite/tests/rts/all.T2
-rw-r--r--testsuite/tests/rts/atomicxchg.c15
2 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index 94328466d2..334862c602 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -83,6 +83,8 @@ test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
compile_and_run, [''])
test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
+test('atomicxchg', [ c_src, only_ways(['threaded1', 'threaded2']) ],
+compile_and_run, [''])
test('T3424', # it's slow:
[ when(fast(), skip), only_ways(['normal','threaded1','ghci']) ],
diff --git a/testsuite/tests/rts/atomicxchg.c b/testsuite/tests/rts/atomicxchg.c
new file mode 100644
index 0000000000..379201a9c8
--- /dev/null
+++ b/testsuite/tests/rts/atomicxchg.c
@@ -0,0 +1,15 @@
+#include "Rts.h"
+
+StgWord i;
+
+int main(int argc, char *argv[])
+{
+ StgWord j;
+
+ i = 0;
+ j = xchg(&i,42);
+ CHECK(j == 0);
+ CHECK(i == 42);
+
+ return 0;
+}