aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbin Tonnerre <albin.tonnerre@gmail.com>2014-02-12 11:50:48 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-02-12 16:33:58 +0900
commit5ff5f509fccab9196449f1c31109e316a1a7fed3 (patch)
treed16743e007efabe786575dd294115a69db75a441
parentEvas textblock: Fix rendering of spaces in some cases. (diff)
downloadefl-5ff5f509fccab9196449f1c31109e316a1a7fed3.tar.gz
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>
-rw-r--r--src/lib/eina/eina_inline_private.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/eina/eina_inline_private.h b/src/lib/eina/eina_inline_private.h
index ee0c49bb94..fe0d7b4647 100644
--- a/src/lib/eina/eina_inline_private.h
+++ b/src/lib/eina/eina_inline_private.h
@@ -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 */