blob: 0b579853339ba6e913b6533d976db02e9c74cdd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
{-# LANGUAGE ForeignFunctionInterface #-}
-- Test that the Win32 error code from getLastError is thread-local.
import System.Win32
import Control.Monad
import Control.Concurrent
main = do
setLastError 42
r <- getLastError
when (r /= 42) $ fail ("wrong: " ++ show r)
m <- newEmptyMVar
forkIO $ do setLastError 43; putMVar m ()
takeMVar m
r <- getLastError
when (r /= 42) $ fail ("wrong: " ++ show r)
foreign import stdcall unsafe "windows.h SetLastError"
setLastError :: ErrCode -> IO ()
|