{-# LINE 1 "Network/Socket/ByteString/IOVec.hsc" #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}

-- | Support module for the POSIX writev system call.
module Network.Socket.ByteString.IOVec
    ( IOVec(..)
    ) where

import Network.Socket.Imports




data IOVec = IOVec
    { IOVec -> Ptr CChar
iovBase :: !(Ptr CChar)
    , IOVec -> CSize
iovLen  :: !CSize
    }

instance Storable IOVec where
  sizeOf :: IOVec -> Int
sizeOf IOVec
_    = (Int
16)
{-# LINE 20 "Network/Socket/ByteString/IOVec.hsc" #-}
  alignment _ = alignment (undefined :: CInt)

  peek :: Ptr IOVec -> IO IOVec
peek Ptr IOVec
p = do
    Ptr CChar
base <- ((\Ptr IOVec
hsc_ptr -> Ptr IOVec -> Int -> IO (Ptr CChar)
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr IOVec
hsc_ptr Int
0)) Ptr IOVec
p
{-# LINE 24 "Network/Socket/ByteString/IOVec.hsc" #-}
    len  <- ((\hsc_ptr -> peekByteOff hsc_ptr 8))  p
{-# LINE 25 "Network/Socket/ByteString/IOVec.hsc" #-}
    return $ IOVec base len

  poke :: Ptr IOVec -> IOVec -> IO ()
poke Ptr IOVec
p IOVec
iov = do
    ((\Ptr IOVec
hsc_ptr -> Ptr IOVec -> Int -> Ptr CChar -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr IOVec
hsc_ptr Int
0)) Ptr IOVec
p (IOVec -> Ptr CChar
iovBase IOVec
iov)
{-# LINE 29 "Network/Socket/ByteString/IOVec.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8))  p (iovLen  iov)
{-# LINE 30 "Network/Socket/ByteString/IOVec.hsc" #-}