summaryrefslogtreecommitdiff
path: root/m4/math_h.m4
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-04-12 07:22:40 -0600
committerEric Blake <ebb9@byu.net>2008-04-12 07:28:35 -0600
commit833333f7edfb45487d4a2cbae9f5e611c0c542cf (patch)
tree571fe560b473cd9ab9c93b81c10d5816aead3553 /m4/math_h.m4
parentb2cf43d6c45193102d4c90fc82007f15c1e98e47 (diff)
downloadgnulib-833333f7edfb45487d4a2cbae9f5e611c0c542cf.tar.gz
Work around Solaris 10 math.h bug.
* m4/math_h.m4 (gl_MATH_H): Check for bug. (gl_MATH_H_DEFAULTS): Set up default. * modules/math (Makefile.am): Replace new indicators. * lib/math.in.h (NAN, HUGE_VAL): Provide replacements. * tests/test-math.c (main): Test this. * m4/strtod.m4 (gl_FUNC_STRTOD): Don't rely on HUGE_VAL. * doc/posix-headers/math.texi (math.h): Mention bug. Reported by Nelson H. F. Beebe and Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'm4/math_h.m4')
-rw-r--r--m4/math_h.m429
1 files changed, 28 insertions, 1 deletions
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index dd99e7f2d7..3090b6e863 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 9
+# math_h.m4 serial 10
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,31 @@ AC_DEFUN([gl_MATH_H],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([math.h])
+ AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <math.h>],
+ [[/* Solaris 10 has a broken definition of NAN. Other platforms
+ fail to provide NAN, or provide it only in C99 mode; this
+ test only needs to fail when NAN is provided but wrong. */
+ float f = 1.0f;
+#ifdef NAN
+ f = NAN;
+#endif
+ return f == 0;]])],
+ [gl_cv_header_math_nan_works=yes],
+ [gl_cv_header_math_nan_works=no])])
+ if test gl_cv_header_math_nan_works = no; then
+ REPLACE_NAN=1
+ fi
+ AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <math.h>],
+ [[/* Solaris 10 has a broken definition of HUGE_VAL. */
+ double d = HUGE_VAL;
+ return d == 0;]])],
+ [gl_cv_header_math_huge_val_works=yes],
+ [gl_cv_header_math_huge_val_works=no])])
+ if test gl_cv_header_math_huge_val_works = no; then
+ REPLACE_HUGE_VAL=1
+ fi
])
AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -56,8 +81,10 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
+ REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
+ REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])