From 28b592cb5df985a272f29e24d0be326a342b5948 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 10 Aug 2013 11:19:30 -0700 Subject: [PATCH] Fixed bug 1925 - SDL_GetPerformanceFrequency returns incorrect value on iOS PoopiSan Currently on OSX and iOS simulator the values: mach_base_info.denom = 1 mach_base_info.numer = 1 but on the real iOS device mach_base_info.denom = 3 mach_base_info.numer = 125 The calculation is made using following formula mach_base_info.denom / mach_base_info.numer * 1000000 but all values are int32 and the result is casted to int64. This solves the problem: return 1.0 * mach_base_info.denom / mach_base_info.numer * 1000000; --- src/timer/unix/SDL_systimer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 7918cde41..596d749ab 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -135,9 +135,9 @@ SDL_GetPerformanceFrequency(void) #if HAVE_CLOCK_GETTIME return 1000000000; #elif defined(__APPLE__) - Uint64 freq = mach_base_info.numer; + Uint64 freq = mach_base_info.denom; freq *= 1000000000; - freq /= mach_base_info.denom; + freq /= mach_base_info.numer; return freq; #endif } else {