#include #include "time.h" #include void time_get(struct timespec* ts) { uint64_t time = SDL_GetTicks64(); ts->tv_sec = time / 1000U; ts->tv_nsec = (time % 1000U) * 1000U * 1000U; } void time_sleep_until(const struct timespec* ts) { uint64_t t_target = ( (ts->tv_sec * 1000ULL) + (ts->tv_nsec / (1000U * 1000U))); uint64_t t_now = SDL_GetTicks64(); if (t_target > t_now) { SDL_Delay(t_target - t_now); } }