{-# LINE 1 "src/System/LibCPUID/TSC.hsc" #-}
module System.LibCPUID.TSC
(
TSCMark, initialise
, mark, unmark, clockBy
) where
import Foreign.C.Types (CInt(..))
import Foreign.ForeignPtr (ForeignPtr, mallocForeignPtrBytes, withForeignPtr)
import Foreign.Ptr (Ptr)
newtype TSCMark = TSCMark (ForeignPtr ())
initialise :: IO TSCMark
initialise = TSCMark <$> mallocForeignPtrBytes (16)
{-# LINE 41 "src/System/LibCPUID/TSC.hsc" #-}
mark :: TSCMark -> IO ()
mark (TSCMark ptr) = withForeignPtr ptr c_cpu_tsc_mark
foreign import ccall "cpu_tsc_mark"
c_cpu_tsc_mark :: Ptr cpu_mark_t -> IO ()
unmark :: TSCMark -> IO ()
unmark (TSCMark ptr) = withForeignPtr ptr c_cpu_tsc_unmark
foreign import ccall "cpu_tsc_unmark"
c_cpu_tsc_unmark :: Ptr cpu_mark_t -> IO ()
clockBy :: TSCMark -> IO Int
clockBy (TSCMark ptr) = fromIntegral <$> withForeignPtr ptr c_cpu_clock_by_mark
foreign import ccall "cpu_clock_by_mark"
c_cpu_clock_by_mark :: Ptr cpu_mark_t -> IO CInt