Fix clock_gettime detection in autotools
authorlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Sep 2010 19:36:50 +0000 (19:36 +0000)
committerlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Sep 2010 19:36:50 +0000 (19:36 +0000)
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
src/lib/ecore/ecore_time.c

index dfbe5b8..df0a336 100644 (file)
@@ -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
index d7c4ade..1fbb478 100644 (file)
 
 #include <time.h>
 
-#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