From: Ian Lynagh Date: Wed, 4 Apr 2007 15:58:22 +0000 (+0000) Subject: Don't use Fd/FD in foreign decls X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=8dff2a318448b67a99627d54bbad1108010cb61e;p=ghc-base.git Don't use Fd/FD in foreign decls Using CInt makes it much easier to verify that it is right, and we won't get caught out by possible newtype switches between CInt/Int. --- diff --git a/GHC/Conc.lhs b/GHC/Conc.lhs index 7883cd6..d6fdd4f 100644 --- a/GHC/Conc.lhs +++ b/GHC/Conc.lhs @@ -1069,16 +1069,28 @@ foreign import ccall safe "select" -> IO CInt foreign import ccall unsafe "hsFD_SETSIZE" - fD_SETSIZE :: Fd + c_fD_SETSIZE :: CInt + +fD_SETSIZE :: Fd +fD_SETSIZE = fromIntegral c_fD_SETSIZE foreign import ccall unsafe "hsFD_CLR" - fdClr :: Fd -> Ptr CFdSet -> IO () + c_fdClr :: CInt -> Ptr CFdSet -> IO () + +fdClr :: Fd -> Ptr CFdSet -> IO () +fdClr (Fd fd) fdset = c_fdClr fd fdset foreign import ccall unsafe "hsFD_ISSET" - fdIsSet :: Fd -> Ptr CFdSet -> IO CInt + c_fdIsSet :: CInt -> Ptr CFdSet -> IO CInt + +fdIsSet :: Fd -> Ptr CFdSet -> IO CInt +fdIsSet (Fd fd) fdset = c_fdIsSet fd fdset foreign import ccall unsafe "hsFD_SET" - fdSet :: Fd -> Ptr CFdSet -> IO () + c_fdSet :: CInt -> Ptr CFdSet -> IO () + +fdSet :: Fd -> Ptr CFdSet -> IO () +fdSet (Fd fd) fdset = c_fdSet fd fdset foreign import ccall unsafe "hsFD_ZERO" fdZero :: Ptr CFdSet -> IO () diff --git a/GHC/Handle.hs b/GHC/Handle.hs index e826c1f..fd06fc6 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -560,10 +560,10 @@ writeRawBufferPtr loc fd is_stream buf off len = (threadWaitWrite (fromIntegral fd)) foreign import ccall unsafe "__hscore_PrelHandle_read" - read_rawBuffer :: FD -> RawBuffer -> Int -> CInt -> IO CInt + read_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt foreign import ccall unsafe "__hscore_PrelHandle_read" - read_off :: FD -> Ptr CChar -> Int -> CInt -> IO CInt + read_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt foreign import ccall unsafe "__hscore_PrelHandle_write" write_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt @@ -665,10 +665,10 @@ blockingWriteRawBufferPtr loc fd False buf off len = -- These calls may block, but that's ok. foreign import ccall safe "__hscore_PrelHandle_read" - read_rawBuffer :: FD -> RawBuffer -> Int -> CInt -> IO CInt + read_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt foreign import ccall safe "__hscore_PrelHandle_read" - read_off :: FD -> Ptr CChar -> Int -> CInt -> IO CInt + read_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt foreign import ccall safe "__hscore_PrelHandle_write" write_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt @@ -677,10 +677,10 @@ foreign import ccall safe "__hscore_PrelHandle_write" write_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt foreign import ccall safe "__hscore_PrelHandle_recv" - recv_rawBuffer :: FD -> RawBuffer -> Int -> CInt -> IO CInt + recv_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt foreign import ccall safe "__hscore_PrelHandle_recv" - recv_off :: FD -> Ptr CChar -> Int -> CInt -> IO CInt + recv_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt foreign import ccall safe "__hscore_PrelHandle_send" send_rawBuffer :: CInt -> RawBuffer -> Int -> CInt -> IO CInt