[commit: ghc] ghc-7.8: add missing files (#8124) (7d4540f)
git at git.haskell.org
git at git.haskell.org
Mon Mar 17 15:36:11 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.8
Link : http://ghc.haskell.org/trac/ghc/changeset/7d4540f23df4cb32eaba94c3d574df2a0850b8f4/ghc
>---------------------------------------------------------------
commit 7d4540f23df4cb32eaba94c3d574df2a0850b8f4
Author: Simon Marlow <marlowsd at gmail.com>
Date: Sat Mar 1 07:14:47 2014 +0000
add missing files (#8124)
(cherry picked from commit 3fba87599378afbcf425a0fc2a5a61d21e3719d4)
>---------------------------------------------------------------
7d4540f23df4cb32eaba94c3d574df2a0850b8f4
testsuite/tests/rts/T8124.hs | 6 ++++++
testsuite/tests/rts/T8124_c.c | 42 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/testsuite/tests/rts/T8124.hs b/testsuite/tests/rts/T8124.hs
new file mode 100644
index 0000000..c914b03
--- /dev/null
+++ b/testsuite/tests/rts/T8124.hs
@@ -0,0 +1,6 @@
+module T8124 where
+
+f :: Int -> Int
+f x = x + 1
+
+foreign export ccall "f" f :: Int -> Int
diff --git a/testsuite/tests/rts/T8124_c.c b/testsuite/tests/rts/T8124_c.c
new file mode 100644
index 0000000..e7e8739
--- /dev/null
+++ b/testsuite/tests/rts/T8124_c.c
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+#include "T8124_stub.h"
+#include "HsFFI.h"
+#include <pthread.h>
+
+void *thread(void *param)
+{
+ f(3);
+ hs_thread_done();
+ pthread_exit(NULL);
+}
+
+int main (int argc, char *argv[])
+{
+ hs_init(&argc,&argv);
+
+ // check that we can call hs_thread_done() without having made any
+ // Haskell calls:
+ hs_thread_done();
+
+ // check that we can call hs_thread_done() and then make another Haskell
+ // call:
+ int i;
+ for (i=0; i < 1000; i++) {
+ f(3);
+ hs_thread_done();
+ }
+
+ // check that we can call hs_thread_done() twice:
+ hs_thread_done();
+ hs_thread_done();
+
+ // check that hs_thread_done() from child threads works:
+ pthread_t pid;
+ for (i=0; i < 1000; i++) {
+ pthread_create(&pid, NULL, thread, NULL);
+ pthread_join(pid, NULL);
+ }
+
+ hs_exit();
+ exit(0);
+}
More information about the ghc-commits
mailing list