diff options
author | Sam Lantinga <slouken@libsdl.org> | 2013-06-23 22:19:38 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2013-06-23 22:19:38 -0700 |
commit | 924968d2d0dcb730492040e84304e16e79583353 (patch) | |
tree | f8b35e1063b46ae34e62edfd93b95869ac49c868 /src/timer | |
parent | ff47b549bdec68de086df192d02783ad23077861 (diff) |
Updated timer test and fixed performance counter on Mac OS X
Diffstat (limited to 'src/timer')
-rw-r--r-- | src/timer/unix/SDL_systimer.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 514ac2267f..7918cde416 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -66,10 +66,10 @@ SDL_StartTicks(void) has_monotonic_time = SDL_TRUE; } else #elif defined(__APPLE__) - start_mach = mach_absolute_time(); kern_return_t ret = mach_timebase_info(&mach_base_info); if (ret == 0) { has_monotonic_time = SDL_TRUE; + start_mach = mach_absolute_time(); } else #endif { @@ -85,12 +85,11 @@ SDL_GetTicks(void) #if HAVE_CLOCK_GETTIME struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - ticks = - (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - + ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000; #elif defined(__APPLE__) uint64_t now = mach_absolute_time(); - ticks = (now - start_mach) * mach_base_info.numer / mach_base_info.denom / 1000000; + ticks = (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000; #endif } else { struct timeval now; @@ -136,7 +135,10 @@ SDL_GetPerformanceFrequency(void) #if HAVE_CLOCK_GETTIME return 1000000000; #elif defined(__APPLE__) - return mach_base_info.denom / mach_base_info.numer * 1000000; + Uint64 freq = mach_base_info.numer; + freq *= 1000000000; + freq /= mach_base_info.denom; + return freq; #endif } else { return 1000000; |