Ecore: use isfinite() if available
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 11 Apr 2011 19:58:56 +0000 (19:58 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 11 Apr 2011 19:58:56 +0000 (19:58 +0000)
Use isfinite() if available, otherwise use finite() on
compilers != vc++, otherwise use _finite()

and a bit of formatting too (i know, it's bad)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@58566 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
src/lib/ecore/ecore_main.c

index 060872a..838e632 100644 (file)
@@ -1001,34 +1001,56 @@ AC_ISC_POSIX
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(gettimeofday strlcpy)
 
+AC_COMPILE_IFELSE(
+   [AC_LANG_PROGRAM(
+       [[
+#include <math.h>
+       ]],
+       [[
+int i = isfinite(0);
+       ]])],
+   [
+    AC_DEFINE(HAVE_ISFINITE, 1, [Define to 1 if you have `isfinite', as a function or macro.])
+    have_isfinite="yes"
+   ],
+   [have_isfinite="no"])
+
+AC_MSG_CHECKING([for isfinite])
+AC_MSG_RESULT([${have_isfinite}])
+
 have_atfile_source=auto
-AC_ARG_ENABLE(atfile-source,
-        AC_HELP_STRING([--disable-atfile-source],
-                       [disable use of atfile source functions as openat and mkdirat @<:@default=detect@:>@]),
-        [have_atfile_source=$enableval], [have_atfile_source=auto])
-
-if test "x$have_atfile_source" != "xno"; then
-        AC_CHECK_FUNCS(mkdirat,
-                [
-                have_atfile_source=yes
-                AC_DEFINE(HAVE_ATFILE_SOURCE, 1, [mkdirat exists])
-                ],
-                [
-                if test "x$have_atfile_source" = "xyes"; then
-                        AC_MSG_ERROR([required atfile-source but no mkdirat()])
-                fi
-                have_atfile_source=no
-                ])
+AC_ARG_ENABLE([atfile-source],
+   [AC_HELP_STRING([--disable-atfile-source],
+       [disable use of atfile source functions as openat and mkdirat @<:@default=detect@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       have_atfile_source="yes"
+    else
+       have_atfile_source="no"
+    fi],
+   [have_atfile_source=auto])
+
+if ! test "x${have_atfile_source}" = "xno" ; then
+   AC_CHECK_FUNCS(mkdirat,
+      [
+       have_atfile_source="yes"
+       AC_DEFINE(HAVE_ATFILE_SOURCE, 1, [mkdirat exists])
+      ],
+      [
+       if test "x${have_atfile_source}" = "xyes" ; then
+          AC_MSG_ERROR([required atfile-source but no mkdirat()])
+       fi
+       have_atfile_source="no"
+      ])
 fi
 
 ### Checks for optionnal feature
-AC_CHECK_FUNC(mallinfo,
-       [
-         have_mallinfo=yes
-         AC_DEFINE(HAVE_MALLINFO, 1, [Gather memory statistic])
-       ], [
-         have_mallinfo=no
-       ])
+AC_CHECK_FUNC([mallinfo],
+   [
+    have_mallinfo="yes"
+    AC_DEFINE(HAVE_MALLINFO, 1, [Gather memory statistic])
+   ],
+   [have_mallinfo="no"])
 
 ### Ecore modules
 
index ec63b35..0d9aea3 100644 (file)
 # include <float.h>
 #endif
 
+#ifdef HAVE_ISFINITE
+# define ECORE_FINITE(t) isfinite(t)
+#else
+# ifdef _MSC_VER
+#  define ECORE_FINITE(t) _finite(t)
+# else
+#  define ECORE_FINITE(t) finite(t)
+# endif
+#endif
+
 #define FIX_HZ 1
 
 #ifdef FIX_HZ
@@ -1079,7 +1089,7 @@ _ecore_main_select(double timeout)
 #endif
 
    t = NULL;
-   if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity.  */
+   if ((!ECORE_FINITE(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity.  */
      {
         tv.tv_sec = 0;
         tv.tv_usec = 0;