diff --git a/src/SDL/Raw/Timer.hs b/src/SDL/Raw/Timer.hs index 0ac69d1..00e4d54 100644 --- a/src/SDL/Raw/Timer.hs +++ b/src/SDL/Raw/Timer.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module SDL.Raw.Timer ( -- * Timer Support addTimer, @@ -6,6 +8,10 @@ module SDL.Raw.Timer ( getPerformanceFrequency, getTicks, removeTimer + +#ifdef RECENT_ISH + , getTicks64 +#endif ) where import Control.Monad.IO.Class @@ -21,6 +27,10 @@ foreign import ccall "SDL.h SDL_GetPerformanceFrequency" getPerformanceFrequency foreign import ccall "SDL.h SDL_GetTicks" getTicksFFI :: IO Word32 foreign import ccall "SDL.h SDL_RemoveTimer" removeTimerFFI :: TimerID -> IO Bool +#ifdef RECENT_ISH +foreign import ccall "SDL.h SDL_GetTicks64" getTicks64FFI :: IO Word64 +#endif + addTimer :: MonadIO m => Word32 -> TimerCallback -> Ptr () -> m TimerID addTimer v1 v2 v3 = liftIO $ addTimerFFI v1 v2 v3 {-# INLINE addTimer #-} @@ -44,3 +54,9 @@ getTicks = liftIO getTicksFFI removeTimer :: MonadIO m => TimerID -> m Bool removeTimer v1 = liftIO $ removeTimerFFI v1 {-# INLINE removeTimer #-} + +#ifdef RECENT_ISH +getTicks64 :: MonadIO m => m Word64 +getTicks64 = liftIO getTicks64FFI +{-# INLINE getTicks64 #-} +#endif diff --git a/src/SDL/Time.hs b/src/SDL/Time.hs index ea29f9f..861e485 100644 --- a/src/SDL/Time.hs +++ b/src/SDL/Time.hs @@ -1,6 +1,8 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module SDL.Time ( -- * Time Measurement ticks @@ -13,6 +15,10 @@ module SDL.Time , RetriggerTimer(..) , addTimer , removeTimer + +#ifdef RECENT_ISH + , ticks64 +#endif ) where import Control.Monad.IO.Class (MonadIO, liftIO) @@ -93,3 +99,11 @@ addTimer timeout callback = liftIO $ do -- See @@ for C documentation. removeTimer :: MonadIO m => Timer -> m Bool removeTimer f = liftIO $ runTimerRemoval f + +#ifdef RECENT_ISH +-- | Number of milliseconds since library initialization. +-- +-- See @@ for C documentation. +ticks64 :: MonadIO m => m Word64 +ticks64 = Raw.getTicks64 +#endif