--- a/libraries/base/System/Posix/Internals.hs 2005-07-11 12:41:24.000000000 +0300 +++ b/libraries/base/System/Posix/Internals.hs 2009-08-23 16:02:58.598738386 +0300 @@ -67,13 +67,13 @@ type CUtsname = () #ifndef __GLASGOW_HASKELL__ -type FD = Int +type FD = Int32 #endif -- --------------------------------------------------------------------------- -- stat()-related stuff -fdFileSize :: Int -> IO Integer +fdFileSize :: FD -> IO Integer fdFileSize fd = allocaBytes sizeof_stat $ \ p_stat -> do throwErrnoIfMinus1Retry "fileSize" $ @@ -98,7 +98,7 @@ -- NOTE: On Win32 platforms, this will only work with file descriptors -- referring to file handles. i.e., it'll fail for socket FDs. -fdType :: Int -> IO FDType +fdType :: FD -> IO FDType fdType fd = allocaBytes sizeof_stat $ \ p_stat -> do throwErrnoIfMinus1Retry "fdType" $ @@ -130,7 +130,7 @@ c_closesocket :: CInt -> IO CInt #endif -fdGetMode :: Int -> IO IOMode +fdGetMode :: FD -> IO IOMode fdGetMode fd = do #if defined(mingw32_HOST_OS) || defined(__MINGW32__) -- XXX: this code is *BROKEN*, _setmode only deals with O_TEXT/O_BINARY @@ -158,12 +158,12 @@ -- --------------------------------------------------------------------------- -- Terminal-related stuff -fdIsTTY :: Int -> IO Bool +fdIsTTY :: FD -> IO Bool fdIsTTY fd = c_isatty (fromIntegral fd) >>= return.toBool #if defined(HTYPE_TCFLAG_T) -setEcho :: Int -> Bool -> IO () +setEcho :: FD -> Bool -> IO () setEcho fd on = do tcSetAttr fd $ \ p_tios -> do c_lflag <- c_lflag p_tios :: IO CTcflag @@ -172,13 +172,13 @@ | otherwise = c_lflag .&. complement (fromIntegral const_echo) poke_c_lflag p_tios (new_c_lflag :: CTcflag) -getEcho :: Int -> IO Bool +getEcho :: FD -> IO Bool getEcho fd = do tcSetAttr fd $ \ p_tios -> do c_lflag <- c_lflag p_tios :: IO CTcflag return ((c_lflag .&. fromIntegral const_echo) /= 0) -setCooked :: Int -> Bool -> IO () +setCooked :: FD -> Bool -> IO () setCooked fd cooked = tcSetAttr fd $ \ p_tios -> do @@ -231,10 +231,10 @@ #ifdef __GLASGOW_HASKELL__ foreign import ccall unsafe "HsBase.h __hscore_get_saved_termios" - get_saved_termios :: Int -> IO (Ptr CTermios) + get_saved_termios :: FD -> IO (Ptr CTermios) foreign import ccall unsafe "HsBase.h __hscore_set_saved_termios" - set_saved_termios :: Int -> (Ptr CTermios) -> IO () + set_saved_termios :: FD -> (Ptr CTermios) -> IO () #endif #else @@ -247,7 +247,7 @@ -- report that character until another character is input..odd.) This -- latter feature doesn't sit too well with IO actions like IO.hGetLine.. -- consider yourself warned. -setCooked :: Int -> Bool -> IO () +setCooked :: FD -> Bool -> IO () setCooked fd cooked = do x <- set_console_buffering (fromIntegral fd) (if cooked then 1 else 0) if (x /= 0) @@ -259,14 +259,14 @@ -- Note: echoing goes hand in hand with enabling 'line input' / raw-ness -- for Win32 consoles, hence setEcho ends up being the inverse of setCooked. -setEcho :: Int -> Bool -> IO () +setEcho :: FD -> Bool -> IO () setEcho fd on = do x <- set_console_echo (fromIntegral fd) (if on then 1 else 0) if (x /= 0) then ioError (ioe_unk_error "setEcho" "failed to set echoing") else return () -getEcho :: Int -> IO Bool +getEcho :: FD -> IO Bool getEcho fd = do r <- get_console_echo (fromIntegral fd) if (r == (-1))