From: simonm Date: Fri, 14 Aug 1998 13:02:01 +0000 (+0000) Subject: [project @ 1998-08-14 13:02:00 by simonm] X-Git-Tag: Approx_2487_patches~362 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a9aaf3d3d55d5a314c308ae9e4a0f0fd93aa4f45;p=ghc-hetmet.git [project @ 1998-08-14 13:02:00 by simonm] Add _ccall_GC_ test (callbacks and performGC). --- diff --git a/ghc/tests/lib/should_run/Makefile b/ghc/tests/lib/should_run/Makefile index ca76c0f..7ba9700 100644 --- a/ghc/tests/lib/should_run/Makefile +++ b/ghc/tests/lib/should_run/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.5 1998/08/12 11:05:14 simonm Exp $ +# $Id: Makefile,v 1.6 1998/08/14 13:02:00 simonm Exp $ TOP = ../.. include $(TOP)/mk/boilerplate.mk @@ -9,6 +9,7 @@ SRC_HC_OPTS += -dcore-lint packedstring001_HC_OPTS = -syslib misc exceptions001_HC_OPTS = -fglasgow-exts +stableptr002_HC_OPTS = -fglasgow-exts stableptr001_RUNTEST_OPTS = +RTS -K4m dynamic001_HC_OPTS = -syslib exts diff --git a/ghc/tests/lib/should_run/stableptr002.hs b/ghc/tests/lib/should_run/stableptr002.hs new file mode 100644 index 0000000..5d436ad --- /dev/null +++ b/ghc/tests/lib/should_run/stableptr002.hs @@ -0,0 +1,24 @@ +module Main where + +import PrelForeign + +-- Testing callbacks: the initial haskell thread calls out to C with +-- the address of a Haskell callback. The C function runs the callback +-- (in a new thread) and returns. + +-- The stable pointer operation 'performIO' does the job of calling +-- the callback for us. + +-- for an extra stressful test, the callback also does an explicit GC +-- to make sure that the original thread saved away its state +-- properly. + +main = do + io <- makeStablePtr hello + _ccall_GC_ performIO io + putStr "finished" + +hello :: IO () +hello = do + _ccall_GC_ performGC + putStr "hello world!\n" diff --git a/ghc/tests/lib/should_run/stableptr002.stdout b/ghc/tests/lib/should_run/stableptr002.stdout new file mode 100644 index 0000000..4545b6b --- /dev/null +++ b/ghc/tests/lib/should_run/stableptr002.stdout @@ -0,0 +1,2 @@ +hello world! +finished \ No newline at end of file