summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-25 21:35:38 +0000
committerBruno Haible <bruno@clisp.org>2007-03-25 21:35:38 +0000
commit666ce534702d65dd6ebefe0970022ff474a740e2 (patch)
tree586bfd2c6619711b279ed298c0edd6111efc526a /m4
parenta9a762b14f09234a9661f65e9fbe7e8c950d5bd0 (diff)
downloadgnulib-666ce534702d65dd6ebefe0970022ff474a740e2.tar.gz
Provide a replacement for frexpl() if the system has it but it doesn't work.
Diffstat (limited to 'm4')
-rw-r--r--m4/frexpl.m445
-rw-r--r--m4/math_h.m41
2 files changed, 45 insertions, 1 deletions
diff --git a/m4/frexpl.m4 b/m4/frexpl.m4
index 361fd2d867..b10fee2105 100644
--- a/m4/frexpl.m4
+++ b/m4/frexpl.m4
@@ -1,4 +1,4 @@
-# frexpl.m4 serial 1
+# frexpl.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -36,6 +36,18 @@ AC_DEFUN([gl_FUNC_FREXPL],
fi
if test $gl_cv_func_frexpl_no_libm = yes \
|| test $gl_cv_func_frexpl_in_libm = yes; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $FREXPL_LIBM"
+ gl_FUNC_FREXPL_WORKS
+ LIBS="$save_LIBS"
+ case "$gl_cv_func_frexpl_works" in
+ *yes) gl_func_frexpl=yes ;;
+ *) gl_func_frexpl=no; REPLACE_FREXPL=1; FREXPL_LIBM= ;;
+ esac
+ else
+ gl_func_frexpl=no
+ fi
+ if test $gl_func_frexpl = yes; then
AC_DEFINE([HAVE_FREXPL], 1,
[Define if the frexpl() function is available.])
dnl Also check whether it's declared.
@@ -45,3 +57,34 @@ AC_DEFUN([gl_FUNC_FREXPL],
AC_LIBOBJ([frexpl])
fi
])
+
+dnl Test whether frexpl() works also on infinite numbers (this fails e.g. on
+dnl IRIX 6.5).
+AC_DEFUN([gl_FUNC_FREXPL_WORKS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether frexpl works], [gl_cv_func_frexpl_works],
+ [
+ AC_TRY_RUN([
+#include <math.h>
+int main()
+{
+ volatile long double x;
+ /* Test on infinite numbers. */
+ {
+ x = 1.0L / 0.0L;
+ int exp;
+ long double y = frexpl (x, &exp);
+ if (y != x)
+ return 1;
+ }
+ return 0;
+}], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
+ [case "$host_os" in
+ irix*) gl_cv_func_frexpl_works="guessing no";;
+ *) gl_cv_func_frexpl_works="guessing yes";;
+ esac
+ ])
+ ])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index fb3ea09f2b..cc906f6431 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -39,4 +39,5 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
+ REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
])