diff options
Diffstat (limited to 'tests/suite/ecore/src/lib/ecore_time.c')
-rw-r--r-- | tests/suite/ecore/src/lib/ecore_time.c | 106 |
1 files changed, 49 insertions, 57 deletions
diff --git a/tests/suite/ecore/src/lib/ecore_time.c b/tests/suite/ecore/src/lib/ecore_time.c index 1fbb4781f4..837aa8bbb5 100644 --- a/tests/suite/ecore/src/lib/ecore_time.c +++ b/tests/suite/ecore/src/lib/ecore_time.c @@ -1,15 +1,15 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <stdlib.h> #ifdef HAVE_SYS_TIME_H -# include <sys/time.h> +#include <sys/time.h> #endif #ifdef HAVE_EVIL -# include <Evil.h> +#include <Evil.h> #endif #include "Ecore.h" @@ -38,25 +38,23 @@ double _ecore_time_loop_time = -1.0; * messages when the application started). * @ingroup Ecore_Time_Group */ -EAPI double -ecore_time_get(void) +EAPI double ecore_time_get(void) { #ifdef HAVE_CLOCK_GETTIME - struct timespec t; + struct timespec t; - if (EINA_UNLIKELY(_ecore_time_clock_id < 0)) - return ecore_time_unix_get(); + if (EINA_UNLIKELY(_ecore_time_clock_id < 0)) + return ecore_time_unix_get(); - if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t))) - { - CRIT("Cannot get current time."); - /* Try to at least return the latest value retrieved*/ - return _ecore_time_loop_time; - } + if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t))) { + CRIT("Cannot get current time."); + /* Try to at least return the latest value retrieved */ + return _ecore_time_loop_time; + } - return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0); + return (double) t.tv_sec + (((double) t.tv_nsec) / 1000000000.0); #else - return ecore_time_unix_get(); + return ecore_time_unix_get(); #endif } @@ -69,20 +67,20 @@ ecore_time_get(void) * @return The number of seconds since 12.00AM 1st January 1970. * @ingroup Ecore_Time_Group */ -EAPI double -ecore_time_unix_get(void) +EAPI double ecore_time_unix_get(void) { #ifdef HAVE_EVIL - return evil_time_get(); + return evil_time_get(); #else -# ifdef HAVE_GETTIMEOFDAY - struct timeval timev; - - gettimeofday(&timev, NULL); - return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); -# else -# error "Your platform isn't supported yet" -# endif +#ifdef HAVE_GETTIMEOFDAY + struct timeval timev; + + gettimeofday(&timev, NULL); + return (double) timev.tv_sec + + (((double) timev.tv_usec) / 1000000); +#else +#error "Your platform isn't supported yet" +#endif #endif } @@ -108,10 +106,9 @@ ecore_time_unix_get(void) * messages when the application started). * @ingroup Ecore_Time_Group */ -EAPI double -ecore_loop_time_get(void) +EAPI double ecore_loop_time_get(void) { - return _ecore_time_loop_time; + return _ecore_time_loop_time; } @@ -121,36 +118,31 @@ ecore_loop_time_get(void) * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback * to unix time (without specifying the resolution) might be removed */ -void -_ecore_time_init(void) +void _ecore_time_init(void) { #ifdef HAVE_CLOCK_GETTIME - struct timespec t; - - if (_ecore_time_clock_id != -1) return; - - if (!clock_gettime(CLOCK_MONOTONIC, &t)) - { - _ecore_time_clock_id = CLOCK_MONOTONIC; - DBG("using CLOCK_MONOTONIC."); - } - else if (!clock_gettime(CLOCK_REALTIME, &t)) - { - /* may go backwards */ - _ecore_time_clock_id = CLOCK_REALTIME; - WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME."); - } - else - { - _ecore_time_clock_id = -2; - CRIT("Cannot get a valid clock_gettime() clock id! " - "Fallback to unix time."); - } + struct timespec t; + + if (_ecore_time_clock_id != -1) + return; + + if (!clock_gettime(CLOCK_MONOTONIC, &t)) { + _ecore_time_clock_id = CLOCK_MONOTONIC; + DBG("using CLOCK_MONOTONIC."); + } else if (!clock_gettime(CLOCK_REALTIME, &t)) { + /* may go backwards */ + _ecore_time_clock_id = CLOCK_REALTIME; + WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME."); + } else { + _ecore_time_clock_id = -2; + CRIT("Cannot get a valid clock_gettime() clock id! " + "Fallback to unix time."); + } #else -# warning "Your platform isn't supported yet" - CRIT("Platform does not support clock_gettime. " - "Fallback to unix time."); +#warning "Your platform isn't supported yet" + CRIT("Platform does not support clock_gettime. " + "Fallback to unix time."); #endif - _ecore_time_loop_time = ecore_time_get(); + _ecore_time_loop_time = ecore_time_get(); } |