|
@@ -56,10 +56,16 @@ mach_timebase_info_data_t mach_base_info;
|
|
|
#endif
|
|
|
static SDL_bool has_monotonic_time = SDL_FALSE;
|
|
|
static struct timeval start_tv;
|
|
|
+static SDL_bool ticks_started = SDL_FALSE;
|
|
|
|
|
|
void
|
|
|
-SDL_StartTicks(void)
|
|
|
+SDL_InitTicks(void)
|
|
|
{
|
|
|
+ if (ticks_started) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ticks_started = SDL_TRUE;
|
|
|
+
|
|
|
/* Set first ticks value */
|
|
|
#if HAVE_CLOCK_GETTIME
|
|
|
if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) {
|
|
@@ -80,6 +86,10 @@ SDL_StartTicks(void)
|
|
|
Uint32
|
|
|
SDL_GetTicks(void)
|
|
|
{
|
|
|
+ if (!ticks_started) {
|
|
|
+ SDL_InitTicks();
|
|
|
+ }
|
|
|
+
|
|
|
Uint32 ticks;
|
|
|
if (has_monotonic_time) {
|
|
|
#if HAVE_CLOCK_GETTIME
|
|
@@ -105,6 +115,10 @@ SDL_GetTicks(void)
|
|
|
Uint64
|
|
|
SDL_GetPerformanceCounter(void)
|
|
|
{
|
|
|
+ if (!ticks_started) {
|
|
|
+ SDL_InitTicks();
|
|
|
+ }
|
|
|
+
|
|
|
Uint64 ticks;
|
|
|
if (has_monotonic_time) {
|
|
|
#if HAVE_CLOCK_GETTIME
|
|
@@ -131,6 +145,10 @@ SDL_GetPerformanceCounter(void)
|
|
|
Uint64
|
|
|
SDL_GetPerformanceFrequency(void)
|
|
|
{
|
|
|
+ if (!ticks_started) {
|
|
|
+ SDL_InitTicks();
|
|
|
+ }
|
|
|
+
|
|
|
if (has_monotonic_time) {
|
|
|
#if HAVE_CLOCK_GETTIME
|
|
|
return 1000000000;
|