diff options
Diffstat (limited to 'tests/nan.h')
| -rw-r--r-- | tests/nan.h | 38 | 
1 files changed, 25 insertions, 13 deletions
| diff --git a/tests/nan.h b/tests/nan.h index 6a3a239a..d540a0bb 100644 --- a/tests/nan.h +++ b/tests/nan.h @@ -1,5 +1,5 @@ -/* Macros for not-a-number. -   Copyright (C) 2007-2022 Free Software Foundation, Inc. +/* Macros for quiet not-a-number. +   Copyright (C) 2007-2024 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by @@ -14,6 +14,9 @@     You should have received a copy of the GNU General Public License     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */ +#ifndef _GL_NAN_H +#define _GL_NAN_H +  /* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The     former does not support NaN and its isnan() implementation returns zero @@ -26,14 +29,15 @@  /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke     on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains. -   PGI 16.10 complains.  */ +   PGI 16.10 complains.  clang 13 on mips64 does incorrect constant-folding.  */  #if (defined __DECC || defined _MSC_VER \ -     || (defined __MVS__ && defined __IBMC__)   \ -     || defined __PGI) +     || (defined __MVS__ && defined __IBMC__) \ +     || defined __PGI \ +     || defined __mips__)  static float  NaNf ()  { -  static float zero = 0.0f; +  static float volatile zero = 0.0f;    return zero / zero;  }  #else @@ -45,14 +49,15 @@ NaNf ()  /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke     on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains. -   PGI 16.10 complains.  */ +   PGI 16.10 complains.  clang 13 on mips64 does incorrect constant-folding.  */  #if (defined __DECC || defined _MSC_VER \ -     || (defined __MVS__ && defined __IBMC__)   \ -     || defined __PGI) +     || (defined __MVS__ && defined __IBMC__) \ +     || defined __PGI \ +     || defined __mips__)  static double  NaNd ()  { -  static double zero = 0.0; +  static double volatile zero = 0.0;    return zero / zero;  }  #else @@ -66,20 +71,27 @@ NaNd ()     runtime type conversion.     The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L.     The IBM XL C compiler on z/OS complains. -   PGI 16.10 complains.  */ +   PGI 16.10 complains. +   Avoid possible incorrect constant-folding on mips.  */  #ifdef __sgi  static long double NaNl ()  {    double zero = 0.0;    return zero / zero;  } -#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +#elif (defined _MSC_VER \ +       || (defined __MVS__ && defined __IBMC__) \ +       || defined __PGI \ +       || defined __mips__)  static long double  NaNl ()  { -  static long double zero = 0.0L; +  static long double volatile zero = 0.0L;    return zero / zero;  }  #else  # define NaNl() (0.0L / 0.0L)  #endif + + +#endif /* _GL_NAN_H */ | 
