/usr/lib/hugs/packages/time/Data/Time/Clock/CTimeval.hs is in libhugs-time-bundled 98.200609.21-5.4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | {-# OPTIONS -ffi -Wall -Werror -cpp #-}
-- #hide
module Data.Time.Clock.CTimeval where
-- All Unix-specific, this
import Foreign
import Foreign.C
data CTimeval = MkCTimeval CLong CLong
instance Storable CTimeval where
sizeOf _ = (sizeOf (undefined :: CLong)) * 2
alignment _ = alignment (undefined :: CLong)
peek p = do
s <- peekElemOff (castPtr p) 0
mus <- peekElemOff (castPtr p) 1
return (MkCTimeval s mus)
poke p (MkCTimeval s mus) = do
pokeElemOff (castPtr p) 0 s
pokeElemOff (castPtr p) 1 mus
foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt
-- | Get the current POSIX time from the system clock.
getCTimeval :: IO CTimeval
getCTimeval = with (MkCTimeval 0 0) (\ptval -> do
result <- gettimeofday ptval nullPtr
if (result == 0)
then peek ptval
else fail ("error in gettimeofday: " ++ (show result))
)
|