isfinite, isinf, isnan tests: Avoid syntax error on MSVC 9.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 09:26:58 +0000 (11:26 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 09:26:58 +0000 (11:26 +0200)
* m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): New macro.
* modules/isfinite-tests (configure.ac): Require
gl_LONG_DOUBLE_VS_DOUBLE.
* modules/isinf-tests (configure.ac): Likewise.
* modules/isnan-tests (configure.ac): Likewise.
* modules/isnanl-tests (configure.ac): Likewise.
* modules/isnanl-nolibm-tests (configure.ac): Likewise.
* tests/test-isfinite.c (test_isfinitel): Avoid 80-bit long double
tests on platforms where 'long double' is the same as 'double'.
* tests/test-isinf.c (test_isinfl): Likewise.
* tests/test-isnan.c (test_long_double): Likewise.
* tests/test-isnanl.h (main): Likewise.

ChangeLog
m4/math_h.m4
modules/isfinite-tests
modules/isinf-tests
modules/isnan-tests
modules/isnanl-nolibm-tests
modules/isnanl-tests
tests/test-isfinite.c
tests/test-isinf.c
tests/test-isnan.c
tests/test-isnanl.h

index 8c9af25..b36d2e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-10-09  Bruno Haible  <bruno@clisp.org>
+
+       isfinite, isinf, isnan tests: Avoid syntax error on MSVC 9.
+       * m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): New macro.
+       * modules/isfinite-tests (configure.ac): Require
+       gl_LONG_DOUBLE_VS_DOUBLE.
+       * modules/isinf-tests (configure.ac): Likewise.
+       * modules/isnan-tests (configure.ac): Likewise.
+       * modules/isnanl-tests (configure.ac): Likewise.
+       * modules/isnanl-nolibm-tests (configure.ac): Likewise.
+       * tests/test-isfinite.c (test_isfinitel): Avoid 80-bit long double
+       tests on platforms where 'long double' is the same as 'double'.
+       * tests/test-isinf.c (test_isinfl): Likewise.
+       * tests/test-isnan.c (test_long_double): Likewise.
+       * tests/test-isnanl.h (main): Likewise.
+
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
        Tests for module 'tanhf'.
index 0fb405b..1088d16 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 46
+# math_h.m4 serial 47
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -188,3 +188,34 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_TRUNCF=0;            AC_SUBST([REPLACE_TRUNCF])
   REPLACE_TRUNCL=0;            AC_SUBST([REPLACE_TRUNCL])
 ])
+
+# gl_LONG_DOUBLE_VS_DOUBLE
+# determines whether 'long double' and 'double' have the same representation.
+# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
+# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
+# The currently known platforms where this is the case are:
+# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
+AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
+[
+  AC_CACHE_CHECK([whether long double and double are the same],
+    [gl_cv_long_double_equals_double],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[#include <float.h>]],
+          [[typedef int check[sizeof (long double) == sizeof (double)
+                              && LDBL_MANT_DIG == DBL_MANT_DIG
+                              && LDBL_MAX_EXP == DBL_MAX_EXP
+                              && LDBL_MIN_EXP == DBL_MIN_EXP
+                              ? 1 : -1];
+          ]])],
+       [gl_cv_long_double_equals_double=yes],
+       [gl_cv_long_double_equals_double=no])
+    ])
+  if test $gl_cv_long_double_equals_double = yes; then
+    AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1],
+      [Define to 1 if 'long double' and 'double' have the same representation.])
+    HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1
+  else
+    HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0
+  fi
+  AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE])
+])
index dc0ab8c..6e65027 100644 (file)
@@ -10,6 +10,7 @@ configure.ac:
 gl_FLOAT_EXPONENT_LOCATION
 gl_DOUBLE_EXPONENT_LOCATION
 gl_LONG_DOUBLE_EXPONENT_LOCATION
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-isfinite
index 2ee42a7..53e9c31 100644 (file)
@@ -13,6 +13,7 @@ configure.ac:
 gl_FLOAT_EXPONENT_LOCATION
 gl_DOUBLE_EXPONENT_LOCATION
 gl_LONG_DOUBLE_EXPONENT_LOCATION
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-isinf
index e21153b..417e559 100644 (file)
@@ -12,6 +12,7 @@ configure.ac:
 gl_FLOAT_EXPONENT_LOCATION
 gl_DOUBLE_EXPONENT_LOCATION
 gl_LONG_DOUBLE_EXPONENT_LOCATION
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-isnan
index 6a2ed4e..ddc3c94 100644 (file)
@@ -11,6 +11,7 @@ float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-isnanl-nolibm
index c39be31..82a41e9 100644 (file)
@@ -11,6 +11,7 @@ float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-isnanl
index 2f50de3..ca5e543 100644 (file)
@@ -166,7 +166,7 @@ test_isfinitel ()
   }
 #endif
 
-#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
+#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
 # ifdef WORDS_BIGENDIAN
index 266cd7e..a17b0af 100644 (file)
@@ -172,7 +172,7 @@ test_isinfl ()
   }
 #endif
 
-#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
+#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
 # ifdef WORDS_BIGENDIAN
index cfdff84..6c735f2 100644 (file)
@@ -153,7 +153,7 @@ test_long_double (void)
   }
 #endif
 
-#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
+#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
 # ifdef WORDS_BIGENDIAN
index 055d05f..9f1d763 100644 (file)
@@ -65,7 +65,7 @@ main ()
   }
 #endif
 
-#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
+#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
 # ifdef WORDS_BIGENDIAN