Permalink
Browse files

Import constructors for types used in FFI declarations

This is done for `base-4.5.0` and later in order to shut up a compiler
warning in GHC 7.4 and avoid a compiler error in GHC 7.6, e.g.:

    Warning: newtype `Fd' is used in an FFI declaration,
             but its constructor is not in scope.
             This will become an error in GHC 7.6.1.
    When checking declaration:
      foreign import ccall unsafe "static sys/sendfile.h sendfile64" c_sendfile
        :: Fd -> Fd -> Ptr COff -> CSize -> IO CSsize
  • Loading branch information...
1 parent 64a9e77 commit 7dc1b76f23d6dfa0b54fa678b4dc2ef342f1ef8e @hvr hvr committed Aug 13, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/System/SendFile/Linux.hsc
@@ -4,11 +4,19 @@ module System.SendFile.Linux (sendFile) where
import Data.Int
import Foreign.C.Error (eAGAIN, getErrno, throwErrno)
+#if MIN_VERSION_base(4,5,0)
+import Foreign.C.Types (CSize(..), CInt(..))
+#else
import Foreign.C.Types (CSize)
+#endif
import Foreign.Marshal (alloca)
import Foreign.Ptr (Ptr, nullPtr)
import Foreign.Storable (poke)
+#if MIN_VERSION_base(4,5,0)
+import System.Posix.Types (Fd(..), COff(..), CSsize(..))
+#else
import System.Posix.Types (Fd, COff, CSsize)
+#endif
sendFile :: IO () -> Fd -> Fd -> Int64 -> Int64 -> IO Int64
sendFile onBlock out_fd in_fd off count

0 comments on commit 7dc1b76

Please sign in to comment.