summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs
blob: d4ec1acd25e16cd8e28b00ae74a904881a89cbbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE ForeignFunctionInterface #-}

import Data.Word
import Data.IORef
import GHC.Clock
import Control.Concurrent
import Foreign.Ptr
import System.Mem
import Control.Monad

data Capability

foreign import ccall unsafe "RtsAPI.h rts_pause"
    unsafe_rts_pause_c :: IO (Ptr Capability)

main :: IO ()
main = do
  -- Making a unsafe call to rts_pause() should fail. We cannot allow this
  -- haskell thread to continue if the RTS is paused.
  _ <- unsafe_rts_pause_c
  putStrLn "Oops! Haskell thread has continued even though RTS was paused."