{-# LANGUAGE NoImplicitPrelude #-} -- | SDL provides time management functionality. It is useful for dealing with (usually) small durations of time. -- -- This is not to be confused with /calendar time/ management, which is provided by [CategoryTime](https:\/\/wiki.libsdl.org\/SDL3\/CategoryTime). -- -- This category covers measuring time elapsed (@'getTicks'@, @'getPerformanceCounter'@), putting a thread to sleep for a certain amount of time (@'delay'@, @'delayNS'@, @'delayPrecise'@), and firing a callback function after a certain amount of time has elapsed (@'addTimer'@, etc). -- -- There are also useful macros to convert between time units, like @'secondsToNs'@ and such. Number of milliseconds in a second. -- -- This is always 1000. -- -- @since 3.2.0 -- -- == FFI conventions -- -- Unsuffixed aliases are __unsafe__ foreign imports; aliases suffixed @Safe@ are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under @SDL3.Sys.Bindgen.Timer.Unsafe@); functions curated unsafe-only export only the unsuffixed one. Each alias\'s documentation records its flavor and rationale. -- -- The C shims are functions this package defines in C over what the FFI cannot call directly (variadic functions, function-like macros), each named after what it wraps; the same flavor rules apply. Their raw imports live under "SDL3.Sys.Bindgen.TimerShims". -- -- Full conventions: "SDL3.Sys". module SDL3.Sys.Timer ( module SDL3.Sys.Bindgen.Timer, -- * Function aliases SDL3.Sys.Timer.getTicks, SDL3.Sys.Timer.getTicksNS, SDL3.Sys.Timer.getPerformanceCounter, SDL3.Sys.Timer.getPerformanceFrequency, SDL3.Sys.Timer.delay, SDL3.Sys.Timer.delaySafe, SDL3.Sys.Timer.delayNS, SDL3.Sys.Timer.delayNSSafe, SDL3.Sys.Timer.delayPrecise, SDL3.Sys.Timer.delayPreciseSafe, SDL3.Sys.Timer.addTimer, SDL3.Sys.Timer.addTimerSafe, SDL3.Sys.Timer.addTimerNS, SDL3.Sys.Timer.addTimerNSSafe, SDL3.Sys.Timer.removeTimer, SDL3.Sys.Timer.removeTimerSafe, -- * C shims SDL3.Sys.Timer.secondsToNs, SDL3.Sys.Timer.msToNs, SDL3.Sys.Timer.usToNs, ) where import Data.Coerce qualified as Coerce import Prelude (Bool, IO, fmap) import HsBindgen.Runtime.CBool qualified as CBool import HsBindgen.Runtime.Support qualified as BG import SDL3.Sys.Bindgen.Stdinc qualified import SDL3.Sys.Bindgen.Timer import SDL3.Sys.Bindgen.Timer.Safe qualified as Safe import SDL3.Sys.Bindgen.Timer.Unsafe qualified as Unsafe import SDL3.Sys.Bindgen.TimerShims.Unsafe qualified as Unsafe -- | Get the number of milliseconds that have elapsed since the SDL library initialization. -- -- [Returns]: an unsigned 64‑bit integer that represents the number of milliseconds that have elapsed since the SDL library was initialized (typically via a call to SDL_Init). -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'getTicksNS' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_GetTicks@. -- The safe import is not exported -- : reads a monotonic clock value; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_GetTicks@, defined at @SDL3\/SDL_timer.h 201:36@ getTicks :: IO BG.Word64 getTicks :: IO Word64 getTicks = (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce IO Uint64 Unsafe.sDL_GetTicks -- | Get the number of nanoseconds since SDL library initialization. -- -- [Returns]: an unsigned 64-bit value representing the number of nanoseconds since the SDL library initialized. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_GetTicksNS@. -- The safe import is not exported -- : reads a monotonic clock value; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_GetTicksNS@, defined at @SDL3\/SDL_timer.h 213:36@ getTicksNS :: IO BG.Word64 getTicksNS :: IO Word64 getTicksNS = (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce IO Uint64 Unsafe.sDL_GetTicksNS -- | Get the current value of the high resolution counter. -- -- This function is typically used for profiling. -- -- The counter values are only meaningful relative to each other. Differences between values can be converted to times by using @'getPerformanceFrequency'@. -- -- [Returns]: the current counter value. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'getPerformanceFrequency' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_GetPerformanceCounter@. -- The safe import is not exported -- : reads a monotonic clock value; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_GetPerformanceCounter@, defined at @SDL3\/SDL_timer.h 232:36@ getPerformanceCounter :: IO BG.Word64 getPerformanceCounter :: IO Word64 getPerformanceCounter = (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce IO Uint64 Unsafe.sDL_GetPerformanceCounter -- | Get the count per second of the high resolution counter. -- -- [Returns]: a platform-specific count per second. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'getPerformanceCounter' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_GetPerformanceFrequency@. -- The safe import is not exported -- : reads a monotonic clock value; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_GetPerformanceFrequency@, defined at @SDL3\/SDL_timer.h 245:36@ getPerformanceFrequency :: IO BG.Word64 getPerformanceFrequency :: IO Word64 getPerformanceFrequency = (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce IO Uint64 Unsafe.sDL_GetPerformanceFrequency -- | Wait a specified number of milliseconds before returning. -- -- This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delayNS', 'delayPrecise' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_Delay@. -- The safe flavor is 'delaySafe' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_Delay@, defined at @SDL3\/SDL_timer.h 263:34@ delay :: BG.Word32 -- ^ -- -- [@ms@]: the number of milliseconds to delay. -> IO () delay :: Word32 -> IO () delay = \Word32 x00 -> Uint32 -> IO () Unsafe.sDL_Delay (Word32 -> Uint32 forall a b. Coercible a b => a -> b Coerce.coerce Word32 x00) -- | Wait a specified number of milliseconds before returning. -- -- This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delayNS', 'delayPrecise' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_Delay@. -- The unsafe flavor is 'delay' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_Delay@, defined at @SDL3\/SDL_timer.h 263:34@ delaySafe :: BG.Word32 -- ^ -- -- [@ms@]: the number of milliseconds to delay. -> IO () delaySafe :: Word32 -> IO () delaySafe = \Word32 x00 -> Uint32 -> IO () Safe.sDL_Delay (Word32 -> Uint32 forall a b. Coercible a b => a -> b Coerce.coerce Word32 x00) -- | Wait a specified number of nanoseconds before returning. -- -- This function waits a specified number of nanoseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delay', 'delayPrecise' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_DelayNS@. -- The safe flavor is 'delayNSSafe' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_DelayNS@, defined at @SDL3\/SDL_timer.h 281:34@ delayNS :: BG.Word64 -- ^ -- -- [@ns@]: the number of nanoseconds to delay. -> IO () delayNS :: Word64 -> IO () delayNS = \Word64 x00 -> Uint64 -> IO () Unsafe.sDL_DelayNS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) -- | Wait a specified number of nanoseconds before returning. -- -- This function waits a specified number of nanoseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delay', 'delayPrecise' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_DelayNS@. -- The unsafe flavor is 'delayNS' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_DelayNS@, defined at @SDL3\/SDL_timer.h 281:34@ delayNSSafe :: BG.Word64 -- ^ -- -- [@ns@]: the number of nanoseconds to delay. -> IO () delayNSSafe :: Word64 -> IO () delayNSSafe = \Word64 x00 -> Uint64 -> IO () Safe.sDL_DelayNS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) -- | Wait a specified number of nanoseconds before returning. -- -- This function waits a specified number of nanoseconds before returning. It will attempt to wait as close to the requested time as possible, busy waiting if necessary, but could return later due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delay', 'delayNS' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_DelayPrecise@. -- The safe flavor is 'delayPreciseSafe' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_DelayPrecise@, defined at @SDL3\/SDL_timer.h 299:34@ delayPrecise :: BG.Word64 -- ^ -- -- [@ns@]: the number of nanoseconds to delay. -> IO () delayPrecise :: Word64 -> IO () delayPrecise = \Word64 x00 -> Uint64 -> IO () Unsafe.sDL_DelayPrecise (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) -- | Wait a specified number of nanoseconds before returning. -- -- This function waits a specified number of nanoseconds before returning. It will attempt to wait as close to the requested time as possible, busy waiting if necessary, but could return later due to OS scheduling. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'delay', 'delayNS' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_DelayPrecise@. -- The unsafe flavor is 'delayPrecise' -- : sleeps the OS thread; an unsafe call stalls every capability and GC for the duration. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_DelayPrecise@, defined at @SDL3\/SDL_timer.h 299:34@ delayPreciseSafe :: BG.Word64 -- ^ -- -- [@ns@]: the number of nanoseconds to delay. -> IO () delayPreciseSafe :: Word64 -> IO () delayPreciseSafe = \Word64 x00 -> Uint64 -> IO () Safe.sDL_DelayPrecise (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) -- | Call a callback function at a future time. -- -- The callback function is passed the current timer interval and the user supplied parameter from the @'addTimer'@ call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed. -- -- The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns. -- -- Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration. -- -- Timing may be inexact due to OS scheduling. Be sure to note the current time with @'getTicksNS'@ or @'getPerformanceCounter'@ in case your callback needs to adjust for variances. -- -- [Returns]: a timer ID or 0 on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimerNS', 'removeTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_AddTimer@. -- The safe flavor is 'addTimerSafe' -- : registration; the timer fires on SDL\'s timer thread. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_AddTimer@, defined at @SDL3\/SDL_timer.h 368:41@ addTimer :: BG.Word32 -- ^ -- -- [@interval@]: the timer delay, in milliseconds, passed to @callback@. -> SDL_TimerCallback -- ^ -- -- [@callback@]: the 'SDL_TimerCallback' function to call when the specified @interval@ elapses. -> BG.Ptr BG.Void -- ^ -- -- [@userdata@]: a pointer that is passed to @callback@. -> IO SDL_TimerID addTimer :: Word32 -> SDL_TimerCallback -> Ptr Void -> IO SDL_TimerID addTimer = \Word32 x00 -> \SDL_TimerCallback x11 -> \Ptr Void x22 -> Uint32 -> SDL_TimerCallback -> Ptr Void -> IO SDL_TimerID Unsafe.sDL_AddTimer (Word32 -> Uint32 forall a b. Coercible a b => a -> b Coerce.coerce Word32 x00) SDL_TimerCallback x11 Ptr Void x22 -- | Call a callback function at a future time. -- -- The callback function is passed the current timer interval and the user supplied parameter from the @'addTimer'@ call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed. -- -- The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns. -- -- Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration. -- -- Timing may be inexact due to OS scheduling. Be sure to note the current time with @'getTicksNS'@ or @'getPerformanceCounter'@ in case your callback needs to adjust for variances. -- -- [Returns]: a timer ID or 0 on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimerNS', 'removeTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_AddTimer@. -- The unsafe flavor is 'addTimer' -- : registration; the timer fires on SDL\'s timer thread. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_AddTimer@, defined at @SDL3\/SDL_timer.h 368:41@ addTimerSafe :: BG.Word32 -- ^ -- -- [@interval@]: the timer delay, in milliseconds, passed to @callback@. -> SDL_TimerCallback -- ^ -- -- [@callback@]: the 'SDL_TimerCallback' function to call when the specified @interval@ elapses. -> BG.Ptr BG.Void -- ^ -- -- [@userdata@]: a pointer that is passed to @callback@. -> IO SDL_TimerID addTimerSafe :: Word32 -> SDL_TimerCallback -> Ptr Void -> IO SDL_TimerID addTimerSafe = \Word32 x00 -> \SDL_TimerCallback x11 -> \Ptr Void x22 -> Uint32 -> SDL_TimerCallback -> Ptr Void -> IO SDL_TimerID Safe.sDL_AddTimer (Word32 -> Uint32 forall a b. Coercible a b => a -> b Coerce.coerce Word32 x00) SDL_TimerCallback x11 Ptr Void x22 -- | Call a callback function at a future time. -- -- The callback function is passed the current timer interval and the user supplied parameter from the @'addTimerNS'@ call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed. -- -- The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns. -- -- Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ns to execute and returned 1000 (ns), the timer would only wait another 750 ns before its next iteration. -- -- Timing may be inexact due to OS scheduling. Be sure to note the current time with @'getTicksNS'@ or @'getPerformanceCounter'@ in case your callback needs to adjust for variances. -- -- [Returns]: a timer ID or 0 on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimer', 'removeTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_AddTimerNS@. -- The safe flavor is 'addTimerNSSafe' -- : registration; the timer fires on SDL\'s timer thread. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_AddTimerNS@, defined at @SDL3\/SDL_timer.h 430:41@ addTimerNS :: BG.Word64 -- ^ -- -- [@interval@]: the timer delay, in nanoseconds, passed to @callback@. -> SDL_NSTimerCallback -- ^ -- -- [@callback@]: the 'SDL_TimerCallback' function to call when the specified @interval@ elapses. -> BG.Ptr BG.Void -- ^ -- -- [@userdata@]: a pointer that is passed to @callback@. -> IO SDL_TimerID addTimerNS :: Word64 -> SDL_NSTimerCallback -> Ptr Void -> IO SDL_TimerID addTimerNS = \Word64 x00 -> \SDL_NSTimerCallback x11 -> \Ptr Void x22 -> Uint64 -> SDL_NSTimerCallback -> Ptr Void -> IO SDL_TimerID Unsafe.sDL_AddTimerNS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) SDL_NSTimerCallback x11 Ptr Void x22 -- | Call a callback function at a future time. -- -- The callback function is passed the current timer interval and the user supplied parameter from the @'addTimerNS'@ call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed. -- -- The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns. -- -- Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ns to execute and returned 1000 (ns), the timer would only wait another 750 ns before its next iteration. -- -- Timing may be inexact due to OS scheduling. Be sure to note the current time with @'getTicksNS'@ or @'getPerformanceCounter'@ in case your callback needs to adjust for variances. -- -- [Returns]: a timer ID or 0 on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimer', 'removeTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_AddTimerNS@. -- The unsafe flavor is 'addTimerNS' -- : registration; the timer fires on SDL\'s timer thread. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_AddTimerNS@, defined at @SDL3\/SDL_timer.h 430:41@ addTimerNSSafe :: BG.Word64 -- ^ -- -- [@interval@]: the timer delay, in nanoseconds, passed to @callback@. -> SDL_NSTimerCallback -- ^ -- -- [@callback@]: the 'SDL_TimerCallback' function to call when the specified @interval@ elapses. -> BG.Ptr BG.Void -- ^ -- -- [@userdata@]: a pointer that is passed to @callback@. -> IO SDL_TimerID addTimerNSSafe :: Word64 -> SDL_NSTimerCallback -> Ptr Void -> IO SDL_TimerID addTimerNSSafe = \Word64 x00 -> \SDL_NSTimerCallback x11 -> \Ptr Void x22 -> Uint64 -> SDL_NSTimerCallback -> Ptr Void -> IO SDL_TimerID Safe.sDL_AddTimerNS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00) SDL_NSTimerCallback x11 Ptr Void x22 -- | Remove a timer created with @'addTimer'@. -- -- [Returns]: true on success or false on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @SDL_RemoveTimer@. -- The safe flavor is 'removeTimerSafe' -- . -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_RemoveTimer@, defined at @SDL3\/SDL_timer.h 445:34@ removeTimer :: SDL_TimerID -- ^ -- -- [@id@]: the ID of the timer to remove. -> IO Bool removeTimer :: SDL_TimerID -> IO Bool removeTimer = \SDL_TimerID x00 -> (CBool -> Bool) -> IO CBool -> IO Bool forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap CBool -> Bool forall b. (Eq b, Num b) => b -> Bool CBool.toBool (SDL_TimerID -> IO CBool Unsafe.sDL_RemoveTimer SDL_TimerID x00) -- | Remove a timer created with @'addTimer'@. -- -- [Returns]: true on success or false on failure; call 'SDL3.Sys.Error.getError' for more information. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- [See also]: 'addTimer' -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Safe__ foreign import of @SDL_RemoveTimer@. -- The unsafe flavor is 'removeTimer' -- . -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @SDL_RemoveTimer@, defined at @SDL3\/SDL_timer.h 445:34@ removeTimerSafe :: SDL_TimerID -- ^ -- -- [@id@]: the ID of the timer to remove. -> IO Bool removeTimerSafe :: SDL_TimerID -> IO Bool removeTimerSafe = \SDL_TimerID x00 -> (CBool -> Bool) -> IO CBool -> IO Bool forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap CBool -> Bool forall b. (Eq b, Num b) => b -> Bool CBool.toBool (SDL_TimerID -> IO CBool Safe.sDL_RemoveTimer SDL_TimerID x00) -- | Convert seconds to nanoseconds. -- -- The SDL_SECONDS_TO_NS macro as a function. This only converts whole numbers, not fractional seconds. -- -- [Returns]: @s@, expressed in nanoseconds. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @lithon_SDL_SECONDS_TO_NS@. -- The safe import is not exported -- : pure math on immediate values; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @lithon_SDL_SECONDS_TO_NS@, defined at @sdl3-bindgen-sys\/SDL_timer_shims.h 37:26@ secondsToNs :: BG.Word64 -- ^ -- -- [@s@]: the number of seconds to convert. -> IO BG.Word64 secondsToNs :: Word64 -> IO Word64 secondsToNs = \Word64 x00 -> (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce (Uint64 -> IO Uint64 Unsafe.lithon_SDL_SECONDS_TO_NS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00)) -- | Convert milliseconds to nanoseconds. -- -- The SDL_MS_TO_NS macro as a function. This only converts whole numbers, not fractional milliseconds. -- -- [Returns]: @ms@, expressed in nanoseconds. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @lithon_SDL_MS_TO_NS@. -- The safe import is not exported -- : pure math on immediate values; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @lithon_SDL_MS_TO_NS@, defined at @sdl3-bindgen-sys\/SDL_timer_shims.h 55:26@ msToNs :: BG.Word64 -- ^ -- -- [@ms@]: the number of milliseconds to convert. -> IO BG.Word64 msToNs :: Word64 -> IO Word64 msToNs = \Word64 x00 -> (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce (Uint64 -> IO Uint64 Unsafe.lithon_SDL_MS_TO_NS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00)) -- | Convert microseconds to nanoseconds. -- -- The SDL_US_TO_NS macro as a function. This only converts whole numbers, not fractional microseconds. -- -- [Returns]: @us@, expressed in nanoseconds. -- -- [Thread safety]: It is safe to call this function from any thread. -- -- @since 3.2.0 -- -- === __@sdl3-bindgen-sys@ notes__ -- -- [FFI safety]: __Unsafe__ foreign import of @lithon_SDL_US_TO_NS@. -- The safe import is not exported -- : pure math on immediate values; cannot block, lock, or call back. -- -- [Scalars]: The binding generation has mapped C scalars to native Haskell scalars for this function. -- Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate. -- -- [C declaration]: @lithon_SDL_US_TO_NS@, defined at @sdl3-bindgen-sys\/SDL_timer_shims.h 73:26@ usToNs :: BG.Word64 -- ^ -- -- [@us@]: the number of microseconds to convert. -> IO BG.Word64 usToNs :: Word64 -> IO Word64 usToNs = \Word64 x00 -> (Uint64 -> Word64) -> IO Uint64 -> IO Word64 forall a b. (a -> b) -> IO a -> IO b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Uint64 -> Word64 forall a b. Coercible a b => a -> b Coerce.coerce (Uint64 -> IO Uint64 Unsafe.lithon_SDL_US_TO_NS (Word64 -> Uint64 forall a b. Coercible a b => a -> b Coerce.coerce Word64 x00))