SafeHaskell: Added SafeHaskell to base
[packages/base.git] / GHC / Windows.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE NoImplicitPrelude, ForeignFunctionInterface #-}
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module : GHC.Windows
6 -- Copyright : (c) The University of Glasgow, 2009
7 -- License : see libraries/base/LICENSE
8 --
9 -- Maintainer : libraries@haskell.org
10 -- Stability : internal
11 -- Portability : non-portable
12 --
13 -- Windows functionality used by several modules.
14 --
15 -- ToDo: this just duplicates part of System.Win32.Types, which isn't
16 -- available yet. We should move some Win32 functionality down here,
17 -- maybe as part of the grand reorganisation of the base package...
18 --
19 -----------------------------------------------------------------------------
20
21 module GHC.Windows (
22 HANDLE, DWORD, LPTSTR, iNFINITE,
23 throwGetLastError, maperrno
24 ) where
25
26 import GHC.Base
27 import GHC.Ptr
28
29 import Data.Word
30
31 import Foreign.C.Error (throwErrno)
32 import Foreign.C.Types
33
34
35 type HANDLE = Ptr ()
36 type DWORD = Word32
37
38 type LPTSTR = Ptr CWchar
39
40 iNFINITE :: DWORD
41 iNFINITE = 0xFFFFFFFF -- urgh
42
43 throwGetLastError :: String -> IO a
44 throwGetLastError where_from = c_maperrno >> throwErrno where_from
45
46 foreign import ccall unsafe "maperrno" -- in Win32Utils.c
47 c_maperrno :: IO ()
48