{-# LINE 1 "Bindings/Posix/Time.hsc" #-}

{-# LINE 2 "Bindings/Posix/Time.hsc" #-}

{-# LINE 3 "Bindings/Posix/Time.hsc" #-}

-- |This module temporarily exists here, only because bindings-posix
-- currently doesn't have struct tm.

module Bindings.Posix.Time where
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word

{-# LINE 9 "Bindings/Posix/Time.hsc" #-}


{-# LINE 11 "Bindings/Posix/Time.hsc" #-}

{-# LINE 12 "Bindings/Posix/Time.hsc" #-}

{-# LINE 13 "Bindings/Posix/Time.hsc" #-}

{-# LINE 14 "Bindings/Posix/Time.hsc" #-}

{-# LINE 15 "Bindings/Posix/Time.hsc" #-}

{-# LINE 16 "Bindings/Posix/Time.hsc" #-}

{-# LINE 17 "Bindings/Posix/Time.hsc" #-}

{-# LINE 18 "Bindings/Posix/Time.hsc" #-}

{-# LINE 19 "Bindings/Posix/Time.hsc" #-}

{-# LINE 20 "Bindings/Posix/Time.hsc" #-}
data C'tm = C'tm{
  c'tm'tm_sec :: CInt,
  c'tm'tm_min :: CInt,
  c'tm'tm_hour :: CInt,
  c'tm'tm_mday :: CInt,
  c'tm'tm_mon :: CInt,
  c'tm'tm_year :: CInt,
  c'tm'tm_wday :: CInt,
  c'tm'tm_yday :: CInt,
  c'tm'tm_isdst :: CInt
} deriving (Eq,Show)
p'tm'tm_sec p = plusPtr p 0
p'tm'tm_sec :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_min p = plusPtr p 4
p'tm'tm_min :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_hour p = plusPtr p 8
p'tm'tm_hour :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_mday p = plusPtr p 12
p'tm'tm_mday :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_mon p = plusPtr p 16
p'tm'tm_mon :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_year p = plusPtr p 20
p'tm'tm_year :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_wday p = plusPtr p 24
p'tm'tm_wday :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_yday p = plusPtr p 28
p'tm'tm_yday :: Ptr (C'tm) -> Ptr (CInt)
p'tm'tm_isdst p = plusPtr p 32
p'tm'tm_isdst :: Ptr (C'tm) -> Ptr (CInt)
instance Storable C'tm where
  sizeOf _ = 44
  alignment = sizeOf
  peek p = do
    v0 <- peekByteOff p 0
    v1 <- peekByteOff p 4
    v2 <- peekByteOff p 8
    v3 <- peekByteOff p 12
    v4 <- peekByteOff p 16
    v5 <- peekByteOff p 20
    v6 <- peekByteOff p 24
    v7 <- peekByteOff p 28
    v8 <- peekByteOff p 32
    return $ C'tm v0 v1 v2 v3 v4 v5 v6 v7 v8
  poke p (C'tm v0 v1 v2 v3 v4 v5 v6 v7 v8) = do
    pokeByteOff p 0 v0
    pokeByteOff p 4 v1
    pokeByteOff p 8 v2
    pokeByteOff p 12 v3
    pokeByteOff p 16 v4
    pokeByteOff p 20 v5
    pokeByteOff p 24 v6
    pokeByteOff p 28 v7
    pokeByteOff p 32 v8
    return ()

{-# LINE 21 "Bindings/Posix/Time.hsc" #-}

c'CLOCKS_PER_SEC = 1000000
c'CLOCKS_PER_SEC :: (Num a) => a

{-# LINE 23 "Bindings/Posix/Time.hsc" #-}

foreign import ccall "clock" c'clock
  :: IO CClock
foreign import ccall "&clock" p'clock
  :: FunPtr (IO CClock)

{-# LINE 25 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "difftime" c'difftime
  :: CTime -> CTime -> IO CDouble
foreign import ccall "&difftime" p'difftime
  :: FunPtr (CTime -> CTime -> IO CDouble)

{-# LINE 26 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "gmtime" c'gmtime
  :: Ptr CTime -> IO (Ptr C'tm)
foreign import ccall "&gmtime" p'gmtime
  :: FunPtr (Ptr CTime -> IO (Ptr C'tm))

{-# LINE 27 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "localtime" c'localtime
  :: Ptr CTime -> IO (Ptr C'tm)
foreign import ccall "&localtime" p'localtime
  :: FunPtr (Ptr CTime -> IO (Ptr C'tm))

{-# LINE 28 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "mktime" c'mktime
  :: Ptr C'tm -> IO CTime
foreign import ccall "&mktime" p'mktime
  :: FunPtr (Ptr C'tm -> IO CTime)

{-# LINE 29 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "strftime" c'strftime
  :: CString -> CSize -> CString -> Ptr C'tm -> IO CSize
foreign import ccall "&strftime" p'strftime
  :: FunPtr (CString -> CSize -> CString -> Ptr C'tm -> IO CSize)

{-# LINE 30 "Bindings/Posix/Time.hsc" #-}
foreign import ccall "time" c'time
  :: Ptr CTime -> IO CTime
foreign import ccall "&time" p'time
  :: FunPtr (Ptr CTime -> IO CTime)

{-# LINE 31 "Bindings/Posix/Time.hsc" #-}