{-# 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 29 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Data.Word (Word64)
{-# LINE 31 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Foreign.C.Types (CInt(..))
import Foreign.Ptr (Ptr)
import System.Posix.Types (CSsize(..))
{-# LINE 35 "src/Streamly/FileSystem/IOVec.hsc" #-}
import Foreign.Storable (Storable(..))
{-# LINE 37 "src/Streamly/FileSystem/IOVec.hsc" #-}
data IOVec = IOVec
{ iovBase :: {-# UNPACK #-} !(Ptr Word8)
{-# LINE 47 "src/Streamly/FileSystem/IOVec.hsc" #-}
, iovLen :: {-# UNPACK #-} !Word64
{-# LINE 49 "src/Streamly/FileSystem/IOVec.hsc" #-}
} deriving (Eq, Show)
{-# LINE 52 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 58 "src/Streamly/FileSystem/IOVec.hsc" #-}
instance Storable IOVec where
sizeOf _ = (16)
{-# LINE 61 "src/Streamly/FileSystem/IOVec.hsc" #-}
alignment _ = 8
{-# LINE 62 "src/Streamly/FileSystem/IOVec.hsc" #-}
peek ptr = do
base <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 64 "src/Streamly/FileSystem/IOVec.hsc" #-}
len :: Word64 <- (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 65 "src/Streamly/FileSystem/IOVec.hsc" #-}
return $ IOVec base len
poke ptr vec = do
let base = iovBase vec
len :: Word64 = iovLen vec
{-# LINE 69 "src/Streamly/FileSystem/IOVec.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr base
{-# LINE 70 "src/Streamly/FileSystem/IOVec.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr len
{-# LINE 71 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 72 "src/Streamly/FileSystem/IOVec.hsc" #-}
{-# LINE 84 "src/Streamly/FileSystem/IOVec.hsc" #-}
c_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_writev = error "writev not implemented"
c_safe_writev :: CInt -> Ptr IOVec -> CInt -> IO CSsize
c_safe_writev = error "writev not implemented"
{-# LINE 90 "src/Streamly/FileSystem/IOVec.hsc" #-}