forked from enlightenment/efl
eina: allow eina_time_get to fall back to other clocks if the first one fails
Summary: eina_time_get tries to use only one clock which is defined at compile-time and returns the result of that one. This causes problems on platforms where eg. CLOCK_PROCESS_CPUTIME_ID is defined but the clock is actually not implemented (ie. clock_gettime returns EINVAL), as we simply don't get any time at all. Instead, make sure we include the code for all defined clocks and simply fall back to other clocks if the previous ones aren't implemented. Reviewers: cedric, raster Reviewed By: cedric CC: cedric Differential Revision: https://phab.enlightenment.org/D547 Signed-off-by: Cedric BAIL <cedric.bail@samsung.com>
This commit is contained in:
parent
56d73cb897
commit
ed06184077
|
@ -41,12 +41,17 @@ _eina_time_get(Eina_Nano_Time *tp)
|
|||
{
|
||||
#ifndef _WIN32
|
||||
# if defined(CLOCK_PROCESS_CPUTIME_ID)
|
||||
return clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp);
|
||||
# elif defined(CLOCK_PROF)
|
||||
return clock_gettime(CLOCK_PROF, tp);
|
||||
# elif defined(CLOCK_REALTIME)
|
||||
return clock_gettime(CLOCK_REALTIME, tp);
|
||||
# else
|
||||
if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp))
|
||||
return 0;
|
||||
# endif
|
||||
# if defined(CLOCK_PROF)
|
||||
if (!clock_gettime(CLOCK_PROF, tp))
|
||||
return 0;
|
||||
# endif
|
||||
# if defined(CLOCK_REALTIME)
|
||||
if (!clock_gettime(CLOCK_REALTIME, tp))
|
||||
return 0;
|
||||
# endif
|
||||
struct timeval tv;
|
||||
|
||||
if (gettimeofday(&tv, NULL))
|
||||
|
@ -56,7 +61,6 @@ _eina_time_get(Eina_Nano_Time *tp)
|
|||
tp->tv_nsec = tv.tv_usec * 1000L;
|
||||
|
||||
return 0;
|
||||
# endif
|
||||
#else
|
||||
return QueryPerformanceCounter(tp);
|
||||
#endif /* _WIN2 */
|
||||
|
|
Loading…
Reference in New Issue