Mercurial > hg > octave-lyh > gnulib-hg
changeset 9901:31d7bf84aa9a
Override the system isnanf also on IRIX 6.5 with gcc.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 12 Apr 2008 18:33:53 +0200 |
parents | 5f47b9c9cc45 |
children | 7b73920a2002 |
files | ChangeLog m4/isnanf.m4 |
diffstat | 2 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-12 Bruno Haible <bruno@clisp.org> + + * m4/isnanf.m4 (gl_ISNANF_WORKS): Add a test for a special NaN. + Reported by Nelson H. F. Beebe <beebe@math.utah.edu>. + 2008-04-12 Jim Meyering <meyering@redhat.com> * m4/math_h.m4 (gl_MATH_H): Fix typos.
--- a/m4/isnanf.m4 +++ b/m4/isnanf.m4 @@ -1,4 +1,4 @@ -# isnanf.m4 serial 5 +# isnanf.m4 serial 6 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, @@ -47,12 +47,14 @@ ]) ]) -dnl Test whether isnanf() recognizes a NaN (this fails on IRIX 6.5) and rejects -dnl Infinity (this fails on Solaris 2.5.1). +dnl Test whether isnanf() rejects Infinity (this fails on Solaris 2.5.1), +dnl recognizes a NaN (this fails on IRIX 6.5 with cc), and recognizes a NaN +dnl with in-memory representation 0x7fbfffff (this fails on IRIX 6.5). AC_DEFUN([gl_ISNANF_WORKS], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_FLOAT_EXPONENT_LOCATION]) AC_CACHE_CHECK([whether isnan(float) works], [gl_cv_func_isnanf_works], [ AC_TRY_RUN([ @@ -75,12 +77,34 @@ #else # define NaN() (0.0f / 0.0f) #endif +#define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { unsigned int word[NWORDS]; float value; } memory_float; int main() { + memory_float m; + + if (isnanf (1.0f / 0.0f)) + return 1; + if (!isnanf (NaN ())) return 1; - if (isnanf (1.0f / 0.0f)) - return 1; + +#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + /* The isnanf function should be immune against changes in the sign bit and + in the mantissa bits. The xor operation twiddles a bit that can only be + a sign bit or a mantissa bit. */ + if (FLT_EXPBIT0_WORD == 0 && FLT_EXPBIT0_BIT > 0) + { + m.value = NaN (); + /* Set the bits below the exponent to 01111...111. */ + m.word[0] &= -1U << FLT_EXPBIT0_BIT; + m.word[0] |= 1U << (FLT_EXPBIT0_BIT - 1) - 1; + if (!isnanf (m.value)) + return 1; + } +#endif + return 0; }], [gl_cv_func_isnanf_works=yes], [gl_cv_func_isnanf_works=no], [case "$host_os" in