From 4b9ce55ebe2fce02841a2d5d283b5f02f9a534eb Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 9 Dec 2021 16:16:33 +0100 Subject: Add timer.h functions --- sdl2/timer.ha | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sdl2/timer.ha (limited to 'sdl2/timer.ha') diff --git a/sdl2/timer.ha b/sdl2/timer.ha new file mode 100644 index 0000000..da958b6 --- /dev/null +++ b/sdl2/timer.ha @@ -0,0 +1,32 @@ +// Get the number of milliseconds since SDL library initialization. +// +// This value wraps if the program runs for more than ~49 days. +// +// Returns an unsigned 32-bit value representing the number of milliseconds +// since the SDL library initialized. +export @symbol("SDL_GetTicks") fn getticks() u32; + +// 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. +export @symbol("SDL_GetPerformanceCounter") fn getperformancecounter() u64; + +// Get the count per second of the high resolution counter. +// +// Returns a platform-specific count per second. +export @symbol("SDL_GetPerformanceFrequency") fn getperformancefrequency() u64; + +// 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. +export @symbol("SDL_Delay") fn delay(ms: u32) void; + +// TODO: Timers -- cgit v1.2.3