From d5f832c772457d4d20f98d8cfd5174aaa0340580 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 28 Sep 2010 19:36:50 +0000 Subject: [PATCH] Fix clock_gettime detection in autotools AC_CHECK_FUNCS checks for the existence of functions in the C standard library, so we don't need it. Instead, we need to define HAVE_CLOCK_GETTIME if the function was found inside the librt. Moreover, in source file check if HAVE_CLOCK_GETTIME is defined rather than of checking if it's 0. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@52863 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- configure.ac | 6 +----- src/lib/ecore/ecore_time.c | 13 +++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index dfbe5b8..df0a336 100644 --- a/configure.ac +++ b/configure.ac @@ -421,11 +421,7 @@ AC_SUBST(dlopen_libs) AC_SUBST(rt_libs) if test -n "$rt_libs"; then - _bkp_LIBS="$LIBS" - LIBS="$LIBS $rt_libs" - AC_CHECK_FUNCS(clock_gettime) - LIBS="$_bkp_LIBS" - unset _bkp_LIBS + AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [Have clock_gettime()]) fi # Eina library diff --git a/src/lib/ecore/ecore_time.c b/src/lib/ecore/ecore_time.c index d7c4ade..1fbb478 100644 --- a/src/lib/ecore/ecore_time.c +++ b/src/lib/ecore/ecore_time.c @@ -17,10 +17,8 @@ #include -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME static clockid_t _ecore_time_clock_id = -1; -#else -static int _ecore_time_clock_id = -1; #endif double _ecore_time_loop_time = -1.0; @@ -43,9 +41,7 @@ double _ecore_time_loop_time = -1.0; EAPI double ecore_time_get(void) { -#if !HAVE_CLOCK_GETTIME - return ecore_time_unix_get(); -#else +#ifdef HAVE_CLOCK_GETTIME struct timespec t; if (EINA_UNLIKELY(_ecore_time_clock_id < 0)) @@ -59,6 +55,8 @@ ecore_time_get(void) } return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0); +#else + return ecore_time_unix_get(); #endif } @@ -126,7 +124,7 @@ ecore_loop_time_get(void) void _ecore_time_init(void) { -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME struct timespec t; if (_ecore_time_clock_id != -1) return; @@ -150,7 +148,6 @@ _ecore_time_init(void) } #else # warning "Your platform isn't supported yet" - _ecore_time_clock_id = -2; CRIT("Platform does not support clock_gettime. " "Fallback to unix time."); #endif -- 2.7.4