From cabfe198fd954fbf1c2afd839fd36eb20a803baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 11 May 2009 22:11:25 +0200 Subject: [PATCH] Ask for IEEE floating point behavior on Alpha and SH. * configure.in (CPPFLAGS): Add `-mieee' or `-ieee' on Alpha and SH. * libguile/numbers.c (guile_ieee_init): Make sure `-mieee' was passed when using GCC on Alpha. * NEWS: Update. --- NEWS | 1 + configure.in | 34 ++++++++++++++++++++++++++++++++++ libguile/numbers.c | 7 +++++++ 3 files changed, 42 insertions(+) diff --git a/NEWS b/NEWS index a65a81361..fa92e327b 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ Changes in 1.8.7 (since 1.8.6) ** Fix build problem when scm_t_timespec is different from struct timespec ** Fix build when compiled with -Wundef -Werror ** More build fixes for `alphaev56-dec-osf5.1b' (Tru64) +** With GCC, always compile with `-mieee' on `alpha*' and `sh*' ** Allow @ macro to work with (ice-9 syncase) diff --git a/configure.in b/configure.in index b53b862e7..721394b1c 100644 --- a/configure.in +++ b/configure.in @@ -222,6 +222,40 @@ case "$use_64_calls" in ;; esac +AC_MSG_CHECKING([whether the compiler defaults to IEEE floating point behavior]) +# The following snippet was taken from Gnulib's `fpieee'. See also the definition +# of `guile_NaN' in `numbers.c'. + +# IEEE behaviour is the default on all CPUs except Alpha and SH +# (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 +# and the GCC 4.1.2 manual). +case "$host_cpu" in +alpha*) + # On Alpha systems, a compiler option provides the behaviour. + # See the ieee(3) manual page, also available at + # + AC_MSG_RESULT([no]) + if test -n "$GCC"; then + # GCC has the option -mieee. + CPPFLAGS="$CPPFLAGS -mieee" + else + # Compaq (ex-DEC) C has the option -ieee. + CPPFLAGS="$CPPFLAGS -ieee" + fi + ;; +sh*) + AC_MSG_RESULT([no]) + if test -n "$GCC"; then + # GCC has the option -mieee. + CPPFLAGS="$CPPFLAGS -mieee" + fi + ;; +*) + AC_MSG_RESULT([yes]) + ;; +esac + + #-------------------------------------------------------------------- dnl Check for dynamic linking diff --git a/libguile/numbers.c b/libguile/numbers.c index 37435b50b..25b0c1a62 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -637,6 +637,13 @@ guile_ieee_init (void) #if defined (HAVE_ISNAN) +#if defined __GNUC__ && defined __alpha__ && !defined _IEEE_FP + /* On Alpha GCC must be passed `-mieee' to provide proper NaN handling. + See http://lists.gnu.org/archive/html/bug-gnulib/2009-05/msg00010.html + for more details. */ +# error NaN handling will not work when compiling without -mieee +#endif + #ifdef NAN /* C99 NAN, when available */ guile_NaN = NAN;