Add errno to the IOError type
[ghc-base.git] / System / Posix / Internals.hs
index 0b4f7d4..ebd9ec9 100644 (file)
@@ -1,4 +1,5 @@
 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
+{-# OPTIONS_GHC -fno-warn-unused-binds #-}
 {-# OPTIONS_HADDOCK hide #-}
 
 -----------------------------------------------------------------------------
@@ -24,7 +25,9 @@ module System.Posix.Internals where
 
 #include "HsBaseConfig.h"
 
+#if ! (defined(mingw32_HOST_OS) || defined(__MINGW32__))
 import Control.Monad
+#endif
 import System.Posix.Types
 
 import Foreign
@@ -126,7 +129,11 @@ statGetType p_stat = do
     
 ioe_unknownfiletype :: IOException
 ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType"
-                        "unknown file type" Nothing
+                        "unknown file type"
+#if __GLASGOW_HASKELL__
+                        Nothing
+#endif
+                        Nothing
 
 #if __GLASGOW_HASKELL__ && (defined(mingw32_HOST_OS) || defined(__MINGW32__))
 closeFd :: Bool -> CInt -> IO CInt
@@ -139,12 +146,13 @@ foreign import stdcall unsafe "HsBase.h closesocket"
 #endif
 
 fdGetMode :: FD -> IO IOMode
-fdGetMode fd = do
 #if defined(mingw32_HOST_OS) || defined(__MINGW32__)
+fdGetMode _ = do
     -- We don't have a way of finding out which flags are set on FDs
     -- on Windows, so make a handle that thinks that anything goes.
     let flags = o_RDWR
 #else
+fdGetMode fd = do
     flags <- throwErrnoIfMinus1Retry "fdGetMode" 
                 (c_fcntl_read fd const_f_getfl)
 #endif
@@ -260,6 +268,7 @@ setCooked fd cooked = do
    then ioError (ioe_unk_error "setCooked" "failed to set buffering")
    else return ()
 
+ioe_unk_error :: String -> String -> IOException
 ioe_unk_error loc msg 
  = IOError Nothing OtherError loc msg Nothing
 
@@ -293,8 +302,8 @@ foreign import ccall unsafe "consUtils.h get_console_echo__"
 -- ---------------------------------------------------------------------------
 -- Turning on non-blocking for a file descriptor
 
-#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
 setNonBlockingFD :: FD -> IO ()
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
 setNonBlockingFD fd = do
   flags <- throwErrnoIfMinus1Retry "setNonBlockingFD"
                  (c_fcntl_read fd const_f_getfl)
@@ -307,7 +316,7 @@ setNonBlockingFD fd = do
 #else
 
 -- bogus defns for win32
-setNonBlockingFD fd = return ()
+setNonBlockingFD _ = return ()
 
 #endif
 
@@ -504,11 +513,10 @@ foreign import ccall unsafe "HsBase.h __hscore_poke_lflag" poke_c_lflag :: Ptr C
 foreign import ccall unsafe "HsBase.h __hscore_ptr_c_cc" ptr_c_cc  :: Ptr CTermios -> IO (Ptr Word8)
 #endif
 
-#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
-foreign import ccall unsafe "HsBase.h __hscore_s_issock" c_s_issock :: CMode -> CInt
 s_issock :: CMode -> Bool
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
 s_issock cmode = c_s_issock cmode /= 0
+foreign import ccall unsafe "HsBase.h __hscore_s_issock" c_s_issock :: CMode -> CInt
 #else
-s_issock :: CMode -> Bool
-s_issock cmode = False
+s_issock _ = False
 #endif