{-# LINE 1 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Streamly.FileSystem.IOVec
( IOVec(..)
, c_writev
, c_safe_writev
)
where
import Data.Word (Word8)
{-# LINE 31 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Data.Word (Word64)
{-# LINE 33 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Foreign.C.Types (CInt(..))
import Foreign.Ptr (Ptr)
import System.Posix.Types (CSsize(..))
{-# LINE 37 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Foreign.Storable (Storable(..))
{-# LINE 39 "src/Streamly/FileSystem/IOVec.hsc" #-}
data IOVec = IOVec
{ IOVec -> Ptr Word8
iovBase :: {-# UNPACK #-} !(Ptr Word8)
{-# LINE 49 "src/Streamly/FileSystem/IOVec.hsc" #-}
, IOVec -> Word64
iovLen :: {-# UNPACK #-} !Word64
{-# LINE 51 "src/Streamly/FileSystem/IOVec.hsc" #-}
} deriving (Eq, Show)
{-# LINE 54 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 60 "src/Streamly/FileSystem/IOVec.hsc" #-}
instance Storable IOVec where
sizeOf :: IOVec -> Int
sizeOf IOVec
_ = (Int
16)
{-# LINE 63 "src/Streamly/FileSystem/IOVec.hsc" #-}
alignment _ = 8
{-# LINE 64 "src/Streamly/FileSystem/IOVec.hsc" #-}
peek ptr = do
base <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 66 "src/Streamly/FileSystem/IOVec.hsc" #-}
len :: Word64 <- (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 67 "src/Streamly/FileSystem/IOVec.hsc" #-}
return $ IOVec base len
poke :: Ptr IOVec -> IOVec -> IO ()
poke Ptr IOVec
ptr IOVec
vec = do
let base :: Ptr Word8
base = IOVec -> Ptr Word8
iovBase IOVec
vec
Word64
len :: Word64 = IOVec -> Word64
iovLen IOVec
vec
{-# LINE 71 "src/Streamly/FileSystem/IOVec.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr base
{-# LINE 72 "src/Streamly/FileSystem/IOVec.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr len
{-# LINE 73 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 74 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 86 "src/Streamly/FileSystem/IOVec.hsc" #-}
c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_writev = String -> CInt -> Ptr IOVec -> CInt -> IO CSsize
forall a. HasCallStack => String -> a
error String
"writev not implemented"
c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_safe_writev = String -> CInt -> Ptr IOVec -> CInt -> IO CSsize
forall a. HasCallStack => String -> a
error String
"writev not implemented"
{-# LINE 92 "src/Streamly/FileSystem/IOVec.hsc" #-}