From 44a8b5240a8766f2561f36400713ea524dd745b0 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 30 Jan 2016 17:25:01 +0100 Subject: Replace `__hsunix_time` wrapper with CApiFFI --- System/Posix/Time.hs | 41 +++++++++++++++++++++++++++++++++++++++++ System/Posix/Time.hsc | 41 ----------------------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 System/Posix/Time.hs delete mode 100644 System/Posix/Time.hsc (limited to 'System') diff --git a/System/Posix/Time.hs b/System/Posix/Time.hs new file mode 100644 index 0000000..7a2232f --- /dev/null +++ b/System/Posix/Time.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE CPP #-} +#if __GLASGOW_HASKELL__ >= 709 +{-# LANGUAGE Safe #-} +#elif __GLASGOW_HASKELL__ >= 703 +{-# LANGUAGE Trustworthy #-} +#endif +----------------------------------------------------------------------------- +-- | +-- Module : System.Posix.Time +-- Copyright : (c) The University of Glasgow 2002 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : provisional +-- Portability : non-portable (requires POSIX) +-- +-- POSIX Time support +-- +----------------------------------------------------------------------------- + +module System.Posix.Time ( + epochTime, + -- ToDo: lots more from sys/time.h + -- how much already supported by System.Time? + ) where + +import System.Posix.Types +import Foreign +import Foreign.C + +-- ----------------------------------------------------------------------------- +-- epochTime + +-- | @epochTime@ calls @time@ to obtain the number of +-- seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970). +epochTime :: IO EpochTime +epochTime = throwErrnoIfMinus1 "epochTime" (c_time nullPtr) + +foreign import capi unsafe "HsUnix.h time" + c_time :: Ptr CTime -> IO CTime diff --git a/System/Posix/Time.hsc b/System/Posix/Time.hsc deleted file mode 100644 index a28050d..0000000 --- a/System/Posix/Time.hsc +++ /dev/null @@ -1,41 +0,0 @@ -#if __GLASGOW_HASKELL__ >= 709 -{-# LANGUAGE Safe #-} -#elif __GLASGOW_HASKELL__ >= 703 -{-# LANGUAGE Trustworthy #-} -#endif ------------------------------------------------------------------------------ --- | --- Module : System.Posix.Time --- Copyright : (c) The University of Glasgow 2002 --- License : BSD-style (see the file libraries/base/LICENSE) --- --- Maintainer : libraries@haskell.org --- Stability : provisional --- Portability : non-portable (requires POSIX) --- --- POSIX Time support --- ------------------------------------------------------------------------------ - -module System.Posix.Time ( - epochTime, - -- ToDo: lots more from sys/time.h - -- how much already supported by System.Time? - ) where - -#include "HsUnix.h" - -import System.Posix.Types -import Foreign -import Foreign.C - --- ----------------------------------------------------------------------------- --- epochTime - --- | @epochTime@ calls @time@ to obtain the number of --- seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970). -epochTime :: IO EpochTime -epochTime = throwErrnoIfMinus1 "epochTime" (c_time nullPtr) - -foreign import ccall unsafe "__hsunix_time" - c_time :: Ptr CTime -> IO CTime -- cgit v1.2.3