{-# LINE 1 "Data/UnixTime/Sys.hsc" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module Data.UnixTime.Sys (getUnixTime) where
import Data.UnixTime.Types
import Foreign.C.Error
import Foreign.C.Types
import Foreign.Marshal.Alloc
import Foreign.Ptr
import Foreign.Storable
type CTimeVal = ()
type CTimeZone = ()
foreign import ccall unsafe "gettimeofday"
c_gettimeofday :: Ptr CTimeVal -> Ptr CTimeZone -> IO CInt
getUnixTime :: IO UnixTime
getUnixTime = allocaBytes (16) $ \ p_timeval -> do
{-# LINE 28 "Data/UnixTime/Sys.hsc" #-}
throwErrnoIfMinus1_ "getClockTime" $ c_gettimeofday p_timeval nullPtr
sec <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p_timeval
{-# LINE 30 "Data/UnixTime/Sys.hsc" #-}
usec <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p_timeval
{-# LINE 31 "Data/UnixTime/Sys.hsc" #-}
return $ UnixTime sec usec