X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FIO%2FFD.hs;h=4425a3a76d2a3fe9b47d42d674267ab7da640c09;hb=ccc7548348fa0d5a10e4c795c5edc13d0dd3f014;hp=98eeeab0043c17503d21bb6ff7848b2499b1bbc2;hpb=7d39e10019df33f1a19d65b3c58c4d01a7dc8d30;p=ghc-base.git diff --git a/GHC/IO/FD.hs b/GHC/IO/FD.hs index 98eeeab..4425a3a 100644 --- a/GHC/IO/FD.hs +++ b/GHC/IO/FD.hs @@ -22,17 +22,13 @@ module GHC.IO.FD ( stdin, stdout, stderr ) where -#undef DEBUG_DUMP - import GHC.Base import GHC.Num import GHC.Real import GHC.Show import GHC.Enum import Data.Maybe -#ifndef mingw32_HOST_OS import Control.Monad -#endif import Data.Typeable import GHC.IO @@ -51,6 +47,9 @@ import System.Posix.Internals hiding (FD, setEcho, getEcho) import System.Posix.Types -- import GHC.Ptr +c_DEBUG_DUMP :: Bool +c_DEBUG_DUMP = False + -- ----------------------------------------------------------------------------- -- The file-descriptor IO device @@ -108,20 +107,17 @@ instance BufferedIO FD where readBuf' :: FD -> Buffer Word8 -> IO (Int, Buffer Word8) readBuf' fd buf = do -#ifdef DEBUG_DUMP - puts ("readBuf fd=" ++ show fd ++ " " ++ summaryBuffer buf ++ "\n") -#endif + when c_DEBUG_DUMP $ + puts ("readBuf fd=" ++ show fd ++ " " ++ summaryBuffer buf ++ "\n") (r,buf') <- readBuf fd buf -#ifdef DEBUG_DUMP - puts ("after: " ++ summaryBuffer buf' ++ "\n") -#endif + when c_DEBUG_DUMP $ + puts ("after: " ++ summaryBuffer buf' ++ "\n") return (r,buf') writeBuf' :: FD -> Buffer Word8 -> IO (Buffer Word8) writeBuf' fd buf = do -#ifdef DEBUG_DUMP - puts ("writeBuf fd=" ++ show fd ++ " " ++ summaryBuffer buf ++ "\n") -#endif + when c_DEBUG_DUMP $ + puts ("writeBuf fd=" ++ show fd ++ " " ++ summaryBuffer buf ++ "\n") writeBuf fd buf -- ----------------------------------------------------------------------------- @@ -626,8 +622,7 @@ foreign import ccall unsafe "unlockFile" unlockFile :: CInt -> IO CInt #endif -#if defined(DEBUG_DUMP) puts :: String -> IO () -puts s = do withCStringLen s $ \(p,len) -> c_write 1 p (fromIntegral len) +puts s = do _ <- withCStringLen s $ \(p,len) -> + c_write 1 (castPtr p) (fromIntegral len) return () -#endif