Fixed bug 1925 - SDL_GetPerformanceFrequency returns incorrect value on iOS
authorSam Lantinga <slouken@libsdl.org>
Sat, 10 Aug 2013 11:19:30 -0700
changeset 7628ebf5f6859e40
parent 7627 401c4e0f492f
child 7629 a0a3bd77cbc4
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
     1.1 --- a/src/timer/unix/SDL_systimer.c	Sat Aug 10 10:57:54 2013 -0700
     1.2 +++ b/src/timer/unix/SDL_systimer.c	Sat Aug 10 11:19:30 2013 -0700
     1.3 @@ -135,9 +135,9 @@
     1.4  #if HAVE_CLOCK_GETTIME
     1.5          return 1000000000;
     1.6  #elif defined(__APPLE__)
     1.7 -        Uint64 freq = mach_base_info.numer;
     1.8 +        Uint64 freq = mach_base_info.denom;
     1.9          freq *= 1000000000;
    1.10 -        freq /= mach_base_info.denom;
    1.11 +        freq /= mach_base_info.numer;
    1.12          return freq;
    1.13  #endif
    1.14      } else {