bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

isnanf: portability to IRIX and Solaris


From: Bruno Haible
Subject: isnanf: portability to IRIX and Solaris
Date: Sun, 20 May 2007 01:54:56 +0200
User-agent: KMail/1.5.4

The test-isnanf failed on IRIX 6.5 and Solaris 2.5.1, because of bugs in
the system functions. This activates the workaround.

2007-05-19  Bruno Haible  <address@hidden>

        * m4/isnanf.m4 (gl_ISNANF_WORKS): New macro.
        (gl_FUNC_ISNANF_NO_LIBM): Invoke it.
        * lib/isnan.c (FUNC): Use run-time expressions for SGI compiler.
        Needed for IRIX 6.5 and Solaris 2.5.1.

*** m4/isnanf.m4        6 Apr 2007 20:19:19 -0000       1.1
--- m4/isnanf.m4        19 May 2007 23:47:10 -0000
***************
*** 1,4 ****
! # isnanf.m4 serial 1
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # isnanf.m4 serial 2
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
***************
*** 10,15 ****
--- 10,19 ----
  [
    gl_HAVE_ISNANF_NO_LIBM
    if test $gl_cv_func_isnanf_no_libm = yes; then
+     gl_ISNANF_WORKS
+   fi
+   if test $gl_cv_func_isnanf_no_libm = yes \
+      && test $gl_cv_func_isnanf_works = yes; then
      AC_DEFINE([HAVE_ISNANF_IN_LIBC], 1,
        [Define if the isnan(float) function is available in libc.])
    else
***************
*** 36,41 ****
--- 40,86 ----
      ])
  ])
  
+ dnl Test whether isnanf() recognizes a NaN (this fails on IRIX 6.5) and 
rejects
+ dnl Infinity (this fails on Solaris 2.5.1).
+ AC_DEFUN([gl_ISNANF_WORKS],
+ [
+   AC_REQUIRE([AC_PROG_CC])
+   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+   AC_CACHE_CHECK([whether isnanf works], [gl_cv_func_isnanf_works],
+     [
+       AC_TRY_RUN([
+ #include <math.h>
+ #ifdef isnan
+ # undef isnanf
+ # define isnanf(x) isnan ((float)(x))
+ #endif
+ /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
+ #ifdef __DECC
+ static float
+ NaN ()
+ {
+   static float zero = 0.0f;
+   return zero / zero;
+ }
+ #else
+ # define NaN() (0.0f / 0.0f)
+ #endif
+ int main()
+ {
+   if (!isnanf (NaN ()))
+     return 1;
+   if (isnanf (1.0f / 0.0f))
+     return 1;
+   return 0;
+ }], [gl_cv_func_isnanf_works=yes], [gl_cv_func_isnanf_works=no],
+         [case "$host_os" in
+            irix* | solaris*) gl_cv_func_isnanf_works="guessing no";;
+            *)                gl_cv_func_isnanf_works="guessing yes";;
+          esac
+         ])
+     ])
+ ])
+ 
  AC_DEFUN([gl_FLOAT_EXPONENT_LOCATION],
  [
    AC_CACHE_CHECK([where to find the exponent in a 'float'],
*** lib/isnan.c 6 Apr 2007 20:19:19 -0000       1.6
--- lib/isnan.c 19 May 2007 23:47:10 -0000
***************
*** 74,84 ****
  #ifdef KNOWN_EXPBIT0_LOCATION
    /* Be careful to not do any floating-point operation on x, such as x == x,
       because x may be a signaling NaN.  */
! # if defined __SUNPRO_C || defined __DECC
    /* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
       recognize the initializers as constant expressions.  The latter compiler
       also fails when constant-folding 0.0 / 0.0 even when constant-folding is
!      not required.  */
    static DOUBLE zero = L_(0.0);
    memory_double nan;
    DOUBLE plus_inf = L_(1.0) / L_(0.0);
--- 74,85 ----
  #ifdef KNOWN_EXPBIT0_LOCATION
    /* Be careful to not do any floating-point operation on x, such as x == x,
       because x may be a signaling NaN.  */
! # if defined __SUNPRO_C || defined __DECC || (defined __sgi && !defined 
__GNUC__)
    /* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
       recognize the initializers as constant expressions.  The latter compiler
       also fails when constant-folding 0.0 / 0.0 even when constant-folding is
!      not required.  The SGI MIPSpro C compiler complains about "floating-point
!      operation result is out of range".  */
    static DOUBLE zero = L_(0.0);
    memory_double nan;
    DOUBLE plus_inf = L_(1.0) / L_(0.0);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]