]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use a more bulletproof test for whether finite() and isinf() are present.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Jan 2006 19:24:02 +0000 (19:24 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Jan 2006 19:24:02 +0000 (19:24 +0000)
It seems that recent gcc versions can optimize away calls to these functions
even when the functions do not exist on the platform, resulting in a bogus
positive result.  Avoid this by using a non-constant argument and ensuring
that the function result is not simply discarded.  Per report from
François Laupretre.

configure
configure.in

index 5a321407a6b067b436525d704899c9a5b30b829a..fe36df8193a7d18cdc2817191f479f0dcb2525ff 100755 (executable)
--- a/configure
+++ b/configure
@@ -12344,7 +12344,6 @@ fi
 
 
 
-# do this one the hard way in case isinf() is a macro
 echo "$as_me:$LINENO: checking for isinf" >&5
 echo $ECHO_N "checking for isinf... $ECHO_C" >&6
 if test "${ac_cv_func_isinf+set}" = set; then
@@ -12353,7 +12352,9 @@ else
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+
 #include <math.h>
+double glob_double;
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -12364,7 +12365,7 @@ else
 int
 main ()
 {
-double x = 0.0; int res = isinf(x);
+return isinf(glob_double) ? 0 : 1;
   ;
   return 0;
 }
@@ -12985,7 +12986,10 @@ echo $ECHO_N "checking for finite... $ECHO_C" >&6
 cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+
 #include <math.h>
+double glob_double;
+
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
@@ -12995,7 +12999,7 @@ cat >conftest.$ac_ext <<_ACEOF
 int
 main ()
 {
-int dummy=finite(1.0);
+return finite(glob_double) ? 0 : 1;
   ;
   return 0;
 }
index 9f69cd5f59300de1cf44b41780fcbaa1417aa8a5..6bc857d29c3af17eae99047799e5f1ccf9c6baaf 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.398.4.9 2006/01/05 04:00:26 momjian Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.398.4.10 2006/01/12 19:24:02 tgl Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -894,12 +894,13 @@ AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
 AC_CHECK_DECLS([snprintf, vsnprintf])
 
 
-# do this one the hard way in case isinf() is a macro
+dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
-[AC_TRY_LINK(
-[#include <math.h>
+[AC_TRY_LINK([
+#include <math.h>
+double glob_double;
 ],
-[double x = 0.0; int res = isinf(x);],
+[return isinf(glob_double) ? 0 : 1;],
 [ac_cv_func_isinf=yes],
 [ac_cv_func_isinf=no])])
 
@@ -960,8 +961,11 @@ fi
 
 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
 AC_MSG_CHECKING(for finite)
-AC_TRY_LINK([#include <math.h>],
-            [int dummy=finite(1.0);],
+AC_TRY_LINK([
+#include <math.h>
+double glob_double;
+],
+            [return finite(glob_double) ? 0 : 1;],
             [AC_DEFINE(HAVE_FINITE, 1, [Define to 1 if you have finite().])
 AC_MSG_RESULT(yes)],
             [AC_MSG_RESULT(no)])