Commit 2511c656 authored by simonmar's avatar simonmar

[project @ 2005-04-19 14:40:23 by simonmar]

FFI/threaded test
parent 273f77a7
......@@ -68,3 +68,5 @@ test('ffi012', f, compile_and_run, [''])
# Doesn't work with External Core due to __labels
test('ffi013', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
test('ffi014', only_ways(['threaded']), compile_and_run, ['ffi014_cbits.c'])
-- exposed a bug in GHC 6.4 threaded RTS, fixed in Schedule.c rev. 1.232
module Main where
import Control.Concurrent
import Control.Monad
import Foreign.Ptr
import Data.IORef
main = replicateM 100 (putStrLn "." >> forkOS thread >> thread)
thread = do var <- newIORef 0
let f = modifyIORef var (1+)
callC =<< mkFunc f
type FUNC = IO ()
foreign import ccall unsafe "wrapper"
mkFunc :: FUNC -> IO (FunPtr FUNC)
foreign import ccall threadsafe "ffi014_cbits.h callC"
callC:: FunPtr FUNC -> IO ()
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
#include "ffi014_cbits.h"
void callC( FUNC* f) {
int i;
for(i=0;i<1000;i++) f();
}
typedef void FUNC();
void callC( FUNC* f);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment