module System.Posix.Realtime.RTDataTypes (
Sigval(..),
Sigevent(..),
TimeSpec(..),
ItimerSpec(..)
) where
import System.IO
import System.IO.Error
import System.Posix.Signals
import System.Posix.Types
import System.Posix.Error
import System.Posix.Internals
import Foreign
import Foreign.C
import Data.Bits
import Data.Word
import GHC.IO
import GHC.IO.Handle hiding (fdToHandle)
import qualified GHC.IO.Handle
newtype Sigval = SivalInt Int
deriving(Show)
instance Storable Sigval where
sizeOf _ = (8)
alignment _ = 1
poke p_Sigval (SivalInt i) = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_Sigval i
peek p_Sigval = do
sigvalInt <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p_Sigval
return (SivalInt sigvalInt)
data Sigevent = Sigevent {
sigevVal :: Sigval,
sigevSigno :: Signal,
sigevNotify :: Int,
sigevFunction :: FunPtr (Sigval -> IO ()),
sigevAttribute :: Ptr Char
} deriving(Show)
instance Storable Sigevent where
sizeOf _ = (64)
alignment _ = 1
poke p_Sigevent (Sigevent sigevVal sigevSigno sigevNotify sigevFunction sigevAttribute) = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_Sigevent sigevVal
((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p_Sigevent sigevSigno
((\hsc_ptr -> pokeByteOff hsc_ptr 12)) p_Sigevent sigevNotify
((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p_Sigevent sigevFunction
((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p_Sigevent sigevAttribute
peek p_Sigevent = do
sigevVal <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p_Sigevent
sigevSigno <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p_Sigevent
sigevNotify <- ((\hsc_ptr -> peekByteOff hsc_ptr 12)) p_Sigevent
sigevFunction <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p_Sigevent
sigevAttribute <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p_Sigevent
return (Sigevent sigevVal sigevSigno sigevNotify sigevFunction sigevAttribute)
data TimeSpec = TimeSpec {
tvSec :: Int,
tvNsec :: Int
} deriving Show
instance Storable TimeSpec where
sizeOf _ = (16)
alignment _ = 1
poke p_timespec (TimeSpec tvSec tvNsec) = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_timespec tvSec
((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p_timespec tvNsec
peek p_timespec = do
tvSec <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p_timespec
tvNsec <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p_timespec
return (TimeSpec tvSec tvNsec)
data ItimerSpec = ItimerSpec {
itInterval :: TimeSpec,
itValue :: TimeSpec
} deriving(Show)
instance Storable ItimerSpec where
sizeOf _ = (32)
alignment _ = 1
poke p_itimerspec (ItimerSpec itInterval itValue) = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_itimerspec itInterval
((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p_itimerspec itValue
peek p_itimerspec = do
itInterval <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p_itimerspec
itValue <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p_itimerspec
return (ItimerSpec itInterval itValue)