summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-05-20 13:33:13 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-05-20 13:33:13 +0000
commit2bf912f30bf300e0616dcfd29139c3a7fa4cf944 (patch)
tree2371e23896b89d84779e09185822b280ca8ec574
parent58092473aedf4ba8450cb6efe1f6a40d9b04c0e5 (diff)
downloadmpfr-2bf912f30bf300e0616dcfd29139c3a7fa4cf944.tar.gz
[acinclude.m4] Added a test for signed zeros (defines HAVE_SIGNEDZ).
[tests/{tset_d.c,tget_flt.c}] Disabled two tests when HAVE_SIGNEDZ isn't defined, because these tests rely on signed zeros. Note: this is needed for compilers that don't support signed zeros, like tcc 0.9.26 and before. (merged changesets r8339-8340 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9413 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--acinclude.m416
-rw-r--r--tests/tget_flt.c2
-rw-r--r--tests/tset_d.c2
3 files changed, 20 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 3a54a85af..ab2660d65 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -214,6 +214,22 @@ if test "$mpfr_cv_have_denorms" = "yes"; then
AC_DEFINE(HAVE_DENORMS,1,[Define if subnormal (denormalized) floats work.])
fi
+dnl Check if signed zeros are supported. Note: the test will fail
+dnl if the division by 0 generates a trap.
+AC_CACHE_CHECK([for signed zeros], mpfr_cv_have_signedz, [
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+int main() {
+ return 1.0 / 0.0 == 1.0 / -0.0;
+}
+]])],
+ [mpfr_cv_have_signedz="yes"],
+ [mpfr_cv_have_signedz="no"],
+ [mpfr_cv_have_signedz="cannot test, assume no"])
+])
+if test "$mpfr_cv_have_signedz" = "yes"; then
+ AC_DEFINE(HAVE_SIGNEDZ,1,[Define if signed zeros are supported.])
+fi
+
dnl Check the FP division by 0 fails (e.g. on a non-IEEE-754 platform).
dnl In such a case, MPFR_ERRDIVZERO is defined to disable the tests
dnl involving a FP division by 0.
diff --git a/tests/tget_flt.c b/tests/tget_flt.c
index 561c27f6c..ed73401f5 100644
--- a/tests/tget_flt.c
+++ b/tests/tget_flt.c
@@ -98,6 +98,7 @@ main (void)
exit (1);
}
+#ifdef HAVE_SIGNEDZ
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_neg (x, x, MPFR_RNDN);
f = mpfr_get_flt (x, MPFR_RNDN);
@@ -107,6 +108,7 @@ main (void)
printf ("Error for mpfr_set_flt(mpfr_get_flt(-0))\n");
exit (1);
}
+#endif /* HAVE_SIGNEDZ */
mpfr_set_ui (x, 17, MPFR_RNDN);
f = mpfr_get_flt (x, MPFR_RNDN);
diff --git a/tests/tset_d.c b/tests/tset_d.c
index 941ad1e6d..c93a29411 100644
--- a/tests/tset_d.c
+++ b/tests/tset_d.c
@@ -92,6 +92,7 @@ main (int argc, char *argv[])
}
#endif /* MPFR_ERRDIVZERO */
+#ifdef HAVE_SIGNEDZ
d = 0.0;
mpfr_set_d (x, d, MPFR_RNDN);
MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
@@ -102,6 +103,7 @@ main (int argc, char *argv[])
printf ("Error in mpfr_set_d on -0\n");
exit (1);
}
+#endif /* HAVE_SIGNEDZ */
#if !defined(MPFR_ERRDIVZERO)
mpfr_set_inf (x, 1);