(root)/
gettext-0.22.4/
gettext-tools/
gnulib-tests/
nan.h
       1  /* Macros for quiet not-a-number.
       2     Copyright (C) 2007-2023 Free Software Foundation, Inc.
       3  
       4     This program is free software: you can redistribute it and/or modify
       5     it under the terms of the GNU General Public License as published by
       6     the Free Software Foundation, either version 3 of the License, or
       7     (at your option) any later version.
       8  
       9     This program is distributed in the hope that it will be useful,
      10     but WITHOUT ANY WARRANTY; without even the implied warranty of
      11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12     GNU General Public License for more details.
      13  
      14     You should have received a copy of the GNU General Public License
      15     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      16  
      17  #ifndef _GL_NAN_H
      18  #define _GL_NAN_H
      19  
      20  
      21  /* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The
      22     former does not support NaN and its isnan() implementation returns zero
      23     for all values.  */
      24  #if defined __MVS__ && defined __IBMC__ && !defined __BFP__
      25  # error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee"
      26  #endif
      27  
      28  /* NaNf () returns a 'float' not-a-number.  */
      29  
      30  /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
      31     on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains.
      32     PGI 16.10 complains.  clang 13 on mips64 does incorrect constant-folding.  */
      33  #if (defined __DECC || defined _MSC_VER \
      34       || (defined __MVS__ && defined __IBMC__) \
      35       || defined __PGI \
      36       || defined __mips__)
      37  static float
      38  NaNf ()
      39  {
      40    static float volatile zero = 0.0f;
      41    return zero / zero;
      42  }
      43  #else
      44  # define NaNf() (0.0f / 0.0f)
      45  #endif
      46  
      47  
      48  /* NaNd () returns a 'double' not-a-number.  */
      49  
      50  /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
      51     on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains.
      52     PGI 16.10 complains.  clang 13 on mips64 does incorrect constant-folding.  */
      53  #if (defined __DECC || defined _MSC_VER \
      54       || (defined __MVS__ && defined __IBMC__) \
      55       || defined __PGI \
      56       || defined __mips__)
      57  static double
      58  NaNd ()
      59  {
      60    static double volatile zero = 0.0;
      61    return zero / zero;
      62  }
      63  #else
      64  # define NaNd() (0.0 / 0.0)
      65  #endif
      66  
      67  
      68  /* NaNl () returns a 'long double' not-a-number.  */
      69  
      70  /* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the
      71     runtime type conversion.
      72     The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L.
      73     The IBM XL C compiler on z/OS complains.
      74     PGI 16.10 complains.
      75     Avoid possible incorrect constant-folding on mips.  */
      76  #ifdef __sgi
      77  static long double NaNl ()
      78  {
      79    double zero = 0.0;
      80    return zero / zero;
      81  }
      82  #elif (defined _MSC_VER \
      83         || (defined __MVS__ && defined __IBMC__) \
      84         || defined __PGI \
      85         || defined __mips__)
      86  static long double
      87  NaNl ()
      88  {
      89    static long double volatile zero = 0.0L;
      90    return zero / zero;
      91  }
      92  #else
      93  # define NaNl() (0.0L / 0.0L)
      94  #endif
      95  
      96  
      97  #endif /* _GL_NAN_H */