Skip to content
Snippets Groups Projects
Commit 7d4540f2 authored by Simon Marlow's avatar Simon Marlow Committed by thoughtpolice
Browse files

add missing files (#8124)

(cherry picked from commit 3fba8759)
parent 702fb1dd
No related branches found
No related tags found
No related merge requests found
module T8124 where
f :: Int -> Int
f x = x + 1
foreign export ccall "f" f :: Int -> Int
#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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment