| Summary: | Even if built with --enable-clock_gettime, SDL2 still calls gettimeofday(). | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Tiago O. <toacn-foss> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | ravas.gorefiend |
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | When clock_gettime is available, make SDL_syscond.c and SDL_syssem.c use it | ||
|
Description
Tiago O.
2014-02-21 20:37:05 UTC
Since 2013-05-02 the configure script defaults to using clock_gettime. I verified by adding a print statement in SDL_GetTicks() that clock_gettime was used with the latest revision in HG. I checked the SDL 2.0.2 package in the Ubuntu repository and it uses clock_gettime. I compared the value returned by SDL_GetPerformanceCounter() to the values from calls to clock_gettime() and gettimeofday(). The values were: SDL_GetPerformanceCounter() returned 13044428999245 clock_gettime() in nanoseconds returned 13044428999743 gettimeofday() in microseconds returned 1416419469058256 As of rev 9224, SDL2 has references to gettimeofday without a clock_gettime alternative in:
src/thread/pthread/SDL_syscond.c line 108
src/thread/pthread/SDL_syssem.c line 128
src/audio/nas/SDL_nasaudio.c lines 237 and 249
"readelf -s libSDL2-2.0.so.0.4.0 | grep gettime" prints:
64: 0000000000000000 0 FUNC GLOBAL DEFAULT UND gettimeofday@GLIBC_2.2.5 (3)
127: 0000000000000000 0 FUNC GLOBAL DEFAULT UND clock_gettime@GLIBC_2.2.5 (10)
Created attachment 1942 [details]
When clock_gettime is available, make SDL_syscond.c and SDL_syssem.c use it
Makes SDL_syscond.c and SDL_syssem.c use clock_gettime(CLOCK_REALTIME) when HAVE_CLOCK_GETTIME is defined.
I've attached a patch making SDL_CondWaitTimeout and SDL_SemWaitTimeout use clock_gettime(CLOCK_REALTIME) when HAVE_CLOCK_GETTIME is defined. I did not change the usage in SDL_nasaudio.c. The value of gettimeofday there is not actually used anywhere so it may just be for debugging purposes. Fixed, thanks! https://hg.libsdl.org/SDL/rev/9f8962b9b09e |