diff options
author | Simon Marlow <marlowsd@gmail.com> | 2014-11-17 13:03:56 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2014-11-17 13:03:56 +0000 |
commit | 2a6f193bb82f88e8dcb919ee7affc13feae56e98 (patch) | |
tree | ff36315687ad03528bc4ab66eabd6bf1f37f485f /testsuite/tests/ffi | |
parent | a2c0a8dd15de2023e17078fa5f421ba581b3a5fa (diff) | |
download | haskell-2a6f193bb82f88e8dcb919ee7affc13feae56e98.tar.gz |
Fix a bug introduced with allocation counters
Diffstat (limited to 'testsuite/tests/ffi')
-rw-r--r-- | testsuite/tests/ffi/should_run/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/ffi023.hs | 23 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_run/ffi023_c.c | 9 |
3 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_run/all.T b/testsuite/tests/ffi/should_run/all.T index 6fe087884d..04996317f5 100644 --- a/testsuite/tests/ffi/should_run/all.T +++ b/testsuite/tests/ffi/should_run/all.T @@ -209,3 +209,7 @@ test('T8083', compile_and_run, ['T8083_c.c']) +test('ffi023', [ omit_ways(['ghci']), + extra_clean(['ffi023_c.o']), + extra_run_opts('1000 4') ], + compile_and_run, ['ffi023_c.c']) diff --git a/testsuite/tests/ffi/should_run/ffi023.hs b/testsuite/tests/ffi/should_run/ffi023.hs new file mode 100644 index 0000000000..96a6092301 --- /dev/null +++ b/testsuite/tests/ffi/should_run/ffi023.hs @@ -0,0 +1,23 @@ +-- Tests for a bug fixed in + +module Main where + +import System.Environment +import Control.Concurrent +import Control.Monad + +foreign import ccall safe "out" + out :: Int -> IO Int + +foreign export ccall "incall" incall :: Int -> IO Int + +incall :: Int -> IO Int +incall x = return $ x + 1 + +main = do + [n, m] <- fmap (fmap read) getArgs + ms <- replicateM m $ do + v <- newEmptyMVar + forkIO $ do mapM out [0..n]; putMVar v () + return v + mapM_ takeMVar ms diff --git a/testsuite/tests/ffi/should_run/ffi023_c.c b/testsuite/tests/ffi/should_run/ffi023_c.c new file mode 100644 index 0000000000..a8a5a15447 --- /dev/null +++ b/testsuite/tests/ffi/should_run/ffi023_c.c @@ -0,0 +1,9 @@ +#include "ffi023_stub.h" +#include "HsFFI.h" +#include "Rts.h" + +HsInt out (HsInt x) +{ + performMajorGC(); + return incall(x); +} |